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

Diff for /pegasus/src/Pegasus/Common/Executor.cpp between version 1.1.4.12 and 1.3

version 1.1.4.12, 2007/05/24 19:34:56 version 1.3, 2007/05/30 20:41:28
Line 55 
Line 55 
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/String.h> #include <Pegasus/Common/String.h>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
   #include <Pegasus/Common/System.h>
 #include <Pegasus/Common/Executor.h> #include <Pegasus/Common/Executor.h>
  
 #include <Executor/Strlcpy.h> #include <Executor/Strlcpy.h>
Line 105 
Line 106 
         const char* module,         const char* module,
         const String& pegasusHome,         const String& pegasusHome,
         const String& userName,         const String& userName,
         int uid,  
         int gid,  
         int& pid,         int& pid,
         AnonymousPipe*& readPipe,         AnonymousPipe*& readPipe,
         AnonymousPipe*& writePipe) = 0;         AnonymousPipe*& writePipe) = 0;
Line 197 
Line 196 
         const char* module,         const char* module,
         const String& pegasusHome,         const String& pegasusHome,
         const String& userName,         const String& userName,
         int uid,  
         int gid,  
         int& pid,         int& pid,
         AnonymousPipe*& readPipe,         AnonymousPipe*& readPipe,
         AnonymousPipe*& writePipe)         AnonymousPipe*& writePipe)
Line 308 
Line 305 
             String path = FileSystem::getAbsolutePath(             String path = FileSystem::getAbsolutePath(
                 pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME);                 pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME);
  
   # if !defined(PEGASUS_DISABLE_PROV_USERCTXT)
   
               PEGASUS_UID_T newUid = (PEGASUS_UID_T)-1;
               PEGASUS_GID_T newGid = (PEGASUS_GID_T)-1;
   
               if (userName != System::getEffectiveUserName())
               {
                   if (!System::lookupUserId(
                            userName.getCString(), newUid, newGid))
                   {
                       PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
                           "System::lookupUserId(%s) failed.",
                           (const char*)userName.getCString()));
                       return -1;
                   }
               }
   
   # endif /* !defined(PEGASUS_DISABLE_PROV_USERCTXT) */
   
             // Create "to-agent" pipe:             // Create "to-agent" pipe:
  
             if (pipe(to) != 0)             if (pipe(to) != 0)
Line 356 
Line 372 
  
 #endif /* !defined(PEGASUS_OS_VMS) */ #endif /* !defined(PEGASUS_OS_VMS) */
  
                 // Set uid and gid for the new provider agent process.  
   
 # if !defined(PEGASUS_DISABLE_PROV_USERCTXT) # if !defined(PEGASUS_DISABLE_PROV_USERCTXT)
  
                 if (uid != -1 && gid != -1)                  // Set uid and gid for the new provider agent process.
                 {  
                     PEG_TRACE((TRC_OS_ABSTRACTION, Tracer::LEVEL4,  
                         "Changing user context to: userName=%s uid=%d, gid=%d",  
                         (const char*)userName.getCString(), uid, gid));  
  
                     if (setgid(gid) != 0)                  if (newUid != (PEGASUS_UID_T)-1 && newGid != (PEGASUS_GID_T)-1)
                     {                     {
                         PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2,                      if (!System::changeUserContext_SingleThreaded(
                           String("setgid failed: ") + String(strerror(errno)));                               userName.getCString(), newUid, newGid))
                         return -1;  
                     }  
   
                     if (setuid(uid) != 0)  
                     {                     {
                         PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2,  
                           String("setuid failed: ") + String(strerror(errno)));  
                         return -1;                         return -1;
                     }                     }
                 }                 }
Line 668 
Line 672 
         const char* module,         const char* module,
         const String& pegasusHome,         const String& pegasusHome,
         const String& userName,         const String& userName,
         int uid,  
         int gid,  
         int& pid,         int& pid,
         AnonymousPipe*& readPipe,         AnonymousPipe*& readPipe,
         AnonymousPipe*& writePipe)         AnonymousPipe*& writePipe)
Line 681 
Line 683 
  
         // Reject strings longer than EXECUTOR_BUFFER_SIZE.         // Reject strings longer than EXECUTOR_BUFFER_SIZE.
  
         size_t n = strlen(module);          size_t moduleNameLength = strlen(module);
   
           if (moduleNameLength >= EXECUTOR_BUFFER_SIZE)
               return -1;
   
           CString userNameCString = userName.getCString();
           size_t userNameLength = strlen(userNameCString);
  
         if (n >= EXECUTOR_BUFFER_SIZE)          if (userNameLength >= EXECUTOR_BUFFER_SIZE)
             return -1;             return -1;
  
         // _send request header:         // _send request header:
Line 698 
Line 706 
  
         ExecutorStartProviderAgentRequest request;         ExecutorStartProviderAgentRequest request;
         memset(&request, 0, sizeof(request));         memset(&request, 0, sizeof(request));
         memcpy(request.module, module, n);          memcpy(request.module, module, moduleNameLength);
         request.uid = uid;          memcpy(request.userName, userNameCString, userNameLength);
         request.gid = gid;  
  
         if (_send(_sock, &request, sizeof(request)) != sizeof(request))         if (_send(_sock, &request, sizeof(request)) != sizeof(request))
             return -1;             return -1;
Line 1068 
Line 1075 
     const char* module,     const char* module,
     const String& pegasusHome,     const String& pegasusHome,
     const String& userName,     const String& userName,
     int uid,  
     int gid,  
     int& pid,     int& pid,
     AnonymousPipe*& readPipe,     AnonymousPipe*& readPipe,
     AnonymousPipe*& writePipe)     AnonymousPipe*& writePipe)
 { {
     return _getImpl()->startProviderAgent(module, pegasusHome,      return _getImpl()->startProviderAgent(
         userName, uid, gid, pid, readPipe, writePipe);          module, pegasusHome, userName, pid, readPipe, writePipe);
 } }
  
 int Executor::daemonizeExecutor() int Executor::daemonizeExecutor()


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2