Skip to content

Commit 20aa756

Browse files
committed
User management changes
default to the ossec user Signed-off-by: Scott R. Shinn <scott@atomicorp.com>
1 parent 06b2e18 commit 20aa756

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/os_auth/main-server.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
155155
char *port = DEFAULT_PORT;
156156
char *ciphers = DEFAULT_CIPHERS;
157157
const char *dir = DEFAULTDIR;
158-
const char *user = MAILUSER;
158+
const char *user = USER;
159159
const char *group = GROUPGLOBAL;
160160
const char *server_cert = NULL;
161161
const char *server_key = NULL;
@@ -307,6 +307,18 @@ int main(int argc, char **argv)
307307
exit(1);
308308
}
309309
fclose(fp);
310+
311+
/* Set ownership to ossec user and group */
312+
if (chown(KEYSFILE_PATH, uid, gid) < 0) {
313+
merror("%s: ERROR: Unable to set ownership of %s to %d:%d (%s)", ARGV0, KEYSFILE_PATH, uid, gid, strerror(errno));
314+
exit(1);
315+
}
316+
317+
/* Set permissions to read/write for owner, read for group */
318+
if (chmod(KEYSFILE_PATH, 0640) < 0) {
319+
merror("%s: ERROR: Unable to set permissions of %s to 0640 (%s)", ARGV0, KEYSFILE_PATH, strerror(errno));
320+
exit(1);
321+
}
310322

311323
if (use_pass) {
312324

@@ -556,8 +568,6 @@ int main(int argc, char **argv)
556568
finalkey = OS_AddNewAgent(agentname, NULL, NULL);
557569
}
558570
if (!finalkey) {
559-
merror("%s: ERROR: Unable to add agent: %s (internal error - debug check paths and files)", ARGV0, agentname);
560-
561571
merror("%s: ERROR: Unable to add agent: %s (internal error)", ARGV0, agentname);
562572
snprintf(response, 2048, "ERROR: Internal manager error adding agent: %s\n\n", agentname);
563573
SSL_write(ssl, response, strlen(response));

0 commit comments

Comments
 (0)