2004-05-17
2004-05-17 13:20:05 by Martin Nilsson <mani@lysator.liu.se>
-
9e18537badf8586a8e1ab81b8d0b2129549a7dbf
(95 lines)
(+64/-31)
[
Show
| Annotate
]
Branch: Aphoto_2.0_beta3
WebServer sync. [2.91]
Rev: server/plugins/protocols/ftp.pike:2.93
4:
/*
* FTP protocol mk 2
*
- * $Id: ftp.pike,v 2.92 2004/05/17 13:17:23 mani Exp $
+ * $Id: ftp.pike,v 2.93 2004/05/17 13:20:05 mani Exp $
*
* Henrik Grubbström <grubba@roxen.com>
*/
172: Inside #if defined(FTP_REQUESTID_DEBUG)
{
#ifdef FTP_REQUESTID_DEBUG
_num = ++__num[0];
- report_debug("REQUESTID: New request id #%d.\n", _num);
+ if (m_rid) {
+ report_debug("REQUESTID: New request id #%d (CHILD to #%d).\n",
+ _num, m_rid->_num);
+ } else {
+ report_debug("REQUESTID: New request id #%d (MASTER).\n", _num);
+ }
#else
DWRITE("REQUESTID: New request id.\n");
#endif
712:
{
array|object st = stat_cache[long];
if (zero_type(st)) {
- if (!session) {
- session = RequestID2(master_session);
+ session = RequestID2(session || master_session);
session->method = "DIR";
- }
+
long = replace(long, "//", "/");
st = session->conf->stat_file(long, session);
stat_cache[long] = st;
-
+ destruct(session);
}
return st;
}
879:
dir = session->conf->find_dir_stat(long, session);
};
+ destruct(session);
+
if (err) {
report_error("FTP: LSFile->list_next_directory(): "
"find_dir_stat(\"%s\") failed:\n"
1046:
output(short + ": not found\n");
session->conf->log(([ "error":404 ]), session);
}
+ destruct(session);
}
DWRITE("FTP: LSFile: %d files, %d directories\n",
1062:
session->method = "LIST";
session->conf->sent = sizeof(s);
session->conf->log(([ "error":200, "len":sizeof(s) ]), session);
+ destruct(session);
}
if (dir_stack->ptr) {
name_directories = dir_stack->ptr &&
1794:
session->conf->log(session->file, session);
session->file = 0;
}
-
+ destruct(session);
send(226, ({ "Transfer complete." }));
}
1803:
{
mapping file;
- if (!session) {
- session = RequestID2(master_session);
+ session = RequestID2(session || master_session);
session->method = "STAT";
- }
-
+
session->not_query = fname;
foreach(conf->first_modules(), function funp) {
1818:
if (!file) {
fname = replace(fname, "//", "/");
- return(conf->stat_file(fname, session));
+ file = conf->stat_file(fname, session);
}
- return(file);
+ destruct(session);
+ return file;
}
static private int expect_argument(string cmd, string args)
1958:
else
{
send(425, ({ "Can't build data connect: Connection refused." }));
+ destruct(session);
return;
}
switch(file->mode) {
2081:
}
session->conf->sent = session->file->len;
session->conf->log(session->file, session);
+ destruct(session);
return;
}
master_session->file = session->file;
2089:
if (fd) {
BACKEND_CLOSE(fd);
}
+ destruct(session);
}
}
2280:
}
}
}
+ destruct(id);
}
matches = new_matches;
} else {
2312:
object id = RequestID2(m_id);
id->method = "LIST";
id->not_query = combine_path(cwd, short);
- return(id->conf->stat_file(id->not_query,
- id));
+ mapping res =
+ id->conf->stat_file(id->not_query, id);
+ destruct(id);
+ return res;
}, cwd, master_session);
if (sizeof(matches)) {
args[index] = matches;
2792:
object session = RequestID2(master_session);
session->method = "STAT";
array(int)|object st = conf->stat_file(home, session);
+ destruct(session);
if (st && (st[1] < 0)) {
cwd = home;
2825:
ncwd) }));
session->conf->sent = session->file && session->file->len;
session->conf->log(session->file || ([ "error":404 ]), session);
+ destruct(session);
return;
}
if (!(< -2, -3 >)[st[1]]) {
send(504, ({ sprintf("%s: Not a directory.", ncwd) }));
session->conf->log(([ "error":400 ]), session);
-
+ destruct(session);
return;
}
2872:
send(250, reply);
session->conf->sent = sizeof(reply * "\n");
session->conf->log(([ "error":200, "len":session->conf->sent ]), session);
+ destruct(session);
}
void ftp_XCWD(string args)
3157:
restart_point = 0;
send(550, ({ "'RETR': Error restoring restart point." }));
discard_data_connection();
+ destruct(session);
return;
}
restart_point = 0;
3165:
connect_and_send(session->file, session);
}
- else
+ else {
discard_data_connection();
-
+ destruct(session);
}
-
+ }
void ftp_STOR(string args)
{
3234:
} else {
send(550, ({ sprintf("%s: no such file or permission denied.",args) }) );
}
+ destruct(session);
}
void ftp_RNTO(string args)
3257:
session->conf->log(([ "error":200 ]), session);
}
rename_from = 0;
+ destruct(session);
}
3293:
} else {
send_error("MLST", args, session->file, session);
}
+ destruct(session);
}
void ftp_MLSD(string args)
3320:
send_error("MLSD", args, session->file, session);
discard_data_connection();
}
+ destruct(session);
}
void ftp_DELE(string args)
3339:
if (open_file(args, session, "DELE")) {
send(250, ({ sprintf("%s deleted.", args) }));
session->conf->log(([ "error":200 ]), session);
- return;
+
}
-
+ destruct(session);
}
void ftp_RMD(string args)
3361:
if (!st) {
send_error("RMD", args, session->file, session);
+ destruct(session);
return;
} else if (st[1] != -2) {
if (st[1] == -3) {
3370:
send(504, ({ sprintf("%s is not a directory.", args) }));
session->conf->log(([ "error":405 ]), session);
}
+ destruct(session);
return;
}
if (open_file(args, session, "RMD")) {
send(250, ({ sprintf("%s deleted.", args) }));
session->conf->log(([ "error":200 ]), session);
- return;
+
}
-
+ destruct(session);
}
void ftp_XRMD(string args)
3402:
if (open_file(args, session, "MKD")) {
send(257, ({ sprintf("\"%s\" created.", args) }));
session->conf->log(([ "error":200 ]), session);
- return;
+
}
-
+ destruct(session);
}
void ftp_XMKD(string args)
3456:
if (!arrayp(st) && !objectp(st)) {
send_error("MDTM", args, st, session);
- return;
- }
+ } else {
send(213, ({ make_MDTM(st[3]) }));
}
-
+ destruct(session);
+ }
void ftp_SIZE(string args)
{
3474:
if (!arrayp(st) && !objectp(st)) {
send_error("SIZE", args, st, session);
+ destruct(session);
return;
}
int size = st[1];
if (size < 0) {
send_error("SIZE", args, ([ "error":405, ]), session);
- return;
+
// size = 512;
- }
+ } else {
send(213, ({ (string)size }));
}
-
+ destruct(session);
+ }
void ftp_STAT(string args)
{
3531:
if (!arrayp(st) && !objectp(st)) {
send_error("STAT", long, st, session);
- return;
- }
-
+ } else {
string s = LS_L(master_session)->ls_l(args, st);
send(213, sprintf("status of \"%s\":\n"
"%s"
"End of Status", args, s)/"\n");
}
-
+ destruct(session);
+ }
void ftp_NOOP(string args)
{
3650:
fname, mode) }));
session->conf->log(([ "error":200 ]), session);
}
+ destruct(session);
}
void ftp_SITE_UMASK(array(string) args)
3839:
logout();
port_obj->sessions--;
+ if (master_session) {
+ destruct(master_session);
}
-
+ }
void create(object fd, object c)
{