diff options
| author | lukem <lukem@NetBSD.org> | 1999-12-16 02:21:37 +0000 |
|---|---|---|
| committer | lukem <lukem@NetBSD.org> | 1999-12-16 02:21:37 +0000 |
| commit | e11b8f48c5340e656b0e69eda158bb56e49574e3 (patch) | |
| tree | 7960facb58d30f579bf92c7f9010c060843286d7 /libexec | |
| parent | 6be4a7c9bdfd33a843dcab44473c488d6be59a42 (diff) | |
* add support for `-h hostname', which defines the hostname to advertise
as (useful for virtual ftp servers in conjunction with inetd.conf(5)'s
ability to bind to a specific address).
if this option is used, add `hostname' to the syslog messages.
* improve documentation of command-line options
* don't allow class names of `all' or `none' in ftpusers
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ftpd/ftpd.8 | 36 | ||||
| -rw-r--r-- | libexec/ftpd/ftpd.c | 40 |
2 files changed, 58 insertions, 18 deletions
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8 index 0862fabf884..58f37bad735 100644 --- a/libexec/ftpd/ftpd.8 +++ b/libexec/ftpd/ftpd.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftpd.8,v 1.43 1999/12/16 01:16:04 lukem Exp $ +.\" $NetBSD: ftpd.8,v 1.44 1999/12/16 02:21:37 lukem Exp $ .\" .\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -67,7 +67,7 @@ .\" .\" @(#)ftpd.8 8.2 (Berkeley) 4/19/94 .\" -.Dd December 13, 1999 +.Dd December 16, 1999 .Dt FTPD 8 .Os .Sh NAME @@ -80,6 +80,7 @@ Internet File Transfer Protocol server .Op Fl a Ar anondir .Op Fl c Ar confdir .Op Fl C Ar user +.Op Fl h Ar hostname .Sh DESCRIPTION .Nm is the Internet File Transfer Protocol server process. @@ -92,18 +93,22 @@ service specification; see .Pp Available options: .Bl -tag -width Ds -.It Fl a -Define the directory to +.It Fl a Ar anondir +Define +.Ar anondir +as the directory to .Xr chroot 2 into for anonymous logins. Default is the home directory for the ftp user. -.It Fl c +.It Fl c Ar confdir Change the root directory of the configuration files from .Dq Pa /etc to -.Ar directory . -.It Fl C -Check whether the specified user would be granted access under +.Ar confdir . +.It Fl C Ar user +Check whether +.Ar user +would be granted access under the restrictions given in .Xr ftpusers 5 and exit without attempting a connection. @@ -112,6 +117,21 @@ exits with an exit code of 0 if access would be granted, or 1 otherwise. This can be useful for testing configurations. .It Fl d Debugging information is written to the syslog using LOG_FTP. +.It Fl h Ar hostname +Hostname to advertise as (defaults to +.Xr hostname 1 ) . +If this option is used, each syslog messages has +.Ar hostname +inserted before the +.Dq ftpd[\fIpid\fR] +string. +This option is useful when configuring +.Sq virtual +.Tn FTP +servers, each listening on separate addresses as separate names. +Refer to +.Xr inetd.conf 5 +for more information on starting services to listen on specific IP addresses. .It Fl l Each successful and failed .Xr ftp 1 diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 433059756ae..1ac5da1d177 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftpd.c,v 1.75 1999/12/13 16:30:37 itojun Exp $ */ +/* $NetBSD: ftpd.c,v 1.76 1999/12/16 02:21:40 lukem Exp $ */ /* * Copyright (c) 1997-1999 The NetBSD Foundation, Inc. @@ -109,7 +109,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: ftpd.c,v 1.75 1999/12/13 16:30:37 itojun Exp $"); +__RCSID("$NetBSD: ftpd.c,v 1.76 1999/12/16 02:21:40 lukem Exp $"); #endif #endif /* not lint */ @@ -265,17 +265,19 @@ main(argc, argv) int argc; char *argv[]; { - int addrlen, ch, on = 1, tos, keepalive; + int addrlen, ch, on = 1, tos, keepalive; + char thost[MAXHOSTNAMELEN+6]; /* hostname + " ftpd" */ #ifdef KERBEROS5 - krb5_error_code kerror; + krb5_error_code kerror; #endif debug = 0; logging = 0; sflag = 0; (void)strcpy(confdir, _DEFAULT_CONFDIR); + hostname[0] = '\0'; - while ((ch = getopt(argc, argv, "a:c:C:dlst:T:u:v46")) != -1) { + while ((ch = getopt(argc, argv, "a:c:C:dh:lst:T:u:v46")) != -1) { switch (ch) { case 'a': anondir = optarg; @@ -294,6 +296,10 @@ main(argc, argv) debug = 1; break; + case 'h': + strlcpy(hostname, optarg, sizeof(hostname)); + break; + case 'l': logging++; /* > 1 == extra logging */ break; @@ -329,7 +335,9 @@ main(argc, argv) * LOG_NDELAY sets up the logging connection immediately, * necessary for anonymous ftp's that chroot and can't do it later. */ - openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); + snprintf(thost, sizeof(thost), "%s%sftpd", hostname, + hostname[0] != '\0' ? " " : ""); + openlog(thost, LOG_PID | LOG_NDELAY, LOG_FTP); addrlen = sizeof(his_addr); /* xxx */ if (getpeername(0, (struct sockaddr *)&his_addr, &addrlen) < 0) { syslog(LOG_ERR, "getpeername (%s): %m",argv[0]); @@ -447,8 +455,10 @@ main(argc, argv) } (void)format_file(conffilename(_PATH_FTPWELCOME), 220); /* reply(220,) must follow */ - (void)gethostname(hostname, sizeof(hostname)); - hostname[sizeof(hostname) - 1] = '\0'; + if (hostname[0] == '\0') { + (void)gethostname(hostname, sizeof(hostname)); + hostname[sizeof(hostname) - 1] = '\0'; + } reply(220, "%s FTP server (%s) ready.", hostname, version); curclass.timeout = 300; /* 5 minutes, as per login(1) */ @@ -609,7 +619,7 @@ checkuser(fname, name, def, nofile, retclass) FILE *fd; int retval; char *glob, *perm, *class, *buf, *p; - size_t len; + size_t len, line; retval = def; if (retclass != NULL) @@ -617,8 +627,9 @@ checkuser(fname, name, def, nofile, retclass) if ((fd = fopen(conffilename(fname), "r")) == NULL) return nofile; + line = 0; for (; - (buf = fparseln(fd, &len, NULL, NULL, FPARSELN_UNESCCOMM | + (buf = fparseln(fd, &len, &line, NULL, FPARSELN_UNESCCOMM | FPARSELN_UNESCCONT | FPARSELN_UNESCESC)) != NULL; free(buf), buf = NULL) { glob = perm = class = NULL; @@ -635,6 +646,15 @@ checkuser(fname, name, def, nofile, retclass) NEXTWORD(p, class); if (EMPTYSTR(glob)) continue; + if (!EMPTYSTR(class)) { + if (strcasecmp(class, "all") == 0 || + strcasecmp(class, "none") == 0) { + syslog(LOG_WARNING, + "%s line %d: illegal user-defined class `%s' - skipping entry", + fname, (int)line, class); + continue; + } + } /* have a host specifier */ if ((p = strchr(glob, '@')) != NULL) { |
