chsh/passwd -s in 4.3BSD
Andy Linton
andy at cheviot.newcastle.ac.uk
Sat Jan 17 02:16:19 AEST 1987
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 at cs.ucl.ac.uk
JANET : andy at uk.ac.newcastle.cheviot
UUCP : andy at cheviot.UUCP
*** Ni fui moran beagan d'aon rud, ach is fui moran beagan ceille. ***
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list