From: Miroslav Lichvar Date: Fri, 16 Feb 2018 09:36:41 +0000 (+0100) Subject: main: create directories before refclock initialization X-Git-Tag: 3.3-pre1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5d8af028581a8cdb68ebdd7a314454cc5eeb8ec;p=thirdparty%2Fchrony.git main: create directories before refclock initialization This allows the SOCK refclock to open sockets in the /var/run/chrony directory. --- diff --git a/main.c b/main.c index c198ac68..8b3f3444 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);