Subject: bin/20232: "ntpd -u user:group" ignores group, but uses user's group
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kamada@hongo.wide.ad.jp>
List: netbsd-bugs
Date: 02/07/2003 19:32:02
>Number:         20232
>Category:       bin
>Synopsis:       "ntpd -u user:group" ignores group, but uses user's group
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 07 02:33:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     KAMADA Ken'ichi
>Release:        NetBSD 1.6N
>Organization:
>Environment:
System: NetBSD setsuna 1.6N NetBSD 1.6N (SETSUNA) #4: Fri Feb 7 13:44:24 JST 2003 ken@setsuna:/usr/src/sys/arch/i386/compile/SETSUNA i386
Architecture: i386
Machine: i386
>Description:

When you give -u USER:GRUOP option to ntpd(8), it uses USER's group
instead of GRUOP.

>How-To-Repeat:

% id testuser
uid=20001(testuser) gid=20002(testgroup) groups=20002(testgroup)
% id ntpd
uid=15(ntpd) gid=15(ntpd) groups=15(ntpd)
# ntpd -u testuser:ntpd
% ps -aux -ouid,rgid | grep ntpd
testuser 476  0.3  0.2   732  1620 ?? S<s   6:31PM 0:00.05 ntpd -u 20001 20002

>Fix:

--- dist/ntp/ntpd/ntpd.c.orig	2002-04-19 08:18:42.000000000 +0900
+++ dist/ntp/ntpd/ntpd.c	2003-02-07 18:36:56.000000000 +0900
@@ -837,7 +837,7 @@
 	        } else {
 getgroup:	
 	                if ((gr = getgrnam(group)) != NULL) {
-	                        sw_gid = pw->pw_gid;
+	                        sw_gid = gr->gr_gid;
 	                } else {
 	                        errno = 0;
 	                        msyslog(LOG_ERR, "Cannot find group `%s'", group);
>Release-Note:
>Audit-Trail:
>Unformatted: