Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/ntp/dist/ntpd use initgroups/setgroups
details: https://anonhg.NetBSD.org/src/rev/471f025f1439
branches: trunk
changeset: 749981:471f025f1439
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 14 00:42:47 2009 +0000
description:
use initgroups/setgroups
proper types for uid and gid.
diffstat:
external/bsd/ntp/dist/ntpd/ntpd.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (31 lines):
diff -r dd47393b11e8 -r 471f025f1439 external/bsd/ntp/dist/ntpd/ntpd.c
--- a/external/bsd/ntp/dist/ntpd/ntpd.c Mon Dec 14 00:42:21 2009 +0000
+++ b/external/bsd/ntp/dist/ntpd/ntpd.c Mon Dec 14 00:42:47 2009 +0000
@@ -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);
Home |
Main Index |
Thread Index |
Old Index