From owner-freebsd-hackers Fri Feb 7 21:42:14 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6DFC837B401; Fri, 7 Feb 2003 21:42:12 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57AFD43F3F; Fri, 7 Feb 2003 21:42:11 -0800 (PST) (envelope-from keramida@freebsd.org) Received: from gothmog.gr (patr530-b222.otenet.gr [212.205.244.230]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id h185g8Wx006848; Sat, 8 Feb 2003 07:42:08 +0200 (EET) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.6/8.12.6) with ESMTP id h185g7Y9001453; Sat, 8 Feb 2003 07:42:07 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.12.6/8.12.6/Submit) id h185g7O6001452; Sat, 8 Feb 2003 07:42:07 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Sat, 8 Feb 2003 07:42:07 +0200 From: Giorgos Keramidas To: Adrian Chadd Cc: freebsd-hackers@freebsd.org Subject: Re: adduser change: telling you when a group isn't there Message-ID: <20030208054207.GC986@gothmog.gr> References: <20030207081056.GA84685@skywalker.creative.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030207081056.GA84685@skywalker.creative.net.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2003-02-07 16:10, Adrian Chadd wrote: > Hi, > The adduser in -current doesn't check if a specified group exists > until the call to pw right at the end. eep. > > My sh foo isn't terribly great, but this did it for me. > > Comments/rewrites are welcome. I'll commit the group consensus. Hmmm, looking at it now, I see this part: get_groups() { ugroups="$defaultgroups" _input= _group=${ulogingroup:-"${username}"} # ... read _input [ -n "$_input" ] && ugroups="$_input" } It doesn't need to ( read as "should not" ) check for all the groups involved, since when the group is the same as the username, it's obvious that it will probably not exist. But if it already does, is it an error? I think not, since one might want to create many users who share the same group. What do you all think about the following patch then? ---8<--- cut here ---8<--- cut here ---8<--- cut here ---8<--- cut here --- Index: adduser.sh =================================================================== RCS file: /home/ncvs/src/usr.sbin/adduser/adduser.sh,v retrieving revision 1.9 diff -u -r1.9 adduser.sh --- adduser.sh 24 Jan 2003 02:05:51 -0000 1.9 +++ adduser.sh 8 Feb 2003 05:41:06 -0000 @@ -464,7 +464,12 @@ fi read _input - [ -n "$_input" ] && ugroups="$_input" + if [ -n "$_input" ] ; then + for tmpgroup in ${_input} ;do + grep -q "^${tmpgroup}:" /etc/group && \ + ugroups="$_input" + fi + fi } # get_expire_dates ---8<--- cut here ---8<--- cut here ---8<--- cut here ---8<--- cut here --- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message