]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
main: create directories before refclock initialization
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 16 Feb 2018 09:36:41 +0000 (10:36 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 16 Feb 2018 10:09:54 +0000 (11:09 +0100)
This allows the SOCK refclock to open sockets in the /var/run/chrony
directory.

main.c

diff --git a/main.c b/main.c
index c198ac687affb7c4128dca05a76ed1118a3e011a..8b3f34440f6aae0ce5f37242de7edfab913ba372 100644 (file)
--- 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);