Subject: Fixes/cleanup for HP-UX

From: Richard Allen <[email-masked]>
Date: Wed, 14 Jan 1998 15:46:45 +0000

I've been toying around a bit with wu-ftpd beta 16 and frankly it look's
very nice, except for a few things on HP-UX.  The biggest feature of
the included patch is support for HP-UX 10 trusted mode (HP's shadow
passwd's). All the code was already in wu-ftpd, disguised as SecureWare
(OSF) code ;)  Therefore, all that was needed was to tweak ifdef's 
around a bit.

Regards...

*** src/ftpd.c.cln	Sun des 21 23:25:06 1997
--- src/ftpd.c	Mið jan 14 15:27:03 1998
***************
*** 245,250 ****
--- 245,255 ----
  #include <prot.h>
  #endif
  
+ #ifdef HPUX_10_TRUSTED
+ #include <hpsecurity.h>
+ #include <prot.h>
+ #endif
+ 
  int anonymous = 1;
  int guest;
  int type;
***************
*** 920,926 ****
      register struct authorization *q;
  #endif /* KERBEROS */
  
! #ifdef SecureWare
      struct pr_passwd *pr;
  #endif
  
--- 925,931 ----
      register struct authorization *q;
  #endif /* KERBEROS */
  
! #if defined(SecureWare) || defined(HPUX_10_TRUSTED)
      struct pr_passwd *pr;
  #endif
  
***************
*** 931,947 ****
  #endif /* KERBEROS */
  
  #ifdef M_UNIX
! # ifdef SecureWare
      if ((pr = getprpwnam(name)) == NULL)
          goto DONE;
! # endif /* SecureWare */
      if ((p = getpwnam(name)) == NULL)
          goto DONE;
  #else   /* M_UNIX */
! # ifdef SecureWare
      if ((pr = getprpwnam(name)) == NULL)
          return((struct passwd *) pr);
! # endif /* SecureWare */
      if ((p = getpwnam(name)) == NULL)
          return (p);
  #endif  /* M_UNIX */
--- 936,952 ----
  #endif /* KERBEROS */
  
  #ifdef M_UNIX
! # if defined(SecureWare) || defined(HPUX_10_TRUSTED)
      if ((pr = getprpwnam(name)) == NULL)
          goto DONE;
! # endif /* SecureWare || HPUX_10_TRUSTED */
      if ((p = getpwnam(name)) == NULL)
          goto DONE;
  #else   /* M_UNIX */
! # if defined(SecureWare) || defined(HPUX_10_TRUSTED)
      if ((pr = getprpwnam(name)) == NULL)
          return((struct passwd *) pr);
! # endif /* SecureWare || HPUX_10_TRUSTED */
      if ((p = getpwnam(name)) == NULL)
          return (p);
  #endif  /* M_UNIX */
***************
*** 958,964 ****
  
  #ifdef KERBEROS
      save.pw_passwd = sgetsave(q->a_password);
! #elif defined(SecureWare)
      if (pr->uflg.fg_encrypt && pr->ufld.fd_encrypt && *pr->ufld.fd_encrypt)
         save.pw_passwd = sgetsave(pr->ufld.fd_encrypt);
      else
--- 963,969 ----
  
  #ifdef KERBEROS
      save.pw_passwd = sgetsave(q->a_password);
! #elif defined(SecureWare) || defined(HPUX_10_TRUSTED)
      if (pr->uflg.fg_encrypt && pr->ufld.fd_encrypt && *pr->ufld.fd_encrypt)
         save.pw_passwd = sgetsave(pr->ufld.fd_encrypt);
      else
***************
*** 1007,1013 ****
  DONE:
      endpwent();
  #endif
! #ifdef SecureWare
      endprpwent();
  #endif
  #ifdef M_UNIX
--- 1012,1018 ----
  DONE:
      endpwent();
  #endif
! #if defined(SecureWare) || defined(HPUX_10_TRUSTED)
      endprpwent();
  #endif
  #ifdef M_UNIX
***************
*** 1431,1437 ****
  	  salt = "xx";
  	else
  	  salt = pw->pw_passwd;
! #ifdef SECUREOSF
  	  xpasswd = bigcrypt(passwd, salt);
  #else
  #ifdef KERBEROS
--- 1436,1442 ----
  	  salt = "xx";
  	else
  	  salt = pw->pw_passwd;
! #if defined(SECUREOSF) || defined(HPUX_10_TRUSTED)
  	  xpasswd = bigcrypt(passwd, salt);
  #else
  #ifdef KERBEROS
***************
*** 2366,2372 ****
   
          timeout.tv_usec = 0;
          timeout.tv_sec = 120;
! #ifdef hpux
          if (select(pdata+1, (int *)&set, NULL, NULL, &timeout) == 0 ||
  #else
          if (select(pdata+1, &set, (fd_set *) 0, (fd_set *) 0, &timeout) == 0 ||
--- 2371,2377 ----
   
          timeout.tv_usec = 0;
          timeout.tv_sec = 120;
! #ifdef HPUX9
          if (select(pdata+1, (int *)&set, NULL, NULL, &timeout) == 0 ||
  #else
          if (select(pdata+1, &set, (fd_set *) 0, (fd_set *) 0, &timeout) == 0 ||
*** src/pathnames.h.cln	Mið jan 14 13:48:55 1998
--- src/pathnames.h	Mið jan 14 15:31:41 1998
***************
*** 45,50 ****
--- 45,56 ----
  #define _PATH_CVT       "/etc/ftpd/ftpconversions"
  #define _PATH_PRIVATE   "/etc/ftpd/ftpgroups"
  #else
+ #ifdef USE_OPT_FTPD
+ #define _PATH_FTPUSERS  "/opt/ftpd/lib/ftpusers"
+ #define _PATH_FTPACCESS "/opt/ftpd/lib/ftpaccess"
+ #define _PATH_CVT       "/opt/ftpd/lib/ftpconversions"
+ #define _PATH_PRIVATE   "/opt/ftpd/lib/ftpgroups"
+ #else
  #define _PATH_FTPUSERS  "/usr/local/lib/ftpd/ftpusers"
  #define _PATH_FTPACCESS "/usr/local/lib/ftpd/ftpaccess"
  #define _PATH_CVT       "/usr/local/lib/ftpd/ftpconversions"
***************
*** 51,56 ****
--- 57,63 ----
  #define _PATH_PRIVATE   "/usr/local/lib/ftpd/ftpgroups"
  #endif
  #endif
+ #endif
  
  #ifdef USE_VAR
  #ifdef USE_PID
***************
*** 117,123 ****
--- 124,134 ----
  #ifdef USE_ETC_FTPD
  #define _PATH_FTPHOSTS  "/etc/ftpd/ftphosts"
  #else
+ #ifdef USE_OPT_FTPD
+ #define _PATH_FTPHOSTS  "/opt/ftpd/lib/ftphosts"
+ #else
  #define _PATH_FTPHOSTS  "/usr/local/lib/ftpd/ftphosts"
+ #endif
  #endif
  #endif
  #endif
*** src/config/config.hpx.cln	Mið jan 14 13:37:00 1998
--- src/config/config.hpx	Mið jan 14 15:00:20 1998
***************
*** 21,29 ****
  #define REGEX
  #define REGEXEC
  #define SPT_TYPE SPT_PSTAT
- #ifdef V4FS
  #define HAVE_GETRLIMIT
- #endif
  #undef  SHADOW_PASSWORD
  #define SVR4
  #define UPLOAD
--- 21,27 ----
***************
*** 31,38 ****
--- 29,46 ----
  #ifndef VIRTUAL
  #define VIRTUAL
  #endif
+ #undef HPUX9
+ #undef HPUX_10_TRUSTED
  
+ #ifdef HPUX9
  #define _PATH_WTMP "/etc/wtmp"
+ #undef USE_VAR
+ #else
+ #define _PATH_WTMP "/var/adm/wtmp"
+ #define USE_OPT_FTPD
+ #define USE_VAR
+ #define VAR_RUN
+ #endif
  
  #define RLIM_INFINITY 0x7fffffff
  #define	seteuid(x)	setresuid(-1,x,-1)
*** src/makefiles/Makefile.hpx.cln	Mið jan 14 13:58:53 1998
--- src/makefiles/Makefile.hpx	Mið jan 14 14:52:12 1998
***************
*** 5,12 ****
  CC       = cc
  IFLAGS   = -I.. -I../support
  LFLAGS   =
! CFLAGS   = -Aa -Dunix -D_HPUX_SOURCE -O ${IFLAGS} ${LFLAGS}
! LIBES    = ../support/libsupport.a
  LIBC     = /lib/libc.a
  LINTFLAGS=	
  LKERB    = -lauth -lckrb -lkrb -ldes
--- 5,12 ----
  CC       = cc
  IFLAGS   = -I.. -I../support
  LFLAGS   =
! CFLAGS   = -Aa -Dunix -D_HPUX_SOURCE -O +Onolimit ${IFLAGS} ${LFLAGS}
! LIBES    = ../support/libsupport.a -lsec
  LIBC     = /lib/libc.a
  LINTFLAGS=	
  LKERB    = -lauth -lckrb -lkrb -ldes

-- 
Rikki.
Bell Labs Unix -- Reach out and grep someone.
ech`echo "xiun"|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol

---

From: [email-masked] (Einar Indridason)
Date: Wed, 14 Jan 1998 16:34:17 +0000 (GMT)

> (OSF) code ;)  Therefore, all that was needed was to tweak ifdef's 

Which brings up a question I have.  Wouldn't it be better to restruct the
wu-ftpd code so that we won't have that spaghetti of "ifdef this and that
and not this_one", but would instead have something like:

#ifdef HAS_THIS_FUNCTION
	x = has_this_function(a1, a2, a3);
#endif
#ifdef HAS_THAT_FUNCTION
	x = has_that_function(a3, a1, a2);
#endif

We might even look at using some auto-configuration tool, like (for
example) GNU's autoconfig.  That way, we might have something like:

% ./configure --with-chroot-for-ordinary-users --log-paranoid
--deny-port-bounce --log-level=local7
...........
% make

Instead of the current one:

% ./build lnx
% ./build ult
% ./build sol
% ./build s41

etc...

???  This is just a thought...

--
[email-masked]