To: jkimball@src.honeywell.com (John Kimball)
Cc: sun-nets@brillig.umd.edu
Subject: My SunOS 3.5 patches for the Berkeley ftpd source
Date: Thu, 17 Nov 88 12:02:20 -0800
From: steve@mahendo.Jpl.Nasa.Gov
Sender: Sun-Nets-request@brillig.umd.edu


When I went to put the Berkeley ftpd code together I also ran into
compiler/ linker problems.  I did a mild hack on the code and was able
to get it to compile/link and run on a Sun 3/160, a 3/50 and a 3/60 all
running SunOS 3.5 It was necessary to define LOG_DAEMON (openlog is
differant--on 3.5 it doesn't take a third argument) uid_t (not defined
anywhere--used for process ID so I defined it to be int).  Under 3.5
there is no /etc/shells file and no getusershell() or endusershell()
functions.  For these, I replaced the code in ftpd.c with strcmp's to
"/bin/sh" and "/bin/csh" and don't allow any other shells.  Good enough
for mahendo et al.  Others may need to add other shells by modifying
the code.

		steve@mahendo.jpl.nasa.gov [128.149.16.2]

Context diffs suitable for patch follow:

*** Makefile.old	Wed Nov  9 14:53:39 1988
--- Makefile	Wed Nov  9 10:56:49 1988
***************
*** 16,22 ****
  #
  #	@(#)Makefile	5.8 (Berkeley) 9/22/88
  #
! CFLAGS=	-O
  LIBC=	/lib/libc.a
  SRCS=	ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c
  OBJS=	ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o
--- 16,23 ----
  #
  #	@(#)Makefile	5.8 (Berkeley) 9/22/88
  #
! CFLAGS=	-O -DLOG_DAEMON -fsoft -Duid_t=int
! # originally was CFLAGS=	-O
  LIBC=	/lib/libc.a
  SRCS=	ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c
  OBJS=	ftpd.o ftpcmd.o glob.o logwtmp.o popen.o vers.o
*** ftpd.c.old	Wed Nov  9 10:31:37 1988
--- ftpd.c	Wed Nov  9 11:07:59 1988
***************
*** 836,851 ****
  	struct passwd *p;
  	char *shell;
  	int found = 0;
! 	char line[BUFSIZ], *index(), *getusershell();
  
  	if ((p = getpwnam(name)) == NULL)
  		return (0);
  	if ((shell = p->pw_shell) == NULL || *shell == 0)
  		shell = "/bin/sh";
! 	while ((cp = getusershell()) != NULL)
! 		if (strcmp(cp, shell) == 0)
! 			break;
! 	endusershell();
  	if (cp == NULL)
  		return (0);
  	if ((fd = fopen(FTPUSERS, "r")) == NULL)
--- 836,861 ----
  	struct passwd *p;
  	char *shell;
  	int found = 0;
! 	char line[BUFSIZ], *index();
! /*	char *getusershell();			not available on SunOS 3.5
!  *						steve@mahendo.jpl.nasa.gov
!  */
  
  	if ((p = getpwnam(name)) == NULL)
  		return (0);
  	if ((shell = p->pw_shell) == NULL || *shell == 0)
  		shell = "/bin/sh";
! 	if( !strcmp( shell, "/bin/sh" ) )
! 		cp = "/bin/sh";
! 	else if( !strcmp( shell, "/bin/csh" ) )
! 		cp = "/bin/csh";
! 	else
! 		cp = (char *)0;
! /*	while ((cp = getusershell()) != NULL)	steve@mahendo.jpl.nasa.gov
!  *		if (strcmp(cp, shell) == 0)
!  *			break;
!  *	endusershell();
!  */
  	if (cp == NULL)
  		return (0);
  	if ((fd = fopen(FTPUSERS, "r")) == NULL)

