Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/libexec/ftpd sync ftpd to -current with the following r...



details:   https://anonhg.NetBSD.org/src/rev/c78cd00fa9ff
branches:  netbsd-1-5
changeset: 490969:c78cd00fa9ff
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Mar 29 14:14:16 2001 +0000

description:
sync ftpd to -current with the following revisions (for lukem/christos):
        Makefile        1.43-1.44
        cmds.c          1.7-1.8,  1.10-1.12
        conf.c          1.35-1.40
        extern.h        1.32-1.38
        ftpcmd.y        1.53-1.59
        ftpd.8          1.58-1.63
        ftpd.c          1.102-1.104,  1.106-1.122
        ftpd.conf.5     1.12-1.15
        ftpusers.5      1.8
        logwtmp.c       1.16
        popen.c         1.23-1.25
        version.h       1.28

a quick summary of user-visible changes;
        - fix glob DoS by using GLOB_LIMIT
        - add ftpd.conf directives `advertise', `maxfilesize', `sanenames'
        - add flags: -P dataport, -X - wuftpd style log entries,
          -q/-Q - (en|dis)able pidfiles, -u/-U - (en|dis)able utmp,
          -w/-W - (en|dis)able wtmp

diffstat:

 libexec/ftpd/Makefile    |   42 ++
 libexec/ftpd/cmds.c      |   59 +-
 libexec/ftpd/conf.c      |  292 ++++++++++----
 libexec/ftpd/extern.h    |  142 +++++--
 libexec/ftpd/ftpcmd.y    |  411 +++++++++------------
 libexec/ftpd/ftpd.8      |  148 ++++++-
 libexec/ftpd/ftpd.c      |  879 +++++++++++++++++++++++++++++++++-------------
 libexec/ftpd/ftpd.conf.5 |  242 +++++++++---
 libexec/ftpd/ftpusers.5  |    5 +-
 libexec/ftpd/logwtmp.c   |    5 +-
 libexec/ftpd/popen.c     |   22 +-
 libexec/ftpd/version.h   |    4 +-
 12 files changed, 1506 insertions(+), 745 deletions(-)

diffs (truncated from 4128 to 300 lines):

diff -r 311742f351c5 -r c78cd00fa9ff libexec/ftpd/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/ftpd/Makefile     Thu Mar 29 14:14:16 2001 +0000
@@ -0,0 +1,42 @@
+#      $NetBSD: Makefile,v 1.42.2.2 2001/03/29 14:14:16 lukem Exp $
+#      @(#)Makefile    8.2 (Berkeley) 4/4/94
+
+PROG=  ftpd
+SRCS=  cmds.c conf.c ftpd.c ftpcmd.y logutmp.c logwtmp.c popen.c
+CPPFLAGS+=-I${.CURDIR}
+DPADD+=        ${LIBCRYPT} ${LIBUTIL}
+LDADD+=        -lcrypt -lutil
+MAN=   ftpd.conf.5 ftpusers.5 ftpd.8
+MLINKS=        ftpusers.5 ftpchroot.5
+
+# for `internal' ls
+SRCS+= ls.c cmp.c print.c stat_flags.c util.c
+.PATH: ${.CURDIR}/../../bin/ls
+
+CPPFLAGS+=-DINET6
+.include <bsd.own.mk>
+
+.ifdef SKEY
+CPPFLAGS+=-DSKEY
+DPADD+= ${LIBSKEY}
+LDADD+= -lskey
+.endif
+
+ftpd.o ftpcmd.o: version.h
+
+# XXX Kerberos support is broken right now.
+#.PATH:        ${.CURDIR}/../../usr.bin/login
+
+#.ifdef KERBEROS5
+#SRCS+=        k5login.c
+#CPPFLAGS+=-DKERBEROS5
+#DPADD+= ${LIBKRB5} ${LIBK5CRYPTO} ${LIBCOM_ERR}
+#LDADD+= -lkrb5 -lk5crypto -lcom_err
+#.else
+#SRCS+=        klogin.c
+#CPPFLAGS+=-DKERBEROS
+#DPADD+= ${LIBKRB} ${LIBDES} ${LIBCOM_ERR}
+#LDADD+= -lkrb -kdes -lcom_err
+#.endif
+
+.include <bsd.prog.mk>
diff -r 311742f351c5 -r c78cd00fa9ff libexec/ftpd/cmds.c
--- a/libexec/ftpd/cmds.c       Thu Mar 29 13:03:58 2001 +0000
+++ b/libexec/ftpd/cmds.c       Thu Mar 29 14:14:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.4.2.2 2000/12/13 21:18:09 he Exp $  */
+/*     $NetBSD: cmds.c,v 1.4.2.3 2001/03/29 14:14:17 lukem Exp $       */
 
 /*
  * Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cmds.c,v 1.4.2.2 2000/12/13 21:18:09 he Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.4.2.3 2001/03/29 14:14:17 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -188,7 +188,7 @@
                perror_reply(550, name);
        } else
                ack("DELE");
-       logcmd("delete", -1, name, NULL, NULL, p);
+       logxfer("delete", -1, name, NULL, NULL, p);
 }
 
 void
@@ -219,7 +219,7 @@
                perror_reply(550, name);
        } else
                replydirname(name, "directory created.");
-       logcmd("mkdir", -1, name, NULL, NULL, p);
+       logxfer("mkdir", -1, name, NULL, NULL, p);
 }
 
 void
@@ -412,7 +412,7 @@
                perror_reply(550, name);
        } else
                ack("RMD");
-       logcmd("rmdir", -1, name, NULL, NULL, p);
+       logxfer("rmdir", -1, name, NULL, NULL, p);
 }
 
 char *
@@ -438,7 +438,7 @@
                perror_reply(550, "rename");
        } else
                ack("RNTO");
-       logcmd("rename", -1, from, to, NULL, p);
+       logxfer("rename", -1, from, to, NULL, p);
 }
 
 void
@@ -446,14 +446,17 @@
 {
        switch (type) {
        case TYPE_L:
-       case TYPE_I: {
+       case TYPE_I:
+           {
                struct stat stbuf;
                if (stat(filename, &stbuf) < 0 || !S_ISREG(stbuf.st_mode))
                        reply(550, "%s: not a plain file.", filename);
                else
-                       reply(213, "%qu", (qufmt_t)stbuf.st_size);
-               break; }
-       case TYPE_A: {
+                       reply(213, ULLF, (ULLT)stbuf.st_size);
+               break;
+           }
+       case TYPE_A:
+           {
                FILE *fin;
                int c;
                off_t count;
@@ -477,8 +480,9 @@
                }
                (void) fclose(fin);
 
-               reply(213, "%qd", (qdfmt_t)count);
-               break; }
+               reply(213, LLF, (LLT)count);
+               break;
+           }
        default:
                reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
        }
@@ -602,7 +606,7 @@
                         * since we only need this info in such a case.
                         */
        pdir = fe->pdirstat;
-       if (pdir == NULL && curclass.modify) {
+       if (pdir == NULL && CURCLASS_FLAGS_ISSET(modify)) {
                size_t          len;
                char            realdir[MAXPATHLEN], *p;
                struct stat     dir;
@@ -636,15 +640,15 @@
        }
 
                        /* 'a': can APPE to file */
-       if (wok && curclass.upload && S_ISREG(fe->stat->st_mode))
+       if (wok && CURCLASS_FLAGS_ISSET(upload) && S_ISREG(fe->stat->st_mode))
                CPUTC('a', fd);
 
                        /* 'c': can create or append to files in directory */
-       if (wok && curclass.modify && S_ISDIR(fe->stat->st_mode))
+       if (wok && CURCLASS_FLAGS_ISSET(modify) && S_ISDIR(fe->stat->st_mode))
                CPUTC('c', fd);
 
                        /* 'd': can delete file or directory */
-       if (pdirwok && curclass.modify) {
+       if (pdirwok && CURCLASS_FLAGS_ISSET(modify)) {
                int candel;
 
                candel = 1;
@@ -674,7 +678,7 @@
                CPUTC('e', fd);
 
                        /* 'f': can rename file or directory */
-       if (pdirwok && curclass.modify)
+       if (pdirwok && CURCLASS_FLAGS_ISSET(modify))
                CPUTC('f', fd);
 
                        /* 'l': can list directory */
@@ -682,11 +686,11 @@
                CPUTC('l', fd);
 
                        /* 'm': can create directory */
-       if (wok && curclass.modify && S_ISDIR(fe->stat->st_mode))
+       if (wok && CURCLASS_FLAGS_ISSET(modify) && S_ISDIR(fe->stat->st_mode))
                CPUTC('m', fd);
 
                        /* 'p': can remove files in directory */
-       if (wok && curclass.modify && S_ISDIR(fe->stat->st_mode))
+       if (wok && CURCLASS_FLAGS_ISSET(modify) && S_ISDIR(fe->stat->st_mode))
                CPUTC('p', fd);
 
                        /* 'r': can RETR file */
@@ -694,7 +698,7 @@
                CPUTC('r', fd);
 
                        /* 'w': can STOR file */
-       if (wok && curclass.upload && S_ISREG(fe->stat->st_mode))
+       if (wok && CURCLASS_FLAGS_ISSET(upload) && S_ISREG(fe->stat->st_mode))
                CPUTC('w', fd);
 
        CPUTC(';', fd);
@@ -705,7 +709,7 @@
 {
 
        if (S_ISREG(fe->stat->st_mode))
-               cprintf(fd, "%s=%lld;", fact, (long long)fe->stat->st_size);
+               cprintf(fd, "%s=" LLF ";", fact, (LLT)fe->stat->st_size);
 }
 
 static void
@@ -788,18 +792,21 @@
 replydirname(const char *name, const char *message)
 {
        char *p, *ep;
-       char npath[MAXPATHLEN];
+       char npath[MAXPATHLEN * 2];
 
        p = npath;
        ep = &npath[sizeof(npath) - 1];
        while (*name) {
-               if (*name == '"' && ep - p >= 2) {
+               if (*name == '"') {
+                       if (ep - p < 2)
+                               break;
                        *p++ = *name++;
                        *p++ = '"';
-               } else if (ep - p >= 1)
+               } else {
+                       if (ep - p < 1)
+                               break;
                        *p++ = *name++;
-               else
-                       break;
+               }
        }
        *p = '\0';
        reply(257, "\"%s\" %s", npath, message);
diff -r 311742f351c5 -r c78cd00fa9ff libexec/ftpd/conf.c
--- a/libexec/ftpd/conf.c       Thu Mar 29 13:03:58 2001 +0000
+++ b/libexec/ftpd/conf.c       Thu Mar 29 14:14:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.31.2.1 2000/07/25 08:38:37 lukem Exp $      */
+/*     $NetBSD: conf.c,v 1.31.2.2 2001/03/29 14:14:17 lukem Exp $      */
 
 /*-
  * Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
@@ -38,17 +38,19 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: conf.c,v 1.31.2.1 2000/07/25 08:38:37 lukem Exp $");
+__RCSID("$NetBSD: conf.c,v 1.31.2.2 2001/03/29 14:14:17 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/param.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
 
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <glob.h>
+#include <netdb.h>
 #include <setjmp.h>
 #include <signal.h>
 #include <stdio.h>
@@ -71,6 +73,13 @@
 static int filetypematch(char *, int);
 
 
+               /* class defaults */
+#define DEFAULT_LIMIT          -1              /* unlimited connections */
+#define DEFAULT_MAXFILESIZE    -1              /* unlimited file size */
+#define DEFAULT_MAXTIMEOUT     7200            /* 2 hours */
+#define DEFAULT_TIMEOUT                900             /* 15 minutes */
+#define DEFAULT_UMASK          027             /* 15 minutes */
+
 /*
  * Initialise curclass to an `empty' state
  */
@@ -88,29 +97,34 @@
                free(conv);
        }
 
-       curclass.checkportcmd = 1;
+       memset((char *)&curclass.advertise, 0, sizeof(curclass.advertise));
+       curclass.advertise.su_len = 0;          /* `not used' */
        REASSIGN(curclass.chroot, NULL);
        REASSIGN(curclass.classname, NULL);
        curclass.conversions =  NULL;
        REASSIGN(curclass.display, NULL);
        REASSIGN(curclass.homedir, NULL);
-       curclass.limit =        -1;             /* unlimited connections */
+       curclass.limit =        DEFAULT_LIMIT;  
        REASSIGN(curclass.limitfile, NULL);
+       curclass.maxfilesize =  DEFAULT_MAXFILESIZE;
        curclass.maxrateget =   0;
        curclass.maxrateput =   0;
-       curclass.maxtimeout =   7200;           /* 2 hours */
-       curclass.modify =       1;
+       curclass.maxtimeout =   DEFAULT_MAXTIMEOUT;
        REASSIGN(curclass.motd, xstrdup(_PATH_FTPLOGINMESG));
        REASSIGN(curclass.notify, NULL);
-       curclass.passive =      1;
        curclass.portmin =      0;
        curclass.portmax =      0;



Home | Main Index | Thread Index | Old Index