From rea-fbsd@codelabs.ru  Thu Sep 20 21:04:08 2007
Return-Path: <rea-fbsd@codelabs.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0E31C16A41B
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 Sep 2007 21:04:08 +0000 (UTC)
	(envelope-from rea-fbsd@codelabs.ru)
Received: from pobox.codelabs.ru (pobox.codelabs.ru [144.206.177.45])
	by mx1.freebsd.org (Postfix) with ESMTP id 9BE5913C4AC
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 Sep 2007 21:04:07 +0000 (UTC)
	(envelope-from rea-fbsd@codelabs.ru)
Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25])
	by pobox.codelabs.ru with esmtps (TLSv1:CAMELLIA256-SHA:256)
	id 1IYR7Y-000InZ-8v; Thu, 20 Sep 2007 22:51:28 +0400
Message-Id: <20070920185127.B05CF1AF41C@void.codelabs.ru>
Date: Thu, 20 Sep 2007 22:51:27 +0400 (MSD)
From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Reply-To: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: mtm@FreeBSD.Org
Subject: teach adduser(8) to respect -G flag in the batch mode
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         116487
>Category:       bin
>Synopsis:       teach adduser(8) to respect -G flag in the batch mode
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mtm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 20 21:10:01 GMT 2007
>Closed-Date:    Fri Jan 25 15:33:05 UTC 2008
>Last-Modified:  Fri Jan 25 15:33:05 UTC 2008
>Originator:     Eygene Ryabinkin
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
Code Labs
>Environment:

System: FreeBSD XXX 7.0-CURRENT FreeBSD 7.0-CURRENT #10: Wed Sep 12 16:16:49 MSD 2007 root@XXX:/usr/src/sys/i386/compile/XXX i386

>Description:

Current adduser(8) does not honor the value of '-G' flag if it is
working in the batch mode.  This is not good, because one can use
batch mode to add a number of users and will want them to be in the
same secondary group(s).

>How-To-Repeat:

Invoke 'adduser -f file-with-account-data -G nogroup' and see that
users are added to the passwd, but not to the 'nogroup' group.

>Fix:

The following patch will cure the situation.  I had also clarified
the '-G' flag syntax in the man page.

A side note: may be it will be better to use comma in the '-G'
option value instead of space -- it is just more convinient to type.
But this can break POLA and I am not making such change now, so
this is just an idea.

--- adduser.patch begins here ---
diff -urN orig/adduser.8 new/adduser.8
--- orig/adduser.8	2007-09-20 22:37:29.000000000 +0400
+++ new/adduser.8	2007-09-20 22:43:27.000000000 +0400
@@ -212,7 +212,7 @@
 .Ar login_group
 the default.
 .It Fl G Ar groups
-Additional groups.
+Space-separated list of additional groups.
 This option allows the user to specify additional groups to add users to.
 The user is a member of these groups in addition to their login group.
 .It Fl h
diff -urN orig/adduser.sh new/adduser.sh
--- orig/adduser.sh	2007-09-20 22:37:29.000000000 +0400
+++ new/adduser.sh	2007-09-20 22:42:57.000000000 +0400
@@ -598,6 +598,7 @@
 			get_gecos
 			get_uid
 			get_logingroup
+			ugroups=`echo "$defaultgroups" | tr ' ' ,`
 			get_class
 			get_shell
 			get_homedir
--- adduser.patch ends here ---
>Release-Note:
>Audit-Trail:

From: Mike Makonnen <mtm@FreeBSD.Org>
To: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
Cc: bug-followup@freebsd.org
Subject: Re: bin/116487: teach adduser(8) to respect -G flag in the batch mode
Date: Mon, 8 Oct 2007 20:51:26 +0300

 --sdtB3X0nJg68CQEu
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Thanks! I have prepared a slightly modified patch to be commited once
 -CURRENT is unfrozen. I've stripped out the conversion of spaces to
 commas because that would be different from how it's handled in the
 rest of the script and because pw(8) accpets it fine.
 
 Cheers.
 -- 
 Mike Makonnen         | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
 mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
 mtm @ FreeBSD.Org     | FreeBSD - http://www.freebsd.org
 
 --sdtB3X0nJg68CQEu
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=adduser-patch
 
 Index: usr.sbin/adduser/adduser.8
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/adduser/adduser.8,v
 retrieving revision 1.59
 diff -u -r1.59 adduser.8
 --- usr.sbin/adduser/adduser.8	5 Dec 2006 23:20:14 -0000	1.59
 +++ usr.sbin/adduser/adduser.8	8 Oct 2007 11:50:13 -0000
 @@ -212,7 +212,7 @@
  .Ar login_group
  the default.
  .It Fl G Ar groups
 -Additional groups.
 +Space-separated list of additional groups.
  This option allows the user to specify additional groups to add users to.
  The user is a member of these groups in addition to their login group.
  .It Fl h
 Index: usr.sbin/adduser/adduser.sh
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/adduser/adduser.sh,v
 retrieving revision 1.30
 diff -u -r1.30 adduser.sh
 --- usr.sbin/adduser/adduser.sh	12 Apr 2007 08:17:56 -0000	1.30
 +++ usr.sbin/adduser/adduser.sh	8 Oct 2007 12:40:33 -0000
 @@ -603,6 +603,7 @@
  			get_homedir
  			get_password
  			get_expire_dates
 +			ugroups="$defaultgroups"
  
  			add_user
  			;;
 
 --sdtB3X0nJg68CQEu--
State-Changed-From-To: open->analyzed 
State-Changed-By: mtm 
State-Changed-When: Mon Oct 8 18:07:43 UTC 2007 
State-Changed-Why:  
I'll be commiting a slightly modified path once -CURRENT is unfrozen. 
I've stripped out the translation from spaces to commas since that 
is a separate issue and doesn't need fixing. 


Responsible-Changed-From-To: freebsd-bugs->mtm	 
Responsible-Changed-By: mtm 
Responsible-Changed-When: Mon Oct 8 18:07:43 UTC 2007 
Responsible-Changed-Why:  
I'll be dealing with this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116487 
State-Changed-From-To: analyzed->closed 
State-Changed-By: mtm 
State-Changed-When: Fri Jan 25 15:30:57 UTC 2008 
State-Changed-Why:  
Fixed in HEAD rev. 1.31 and RELENG_7 and RELENG_6  as well. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116487 
>Unformatted:
