/* 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();
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);