Roxen.git / server / plugins / protocols / ftp.pike

version» Context lines:

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.104 2004/06/09 00:17:42 _cvs_stephen Exp $ +  * $Id: ftp.pike,v 2.105 2004/07/08 23:32:55 _cvs_stephen Exp $    *    * Henrik Grubbström <grubba@roxen.com>    */      /*    * TODO:    *    * How much is supposed to be logged?    */   
Roxen.git/server/plugins/protocols/ftp.pike:666:    }       mapping lt = localtime(st->mtime);       // NOTE: SiteBuilder may set st[5] and st[6] to strings.    string user = (string)st->uid;    string group = (string)st->gid;    if (!(flags & LS_FLAG_n)) {    // Use symbolic names for uid and gid.    if (!stringp(st->uid)) { -  user = name_from_uid(st-uid); +  user = name_from_uid(st->uid);    }       // FIXME: Convert st[6] to symbolic group name.    }       string ts;    int now = time(1);    // Half a year:    // 365.25*24*60*60/2 = 15778800    if ((st->mtime <= now - 15778800) || (st->mtime > now)) {
Roxen.git/server/plugins/protocols/ftp.pike:880:    string short = dir_stack->pop();    string long = fix_path(short);       if ((!sizeof(long)) || (long[-1] != '/')) {    long += "/";    }    RequestID session = RequestID2(master_session);    session->method = "DIR";       mixed err; -  mapping(string:array) dir; +  mapping(string:Stat|array) dir;    err = catch {    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"    "%s\n", long, describe_backtrace(err));
Roxen.git/server/plugins/protocols/ftp.pike:1808:       if (session && session->file) {    session->file->len = amount;    session->conf->log(session->file, session);    session->file = 0;    }    destruct(session);    send(226, ({ "Transfer complete." }));    }    -  static private Stdio.Stat stat_file(string fname, +  static private mixed stat_file(string fname,    object|void session)    { -  mapping file; +  mixed file;       session = RequestID2(session || master_session);    session->method = "STAT";    session->not_query = fname;       foreach(conf->first_modules(), function funp) {    if ((file = funp(session))) {    break;    }    }
Roxen.git/server/plugins/protocols/ftp.pike:1883:    send(550, ({ sprintf("'%s': %s: No such file or directory.",    cmd, f) }));    break;    }    session->conf->sent = file->len;    session->conf->log(file, session);    }       static private int open_file(string fname, object session, string cmd)    { -  Stdio.Stat file = stat_file(fname, session); +  mixed 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)) { +  if (objectp(file)) {    Stdio.Stat st = file;    file = 0;    if (st && !st->isreg && !((<"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"    "%s\n", fname, describe_backtrace(err));
Roxen.git/server/plugins/protocols/ftp.pike:2514:    */       string make_MDTM(int t)    {    mapping lt = gmtime(t);    return sprintf("%04d%02d%02d%02d%02d%02d",    lt->year + 1900, lt->mon + 1, lt->mday,    lt->hour, lt->min, lt->sec);    }    -  string make_MLSD_fact(string f, mapping(string:array) dir, object session) +  string make_MLSD_fact(string f, mapping(string:Stat) dir, +  object session)    { -  array st = dir[f]; +  Stdio.Stat st = dir[f];       mapping(string:string) facts = ([]);       // Construct the facts here.       facts["UNIX.mode"] = st->mode;       if (st->isreg) {    facts->size = (string)st->size;    facts->type = "File";
Roxen.git/server/plugins/protocols/ftp.pike:2544:       facts->charset = "8bit";       // Construct and return the answer.       return(Array.map(indices(facts), lambda(string s, mapping f) {    return s + "=" + f[s];    }, facts) * ";" + " " + f);    }    -  void send_MLSD_response(mapping(string:array) dir, object session) +  void send_MLSD_response(mapping(string:Stat) dir, +  object session)    {    dir = dir || ([]);       array f = indices(dir);       session->file->data = sizeof(f) ?    (Array.map(f, make_MLSD_fact, dir, session) * "\r\n") + "\r\n" :    "" ;       session->file->mode = "I";    connect_and_send(session->file, session);    }    -  void send_MLST_response(mapping(string:array) dir, object session) +  void send_MLST_response(mapping(string:Stat) dir, +  object session)    {    dir = dir || ([]);    send(250,({ "OK" }) +    Array.map(indices(dir), make_MLSD_fact, dir, session) +    ({ "OK" }) );    }       /*    * Session handling    */
Roxen.git/server/plugins/protocols/ftp.pike:3477:    send(211, ({ "The following features are supported:" }) + a +    ({ "END" }));    }       void ftp_MDTM(string args)    {    if (!expect_argument("MDTM", args)) {    return;    }    args = fix_path(args); -  Stdio.Stat st = stat_file(args); +  mixed st = stat_file(args);    -  if (!arrayp(st) && !objectp(st)) { +  if (!objectp(st)) {    send_error("MDTM", args, st, master_session);    } else {    send(213, ({ make_MDTM(st->mtime) }));    }    }       void ftp_SIZE(string args)    {    if (!expect_argument("SIZE", args)) {    return;    }    args = fix_path(args);    -  Stdio.Stat st = stat_file(args); +  mixed st = stat_file(args);    -  if (!arrayp(st) && !objectp(st)) { +  if (!objectp(st)) {    send_error("SIZE", args, st, master_session);    return;    }    if (!st->isreg) {    send_error("SIZE", args, ([ "error":405, ]), master_session);    // size = 512;    } else {    send(213, ({ (string)st->size }));    }    }
Roxen.git/server/plugins/protocols/ftp.pike:3547:    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); -  Stdio.Stat st = stat_file(long); +  mixed st = stat_file(long);    -  if (!arrayp(st) && !objectp(st)) { +  if (!objectp(st)) {    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");    }    }