aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2003-01-30 13:31:37 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2003-01-30 13:31:37 +0000
commitfe60f7af90a6f139d0deccc7b65ff78bd4d3e0c2 (patch)
treee4b4a26facf7fe38fc7fdf8e97dee160ddbe7052 /libexec
parent1a7d47149998693aebfc47822704707c9b7929ae (diff)
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpd.813
-rw-r--r--libexec/ftpd/ftpd.c15
2 files changed, 23 insertions, 5 deletions
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index 3af08131be8e..e5d822feab13 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -44,6 +44,7 @@
.Op Fl l Op Fl l
.Op Fl a Ar address
.Op Fl p Ar file
+.Op Fl P Ar port
.Op Fl t Ar timeout
.Op Fl T Ar maxtimeout
.Op Fl u Ar umask
@@ -54,7 +55,9 @@ Internet File Transfer Protocol
server process. The server uses the
.Tn TCP
protocol
-and listens at the port specified in the
+and listens at the port specified with the
+.Fl P
+option or in the
.Dq ftp
service specification; see
.Xr services 5 .
@@ -141,6 +144,14 @@ When
.Fl D
is specified, write the daemon's process ID to
.Ar file .
+.It Fl P
+When
+.Fl D
+is specified, accept connections at
+.Ar port ,
+specified as a numeric value or service name, instead of at the default
+.Dq ftp
+port.
.It Fl r
Put server in read-only mode.
All commands which may modify the local filesystem are disabled.
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 47d596ed3605..702f846c0e9c 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -122,6 +122,7 @@ union sockunion pasv_addr;
int daemon_mode;
int data;
+int dataport;
int logged_in;
struct passwd *pw;
int ftpdebug;
@@ -286,6 +287,7 @@ main(argc, argv, envp)
FILE *fd;
int error;
char *bindname = NULL;
+ const char *bindport = "ftp";
int family = AF_UNSPEC;
int enable_v4 = 0;
struct sigaction sa;
@@ -305,7 +307,7 @@ main(argc, argv, envp)
#endif /* OLD_SETPROCTITLE */
- while ((ch = getopt(argc, argv, "46a:AdDElmMoOp:rRSt:T:u:UvW")) != -1) {
+ while ((ch = getopt(argc, argv, "46a:AdDElmMoOp:P:rRSt:T:u:UvW")) != -1) {
switch (ch) {
case '4':
enable_v4 = 1;
@@ -361,6 +363,10 @@ main(argc, argv, envp)
pid_file = optarg;
break;
+ case 'P':
+ bindport = optarg;
+ break;
+
case 'r':
readonly = 1;
break;
@@ -445,11 +451,11 @@ main(argc, argv, envp)
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_PASSIVE;
- error = getaddrinfo(bindname, "ftp", &hints, &res);
+ error = getaddrinfo(bindname, bindport, &hints, &res);
if (error) {
if (family == AF_UNSPEC) {
hints.ai_family = AF_UNSPEC;
- error = getaddrinfo(bindname, "ftp", &hints,
+ error = getaddrinfo(bindname, bindport, &hints,
&res);
}
}
@@ -562,6 +568,7 @@ main(argc, argv, envp)
syslog(LOG_ERR, "getsockname (%s): %m",argv[0]);
exit(1);
}
+ dataport = ntohs(ctrl_addr.su_port) - 1; /* as per RFC 959 */
#ifdef VIRTUAL_HOSTING
/* select our identity from virtual host table */
selecthost(&ctrl_addr);
@@ -1693,7 +1700,7 @@ getdatasock(mode)
syslog(LOG_WARNING, "data setsockopt (SO_REUSEADDR): %m");
/* anchor socket to avoid multi-homing problems */
data_source = ctrl_addr;
- data_source.su_port = htons(20); /* ftp-data port */
+ data_source.su_port = htons(dataport);
for (tries = 1; ; tries++) {
if (bind(s, (struct sockaddr *)&data_source,
data_source.su_len) >= 0)