c - how to get back to original status/user after setuid()? -


i have program run root, , during execution program few things different uers, wanted use serial of setuid()s. but, found that, after setuid(user1), become user1 , don't have privilege setuid(user2).

how can root can setuid(user2)?

thanks.

use fork, let child setuid , perform whatever actions needs done second user. root parent waits child , continues when child has finished executing.

childpid = fork(); if (childpid < 0) {     // fork failed }  if (childpid == 0) {   // child   setuid(user1);   prepareuser1();  // stuff user1.   exit(0);         // done user1 } else {   // parent: wait child finish   waitpid(childpid); } // parent continues root... 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -