From c5d8af028581a8cdb68ebdd7a314454cc5eeb8ec Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 16 Feb 2018 10:36:41 +0100 Subject: [PATCH] main: create directories before refclock initialization This allows the SOCK refclock to open sockets in the /var/run/chrony directory. --- main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index c198ac6..8b3f344 100644 --- a/main.c +++ b/main.c @@ -524,6 +524,16 @@ int main /* Write our pidfile to prevent other chronyds running */ write_pidfile(); + if (!user) + user = CNF_GetUser(); + + pw = getpwnam(user); + if (!pw) + LOG_FATAL("Could not get user/group ID of %s", user); + + /* Create directories for sockets, log files, and dump files */ + CNF_CreateDirs(pw->pw_uid, pw->pw_gid); + PRV_Initialise(); LCL_Initialise(); SCH_Initialise(); @@ -551,16 +561,6 @@ int main SYS_LockMemory(); } - if (!user) { - user = CNF_GetUser(); - } - - if ((pw = getpwnam(user)) == NULL) - LOG_FATAL("Could not get user/group ID of %s", user); - - /* Create all directories before dropping root */ - CNF_CreateDirs(pw->pw_uid, pw->pw_gid); - /* Drop root privileges if the specified user has a non-zero UID */ if (!geteuid() && (pw->pw_uid || pw->pw_gid)) SYS_DropRoot(pw->pw_uid, pw->pw_gid);