[comp.bugs.4bsd] ftpd doesn't believe passwd

mark@sickkids.UUCP (Mark Bartelt) (11/13/90)

This is one of those "I find it hard to believe nobody has reported this
before" bugs, but nonetheless ...  In vanilla 4.3bsd on a VAX:

ftpd(8) sez ...

   _F_t_p_d authenticates users according to three rules.
    [ ... ]
   3)   The user must have a standard shell returned by getusershell(3).

passwd(5) sez ...

   [ ... ] if the Shell field is null, then /_b_i_n/_s_h is used.

But ftpd nonetheless refuses to authorize a user whose shell field in
/etc/passwd is null; it won't let a Bourne shell user in unless /bin/sh
is explicitly specified in /etc/passwd.  One of several ways to fix the
problem in ftpd.c/checkuser():

Replace
	while ((cp = getusershell()) != NULL)
		if (strcmp(cp, pw->pw_shell) == 0)
			break;
	endpwent();
	endusershell();
	if (cp == NULL)
		return (0);

with
	if ( !*(pw->pw_shell) )
		endpwent();
	else {
		while ((cp = getusershell()) != NULL)
			if (strcmp(cp, pw->pw_shell) == 0)
				break;
		endpwent();
		endusershell();
		if (cp == NULL)
			return (0);
	}

Mark Bartelt                          INTERNET: mark@sickkids.toronto.edu
Hospital for Sick Children, Toronto             mark@sickkids.utoronto.ca
416/598-6442                          UUCP: {utzoo,decvax}!sickkids!mark