diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8 index 29c020a7d07b..22b7c8702cd3 100644 --- a/libexec/ftpd/ftpd.8 +++ b/libexec/ftpd/ftpd.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftpd.8,v 1.47 1999/12/18 06:33:54 lukem Exp $ +.\" $NetBSD: ftpd.8,v 1.48 1999/12/19 00:09:31 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 18, 1999 +.Dd December 19, 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. @@ -117,6 +118,22 @@ This can be useful for testing configurations. .It Fl d Debugging information is written to the syslog using .Dv LOG_FTP . +.It Fl h Ar hostname +Explicitly set the hostname to advertise as. +Defaults to the hostname associated with the IP address that +.NM +is listening on. +This ability (with or without +.Fl h ) , +in conjunction with +.Fl c Ar confdir , +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 .Tn FTP @@ -475,21 +492,6 @@ to allow logging-in via into the accounts, which must have .Pa /sbin/ftplogin as login shell. -.Sh Multiple virtual FTP servers -If -.Nm -is started on a specific IP address (with a separate IP name to the -system's hostname), then that separate name will be returned to the -client as the hostname that the client is connecting to. -This feature, in conjunction with -.Fl c Ar confdir , -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. .Sh FILES .Bl -tag -width /etc/ftpwelcome -compact .It Pa /etc/ftpchroot diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 83cdbc48d909..6ac207141ab6 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftpd.c,v 1.79 1999/12/18 06:33:54 lukem Exp $ */ +/* $NetBSD: ftpd.c,v 1.80 1999/12/19 00:09:31 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.79 1999/12/18 06:33:54 lukem Exp $"); +__RCSID("$NetBSD: ftpd.c,v 1.80 1999/12/19 00:09:31 lukem Exp $"); #endif #endif /* not lint */ @@ -191,7 +191,6 @@ int mode; int doutmp = 0; /* update utmp file */ int usedefault = 1; /* for data transfers */ int pdata = -1; /* for passive mode */ -int family = AF_INET; int mapped = 0; /* IPv4 connection on AF_INET6 socket */ sig_atomic_t transflag; off_t file_size; @@ -278,8 +277,9 @@ main(argc, argv) logging = 0; sflag = 0; (void)strcpy(confdir, _DEFAULT_CONFDIR); + hostname[0] = '\0'; - while ((ch = getopt(argc, argv, "a:c:C:dlst:T:u:Uv46")) != -1) { + while ((ch = getopt(argc, argv, "a:c:C:dh:lst:T:u:Uv")) != -1) { switch (ch) { case 'a': anondir = optarg; @@ -298,6 +298,10 @@ main(argc, argv) debug = 1; break; + case 'h': + strlcpy(hostname, optarg, sizeof(hostname)); + break; + case 'l': logging++; /* > 1 == extra logging */ break; @@ -317,14 +321,6 @@ main(argc, argv) doutmp = 1; break; - case '4': - family = AF_INET; - break; - - case '6': - family = AF_INET6; - break; - default: if (optopt == 'a' || optopt == 'C') exit(1); @@ -401,10 +397,13 @@ main(argc, argv) #endif data_source.su_port = htons(ntohs(ctrl_addr.su_port) - 1); - if (getnameinfo((struct sockaddr *)&ctrl_addr, ctrl_addr.su_len, - hostname, sizeof(hostname), NULL, 0, 0) != 0) - (void)gethostname(hostname, sizeof(hostname)); - hostname[sizeof(hostname) - 1] = '\0'; + /* if the hostname hasn't been given, attempt to determine it */ + if (hostname[0] == '\0') { + if (getnameinfo((struct sockaddr *)&ctrl_addr, ctrl_addr.su_len, + hostname, sizeof(hostname), NULL, 0, 0) != 0) + (void)gethostname(hostname, sizeof(hostname)); + hostname[sizeof(hostname) - 1] = '\0'; + } /* set this here so klogin can use it... */ (void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid()); diff --git a/libexec/ftpd/version.h b/libexec/ftpd/version.h index 37512bb215d4..6626d19cf086 100644 --- a/libexec/ftpd/version.h +++ b/libexec/ftpd/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.1 1999/12/18 05:51:35 lukem Exp $ */ +/* $NetBSD: version.h,v 1.2 1999/12/19 00:09:31 lukem Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -36,5 +36,5 @@ */ #ifndef FTPD_VERSION -#define FTPD_VERSION "Version: NetBSD-ftpd/19991218" +#define FTPD_VERSION "Version: NetBSD-ftpd/19991219" #endif