summaryrefslogtreecommitdiff
path: root/ntpd/ntpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ntpd/ntpd.c')
-rw-r--r--ntpd/ntpd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c
index ef1baa7..529e6ce 100644
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -168,8 +168,8 @@ int root_dropped;
char *user; /* User to switch to */
char *group; /* group to switch to */
const char *chrootdir; /* directory to chroot to */
-int sw_uid;
-int sw_gid;
+uid_t sw_uid;
+gid_t sw_gid;
char *endp;
struct group *gr;
struct passwd *pw;
@@ -937,6 +937,10 @@ getgroup:
msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group);
exit (-1);
}
+ if (group)
+ setgroups(1, &sw_gid);
+ else
+ initgroups(pw->pw_name, pw->pw_gid);
if (user && setuid(sw_uid)) {
msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user);
exit (-1);
@@ -1258,6 +1262,7 @@ finish(
if (mdns != NULL)
DNSServiceRefDeallocate(mdns);
# endif
+ peer_cleanup();
exit(0);
}
#endif /* !SIM && SIGDIE1 */