/* maximum ms we'll wait for a command */
Maxwait= 1000*60*30, /* inactive for 30 minutes, we hang up */
- Maxerr= 128,
Maxpath= 512,
};
int modecmd(char*);
int namelistcmd(char*);
int nopcmd(char*);
+int optscmd(char*);
int passcmd(char*);
int pasvcmd(char*);
int portcmd(char*);
Cmd cmdtab[] =
{
{ "abor", abortcmd, 0, },
+ { "allo", nopcmd, 1, },
{ "appe", appendcmd, 1, },
{ "cdup", cdupcmd, 1, },
{ "cwd", cwdcmd, 1, },
{ "mode", modecmd, 0, },
{ "nlst", namelistcmd, 1, },
{ "noop", nopcmd, 0, },
+ { "opts", optscmd, 0, },
{ "pass", passcmd, 0, },
{ "pasv", pasvcmd, 1, },
{ "pwd", pwdcmd, 0, },
{
char buf[8192];
va_list arg;
- char errstr[128];
- rerrstr(errstr, sizeof errstr);
va_start(arg, fmt);
vseprint(buf, buf+sizeof(buf), fmt, arg);
va_end(arg);
syslog(0, FTPLOG, "%s.%s %s", nci->rsys, nci->rserv, buf);
- werrstr(errstr, sizeof errstr);
}
static void
if(isnone){
fd = open("#s/boot", ORDWR);
if(fd < 0
- || bind("#/", "/", MAFTER) < 0
- || amount(fd, "/bin", MREPL, "") < 0
- || bind("#c", "/dev", MAFTER) < 0
- || bind(bindir, "/bin", MREPL) < 0)
+ || bind("#/", "/", MAFTER) == -1
+ || amount(fd, "/bin", MREPL, "") == -1
+ || bind("#c", "/dev", MAFTER) == -1
+ || bind(bindir, "/bin", MREPL) == -1)
exits("building name space");
close(fd);
}
return bytes;
}
+int
+optscmd(char *arg)
+{
+ char *p;
+
+ if(arg == 0 || *arg == 0){
+ reply("501 Syntax error in parameters or arguments");
+ return 0;
+ }
+ if(p = strchr(arg, ' '))
+ *p = 0;
+ if(cistrcmp(arg, "UTF-8") == 0 || cistrcmp(arg, "UTF8") == 0){
+ reply("200 Command okay");
+ return 0;
+ }
+ reply("502 %s option not implemented", arg);
+ return 0;
+}
/*
* just reply OK
{
char namefile[128];
AuthInfo *ai;
+ Dir nd;
if(response == nil)
response = "";
ch->nresp = strlen(response);
ai = auth_response(ch);
if(ai == nil || auth_chuid(ai, nil) < 0) {
+ auth_freeAI(ai);
slowdown();
return reply("530 Not logged in: %r");
}
+ /* chown network connection */
+ nulldir(&nd);
+ nd.mode = 0660;
+ nd.uid = ai->cuid;
+ dirfwstat(0, &nd);
+
+ auth_freeAI(ai);
auth_freechal(ch);
ch = nil;
rv = 0;
- if(bind("#/", "/", MAFTER) < 0){
+ if(bind("#/", "/", MAFTER) == -1){
logit("can't bind #/ to /: %r");
return reply("500 can't bind #/ to /: %r");
}
- if(bind(nci->spec, "/net", MBEFORE) < 0){
+ if(bind(nci->spec, "/net", MBEFORE) == -1){
logit("can't bind %s to /net: %r", nci->spec);
rv = reply("500 can't bind %s to /net: %r", nci->spec);
unmount("#/", "/");
dfd = dialdata();
if(dfd < 0){
- reply("425 Error opening data connection:%r");
+ reply("425 Error opening data connection: %r");
return;
}
reply("150 Opened data connection (%s)", data);
reply("150 Opening data connection for %s (%s)", arg, data);
dfd = dialdata();
if(dfd < 0){
- reply("425 Error opening data connection:%r");
+ reply("425 Error opening data connection: %r");
close(fd);
return;
}
reply("150 Opening data connection for %s (%s)", arg, data);
dfd = dialdata();
if(dfd < 0){
- reply("425 Error opening data connection:%r");
+ reply("425 Error opening data connection: %r");
close(fd);
return;
}
USED(arg);
reply("214- the following commands are implemented:");
+ buf[0] = 0;
p = buf;
e = buf+sizeof buf;
for(i = 0; cmdtab[i].name; i++){
{
int fd, cfd;
char ldir[40];
- char err[Maxerr];
+ char err[ERRMAX];
if(mountnet() < 0)
return -1;
- if(!passive.inuse){
+ if(!passive.inuse)
fd = dial(data, "20", 0, 0);
- errstr(err, sizeof err);
- } else {
+ else {
+ fd = -1;
alarm(5*60*1000);
cfd = listen(passive.adir, ldir);
alarm(0);
- errstr(err, sizeof err);
- if(cfd < 0)
- return -1;
- fd = accept(cfd, ldir);
- errstr(err, sizeof err);
- close(cfd);
+ if(cfd >= 0){
+ fd = accept(cfd, ldir);
+ close(cfd);
+ }
}
+ err[0] = 0;
+ errstr(err, sizeof err);
if(fd < 0)
logit("can't dial %s: %s", data, err);
-
unmountnet();
- werrstr(err, sizeof err);
+ errstr(err, sizeof err);
return fd;
}