in NLST unless globbing (a botch, but too incompatible otherwise); bostic's
pathname changes
SCCS-vsn: libexec/ftpd/ftpd.c 5.28
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ftpd.c 5.27.1.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftpd.c 5.28 (Berkeley) %G%";
#include <strings.h>
#include <syslog.h>
#include <varargs.h>
#include <strings.h>
#include <syslog.h>
#include <varargs.h>
/*
* File containing login names
* NOT to be used on this machine.
* Commonly used to disallow uucp.
*/
/*
* File containing login names
* NOT to be used on this machine.
* Commonly used to disallow uucp.
*/
-#define FTPUSERS "/etc/ftpusers"
-
extern int errno;
extern char *sys_errlist[];
extern int sys_nerr;
extern int errno;
extern char *sys_errlist[];
extern int sys_nerr;
nextopt:
argc--, argv++;
}
nextopt:
argc--, argv++;
}
- (void) freopen("/dev/null", "w", stderr);
+ (void) freopen(_PATH_DEVNULL, "w", stderr);
(void) signal(SIGPIPE, lostconn);
(void) signal(SIGCHLD, SIG_IGN);
if ((int)signal(SIGURG, myoob) < 0)
(void) signal(SIGPIPE, lostconn);
(void) signal(SIGCHLD, SIG_IGN);
if ((int)signal(SIGURG, myoob) < 0)
* If account doesn't exist, ask for passwd anyway.
* Otherwise, check user requesting login privileges.
* Disallow anyone who does not have a standard
* If account doesn't exist, ask for passwd anyway.
* Otherwise, check user requesting login privileges.
* Disallow anyone who does not have a standard
- * shell returned by getusershell() (/etc/shells).
- * Disallow anyone mentioned in the file FTPUSERS
+ * shell as returned by getusershell().
+ * Disallow anyone mentioned in the file _PATH_FTPUSERS
* to allow people such as root and uucp to be avoided.
*/
user(name)
* to allow people such as root and uucp to be avoided.
*/
user(name)
}
if (pw = sgetpwnam(name)) {
if ((shell = pw->pw_shell) == NULL || *shell == 0)
}
if (pw = sgetpwnam(name)) {
if ((shell = pw->pw_shell) == NULL || *shell == 0)
while ((cp = getusershell()) != NULL)
if (strcmp(cp, shell) == 0)
break;
while ((cp = getusershell()) != NULL)
if (strcmp(cp, shell) == 0)
break;
pw = (struct passwd *) NULL;
return;
}
pw = (struct passwd *) NULL;
return;
}
- if ((fd = fopen(FTPUSERS, "r")) != NULL) {
+ if ((fd = fopen(_PATH_FTPUSERS, "r")) != NULL) {
while (fgets(line, sizeof (line), fd) != NULL) {
if ((cp = index(line, '\n')) != NULL)
*cp = '\0';
while (fgets(line, sizeof (line), fd) != NULL) {
if ((cp = index(line, '\n')) != NULL)
*cp = '\0';
getdatasock(mode)
char *mode;
{
getdatasock(mode)
char *mode;
{
if (data >= 0)
return (fdopen(data, mode));
if (data >= 0)
return (fdopen(data, mode));
if (s < 0)
return (NULL);
(void) seteuid((uid_t)0);
if (s < 0)
return (NULL);
(void) seteuid((uid_t)0);
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) < 0)
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
+ (char *) &on, sizeof (on)) < 0)
goto bad;
/* anchor socket to avoid multi-homing problems */
data_source.sin_family = AF_INET;
data_source.sin_addr = ctrl_addr.sin_addr;
goto bad;
/* anchor socket to avoid multi-homing problems */
data_source.sin_family = AF_INET;
data_source.sin_addr = ctrl_addr.sin_addr;
- if (bind(s, (struct sockaddr *)&data_source, sizeof (data_source)) < 0)
- goto bad;
+ for (tries = 1; ; tries++) {
+ if (bind(s, (struct sockaddr *)&data_source,
+ sizeof (data_source)) >= 0)
+ break;
+ if (errno != EADDRINUSE || tries > 10)
+ goto bad;
+ sleep(tries);
+ }
(void) seteuid((uid_t)pw->pw_uid);
return (fdopen(s, mode));
bad:
(void) seteuid((uid_t)pw->pw_uid);
return (fdopen(s, mode));
bad:
struct direct *dir;
FILE *dout = NULL;
register char **dirlist, *dirname;
struct direct *dir;
FILE *dout = NULL;
register char **dirlist, *dirname;
char *strpbrk();
if (strpbrk(whichfiles, "~{[*?") != NULL) {
char *strpbrk();
if (strpbrk(whichfiles, "~{[*?") != NULL) {
} else {
onefile[0] = whichfiles;
dirlist = onefile;
} else {
onefile[0] = whichfiles;
dirlist = onefile;
}
if (setjmp(urgcatch)) {
}
if (setjmp(urgcatch)) {
if ((st.st_mode&S_IFMT) == S_IFREG) {
if (dout == NULL) {
if ((st.st_mode&S_IFMT) == S_IFREG) {
if (dout == NULL) {
- dout = dataconn(whichfiles, (off_t)-1, "w");
+ dout = dataconn("file list", (off_t)-1, "w");
if (dout == NULL)
return;
transflag++;
if (dout == NULL)
return;
transflag++;
* We have to do a stat to insure it's
* not a directory or special file.
*/
* We have to do a stat to insure it's
* not a directory or special file.
*/
- if (stat(nbuf, &st) == 0 &&
- (st.st_mode&S_IFMT) == S_IFREG) {
+ if (simple || (stat(nbuf, &st) == 0 &&
+ (st.st_mode&S_IFMT) == S_IFREG)) {
- dout = dataconn(whichfiles, (off_t)-1,
+ dout = dataconn("file list", (off_t)-1,
"w");
if (dout == NULL)
return;
"w");
if (dout == NULL)
return;