version 1.4, 2007/06/05 11:14:41
|
version 1.7, 2007/06/13 21:21:53
|
|
|
| |
#include <Pegasus/Common/Constants.h> | #include <Pegasus/Common/Constants.h> |
#include <Pegasus/Common/Mutex.h> | #include <Pegasus/Common/Mutex.h> |
|
#include <Pegasus/Common/Once.h> |
#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> |
|
|
AnonymousPipe*& readPipe, | AnonymousPipe*& readPipe, |
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
// Add logging here. |
#if !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
| |
#if defined(PEGASUS_OS_TYPE_WINDOWS) | #if defined(PEGASUS_OS_TYPE_WINDOWS) |
| |
|
|
| |
return 0; | return 0; |
| |
#endif /* !defined(START_PROVIDER_AGENT) */ |
# endif /* POSIX CASE */ |
|
|
|
#else /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION is defined */ |
|
|
|
// Out-of-Process providers are never started by the cimserver process |
|
// when Privilege Separation is enabled. |
|
return -1; |
|
|
|
#endif |
} | } |
| |
virtual int daemonizeExecutor() | virtual int daemonizeExecutor() |
|
|
virtual int reapProviderAgent( | virtual int reapProviderAgent( |
int pid) | int pid) |
{ | { |
|
#if !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
|
|
int status = 0; | int status = 0; |
| |
#if defined(PEGASUS_HAS_SIGNALS) | #if defined(PEGASUS_HAS_SIGNALS) |
|
|
#endif | #endif |
| |
return status; | return status; |
|
|
|
#else /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION is defined */ |
|
|
|
// Out-of-Process providers are never started by the cimserver process |
|
// when Privilege Separation is enabled. |
|
return -1; |
|
|
|
#endif |
} | } |
| |
virtual int authenticatePassword( | virtual int authenticatePassword( |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
static int _executorSock = -1; | static int _executorSock = -1; |
static ExecutorImpl* _executorImpl = 0; |
static AutoPtr<ExecutorImpl> _executorImpl; |
static Mutex _executorMutex; |
static Once _executorImplOnce = PEGASUS_ONCE_INITIALIZER; |
| |
static ExecutorImpl* _getImpl() |
static void _initExecutorImpl() |
{ |
|
// Use the double-checked locking technique to avoid the overhead of a lock |
|
// on every call. |
|
|
|
if (_executorImpl == 0) |
|
{ |
|
AutoMutex autoMutex(_executorMutex); |
|
|
|
if (_executorImpl == 0) |
|
{ | { |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
if (_executorSock == -1) | if (_executorSock == -1) |
_executorImpl = new ExecutorLoopbackImpl(); |
_executorImpl.reset(new ExecutorLoopbackImpl()); |
else | else |
_executorImpl = new ExecutorSocketImpl(_executorSock); |
_executorImpl.reset(new ExecutorSocketImpl(_executorSock)); |
#else | #else |
_executorImpl = new ExecutorLoopbackImpl(); |
_executorImpl.reset(new ExecutorLoopbackImpl()); |
#endif | #endif |
} | } |
} |
|
|
|
return _executorImpl; |
|
} |
|
| |
void Executor::setSock(int sock) | void Executor::setSock(int sock) |
{ | { |
AutoMutex autoMutex(_executorMutex); |
|
_executorSock = sock; | _executorSock = sock; |
} | } |
| |
int Executor::detectExecutor() | int Executor::detectExecutor() |
{ | { |
return _getImpl()->detectExecutor(); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->detectExecutor(); |
} | } |
| |
int Executor::ping() | int Executor::ping() |
{ | { |
return _getImpl()->ping(); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->ping(); |
} | } |
| |
FILE* Executor::openFile( | FILE* Executor::openFile( |
const char* path, | const char* path, |
int mode) | int mode) |
{ | { |
return _getImpl()->openFile(path, mode); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->openFile(path, mode); |
} | } |
| |
int Executor::renameFile( | int Executor::renameFile( |
const char* oldPath, | const char* oldPath, |
const char* newPath) | const char* newPath) |
{ | { |
return _getImpl()->renameFile(oldPath, newPath); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->renameFile(oldPath, newPath); |
} | } |
| |
int Executor::removeFile( | int Executor::removeFile( |
const char* path) | const char* path) |
{ | { |
return _getImpl()->removeFile(path); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->removeFile(path); |
} | } |
| |
int Executor::startProviderAgent( | int Executor::startProviderAgent( |
|
|
AnonymousPipe*& readPipe, | AnonymousPipe*& readPipe, |
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
return _getImpl()->startProviderAgent( |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->startProviderAgent( |
module, pegasusHome, userName, pid, readPipe, writePipe); | module, pegasusHome, userName, pid, readPipe, writePipe); |
} | } |
| |
int Executor::daemonizeExecutor() | int Executor::daemonizeExecutor() |
{ | { |
return _getImpl()->daemonizeExecutor(); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->daemonizeExecutor(); |
} | } |
| |
int Executor::reapProviderAgent( | int Executor::reapProviderAgent( |
int pid) | int pid) |
{ | { |
return _getImpl()->reapProviderAgent(pid); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->reapProviderAgent(pid); |
} | } |
| |
int Executor::authenticatePassword( | int Executor::authenticatePassword( |
const char* username, | const char* username, |
const char* password) | const char* password) |
{ | { |
return _getImpl()->authenticatePassword(username, password); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->authenticatePassword(username, password); |
} | } |
| |
int Executor::validateUser( | int Executor::validateUser( |
const char* username) | const char* username) |
{ | { |
return _getImpl()->validateUser(username); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->validateUser(username); |
} | } |
| |
int Executor::challengeLocal( | int Executor::challengeLocal( |
const char* user, | const char* user, |
char challengeFilePath[EXECUTOR_BUFFER_SIZE]) | char challengeFilePath[EXECUTOR_BUFFER_SIZE]) |
{ | { |
return _getImpl()->challengeLocal(user, challengeFilePath); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->challengeLocal(user, challengeFilePath); |
} | } |
| |
int Executor::authenticateLocal( | int Executor::authenticateLocal( |
const char* challengeFilePath, | const char* challengeFilePath, |
const char* response) | const char* response) |
{ | { |
return _getImpl()->authenticateLocal(challengeFilePath, response); |
once(&_executorImplOnce, _initExecutorImpl); |
|
return _executorImpl->authenticateLocal(challengeFilePath, response); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |