]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
main: warn if running with root privileges
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 25 Feb 2021 16:04:01 +0000 (17:04 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 25 Feb 2021 16:06:14 +0000 (17:06 +0100)
Log a warning message if the main process has not dropped the root
privileges, i.e. when the compiled-in user or user specified by the user
directive or -u option is root.

main.c

diff --git a/main.c b/main.c
index 0e54152608258ecc9594ac48596a38b53eff79a0..3290d33d14269d2d06033b3ec0ff9227f0d0c168 100644 (file)
--- a/main.c
+++ b/main.c
@@ -628,6 +628,9 @@ int main
   if (!geteuid() && (pw->pw_uid || pw->pw_gid))
     SYS_DropRoot(pw->pw_uid, pw->pw_gid, SYS_MAIN_PROCESS);
 
+  if (!geteuid())
+    LOG(LOGS_WARN, "Running with root privileges");
+
   REF_Initialise();
   SST_Initialise();
   NSR_Initialise();