Roxen.git / server / modules / filesystems / filesystem.pike

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:1:   // This is a roxen module. Copyright © 1996 - 2001, Roxen IS.      // This is a virtual "file-system".   // It will be located somewhere in the name-space of the server.   // Also inherited by some of the other filesystems.      inherit "module";   inherit "socket";    - constant cvs_version= "$Id: filesystem.pike,v 1.113 2001/09/27 17:53:43 nilsson Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.114 2001/12/21 12:31:45 grubba Exp $";   constant thread_safe=1;      #include <module.h>   #include <roxen.h>   #include <stat.h>   #include <request_trace.h>         //<locale-token project="mod_filesystem">LOCALE</locale-token>   #define LOCALE(X,Y) _DEF_LOCALE("mod_filesystem",X,Y)
Roxen.git/server/modules/filesystems/filesystem.pike:251:   #define SETUID(X) \    if( access_as_user ) \    { \    User uid = id->conf->authenticate( id,access_as_user_db ); \    if( access_as_user_throw && !uid ) \    return id->conf->authenticate_throw( id, "User",access_as_user_db);\    if( uid && uid->uid() ) \    privs=Privs(X, uid->uid(), uid->gid() ); \    }    + #define SETUID_TRACE(X,LEVELS) \ +  if( access_as_user ) \ +  { \ +  User uid = id->conf->authenticate( id,access_as_user_db ); \ +  if( access_as_user_throw && !uid ) { \ +  int levels = (LEVELS); \ +  while(levels--) TRACE_LEAVE(""); \ +  TRACE_LEAVE(X ": Auth required."); \ +  return id->conf->authenticate_throw( id, "User",access_as_user_db);\ +  } \ +  if( uid && uid->uid() ) \ +  privs=Privs(X, uid->uid(), uid->gid() ); \ +  } +    #define SETUID_NT(X) \    if( access_as_user ) \    { \    User uid = id->conf->authenticate( id,access_as_user_db ); \    if( uid && uid->uid() ) \    privs=Privs(X, uid->uid(), uid->gid() ); \    }      mixed stat_file( string f, RequestID id )   {
Roxen.git/server/modules/filesystems/filesystem.pike:593:    if (FILTER_INTERNAL_FILE (f, id))    {    TRACE_LEAVE ("Is internal file");    return 0;    }    }       TRACE_ENTER("Opening file \"" + f + "\"", 0);       object privs; -  SETUID("Open file"); +  SETUID_TRACE("Open file", 1);       o = Stdio.File( );    if(!o->open(norm_f, "r" )) o = 0;    privs = 0;       if(!o || (no_symlinks && (contains_symlinks(path, oldf))))    {    errors++;    report_error(LOCALE(45,"Open of %s failed. Permission denied.\n"),f);   
Roxen.git/server/modules/filesystems/filesystem.pike:650:    return 0;    }       if(query("check_auth") && (!id->conf->authenticate( id ) ) ) {    TRACE_LEAVE("MKDIR: Permission denied");    return Roxen.http_auth_required("foo",    "<h1>Permission to 'MKDIR' denied</h1>");    }    mkdirs++;    object privs; -  SETUID("Creating file"); +  SETUID_TRACE("Creating file", 0);       if (query("no_symlinks") && (contains_symlinks(path, oldf))) {    privs = 0;    errors++;    report_error(LOCALE(46,"Creation of %s failed. Permission denied.\n"),    oldf);    TRACE_LEAVE("MKDIR: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }   
Roxen.git/server/modules/filesystems/filesystem.pike:712:    if (id->misc->quota_obj && (id->misc->len > 0) &&    !id->misc->quota_obj->check_quota(URI, id->misc->len)) {    errors++;    report_warning(LOCALE(47,"Creation of %s failed. Out of quota.\n"),f);    TRACE_LEAVE("PUT: Out of quota.");    return http_low_answer(413, "<h2>Out of disk quota.</h2>",    "413 Out of disk quota");    }       -  SETUID("Saving file"); +  SETUID_TRACE("Saving file", 0);       if (query("no_symlinks") && (contains_symlinks(path, oldf))) {    privs = 0;    errors++;    report_error(LOCALE(46,"Creation of %s failed. Permission denied.\n"),f);    TRACE_LEAVE("PUT: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }       rm(f);
Roxen.git/server/modules/filesystems/filesystem.pike:812:    return 0;    }       if(query("check_auth") && (!id->conf->authenticate( id ) ) ) {    TRACE_LEAVE("CHMOD: Permission denied");    return Roxen.http_auth_required("foo",    "<h1>Permission to 'CHMOD' files denied</h1>");    }       -  SETUID("CHMODing file"); +  SETUID_TRACE("CHMODing file", 0);       if (query("no_symlinks") && (contains_symlinks(path, oldf))) {    privs = 0;    errors++;    TRACE_LEAVE("CHMOD: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }       array err = catch(chmod(f, id->misc->mode & 0777));    privs = 0;
Roxen.git/server/modules/filesystems/filesystem.pike:889:    return 0;    }       if (FILTER_INTERNAL_FILE (movefrom, id) ||    FILTER_INTERNAL_FILE (f, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("MV to or from internal file is disallowed");    return 0;    }    -  SETUID("Moving file"); +  SETUID_TRACE("Moving file", 0);       if (query("no_symlinks") &&    ((contains_symlinks(path, oldf)) ||    (contains_symlinks(path, id->misc->move_from)))) {    privs = 0;    errors++;    TRACE_LEAVE("MV: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }   
Roxen.git/server/modules/filesystems/filesystem.pike:988:    return 0;    }       if(size < -1)    {    id->misc->error_code = 405;    TRACE_LEAVE("MOVE: Cannot overwrite directory");    return 0;    }    -  SETUID("Moving file"); +  SETUID_TRACE("Moving file", 0);       if (query("no_symlinks") &&    ((contains_symlinks(path, f)) ||    (contains_symlinks(path, moveto)))) {    privs = 0;    errors++;    TRACE_LEAVE("MOVE: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }   
Roxen.git/server/modules/filesystems/filesystem.pike:1053:    if (query("no_symlinks") && (contains_symlinks(path, oldf))) {    errors++;    report_error(LOCALE(48,"Deletion of %s failed. Permission denied.\n"),f);    TRACE_LEAVE("DELETE: Contains symlinks");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }       report_notice(LOCALE(49,"DELETING the file %s.\n"),f);    accesses++;    -  SETUID("Deleting file"); +  SETUID_TRACE("Deleting file", 0);       /* Clear the stat-cache for this file */    if (stat_cache) {    cache_set("stat_cache", f, 0);    }       if(!rm(f))    {    privs = 0;    id->misc->error_code = 405;