Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ftpd deprecate -h hostname in favour of automatic de...
details: https://anonhg.NetBSD.org/src/rev/13eb16f39b2d
branches: trunk
changeset: 479691:13eb16f39b2d
user: lukem <lukem%NetBSD.org@localhost>
date: Sat Dec 18 06:33:54 1999 +0000
description:
deprecate -h hostname in favour of automatic determination of local hostname.
this is a much cleaner solution for supporting multihomed virtual servers.
from Geoff C. Wing <gcw%pobox.com@localhost> in [bin/8137].
diffstat:
libexec/ftpd/ftpd.8 | 33 ++++++++++++++++-----------------
libexec/ftpd/ftpd.c | 33 ++++++++++++---------------------
2 files changed, 28 insertions(+), 38 deletions(-)
diffs (163 lines):
diff -r 25b8bf55ff05 -r 13eb16f39b2d libexec/ftpd/ftpd.8
--- a/libexec/ftpd/ftpd.8 Sat Dec 18 05:51:34 1999 +0000
+++ b/libexec/ftpd/ftpd.8 Sat Dec 18 06:33:54 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ftpd.8,v 1.46 1999/12/18 05:51:35 lukem Exp $
+.\" $NetBSD: ftpd.8,v 1.47 1999/12/18 06:33:54 lukem Exp $
.\"
.\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -80,7 +80,6 @@
.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.
@@ -118,21 +117,6 @@
.It Fl d
Debugging information is written to the syslog using
.Dv 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
.Tn FTP
@@ -491,6 +475,21 @@
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 -r 25b8bf55ff05 -r 13eb16f39b2d libexec/ftpd/ftpd.c
--- a/libexec/ftpd/ftpd.c Sat Dec 18 05:51:34 1999 +0000
+++ b/libexec/ftpd/ftpd.c Sat Dec 18 06:33:54 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ftpd.c,v 1.78 1999/12/18 05:51:35 lukem Exp $ */
+/* $NetBSD: ftpd.c,v 1.79 1999/12/18 06:33:54 lukem Exp $ */
/*
* Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@
#if 0
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: ftpd.c,v 1.78 1999/12/18 05:51:35 lukem Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.79 1999/12/18 06:33:54 lukem Exp $");
#endif
#endif /* not lint */
@@ -270,7 +270,6 @@
char *argv[];
{
int addrlen, ch, on = 1, tos, keepalive;
- char thost[MAXHOSTNAMELEN+6]; /* hostname + " ftpd" */
#ifdef KERBEROS5
krb5_error_code kerror;
#endif
@@ -279,9 +278,8 @@
logging = 0;
sflag = 0;
(void)strcpy(confdir, _DEFAULT_CONFDIR);
- hostname[0] = '\0';
- while ((ch = getopt(argc, argv, "a:c:C:dh:lst:T:u:Uv46")) != -1) {
+ while ((ch = getopt(argc, argv, "a:c:C:dlst:T:u:Uv46")) != -1) {
switch (ch) {
case 'a':
anondir = optarg;
@@ -300,10 +298,6 @@
debug = 1;
break;
- case 'h':
- strlcpy(hostname, optarg, sizeof(hostname));
- break;
-
case 'l':
logging++; /* > 1 == extra logging */
break;
@@ -343,9 +337,7 @@
* LOG_NDELAY sets up the logging connection immediately,
* necessary for anonymous ftp's that chroot and can't do it later.
*/
- snprintf(thost, sizeof(thost), "%s%sftpd", hostname,
- hostname[0] != '\0' ? " " : "");
- openlog(thost, LOG_PID | LOG_NDELAY, LOG_FTP);
+ openlog("ftpd", 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]);
@@ -409,6 +401,11 @@
#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';
+
/* set this here so klogin can use it... */
(void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid());
@@ -463,10 +460,6 @@
}
(void)format_file(conffilename(_PATH_FTPWELCOME), 220);
/* reply(220,) must follow */
- 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) */
@@ -2099,16 +2092,14 @@
dolog(who)
struct sockaddr *who;
{
- int error;
- error = getnameinfo(who, who->sa_len, remotehost, sizeof(remotehost),
- NULL, 0, 0);
+ getnameinfo(who, who->sa_len, remotehost, sizeof(remotehost), NULL,0,0);
#ifdef HASSETPROCTITLE
snprintf(proctitle, sizeof(proctitle), "%s: connected", remotehost);
setproctitle(proctitle);
#endif /* HASSETPROCTITLE */
-
if (logging)
- syslog(LOG_INFO, "connection from %s", remotehost);
+ syslog(LOG_INFO, "connection from %s to %s",
+ remotehost, hostname);
}
/*
Home |
Main Index |
Thread Index |
Old Index