From b2ccf8dd31d1457ae9f0ae270054117179220370 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 7 Apr 2015 08:29:34 +0000 Subject: Imported from /home/lorry/working-area/delta_ntp/ntp-4.2.8p2.tar.gz. --- ntpd/ntpd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ntpd/ntpd.c') 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 */ -- cgit v1.2.1