Source-Changes-HG archive

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

[src/trunk]: src/libexec/ftpd * new ftpd.conf directive:



details:   https://anonhg.NetBSD.org/src/rev/664fdfaec368
branches:  trunk
changeset: 480320:664fdfaec368
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Jan 09 10:08:45 2000 +0000

description:
* new ftpd.conf directive:
        template class [refclass]
  following directives for refclass will apply to class as well.
  this makes setting up a `template' class with many default settings
  easy, whilst allowing for class-specific overrides
* prevent crash when the optional limitfile wasn't given to limit
* document count_users()
* document default setting of limit in ftpd.conf(5)
* crank version

diffstat:

 libexec/ftpd/conf.c      |  29 ++++++++++++++++++++++-------
 libexec/ftpd/ftpd.conf.5 |  30 +++++++++++++++++++++++++-----
 libexec/ftpd/version.h   |   4 ++--
 3 files changed, 49 insertions(+), 14 deletions(-)

diffs (194 lines):

diff -r 993d54de67a9 -r 664fdfaec368 libexec/ftpd/conf.c
--- a/libexec/ftpd/conf.c       Sun Jan 09 10:05:55 2000 +0000
+++ b/libexec/ftpd/conf.c       Sun Jan 09 10:08:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.25 2000/01/08 11:09:56 lukem Exp $  */
+/*     $NetBSD: conf.c,v 1.26 2000/01/09 10:08:45 lukem Exp $  */
 
 /*-
  * Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: conf.c,v 1.25 2000/01/08 11:09:56 lukem Exp $");
+__RCSID("$NetBSD: conf.c,v 1.26 2000/01/09 10:08:45 lukem Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -101,8 +101,6 @@
        REASSIGN(curclass.motd, xstrdup(_PATH_FTPLOGINMESG));
        REASSIGN(curclass.notify, NULL);
        curclass.passive =      1;
-       curclass.maxrateget =   0;
-       curclass.maxrateput =   0;
        curclass.rateget =      0;
        curclass.rateput =      0;
        curclass.timeout =      900;            /* 15 minutes */
@@ -124,7 +122,7 @@
        size_t           len;
        int              none, match, rate;
        char            *endp;
-       char            *class, *word, *arg;
+       char            *class, *word, *arg, *template;
        const char      *infile;
        size_t           line;
        unsigned int     timeout;
@@ -142,6 +140,7 @@
                return;
 
        line = 0;
+       template = NULL;
        for (;
            (buf = fparseln(f, &len, &line, NULL, FPARSELN_UNESCCOMM |
                        FPARSELN_UNESCCONT | FPARSELN_UNESCESC)) != NULL;
@@ -162,7 +161,8 @@
                        continue;
                if (strcasecmp(class, "none") == 0)
                        none = 1;
-               if (strcasecmp(class, findclass) != 0 &&
+               if ((strcasecmp(class, findclass) != 0 &&
+                   (template != NULL && strcasecmp(class, template) != 0)) &&
                    !none && strcasecmp(class, "all") != 0)
                        continue;
 
@@ -261,7 +261,8 @@
                                continue;
                        }
                        curclass.limit = limit;
-                       REASSIGN(curclass.limitfile, xstrdup(p));
+                       REASSIGN(curclass.limitfile,
+                           EMPTYSTR(p) ? NULL : xstrdup(p));
 
                } else if (strcasecmp(word, "maxtimeout") == 0) {
                        if (none || EMPTYSTR(arg))
@@ -368,6 +369,11 @@
                        }
                        curclass.timeout = timeout;
 
+               } else if (strcasecmp(word, "template") == 0) {
+                       if (none)
+                               continue;
+                       REASSIGN(template, EMPTYSTR(arg) ? NULL : xstrdup(arg));
+
                } else if (strcasecmp(word, "umask") == 0) {
                        mode_t umask;
 
@@ -397,6 +403,7 @@
                        continue;
                }
        }
+       REASSIGN(template, NULL);
        fclose(f);
 }
 
@@ -742,6 +749,14 @@
        return (val);
 }
 
+/*
+ * Count the number of current connections, reading from
+ *     /var/run/ftpd.pids-<class>
+ * Does a kill -0 on each pid in that file, and only counts
+ * processes that exist (or frees the slot if it doesn't).
+ * Adds getpid() to the first free slot. Truncates the file
+ * if possible.
+ */ 
 void
 count_users()
 {
diff -r 993d54de67a9 -r 664fdfaec368 libexec/ftpd/ftpd.conf.5
--- a/libexec/ftpd/ftpd.conf.5  Sun Jan 09 10:05:55 2000 +0000
+++ b/libexec/ftpd/ftpd.conf.5  Sun Jan 09 10:08:45 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ftpd.conf.5,v 1.6 2000/01/08 11:09:56 lukem Exp $
+.\"    $NetBSD: ftpd.conf.5,v 1.7 2000/01/09 10:08:45 lukem Exp $
 .\"
 .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -34,7 +34,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 8, 2000
+.Dd January 9, 2000
 .Dt FTPD.CONF 5
 .Os
 .Sh NAME
@@ -200,7 +200,7 @@
 exists, and if so, display its contents to the user.
 Escape sequences are supported; refer to
 .Sx Display file escape sequences
-in 
+in
 .Xr ftpd 8
 for more information.
 .It Xo Sy limit Ar class
@@ -258,7 +258,7 @@
 as the message of the day file to display after login.
 Escape sequences are supported; refer to
 .Sx Display file escape sequences
-in 
+in
 .Xr ftpd 8
 for more information.
 .It Sy notify Ar class Op Ar fileglob
@@ -290,7 +290,7 @@
 .Ar rate
 is 0, the throttle is disabled.
 .Pp
-An optional suffix may be provided, which changes the intrepretation of 
+An optional suffix may be provided, which changes the intrepretation of
 .Ar rate
 as follows:
 .Bl -tag -width 3n -offset indent -compact
@@ -310,6 +310,25 @@
 .Ar rate ,
 which is parsed as per
 .Sy rateget Ar rate .
+.It Sy template Ar class Op Ar refclass
+Define
+.Ar refclass
+as the
+.Sq template
+for
+.Ar class ;
+any reference to
+.Ar refclass
+in following directives will also apply to members of
+.Ar class .
+This is useful to define a template class so that other classes which are
+to share common attributes can be easily defined without unnecessary
+duplication.
+There can be only one template defined at a time.
+If
+.Ar refclass
+is not given, disable the template for
+.Ar class .
 .It Sy timeout Ar class Ar time
 Set the inactivity timeout period.
 (the default is fifteen minutes).
@@ -354,6 +373,7 @@
 classtype     guest  GUEST
 classtype     real   REAL
 display       none
+limit         all    -1     # unlimited connections
 maxtimeout    all    7200   # 2 hours
 modify        all
 motd          all    motd
diff -r 993d54de67a9 -r 664fdfaec368 libexec/ftpd/version.h
--- a/libexec/ftpd/version.h    Sun Jan 09 10:05:55 2000 +0000
+++ b/libexec/ftpd/version.h    Sun Jan 09 10:08:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.4 2000/01/08 11:09:56 lukem Exp $        */
+/*     $NetBSD: version.h,v 1.5 2000/01/09 10:08:45 lukem Exp $        */
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,5 +36,5 @@
  */
 
 #ifndef FTPD_VERSION
-#define        FTPD_VERSION    "Version: NetBSD-ftpd/20000108"
+#define        FTPD_VERSION    "Version: NetBSD-ftpd/20000109"
 #endif



Home | Main Index | Thread Index | Old Index