(file) Return to User.c CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Executor

Diff for /pegasus/src/Executor/User.c between version 1.2 and 1.3

version 1.2, 2007/05/25 18:35:07 version 1.3, 2008/02/05 19:59:40
Line 30 
Line 30 
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 */ */
   #include <unistd.h>
 #include <sys/types.h> #include <sys/types.h>
 #include <pwd.h> #include <pwd.h>
   #include <grp.h>
 #include "User.h" #include "User.h"
 #include "Log.h" #include "Log.h"
 #include "Strlcpy.h" #include "Strlcpy.h"
Line 92 
Line 94 
     Strlcpy(username, ptr->pw_name, EXECUTOR_BUFFER_SIZE);     Strlcpy(username, ptr->pw_name, EXECUTOR_BUFFER_SIZE);
     return 0;     return 0;
 } }
   
   /*
   **==============================================================================
   **
   ** SetUserContext()
   **
   **     Set the process user ID, group ID, and supplemental groups
   **
   **==============================================================================
   */
   
   void SetUserContext(const char* username, int uid, int gid)
   {
       if ((int)getgid() != gid)
       {
           if (setgid((gid_t)gid) != 0)
           {
               Log(LL_SEVERE, "setgid(%d) failed\n", gid);
               _exit(1);
           }
       }
   
       if (initgroups(username, gid) != 0)
       {
           Log(LL_SEVERE, "initgroups(%s, %d) failed\n", username, gid);
           _exit(1);
       }
   
       if ((int)getuid() != uid)
       {
           if (setuid((uid_t)uid) != 0)
           {
               Log(LL_SEVERE, "setuid(%d) failed\n", uid);
               _exit(1);
           }
       }
   }


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2