version 1.1.4.11, 2007/05/23 22:27:36
|
version 1.1.4.12, 2007/05/24 19:34:56
|
|
|
| |
virtual int startProviderAgent( | virtual int startProviderAgent( |
const char* module, | const char* module, |
|
const String& pegasusHome, |
const String& userName, | const String& userName, |
int uid, | int uid, |
int gid, | int gid, |
|
|
| |
virtual int startProviderAgent( | virtual int startProviderAgent( |
const char* module, | const char* module, |
|
const String& pegasusHome, |
const String& userName, | const String& userName, |
int uid, | int uid, |
int gid, | int gid, |
|
|
| |
// Create pipes. Export handles to string. | // Create pipes. Export handles to string. |
| |
AnonymousPipe* pipeFromAgent = new AnonymousPipe(); |
AutoPtr<AnonymousPipe> pipeFromAgent(new AnonymousPipe()); |
AnonymousPipe* pipeToAgent = new AnonymousPipe(); |
AutoPtr<AnonymousPipe> pipeToAgent(new AnonymousPipe()); |
| |
char readHandle[32]; | char readHandle[32]; |
char writeHandle[32]; | char writeHandle[32]; |
|
|
| |
// Build full path of "cimprovagt" program. | // Build full path of "cimprovagt" program. |
| |
String path; |
String path = FileSystem::getAbsolutePath( |
|
pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME); |
if (_getProviderAgentPath(path) != 0) |
|
{ |
|
delete pipeToAgent; |
|
delete pipeFromAgent; |
|
return -1; |
|
} |
|
| |
// Format command line. | // Format command line. |
| |
|
|
&siStartInfo, // STARTUPINFO | &siStartInfo, // STARTUPINFO |
&piProcInfo)) // PROCESS_INFORMATION | &piProcInfo)) // PROCESS_INFORMATION |
{ | { |
delete pipeToAgent; |
|
delete pipeFromAgent; |
|
return -1; | return -1; |
} | } |
| |
|
|
pipeToAgent->closeReadHandle(); | pipeToAgent->closeReadHandle(); |
pipeFromAgent->closeWriteHandle(); | pipeFromAgent->closeWriteHandle(); |
| |
readPipe = pipeFromAgent; |
readPipe = pipeFromAgent.release(); |
writePipe = pipeToAgent; |
writePipe = pipeToAgent.release(); |
| |
return 0; | return 0; |
| |
|
|
{ | { |
// Resolve full path of "cimprovagt". | // Resolve full path of "cimprovagt". |
| |
String path; |
String path = FileSystem::getAbsolutePath( |
|
pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME); |
if (_getProviderAgentPath(path) != 0) |
|
return -1; |
|
| |
// Create "to-agent" pipe: | // Create "to-agent" pipe: |
| |
|
|
{ | { |
PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
String("setgid failed: ") + String(strerror(errno))); | String("setgid failed: ") + String(strerror(errno))); |
return false; |
return -1; |
} | } |
| |
if (setuid(uid) != 0) | if (setuid(uid) != 0) |
{ | { |
PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
String("setuid failed: ") + String(strerror(errno))); | String("setuid failed: ") + String(strerror(errno))); |
return false; |
return -1; |
} | } |
} | } |
| |
|
|
| |
private: | private: |
| |
static int _getProviderAgentPath(String& path) |
|
{ |
|
path = PEGASUS_PROVIDER_AGENT_PROC_NAME; |
|
|
|
if (path[0] != '/') |
|
{ |
|
const char* env = getenv("PEGASUS_HOME"); |
|
|
|
if (!env) |
|
return -1; |
|
|
|
path = String(env) + String("/") + path; |
|
} |
|
|
|
return 0; |
|
} |
|
|
|
Mutex _mutex; | Mutex _mutex; |
}; | }; |
| |
|
|
| |
virtual int startProviderAgent( | virtual int startProviderAgent( |
const char* module, | const char* module, |
|
const String& pegasusHome, |
const String& userName, | const String& userName, |
int uid, | int uid, |
int gid, | int gid, |
|
|
| |
int Executor::startProviderAgent( | int Executor::startProviderAgent( |
const char* module, | const char* module, |
|
const String& pegasusHome, |
const String& userName, | const String& userName, |
int uid, | int uid, |
int gid, | int gid, |
|
|
AnonymousPipe*& readPipe, | AnonymousPipe*& readPipe, |
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
return _getImpl()->startProviderAgent(module, |
return _getImpl()->startProviderAgent(module, pegasusHome, |
userName, uid, gid, pid, readPipe, writePipe); | userName, uid, gid, pid, readPipe, writePipe); |
} | } |
| |