benchmarks/vendor/forever/node_modules/daemon/src/daemon.cc
//
// Allow changing the real and effective user ID of this process 
// so a root process can become unprivileged
//
Allow changing the real and effective user ID of this process
so a root process can become unprivileged
Allow changing the real and effective user ID of this process so a root process can become unprivileged
Handle<Value> SetReuid(const Arguments& args) {
  if (args.Length() == 0 || (!args[0]->IsString() && !args[0]->IsInt32()))
    return ThrowException(Exception::Error(
      String::New("Must give a uid or username to become")
    ));
  if (args[0]->IsString()) {
    String::AsciiValue username(args[0]);
    struct passwd* pwd_entry = getpwnam(*username);
    if (pwd_entry) {
      setreuid(pwd_entry->pw_uid, pwd_entry->pw_uid);
    } 
    else {
      return ThrowException(Exception::Error(
        String::New("User not found")
      ));
    }
  }
  else if (args[0]->IsInt32()) {
    uid_t uid;
    uid = args[0]->Int32Value();
    setreuid(uid, uid);
  }
}
Handle < Value > SetReuid ( const Arguments & args ) { if ( args . Length ( ) == 0 || ( ! args [ 0 ] -> IsString ( ) && ! args [ 0 ] -> IsInt32 ( ) ) ) return ThrowException ( Exception :: Error ( String :: New ( " " ) ) ) ; if ( args [ 0 ] -> IsString ( ) ) { String :: AsciiValue username ( args [ 0 ] ) ; struct passwd * pwd_entry = getpwnam ( * username ) ; if ( pwd_entry ) { setreuid ( pwd_entry -> pw_uid , pwd_entry -> pw_uid ) ; } else { return ThrowException ( Exception :: Error ( String :: New ( " " ) ) ) ; } } else if ( args [ 0 ] -> IsInt32 ( ) ) { uid_t uid ; uid = args [ 0 ] -> Int32Value ( ) ; setreuid ( uid , uid ) ; } }
Allow changing the real and effective user ID of this process
so a root process can become unprivileged
Allow changing the real and effective user ID of this process so a root process can become unprivileged