🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #498

chsh/passwd -s in 4.3BSD

#498
From: Andy Linton
Date: Fri, 16 Jan 1987 16:16
62 lines
2424 bytes
Imagine my surprise when I was told by chsh (or passwd -s)
that
/bin/sh is unacceptable as a new shell.

/bin/csh and /bin/msh were equally unacceptable.

The problem occurs because passwd -s uses getusershell()
to read /etc/shells in two places and doesn't rewind to
the beginning of /etc/shells before reading again. This
I feel sure has been seen before but a fix follows.

Feed me to patch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** passwd.c	Fri Jan 16 15:42:16 1987
--- passwd.c.orig	Fri Jan 16 11:10:13 1987
***************
*** 340,346 ****
  {
  	static char newshell[BUFSIZ];
  	char *cp, *valid, *getusershell();
- 	int endusershell();
  
  	if (pwd->pw_shell == 0 || *pwd->pw_shell == '\0')
  		pwd->pw_shell = DEFSHELL;
--- 340,345 ----
***************
*** 348,354 ****
  		for (valid = getusershell(); valid; valid = getusershell())
  			if (strcmp(pwd->pw_shell, valid) == 0)
  				break;
- 		(void) endusershell();	/* close /etc/shells */
  		if (valid == NULL) {
  			printf("Cannot change from restricted shell %s\n",
  				pwd->pw_shell);
--- 347,352 ----
***************
*** 389,396 ****
  				break;
  		}
  	}
! 	(void) endusershell();	/* close /etc/shells */
! 	if (valid == NULL) {
  		printf("%s is unacceptable as a new shell.\n",
  		    newshell);
  		exit(1);
--- 387,393 ----
  				break;
  		}
  	}
! 	if (valid == 0) {
  		printf("%s is unacceptable as a new shell.\n",
  		    newshell);
  		exit(1);
---
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SENDER 	: Andy Linton		PHONE	: +44 91 232 9233
POST	: Computing Lab, University of Newcastle upon Tyne, UK, NE1 7RU
ARPA	: andy%cheviot.newcastle.ac.uk@cs.ucl.ac.uk
JANET	: andy@uk.ac.newcastle.cheviot
UUCP	: andy@cheviot.UUCP

***  Ni fui moran beagan d'aon rud, ach is fui moran beagan ceille.  ***
Technical Details
Message-ID: <1664@cheviot.newcastle.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!ukc!cheviot!andy

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!ukc!cheviot!andy
From: andy@cheviot.newcastle.ac.uk (Andy Linton)
Newsgroups: comp.bugs.4bsd
Subject: chsh/passwd -s in 4.3BSD
Message-ID: <1664@cheviot.newcastle.ac.uk>
Date: Fri, 16-Jan-87 11:16:19 EST
Article-I.D.: cheviot.1664
Posted: Fri Jan 16 11:16:19 1987
Date-Received: Sun, 18-Jan-87 08:40:22 EST
Reply-To: andy@cheviot.newcastle.ac.uk (Andy Linton)
Distribution: world
Organization: U. of Newcastle upon Tyne, U.K.
Lines: 62