[CFR] Fix adduser's recognition of nologin

Peter Pentchev roam at ringlet.net
Mon Sep 20 09:22:07 PDT 2004


Hi,

Any objections to the following patch?  The rationale is described
in PR bin/71786 - http://www.FreeBSD.org/cgi/query-pr.cgi?pr=71786
Basically, the 'exit' inside the 'cat | while' loop does not really
exit the fullpath_from_shell() function, so if the admin specifies
'nologin' as the new user's shell, fullpath_from_shell() actually
outputs "/sbin/nologin\n/sbin/nologin" or something similar, and this
corrupts the modified master.passwd file.

In the PR, the originator confirmed that this solved the problem.
I could commit it 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 at ringlet.net    roam at cnsys.bg    roam at FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
Thit sentence is not self-referential because "thit" is not a word.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20040920/0245ac3b/attachment.bin


More information about the freebsd-hackers mailing list