From owner-freebsd-bugs@FreeBSD.ORG Thu Sep 16 11:50:25 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 45F3816A4CE for ; Thu, 16 Sep 2004 11:50:25 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AD4D43D2D for ; Thu, 16 Sep 2004 11:50:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i8GBoOoj001923 for ; Thu, 16 Sep 2004 11:50:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8GBoOLu001922; Thu, 16 Sep 2004 11:50:24 GMT (envelope-from gnats) Date: Thu, 16 Sep 2004 11:50:24 GMT Message-Id: <200409161150.i8GBoOLu001922@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Peter Pentchev Subject: Re: bin/71786: adduser breaks if /sbin/nologin is included in /etc/shells X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Peter Pentchev List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2004 11:50:25 -0000 The following reply was made to PR bin/71786; it has been noted by GNATS. From: Peter Pentchev To: bug-followup@FreeBSD.org Cc: andrew.hayden@gmail.com Subject: Re: bin/71786: adduser breaks if /sbin/nologin is included in /etc/shells Date: Thu, 16 Sep 2004 14:45:32 +0300 On Thu, Sep 16, 2004 at 11:31:18AM +0000, Peter Pentchev wrote: [snip] > It seems that there is indeed a problem in adduser's handling of the > nologin shell. In the fullpath_from_shell() function, the 'return' > within the while/case/if will only return from the new shell instance > created due to the "cat ${ETCSHELLS}" pipe, and will *not* stop the > shell from executing the nologin special case test. Thus, > fullpath_from_shell() will output *two* lines containing nologin, and > those two lines will be what is added to the end of master.passwd's new > user line. > > Can you try the following patch? Basically, in the > fullpath_from_shell() function, move the nologin special case test > before the cat | while loop. FWIW, for 6.x-CURRENT and 5.3-BETA this patch would assume the following shape. Source committers, please treat this as a request for pre-commit review - I could commit this if no one has any objections: Index: src/usr.sbin/adduser/adduser.sh =================================================================== RCS file: /home/ncvs/src/usr.sbin/adduser/adduser.sh,v retrieving revision 1.24 diff -u -r1.24 adduser.sh --- src/usr.sbin/adduser/adduser.sh 28 Aug 2004 14:32:10 -0000 1.24 +++ src/usr.sbin/adduser/adduser.sh 16 Sep 2004 11:43:23 -0000 @@ -126,6 +126,13 @@ _shell=$1 [ -z "$_shell" ] && return 1 + # /usr/sbin/nologin is a special case + if [ "$_shell" = "${NOLOGIN}" -o \ + "$_shell" = "${NOLOGIN_PATH}" ]; then + echo ${NOLOGIN_PATH} + return 0; + fi + cat ${ETCSHELLS} | while read _path _junk ; do case "$_path" in @@ -141,13 +148,6 @@ esac done - # /usr/sbin/nologin is a special case - if [ "$_shell" = "${NOLOGIN}" -o \ - "$_shell" = "${NOLOGIN_PATH}" ]; then - echo ${NOLOGIN_PATH} - return 0; - fi - return 1 } G'luck, Peter -- Peter Pentchev roam@ringlet.net roam@cnsys.bg roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 This sentence was in the past tense.