Module Name: src
Committed By: christos
Date: Mon Dec 14 00:42:47 UTC 2009
Modified Files:
src/external/bsd/ntp/dist/ntpd: ntpd.c
Log Message:
use initgroups/setgroups
proper types for uid and gid.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/ntp/dist/ntpd/ntpd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/ntp/dist/ntpd/ntpd.c
diff -u src/external/bsd/ntp/dist/ntpd/ntpd.c:1.1.1.1 src/external/bsd/ntp/dist/ntpd/ntpd.c:1.2
--- src/external/bsd/ntp/dist/ntpd/ntpd.c:1.1.1.1 Sun Dec 13 11:56:15 2009
+++ src/external/bsd/ntp/dist/ntpd/ntpd.c Sun Dec 13 19:42:47 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: ntpd.c,v 1.1.1.1 2009/12/13 16:56:15 kardel Exp $ */
+/* $NetBSD: ntpd.c,v 1.2 2009/12/14 00:42:47 christos Exp $ */
/*
* ntpd.c - main program for the fixed point NTP daemon
@@ -177,8 +177,8 @@
char *user = NULL; /* User to switch to */
char *group = NULL; /* group to switch to */
const char *chrootdir = NULL; /* 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;
@@ -962,6 +962,10 @@
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);