SCCS-vsn: libexec/ftpd/ftpd.c 5.19
SCCS-vsn: libexec/ftpd/popen.c 5.3
SCCS-vsn: libexec/ftpd/ftpcmd.y 5.13
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)ftpcmd.y 5.12 (Berkeley) %G%
+ * @(#)ftpcmd.y 5.13 (Berkeley) %G%
-static char sccsid[] = "@(#)ftpcmd.y 5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftpcmd.y 5.13 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
}
}
while (--n > 0 && (c = getc(iop)) != EOF) {
}
}
while (--n > 0 && (c = getc(iop)) != EOF) {
- c = 0377 & c;
- while (c == IAC) {
- switch (c = 0377 & getc(iop)) {
+ while ((0377&c) == IAC) {
+ switch (0377&(c = getc(iop))) {
- c = 0377 & getc(iop);
- printf("%c%c%c", IAC, WONT, c);
+ c = getc(iop);
+ printf("%c%c%c", IAC, WONT, 0377&c);
(void) fflush(stdout);
break;
case DO:
case DONT:
(void) fflush(stdout);
break;
case DO:
case DONT:
- c = 0377 & getc(iop);
- printf("%c%c%c", IAC, DONT, c);
+ c = getc(iop);
+ printf("%c%c%c", IAC, DONT, 0377&c);
(void) fflush(stdout);
break;
default:
break;
}
(void) fflush(stdout);
break;
default:
break;
}
- c = 0377 & getc(iop); /* try next character */
+ c = getc(iop); /* try next character */
- *cs++ = c;
- if (c=='\n')
+ *cs++ = 0377&c;
+ if ((0377&c) == '\n')
break;
}
if (c == EOF && cs == s)
break;
}
if (c == EOF && cs == s)
register char *cp;
register struct tab *p;
int n;
register char *cp;
register struct tab *p;
int n;
for (;;) {
switch (state) {
for (;;) {
switch (state) {
dologout(0);
}
(void) alarm(0);
dologout(0);
}
(void) alarm(0);
- if (index(cbuf, '\r')) {
- cp = index(cbuf, '\r');
- cp[0] = '\n'; cp[1] = 0;
+ if ((cp = index(cbuf, '\r'))) {
+ *cp++ = '\n'; *cp = '\0';
- if (index(cbuf, ' '))
- cpos = index(cbuf, ' ') - cbuf;
- else
- cpos = index(cbuf, '\n') - cbuf;
+ if ((cp = strpbrk(cbuf, " \n")))
+ cpos = cp - cbuf;
if (cpos == 0) {
cpos = 4;
}
if (cpos == 0) {
cpos = 4;
}
{
while (*s != '\0') {
if (islower(*s))
{
while (*s != '\0') {
if (islower(*s))
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ftpd.c 5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)ftpd.c 5.19 (Berkeley) %G%";
extern char *crypt();
extern char version[];
extern char *home; /* pointer to home directory for glob */
extern char *crypt();
extern char version[];
extern char *home; /* pointer to home directory for glob */
-extern FILE *popen(), *fopen(), *freopen();
+extern FILE *ftpd_popen(), *fopen(), *freopen();
extern int pclose(), fclose();
extern char *getline();
extern char cbuf[];
extern int pclose(), fclose();
extern char *getline();
extern char cbuf[];
int unique;
int transflag;
char tmpline[7];
int unique;
int transflag;
char tmpline[7];
-char hostname[32];
-char remotehost[32];
+char hostname[MAXHOSTNAMELEN];
+char remotehost[MAXHOSTNAMELEN];
/*
* Timeout intervals for retrying connections
/*
* Timeout intervals for retrying connections
syslog(LOG_ERR, "signal: %m");
/* handle urgent data inline */
syslog(LOG_ERR, "signal: %m");
/* handle urgent data inline */
+ /* Sequent defines this, but it doesn't work */
- if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)) < 0) {
+ if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)) < 0)
syslog(LOG_ERR, "setsockopt: %m");
syslog(LOG_ERR, "setsockopt: %m");
pgid = getpid();
if (ioctl(fileno(stdin), SIOCSPGRP, (char *) &pgid) < 0) {
syslog(LOG_ERR, "ioctl: %m");
pgid = getpid();
if (ioctl(fileno(stdin), SIOCSPGRP, (char *) &pgid) < 0) {
syslog(LOG_ERR, "ioctl: %m");
mode = MODE_S;
tmpline[0] = '\0';
(void) gethostname(hostname, sizeof (hostname));
mode = MODE_S;
tmpline[0] = '\0';
(void) gethostname(hostname, sizeof (hostname));
- reply(220, "%s FTP server (%s) ready.",
- hostname, version);
+ reply(220, "%s FTP server (%s) ready.", hostname, version);
for (;;) {
(void) setjmp(errcatch);
(void) yyparse();
for (;;) {
(void) setjmp(errcatch);
(void) yyparse();
#endif
if (new == NULL) {
#endif
if (new == NULL) {
- reply(553, "Local resource failure");
+ reply(553, "Local resource failure: malloc");
dologout(1);
}
#ifndef notdef
dologout(1);
}
#ifndef notdef
#ifdef notdef
/* no remote command execution -- it's a security hole */
if (*name == '|')
#ifdef notdef
/* no remote command execution -- it's a security hole */
if (*name == '|')
- fin = popen(name + 1, "r"), closefunc = pclose;
+ fin = ftpd_popen(name + 1, "r"), closefunc = pclose;
else
#endif
fin = fopen(name, "r"), closefunc = fclose;
else
#endif
fin = fopen(name, "r"), closefunc = fclose;
char line[BUFSIZ];
(void) sprintf(line, cmd, name), name = line;
char line[BUFSIZ];
(void) sprintf(line, cmd, name), name = line;
- fin = popen(line, "r"), closefunc = pclose;
+ fin = ftpd_popen(line, "r"), closefunc = pclose;
}
if (fin == NULL) {
if (errno != 0)
}
if (fin == NULL) {
if (errno != 0)
#ifdef notdef
/* no remote command execution -- it's a security hole */
if (name[0] == '|')
#ifdef notdef
/* no remote command execution -- it's a security hole */
if (name[0] == '|')
- fout = popen(&name[1], "w"), closefunc = pclose;
+ fout = ftpd_popen(&name[1], "w"), closefunc = pclose;
pdata = -1;
done:
if (dochown)
pdata = -1;
done:
if (dochown)
- (void) chown(local, pw->pw_uid, -1);
+ (void) fchown(fileno(fout), pw->pw_uid, -1);
makedir(name)
char *name;
{
makedir(name)
char *name;
{
- struct stat st;
- int dochown = stat(name, &st) < 0;
-
- if (mkdir(name, 0777) < 0) {
+ uid_t oldeuid;
+
+ oldeuid = geteuid();
+ seteuid(pw->pw_uid);
+ if (mkdir(name, 0777) < 0)
reply(550, "%s: %s.", name, sys_errlist[errno]);
reply(550, "%s: %s.", name, sys_errlist[errno]);
- return;
- }
- if (dochown)
- (void) chown(name, pw->pw_uid, -1);
- reply(257, "MKD command successful.");
+ else
+ reply(257, "MKD command successful.");
+ seteuid(oldeuid);
-static char sccsid[] = "@(#)popen.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)popen.c 5.3 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
+ftpd_popen(program, type)
char *program, *type;
{
register char *cp;
char *program, *type;
{
register char *cp;