Date: Sat, 8 Feb 2003 07:42:07 +0200 From: Giorgos Keramidas <keramida@freebsd.org> To: Adrian Chadd <adrian@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: Re: adduser change: telling you when a group isn't there Message-ID: <20030208054207.GC986@gothmog.gr> In-Reply-To: <20030207081056.GA84685@skywalker.creative.net.au> References: <20030207081056.GA84685@skywalker.creative.net.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2003-02-07 16:10, Adrian Chadd <adrian@freebsd.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030208054207.GC986>