ftpd doesn't work on multi-homed hosts
cak at Purdue.ARPA
cak at Purdue.ARPA
Mon Mar 26 12:18:00 AEST 1984
From: Christopher A Kent <cak at Purdue.ARPA>
Description:
On multi-homed hosts, ftpd won't always work because the code to
anchor the reply socket is incorrect; the getsockname() call
has a bad argument, thus the filled in address is always 0.
Repeat-By:
ftp to a multi-homed host on the same net as yours, but specify
the alternate address as the host to connect to.
Fix:
getsockname() wants an int *, not an int, for the namelen. I
did it this way (don't trust the line numbers):
*** ftpd.c.old
--- ftpd.c
***************
*** 168,173
continue;
}
if (fork() == 0) {
signal (SIGCHLD, SIG_IGN);
openlog("ftpd", LOG_PID);
dolog(&his_addr);
--- 168,175 -----
continue;
}
if (fork() == 0) {
+ int addrsize;
+
signal (SIGCHLD, SIG_IGN);
openlog("ftpd", LOG_PID);
dolog(&his_addr);
***************
*** 183,189
form = FORM_N;
stru = STRU_F;
mode = MODE_S;
! (void) getsockname(0, &ctrl_addr, sizeof (ctrl_addr));
gethostname(hostname, sizeof (hostname));
reply(220, "%s FTP server (%s) ready.",
hostname, version);
--- 185,192 -----
form = FORM_N;
stru = STRU_F;
mode = MODE_S;
! addrsize = sizeof(ctrl_addr);
! (void) getsockname(0, &ctrl_addr, &addrsize);
gethostname(hostname, sizeof (hostname));
reply(220, "%s FTP server (%s) ready.",
hostname, version);
----------
More information about the Comp.unix.wizards
mailing list