Subject: [227] WU ftpd 2.4 on Irix 5.2?

From: [email-masked] (David J. MacKenzie)
Date: Thu, 28 Jul 1994 10:24:34 -0400

I'm trying to get the WU ftpd 2.4 to work on Irix 5.2 (an Indy).
I had to make a bunch of changes to get it to compile (diffs below),
but even then ftp'ing to the machine gives me "connection refused".
Has anyone done this already?

Specific problems I ran into:

1.  <syslog.h> does #include <stdarg.h> if __STDC__ is defined, so
the #include <varargs.h> in ftpd.c fails.  I modernized ftpd.c to use
stdarg.h if __STDC__, and added decls for the varargs functions.  I'm
not sure which header file is most appropriate for them, so I just
picked one that all their callers include.

2.  stdlib.h declares realpath to have a const first argument.  This
seems reasonable, so I added the const.

3.  sys/param.h doesn't define NCARGS, so I gave it a reasonable
    value.

4.  There's no libc.a, only shared versions, so I commented it out of
    the Makefile.sgi. 

--- 1.1	1994/07/28 13:27:23
+++ ./src/extensions.h	1994/07/28 13:46:32
@@ -44,3 +44,14 @@
 #define ARG8    entry->arg[8]
 #define ARG9    entry->arg[9]
 #define ARG     entry->arg
+
+#if __STDC__
+/* ANSI C requires varargs functions to have prototypes.  */
+#if defined(HAVE_VPRINTF)
+void reply(int n, char *fmt, ...);
+void lreply(int n, char *fmt, ...);
+#endif
+#if defined(SETPROCTITLE) && !defined(setproctitle)
+void setproctitle(char *fmt, ...);
+#endif
+#endif /* __STDC__ */
--- 1.2	1994/07/20 22:35:03
+++ ./src/ftpd.c	1994/07/28 13:35:12
@@ -71,7 +71,13 @@
 #include <netdb.h>
 #include <errno.h>
 #include <string.h>
+#if __STDC__
+#include <stdarg.h>
+#define VA_START(args, lastarg) va_start(args, lastarg)
+#else
 #include <varargs.h>
+#define VA_START(args, lastarg) va_start(args)
+#endif
 #ifdef SYSSYSLOG
 #include <sys/syslog.h>
 #else
@@ -140,7 +146,7 @@
 extern int ftpd_pclose(FILE *iop),
   fclose(FILE *);
 extern char *getline(),
- *realpath(char *pathname, char *result);
+ *realpath(const char *pathname, char *result);
 extern char cbuf[];
 extern off_t restart_point;
 
@@ -2031,18 +2037,19 @@
 
 #if defined (HAVE_VPRINTF)
 /* VARARGS2 */
-reply(va_alist)
+#if __STDC__
+void reply(int n, char *fmt, ...)
+#else
+void
+reply(n, fmt, va_alist)
+  int n;
+  char *fmt;
   va_dcl
+#endif
 {
-    int n;
-    char *fmt;
     va_list ap;
     
-    va_start(ap);
-    /* first argument is always the return code */
-    n = va_arg(ap, int);
-    /* second argument is always fmt string     */
-    fmt = va_arg(ap, char *);
+    VA_START(ap, fmt);
 
     if (autospout != NULL) {
         char *ptr = autospout;
@@ -2082,18 +2089,19 @@
 }
 
 /* VARARGS2 */
-lreply(va_alist)
+#if __STDC__
+void lreply(int n, char *fmt, ...)
+#else
+void
+lreply(n, fmt, va_alist)
+  int n;
+  char *fmt;
   va_dcl
+#endif
 {
     va_list ap;
-    int n;
-    char *fmt;
 
-    va_start(ap);
-    /* first argument is always the return code */
-    n = va_arg(ap, int);
-    /* second argument is always fmt string     */
-    fmt = va_arg(ap, char *);
+    VA_START(ap, fmt);
 
     if (!dolreplies)
         return;
@@ -2115,6 +2123,7 @@
 
 #else
 /* VARARGS2 */
+void
 reply(int n, char *fmt, int p0, int p1, int p2, int p3, int p4, int p5)
 {
     if (autospout != NULL) {
@@ -2149,6 +2158,7 @@
 }
 
 /* VARARGS2 */
+void
 lreply(int n, char *fmt, int p0, int p1, int p2, int p3, int p4, int p5)
 {
     if (!dolreplies)
@@ -2701,11 +2711,16 @@
 #endif
 
 /* VARARGS2 */
-setproctitle(va_alist)
+#if __STDC__
+void setproctitle(char *fmt, ...)
+#else
+void
+setproctitle(fmt, va_alist)
+  char *fmt;
   va_dcl
+#endif
 {
     va_list ap;
-    char *fmt;
 
     register char *p,
      *bp,
@@ -2716,9 +2731,7 @@
     union pstun un;
 #endif
 
-    va_start(ap);
-    /* first argument is always the fmt string */
-    fmt = va_arg(ap, char *);
+    VA_START(ap, fmt);
 
     (void) vsprintf(buf, fmt, ap);
     va_end(ap);
--- 1.1	1994/07/28 13:49:49
+++ ./src/glob.c	1994/07/28 14:03:11
@@ -58,6 +58,10 @@
 #define	QUOTE 0200
 #define	TRIM 0177
 #define	eq(a,b)		(strcmp(a, b)==0)
+#ifndef NCARGS
+/* Irix 5.2 doesn't define NCARGS.  Use the value from Decstations.  */
+#define NCARGS 20480
+#endif
 #define	GAVSIZ		(NCARGS/6)
 #define	isdir(d)	((d.st_mode & S_IFMT) == S_IFDIR)
 
--- 1.2	1994/07/28 13:08:02
+++ ./src/makefiles/Makefile.sgi	1994/07/28 14:04:22
@@ -3,10 +3,10 @@
 LFLAGS   = -L../support
 CFLAGS   = -O -DDEBUG ${IFLAGS} ${LFLAGS}
 LIBES    = -lsupport ${LGLUE}
-LIBC     = /usr/lib/libc.a
+#LIBC     = /usr/lib/libc.a
 LINTFLAGS=	
 LKERB    = -lauth -lckrb -lkrb -ldes
 MKDEP    = ../util/mkdep
 
 SRCS   = ftpd.c ftpcmd.c glob.c logwtmp.c popen.c vers.c access.c extensions.c \
--- 1.1	1994/07/28 13:35:23
+++ ./src/realpath.c	1994/07/28 13:35:27
@@ -42,7 +42,7 @@
 #endif
 
 char *
-realpath(char *pathname, char *result)
+realpath(const char *pathname, char *result)
 {
     struct stat sbuf;
     char curpath[MAXPATHLEN],