(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.17 and 1.18.4.1

version 1.17, 2008/02/05 19:19:17 version 1.18.4.1, 2008/07/01 15:17:57
Line 214 
Line 214 
         AnonymousPipe*& writePipe)         AnonymousPipe*& writePipe)
     {     {
         PEG_METHOD_ENTER(TRC_SERVER,"ExecutorLoopbackImpl::startProviderAgent");         PEG_METHOD_ENTER(TRC_SERVER,"ExecutorLoopbackImpl::startProviderAgent");
   
 #if !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) #if !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
  
           // Resolve full path of "cimprovagt" program.
   
           String path = FileSystem::getAbsolutePath(
               pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME);
   
           // Create CString handles for cimprovagt arguments
   
           CString agentProgramPath = path.getCString();
           CString userNameCString = userName.getCString();
   
   # if defined(PEGASUS_DISABLE_PROV_USERCTXT)
           const char* setUserContextFlag = "0";    // False
   # else
           const char* setUserContextFlag = "1";    // True
   # endif
   
 # if defined(PEGASUS_OS_TYPE_WINDOWS) # if defined(PEGASUS_OS_TYPE_WINDOWS)
  
         AutoMutex autoMutex(_mutex);         AutoMutex autoMutex(_mutex);
Line 247 
Line 264 
         ZeroMemory(&siStartInfo, sizeof (STARTUPINFO));         ZeroMemory(&siStartInfo, sizeof (STARTUPINFO));
         siStartInfo.cb = sizeof (STARTUPINFO);         siStartInfo.cb = sizeof (STARTUPINFO);
  
         // Build full path of "cimprovagt" program.  
   
         String path = FileSystem::getAbsolutePath(  
             pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME);  
   
         // Format command line.         // Format command line.
  
         char cmdLine[2048];         char cmdLine[2048];
  
         sprintf(cmdLine, "\"%s\" %s %s \"%s\"",          sprintf(cmdLine, "\"%s\" %s %s %s \"%s\" \"%s\"",
             (const char*)path.getCString(),              (const char*)agentProgramPath,
               setUserContextFlag,
             readHandle,             readHandle,
             writeHandle,             writeHandle,
               (const char*)userNameCString,
             module);             module);
  
         //  Create provider agent proess.         //  Create provider agent proess.
Line 308 
Line 322 
  
         int to[2];         int to[2];
         int from[2];         int from[2];
           char toPipeArg[32];
 #  if defined(PEGASUS_OS_ZOS)          char fromPipeArg[32];
         // zOS is using __spawn2() instead of frok()  
         struct __inheritance inherit;  
         const char *c_argv[5];  
         char arg1[32];  
         char arg2[32];  
   
 #  endif  
  
         do         do
         {         {
             // Resolve full path of "cimprovagt".  
   
             String path = FileSystem::getAbsolutePath(  
                 pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME);  
   
 #  if !defined(PEGASUS_DISABLE_PROV_USERCTXT) && !defined(PEGASUS_OS_ZOS)  
   
             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_SERVER, Tracer::LEVEL2,  
                         "System::lookupUserId(%s) for provider user "  
                             "context failed.",  
                         (const char*)userName.getCString()));  
                     PEG_METHOD_EXIT();  
                     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 354 
Line 335 
                 return -1;                 return -1;
             }             }
  
   
             // Create "from-agent" pipe:             // Create "from-agent" pipe:
  
             if (pipe(from) != 0)             if (pipe(from) != 0)
Line 363 
Line 343 
                 return -1;                 return -1;
             }             }
  
               // Initialize the cimprovagt pipe arguments:
   
               sprintf(toPipeArg, "%d", to[0]);
               sprintf(fromPipeArg, "%d", from[1]);
   
             // Start provider agent:             // Start provider agent:
  
 #  if defined(PEGASUS_OS_ZOS) #  if defined(PEGASUS_OS_ZOS)
             // zOS is using __spawn2() to start provider agent              // zOS uses __spawn2() instead of fork() to start provider agent
             sprintf(arg1, "%d", to[0]);  
             sprintf(arg2, "%d", from[1]);              struct __inheritance inherit;
               const char *c_argv[7];
             CString program_name = path.getCString();  
               c_argv[0] = agentProgramPath;
             c_argv[0] = program_name;              c_argv[1] = setUserContextFlag;
             c_argv[1] = arg1;              c_argv[2] = toPipeArg;
             c_argv[2] = arg2;              c_argv[3] = fromPipeArg;
             c_argv[3] = module;              c_argv[4] = userNameCString;
             c_argv[4] = NULL;              c_argv[5] = module;
               c_argv[6] = NULL;
  
             // reset the inherit structure             // reset the inherit structure
             memset(&inherit,0,sizeof(inherit));             memset(&inherit,0,sizeof(inherit));
Line 386 
Line 372 
             memcpy( inherit.jobname,"CFZOOPA ",             memcpy( inherit.jobname,"CFZOOPA ",
                     sizeof(inherit.jobname));                     sizeof(inherit.jobname));
  
             CString program = path.getCString();  
   
             PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,             PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,
                        "Starting provider agent: %s %s %s %s %s",                  "Starting provider agent: %s %s %s %s %s %s %s",
                        program,program_name,arg1,arg2,module));                  (const char*)agentProgramPath,
                   c_argv[0],
                   c_argv[1],
                   c_argv[2],
                   c_argv[3],
                   c_argv[4],
                   c_argv[5]));
  
             pid = __spawn2(program,0,NULL,&inherit,              pid = __spawn2(agentProgramPath,0,NULL,&inherit,
                            c_argv,(const char **)environ);                            c_argv,(const char **)environ);
  
             if (pid < 0)             if (pid < 0)
             {             {
                 PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,                  PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
                     "Spawn of provider agent fails:%s "                     "Spawn of provider agent fails:%s "
                         "( errno %d , reason code %08X )",                         "( errno %d , reason code %08X )",
                     strerror(errno) ,errno,__errno2()));                     strerror(errno) ,errno,__errno2()));
Line 405 
Line 395 
                 return -1;                 return -1;
             }             }
  
 #  elif defined(PEGASUS_OS_VMS)  #  else    // !defined(PEGASUS_OS_ZOS)
   
   #   if defined(PEGASUS_OS_VMS)
             pid = (int)vfork();             pid = (int)vfork();
 #  elif defined(PEGASUS_OS_PASE) #  elif defined(PEGASUS_OS_PASE)
             pid = (int)fork400("QUMEPRVAGT",0);             pid = (int)fork400("QUMEPRVAGT",0);
Line 413 
Line 405 
             pid = (int)fork();             pid = (int)fork();
 #  endif #  endif
  
 #  if !defined(PEGASUS_OS_ZOS)  
   
             if (pid < 0)             if (pid < 0)
             {             {
                 PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,                  PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
                      "Fork for provider agent fails: errno = %d",errno));                      "Fork for provider agent fails: errno = %d",errno));
                 PEG_METHOD_EXIT();                 PEG_METHOD_EXIT();
                 return -1;                 return -1;
             }             }
  
             // If child proceses.  
             if (pid == 0)             if (pid == 0)
             {             {
                   // Child process
   
 #   if !defined(PEGASUS_OS_VMS) #   if !defined(PEGASUS_OS_VMS)
                 // Close unused pipe descriptors:                 // Close unused pipe descriptors:
  
                 close(to[1]);                 close(to[1]);
                 close(from[0]);                 close(from[0]);
  
   
                 // Close unused descriptors. Leave stdin, stdout, stderr,                 // Close unused descriptors. Leave stdin, stdout, stderr,
                 // and the child's pipe descriptors open.                 // and the child's pipe descriptors open.
  
Line 449 
Line 439 
  
 #   endif /* !defined(PEGASUS_OS_VMS) */ #   endif /* !defined(PEGASUS_OS_VMS) */
  
 #   if !defined(PEGASUS_DISABLE_PROV_USERCTXT)  
   
                 // Set uid and gid for the new provider agent process.  
   
                 if (newUid != (PEGASUS_UID_T)-1 && newGid != (PEGASUS_GID_T)-1)  
                 {  
                     if (!System::changeUserContext_SingleThreaded(  
                              userName.getCString(), newUid, newGid))  
                     {  
                         return -1;  
                     }  
                 }  
   
 #   endif /* !defined(PEGASUS_DISABLE_PROV_USERCTXT) */  
   
                 // Exec the cimprovagt program.                 // Exec the cimprovagt program.
  
                 char arg1[32];  
                 char arg2[32];  
                 sprintf(arg1, "%d", to[0]);  
                 sprintf(arg2, "%d", from[1]);  
   
                 {                 {
                     CString cstr = path.getCString();                      if (execl(
                     if (execl(cstr, cstr, arg1, arg2, module, (char*)0) == -1)                              agentProgramPath,
                               agentProgramPath,
                               setUserContextFlag,
                               toPipeArg,
                               fromPipeArg,
                               (const char*)userNameCString,
                               module,
                               (char*)0) == -1)
                     {                     {
                         PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,                          PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
                             "execl() failed.  errno = %d.", errno));                             "execl() failed.  errno = %d.", errno));
                         _exit(1);                         _exit(1);
                     }                     }
                 }                 }
             }             }
 #  else  /* PEGASUS_OS_ZOS */  
             if (pid > 0)  
             {  
                 PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,  
                      "Provider agent started suggessfully: Pid(%d).",pid));  
                 break;  
             }  
 #endif /* PEGASUS_OS_ZOS */ #endif /* PEGASUS_OS_ZOS */
   
         }         }
         while (0);         while (0);
  
           PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,
               "Provider agent started: pid(%d).", pid));
   
         // Close unused pipe descriptors.         // Close unused pipe descriptors.
  
         close(to[0]);         close(to[0]);
Line 514 
Line 486 
         readPipe = new AnonymousPipe(readFdStr, 0);         readPipe = new AnonymousPipe(readFdStr, 0);
         writePipe = new AnonymousPipe(0, writeFdStr);         writePipe = new AnonymousPipe(0, writeFdStr);
  
   #  if defined(PEGASUS_HAS_SIGNALS)
   #   if !defined(PEGASUS_DISABLE_PROV_USERCTXT) && !defined(PEGASUS_OS_ZOS)
           // The cimprovagt forks and returns right away.  Clean up the zombie
           // process now instead of in reapProviderAgent().
           int status = 0;
           while ((status = waitpid(pid, 0, 0)) == -1 && errno == EINTR)
               ;
   #   endif
   #  endif
   
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
         return 0;         return 0;
  
Line 541 
Line 523 
         int status = 0;         int status = 0;
  
 # if defined(PEGASUS_HAS_SIGNALS) # if defined(PEGASUS_HAS_SIGNALS)
   #  if defined(PEGASUS_DISABLE_PROV_USERCTXT) || defined(PEGASUS_OS_ZOS)
           // When provider user context is enabled, this is done in
           // startProviderAgent().
         while ((status = waitpid(pid, 0, 0)) == -1 && errno == EINTR)         while ((status = waitpid(pid, 0, 0)) == -1 && errno == EINTR)
             ;             ;
 # endif # endif
   # endif
  
         return status;         return status;
  


Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18.4.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2