Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.1111 2012/02/14 23:10:13 jonasw Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1112 2012/02/18 01:14:34 mast Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:214: Inside #if defined(PRIVS_DEBUG)
   "privs_level: %O\n",    reason, uid, gid, privs_level));   #endif /* PRIVS_DEBUG */      #ifdef HAVE_EFFECTIVE_USER    array u;      #ifdef THREADS    if (euid_egid_lock) {    if (mixed err = catch { mutex_key = euid_egid_lock->lock(); }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    }    threads_disabled = _disable_threads();   #endif /* THREADS */       p_level = privs_level++;       /* Needs to be here since root-priviliges may be needed to    * use getpw{uid,nam}.    */    saved_uid = geteuid();
Roxen.git/server/base_server/roxen.pike:275: Inside #if defined(HAVE_EFFECTIVE_USER)
      if(LOGP)    report_notice(LOC_M(1, "Change to %s(%d):%d privs wanted (%s), from %s"),    (string)u[0], (int)uid, (int)gid,    (string)reason,    (string)dbt(backtrace()[-2]));       if (u[2]) {   #if efun(cleargroups)    if (mixed err = catch { cleargroups(); }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif /* cleargroups */   #if efun(initgroups)    if (mixed err = catch { initgroups(u[0], u[3]); }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif    }    gid = gid || getgid();    int err = (int)setegid(new_gid = gid);    if (err < 0) {    report_warning(LOC_M(2, "Privs: WARNING: Failed to set the "    "effective group id to %d!\n"    "Check that your password database is correct "    "for user %s(%d),\n and that your group "    "database is correct.\n"),
Roxen.git/server/base_server/roxen.pike:372: Inside #if defined(HAVE_EFFECTIVE_USER)
   if (mixed err = catch {    array bt = backtrace();    if (sizeof(bt) >= 2) {    report_notice(LOC_M(3,"Change back to uid#%d gid#%d, from %s")+"\n",    saved_uid, saved_gid, dbt(bt[-2]));    } else {    report_notice(LOC_M(4,"Change back to uid#%d gid#%d, "    "from backend")+"\n", saved_uid, saved_gid);    }    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    }      #ifdef PRIVS_DEBUG    int uid = geteuid();    if (uid != new_uid) {    report_debug("Privs: UID #%d differs from expected #%d\n"    "%s\n",    uid, new_uid, describe_backtrace(backtrace()));    }    int gid = getegid();
Roxen.git/server/base_server/roxen.pike:394: Inside #if defined(HAVE_EFFECTIVE_USER) and #if defined(PRIVS_DEBUG)
   report_debug("Privs: GID #%d differs from expected #%d\n"    "%s\n",    gid, new_gid, describe_backtrace(backtrace()));    }   #endif /* PRIVS_DEBUG */       seteuid(0);    array u = getpwuid(saved_uid);   #if efun(cleargroups)    if (mixed err = catch { cleargroups(); }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif /* cleargroups */    if(u && (sizeof(u) > 3)) {    if (mixed err = catch { initgroups(u[0], u[3]); }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    }    setegid(saved_gid);    seteuid(saved_uid);    enable_coredumps(1);   #endif /* HAVE_EFFECTIVE_USER */    }   #else /* efun(seteuid) */    void create(string reason, int|string|void uid, int|string|void gid){}   #endif /* efun(seteuid) */   }
Roxen.git/server/base_server/roxen.pike:476:    werror (describe_backtrace (err));   #endif /* THREADS */    if (!exit_code || once_mode) {    // We're shutting down; Attempt to take mysqld with us.    if (mixed err =    catch { report_notice("Shutting down MySQL.\n"); } ||    catch {    Sql.Sql db = connect_to_my_mysql(0, "mysql");    db->shutdown();    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    }    // Zap some of the remaining caches.    destruct (argcache);    destruct (cache);   #if 0    // Disabled since it's lying when the server is shut down with a    // SIGTERM or SIGINT to the start script (which include the stop    // action of the init.d script).    if (mixed err = catch {    if (exit_code && !once_mode)    report_notice("Restarting Roxen.\n");    else    report_notice("Shutting down Roxen.\n");    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif    roxenloader.real_exit( exit_code ); // Now we die...   }      private int shutdown_recurse;      // Shutdown Roxen   // exit_code = 0 True shutdown   // exit_code = -1 Restart   private void low_shutdown(int exit_code)   {    if(shutdown_recurse >= 4)    {    if (mixed err =    catch (report_notice("Exiting roxen (spurious signals received).\n")) ||    catch (stop_all_configurations())) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    // Zap some of the remaining caches.    destruct(argcache);    destruct(cache);   #ifdef THREADS    if (mixed err = catch (stop_handler_threads())) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif /* THREADS */    roxenloader.real_exit(exit_code);    }    if (shutdown_recurse++) return;      #ifndef NO_SLOW_REQ_BT    // Turn off the backend thread monitor while we're shutting down.    slow_be_timeout_changed();   #endif       if (mixed err = catch(stop_all_configurations())) -  werror (describe_backtrace (err)); +  master()->handle_error (err);      #ifdef SNMP_AGENT    if(objectp(snmpagent)) {    snmpagent->stop_trap();    snmpagent->disable();    }   #endif       call_out(really_low_shutdown, 0.1, exit_code);   }
Roxen.git/server/base_server/roxen.pike:951:    THREAD_WERR("Handle thread [" + id + "] released");    }    } while(1);    }) {    if (thread_flagged_as_busy)    busy_threads--;   #ifndef NO_SLOW_REQ_BT    if (call_out) monitor->remove_call_out (call_out);   #endif    if (h = catch { -  report_error(/*LOCALE("", "Uncaught error in handler thread: %s" -  "Client will not get any response from Roxen.\n"),*/ -  describe_backtrace(q)); +  master()->handle_error (q);    if (q = catch {h = 0;}) {    report_error(LOC_M(5, "Uncaught error in handler thread: %sClient "    "will not get any response from Roxen.")+"\n",    describe_backtrace(q));    catch (q = 0);    }    }) {    catch {    report_error("Error reporting error:\n");    report_error(sprintf("Raw error: %O\n", h[0]));
Roxen.git/server/base_server/roxen.pike:1530: Inside #if defined(DEBUG)
   if (self_refs < 4)    error ("Minimum ref calculation wrong - have only %d refs.\n", self_refs);   #endif    if (stopping || (self_refs <= 4) || !func) {    stopping = 2; // Stopped.    return;    }    mixed err = catch {    func (@args);    }; -  if (err) { -  catch { -  report_error(LOC_M(66, "Uncaught error in background process:") + -  "%s\n", describe_backtrace(err)); -  }; -  } +  if (err) +  master()->handle_error (err);    background_run (period, repeat, func, args);    }       //! @decl void set_period (int|float period);    //!    //! Changes the period to @[period] seconds between calls.    //!    //! @note    //! This does not change the currently ongoing period, if any. That    //! might be remedied.
Roxen.git/server/base_server/roxen.pike:3344: Inside #if undefined(__NT__)
   ctime(time()) - "\n",    query("abs_timeout"));    // Paranoia exit in case describe_all_threads below hangs.    signal(signum("SIGALRM"), low_engage_abs);    int t = alarm(20);    report_debug("\nTrying to dump backlog: \n");    if (mixed err = catch {    // Catch for paranoia reasons.    describe_all_threads();    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #ifdef THREADS    report_debug("\nHandler queue:\n");    if (mixed err = catch {    t = alarm(20); // Restart the timeout timer.    array(mixed) queue = handle_queue->buffer[handle_queue->r_ptr..];    foreach(queue, mixed v) {    if (!v) continue;    if (!arrayp(v)) {    report_debug(" *** Strange entry: %O ***\n", v);    } else {    report_debug(" %{%O, %}\n", v/({}));    }    }    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif    low_engage_abs();   }      void restart_if_stuck (int force)   //! @note   //! Must be called from the backend thread due to Linux peculiarities.   {    remove_call_out(restart_if_stuck);    if (!(query("abs_engage") || force))
Roxen.git/server/base_server/roxen.pike:4507:    // Always remove entries that are older than one week.    background_run( 10, do_cleanup );    }       void destroy()    {    if (mixed err = catch(sync_meta())) {    report_warning("Failed to sync cached atimes for "+name+"\n");   #if 0   #ifdef DEBUG -  report_debug (describe_backtrace (err)); +  master()->handle_error (err);   #endif   #endif    }    }   }         class ArgCache   //! Generic cache for storing away a persistent mapping of data to be   //! refetched later by a short string key. This being a cache, your
Roxen.git/server/base_server/roxen.pike:5209:    if (!g) gid = pw[3];    }      #ifdef THREADS    Thread.MutexKey mutex_key;    object threads_disabled;    if (!from_handler_thread) {    // If this is necessary from every handler thread, these    // things are thread local and thus are no locks necessary.    if (mixed err = catch { mutex_key = euid_egid_lock->lock(); }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    threads_disabled = _disable_threads();    }   #endif      #if constant(seteuid)    if (geteuid() != getuid()) seteuid (getuid());   #endif      #if constant(initgroups)    if (mixed err = catch {    initgroups(pw[0], gid);    // Doesn't always work - David.    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);   #endif       if (query("permanent_uid")) {   #if constant(setuid)    if (g) {   # if constant(setgid)    setgid(gid);    if (getgid() != gid) {    report_error(LOC_M(25, "Failed to set gid.")+"\n");    g = 0;
Roxen.git/server/base_server/roxen.pike:5506: Inside #if defined(THREADS)
  #ifdef THREADS    if (sscanf( f, "http://%[^/]", string host ) ||    sscanf (f, "https://%[^/]", host)) {    mapping hd = ([    "User-Agent":version(),    "Host":host,    ]);    if (mixed err = catch {    data = Protocols.HTTP.get_url_data( f, 0, hd );    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    }   #endif    if( !data )    return 0;    }    }    id->misc->_load_image_called = 0;    if(!data) return 0;    return low_decode_image( data );   }
Roxen.git/server/base_server/roxen.pike:5538: Inside #if defined(THREADS)
  #ifdef THREADS    if (sscanf( f, "http://%[^/]", string host ) ||    sscanf (f, "https://%[^/]", host)) {    mapping hd = ([    "User-Agent":version(),    "Host":host,    ]);    if (mixed err = catch {    data = Protocols.HTTP.get_url_data( f, 0, hd );    }) -  werror (describe_backtrace (err)); +  master()->handle_error (err);    }   #endif    if( !data )    return res;    }    }    id->misc->_load_image_called = 0;    if(!data) return res;    return decode_layers( data, opt );   }