[torqueusers] changing session id.

Steve Traylen s.traylen at rl.ac.uk
Thu Feb 17 02:08:44 MST 2005


Hi,

  I am looking for some suggestions on how to deal with the problem
  of users changing their session or group id and thus enabling 
  themselves to leave process on batch workers. The code below highlights
  a way to do this.

  Has anyone else considered this and have they implemented anything
  to address the situation. Either to stop it in the first place or
  to clean it up afterwards. For the clean up it is less than trivial
  since we run two jobs per node so simply cleaning all process belonging
  to a user in the epilogue is not an option.

     Steve

  
#include <sys/types.h>
#include <unistd.h>

int main(int argc, char **argv) {
  pid_t p = fork();
  if (p == (pid_t) -1) {
    exit(0);              /* we failed.... */
  } else if (p == 0) {    /* CHILD */
    setsid();             /* new session */
    setpgid(0, 0);
  } else {                /* PARENT */
    exit(0);
  }

  /* Do something usefull here */
  sleep(6000);
}



-- 
Steve Traylen
s.traylen at rl.ac.uk
http://www.gridpp.ac.uk/


More information about the torqueusers mailing list