Branch: Tag:

1999-06-07

1999-06-07 05:21:12 by Martin Stjernholm <mast@lysator.liu.se>

Check that the argument cache is writable. Set uid:gid before starting
the arg cache. Other assorted small fixes from 1.3.

Rev: server/base_server/roxen.pike:1.293

1:   /* -  * $Id: roxen.pike,v 1.292 1999/06/07 00:22:51 mast Exp $ +  * $Id: roxen.pike,v 1.293 1999/06/07 05:21:12 mast Exp $    *    * The Roxen Challenger main program.    *
7:    */      // ABS and suicide systems contributed freely by Francesco Chemolli - constant cvs_version="$Id: roxen.pike,v 1.292 1999/06/07 00:22:51 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.293 1999/06/07 05:21:12 mast Exp $";      object backend_thread;   object argcache;
135:    }      #ifdef THREADS -  mixed mutex_key; // Only one thread may modify the euid/egid at a time. +  static mixed mutex_key; // Only one thread may modify the euid/egid at a time.    static object threads_disabled;   #endif /* THREADS */   
149:    reason, uid, gid, privs_level));   #endif /* PRIVS_DEBUG */    - #ifdef THREADS - #if constant(roxen_pid) && !constant(_disable_threads) -  if(getpid() == roxen_pid) -  { -  // __disallow_threads(); -  werror("Using Privs ("+reason+") in threaded environment, source is\n "+ -  replace(describe_backtrace(backtrace()), "\n", "\n ")+"\n"); -  } - #endif - #endif +    #ifdef HAVE_EFFECTIVE_USER    array u;   
205: Inside #if defined(HAVE_EFFECTIVE_USER)
   if(!u) {    if (uid && (uid != "root")) {    if (intp(uid) && (uid >= 60000)) { -  report_debug(sprintf("Privs: User %d is not in the password database.\n" +  report_warning(sprintf("Privs: User %d is not in the password database.\n"    "Assuming nobody.\n", uid));    // Nobody.    gid = gid || uid; // Fake a gid also.
1602:    u = pw[0], uid = pw[2];    if (!g) gid = pw[3];    } - #if constant(initgroups) -  catch { -  initgroups(pw[0], gid); -  // Doesn't always work - David. -  }; - #endif +       #ifdef THREADS    object mutex_key;
1615:    object threads_disabled = _disable_threads();   #endif    + #if constant(initgroups) +  catch { +  initgroups(pw[0], gid); +  // Doesn't always work - David. +  }; + #endif +    #if constant(seteuid)    if (geteuid() != getuid()) seteuid (getuid());   #endif
2216:    path += "/";    path += replace(name, "/", "_")+"/";    mkdirhier( path + "/tmp" ); +  object test = Stdio.File(); +  if (!test->open (path + "/.testfile", "wc")) +  error ("Can't create files in the argument cache directory " + path + "\n"); +  else { +  test->close(); +  rm (path + "/.testfile");    }    } -  +  }       static string read_args( string id )    {
3678:    roxen_perror("Restart initiated at "+ctime(time()));       define_global_variables(argc, argv); -  create_pid_file(Getopt.find_option(argv, "p", "pid-file", "ROXEN_PID_FILE") -  || QUERY(pidfile)); +     object o;    if(QUERY(locale) != "standard" && (o = Locale.Roxen[QUERY(locale)]))    {
3696:    initiate_supports();       initiate_configuration_port( 1 ); +  enable_configurations(); +  +  set_u_and_gid(); // Running with the right uid:gid from this point on. +  +  create_pid_file(Getopt.find_option(argv, "p", "pid-file", "ROXEN_PID_FILE") +  || QUERY(pidfile)); +     roxen_perror("Initiating argument cache ... ");       int id;
3715:    werror( describe_backtrace( e ) );    }    roxen_perror( "\n" ); -  enable_configurations(); -  if(set_u_and_gid()) -  roxen_perror("Setting UID and GID ...\n"); +        enable_configurations_modules();