Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Sep 2004 19:22:41 +0300
From:      Peter Pentchev <roam@ringlet.net>
To:        freebsd-hackers@FreeBSD.org
Subject:   [CFR] Fix adduser's recognition of nologin
Message-ID:  <20040920162241.GB1813@straylight.m.ringlet.net>

next in thread | raw e-mail | index | archive | help

--8GpibOaaTibBMecb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

Any objections to the following patch?  The rationale is described
in PR bin/71786 - http://www.FreeBSD.org/cgi/query-pr.cgi?pr=3D71786
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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=3D$1
 	[ -z "$_shell" ] && return 1
=20
+	# /usr/sbin/nologin is a special case
+	if [ "$_shell" =3D "${NOLOGIN}" -o \
+	    "$_shell" =3D "${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
=20
-	# /usr/sbin/nologin is a special case
-	if [ "$_shell" =3D "${NOLOGIN}" -o \
-	    "$_shell" =3D "${NOLOGIN_PATH}" ]; then
-		echo ${NOLOGIN_PATH}
-		return 0;
-	fi
-
 	return 1
 }
=20

G'luck,
Peter

--=20
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
Thit sentence is not self-referential because "thit" is not a word.

--8GpibOaaTibBMecb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)

iD8DBQFBTwPR7Ri2jRYZRVMRAjBCAJ9Cfwlfo8TGH0FvjT1DBM+WR07tiQCgoT/h
X6qWlg+wsnVHl1x72ybLfTU=
=5KsN
-----END PGP SIGNATURE-----

--8GpibOaaTibBMecb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040920162241.GB1813>