Roxen.git
/
server
/
plugins
/
protocols
/
ftp.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/plugins/protocols/ftp.pike:1:
// This is a roxen protocol module. // Copyright © 1997 - 2001, Roxen IS. /* * FTP protocol mk 2 *
-
* $Id: ftp.pike,v 2.
95
2004/05/17 16:
35
:
34
mani Exp $
+
* $Id: ftp.pike,v 2.
96
2004/05/17 16:
38
:
23
mani Exp $
* * Henrik Grubbström <grubba@roxen.com> */ /* * TODO: * * How much is supposed to be logged? */
Roxen.git/server/plugins/protocols/ftp.pike:1884:
session->conf->sent = file->len; session->conf->log(file, session); } static private int open_file(string fname, object session, string cmd) { object|array|mapping file; file = stat_file(fname, session);
+
// The caller is assumed to have made a new session object for us
+
// but not to set not_query in it..
+
session->not_query = fname;
+
if (objectp(file) || arrayp(file)) { array|object st = file; file = 0; if (st && (st[1] < 0) && !((<"RMD", "XRMD", "CHMOD">)[cmd])) { send(550, ({ sprintf("%s: not a plain file.", fname) })); return 0; } mixed err; if ((err = catch(file = conf->get_file(session)))) { report_error("FTP: Error opening file \"%s\"\n"
Roxen.git/server/plugins/protocols/ftp.pike:3242:
static private string rename_from; // rename from void ftp_RNFR(string args) { if (!expect_argument("RNFR", args)) { return; } args = fix_path(args);
-
RequestID session = RequestID2(master_session);
-
-
session->method = "STAT";
-
-
if (stat_file(args
, session
)) {
+
if (stat_file(args)) {
send(350, ({ sprintf("%s ok, waiting for destination name.", args) }) ); rename_from = args; } else { send(550, ({ sprintf("%s: no such file or permission denied.",args) }) ); }
-
destruct(session);
+
} void ftp_RNTO(string args) { if(!rename_from) { send(503, ({ "RNFR needed before RNTO." })); return; } if (!expect_argument("RNTO", args)) { return;
Roxen.git/server/plugins/protocols/ftp.pike:3474:
send(211, ({ "The following features are supported:" }) + a + ({ "END" })); } void ftp_MDTM(string args) { if (!expect_argument("MDTM", args)) { return; } args = fix_path(args);
-
RequestID session = RequestID2(master_session);
-
session->method = "STAT";
-
mapping|array|object st = stat_file(args
, session
);
+
mapping|array|object st = stat_file(args);
if (!arrayp(st) && !objectp(st)) {
-
send_error("MDTM", args, st, session);
+
send_error("MDTM", args, st,
master_
session);
} else { send(213, ({ make_MDTM(st[3]) })); }
-
destruct(session);
+
} void ftp_SIZE(string args) { if (!expect_argument("SIZE", args)) { return; } args = fix_path(args);
-
RequestID session = RequestID2(master_session);
-
session->method = "STAT";
-
mapping|array|object st = stat_file(args
, session
);
+
mapping|array|object st = stat_file(args);
if (!arrayp(st) && !objectp(st)) {
-
send_error("SIZE", args, st, session);
-
destruct(session);
+
send_error("SIZE", args, st,
master_
session);
return; } int size = st[1]; if (size < 0) {
-
send_error("SIZE", args, ([ "error":405, ]), session);
+
send_error("SIZE", args, ([ "error":405, ]),
master_
session);
// size = 512; } else { send(213, ({ (string)size })); }
-
destruct(session);
+
} void ftp_STAT(string args) { // According to RFC 1123 4.1.3.3, this command can be sent during // a file-transfer. // RFC 959 4.1.3: // The command may be sent during a file transfer (along with the // Telnet IP and Synch signals--see the Section on FTP Commands) // in which case the server will respond with the status of the
Roxen.git/server/plugins/protocols/ftp.pike:3552:
user?sprintf("as %s", user):"anonymously", (["A":"ASCII", "E":"EBCDIC", "I":"IMAGE", "L":"LOCAL"]) [mode], "Non-Print", "File", "Stream" )/"\n"); return; } string long = fix_path(args);
-
RequestID session = RequestID2(master_session);
-
session->method = "STAT";
+
mapping|array|object st = stat_file(long); if (!arrayp(st) && !objectp(st)) {
-
send_error("STAT", long, st, session);
+
send_error("STAT", long, st,
master_
session);
} 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) { send(200, ({ "Nothing done ok" })); } void ftp_HELP(string args) { if ((< "", 0 >)[args]) {