version 1.1.2.11, 2007/01/09 17:46:28
|
version 1.1.2.12, 2007/01/09 20:25:40
|
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
//// | //// |
//// InProcess stubs: |
//// Loopback stubs: |
//// | //// |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
static int InProcess_ping() |
static int Loopback_ping() |
{ | { |
// Nothing to do. | // Nothing to do. |
return 0; | return 0; |
} | } |
| |
FILE* InProcess_openFile( |
FILE* Loopback_openFile( |
const char* path, | const char* path, |
int mode) | int mode) |
{ | { |
|
|
} | } |
} | } |
| |
static int InProcess_renameFile( |
static int Loopback_renameFile( |
const char* oldPath, | const char* oldPath, |
const char* newPath) | const char* newPath) |
{ | { |
return FileSystem::renameFile(oldPath, newPath) ? 0 : -1; | return FileSystem::renameFile(oldPath, newPath) ? 0 : -1; |
} | } |
| |
static int InProcess_removeFile( |
static int Loopback_removeFile( |
const char* path) | const char* path) |
{ | { |
return FileSystem::removeFile(path) ? 0 : -1; | return FileSystem::removeFile(path) ? 0 : -1; |
|
|
| |
#if defined(PEGASUS_OS_TYPE_WINDOWS) | #if defined(PEGASUS_OS_TYPE_WINDOWS) |
| |
static int InProcess_startProviderAgent( |
static int Loopback_startProviderAgent( |
const char* module, | const char* module, |
int uid, | int uid, |
int gid, | int gid, |
|
|
| |
#elif defined(PEGASUS_OS_OS400) | #elif defined(PEGASUS_OS_OS400) |
| |
static int InProcess_startProviderAgent( |
static int Loopback_startProviderAgent( |
const char* module, | const char* module, |
int uid, | int uid, |
int gid, | int gid, |
|
|
| |
#else /* POSIX CASE FOLLOWS */ | #else /* POSIX CASE FOLLOWS */ |
| |
static int InProcess_startProviderAgent( |
static int Loopback_startProviderAgent( |
const SessionKey& sessionKey, | const SessionKey& sessionKey, |
const char* module, | const char* module, |
int uid, | int uid, |
|
|
| |
#endif /* !defined(START_PROVIDER_AGENT) */ | #endif /* !defined(START_PROVIDER_AGENT) */ |
| |
static int InProcess_daemonizeExecutor() |
static int Loopback_daemonizeExecutor() |
{ | { |
// Nothing to do. | // Nothing to do. |
return 0; | return 0; |
} | } |
| |
static int InProcess_changeOwner( |
static int Loopback_changeOwner( |
const char* path, | const char* path, |
const char* owner) | const char* owner) |
{ | { |
return FileSystem::changeFileOwner(path, owner) ? 0 : -1; | return FileSystem::changeFileOwner(path, owner) ? 0 : -1; |
} | } |
| |
static int InProcess_waitPid( |
static int Loopback_reapProviderAgent( |
|
const SessionKey& sessionKey, |
int pid) | int pid) |
{ | { |
int status; | int status; |
|
|
return status; | return status; |
} | } |
| |
static int InProcess_authenticatePassword( |
static int Loopback_authenticatePassword( |
const char* username, | const char* username, |
const char* password, | const char* password, |
SessionKey& sessionKey) | SessionKey& sessionKey) |
|
|
#endif | #endif |
} | } |
| |
static int InProcess_validateUser( |
static int Loopback_validateUser( |
const char* username) | const char* username) |
{ | { |
#if defined(PEGASUS_PAM_AUTHENTICATION) | #if defined(PEGASUS_PAM_AUTHENTICATION) |
|
|
return 0; | return 0; |
} | } |
| |
static int OutOfProcess_ping() |
static int Socket_ping() |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
| |
|
|
return -1; | return -1; |
} | } |
| |
FILE* OutOfProcess_openFile( |
FILE* Socket_openFile( |
const char* path, | const char* path, |
int mode) | int mode) |
{ | { |
|
|
return NULL; | return NULL; |
} | } |
| |
static int OutOfProcess_renameFile( |
static int Socket_renameFile( |
const char* oldPath, | const char* oldPath, |
const char* newPath) | const char* newPath) |
{ | { |
|
|
return response.status; | return response.status; |
} | } |
| |
static int OutOfProcess_removeFile( |
static int Socket_removeFile( |
const char* path) | const char* path) |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
|
|
return response.status; | return response.status; |
} | } |
| |
static int OutOfProcess_startProviderAgent( |
static int Socket_startProviderAgent( |
const SessionKey& sessionKey, | const SessionKey& sessionKey, |
const char* module, | const char* module, |
int uid, | int uid, |
|
|
return result; | return result; |
} | } |
| |
static int OutOfProcess_daemonizeExecutor() |
static int Socket_daemonizeExecutor() |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
| |
|
|
return response.status; | return response.status; |
} | } |
| |
static int OutOfProcess_waitPid( |
static int Socket_reapProviderAgent( |
|
const SessionKey& sessionKey, |
int pid) | int pid) |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
|
|
// _send request header: | // _send request header: |
| |
ExecutorRequestHeader header; | ExecutorRequestHeader header; |
header.code = EXECUTOR_WAIT_PID_MESSAGE; |
header.code = EXECUTOR_REAP_PROVIDER_AGENT; |
| |
if (_send(_getSock(), &header, sizeof(header)) != sizeof(header)) | if (_send(_getSock(), &header, sizeof(header)) != sizeof(header)) |
return -1; | return -1; |
| |
// _send request body: | // _send request body: |
| |
ExecutorWaitPidRequest request; |
ExecutorReapProviderAgentRequest request; |
|
memset(&request, 0, sizeof(request)); |
|
Strlcpy(request.key, sessionKey.data(), sizeof(request.key)); |
request.pid = pid; | request.pid = pid; |
| |
if (_send(_getSock(), &request, sizeof(request)) != sizeof(request)) | if (_send(_getSock(), &request, sizeof(request)) != sizeof(request)) |
|
|
| |
// Receive the response | // Receive the response |
| |
ExecutorWaitPidResponse response; |
ExecutorReapProviderAgentResponse response; |
| |
if (_recv(_getSock(), &response, sizeof(response)) != sizeof(response)) | if (_recv(_getSock(), &response, sizeof(response)) != sizeof(response)) |
return -1; | return -1; |
|
|
return response.status; | return response.status; |
} | } |
| |
static int OutOfProcess_authenticatePassword( |
static int Socket_authenticatePassword( |
const char* username, | const char* username, |
const char* password, | const char* password, |
SessionKey& sessionKey) | SessionKey& sessionKey) |
|
|
return response.status; | return response.status; |
} | } |
| |
static int OutOfProcess_validateUser( |
static int Socket_validateUser( |
const char* username) | const char* username) |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
|
|
return response.status; | return response.status; |
} | } |
| |
int OutOfProcess_challengeLocal( |
int Socket_challengeLocal( |
const char* user, | const char* user, |
char challenge[EXECUTOR_BUFFER_SIZE], | char challenge[EXECUTOR_BUFFER_SIZE], |
SessionKey& sessionKey) | SessionKey& sessionKey) |
|
|
return response.status; | return response.status; |
} | } |
| |
int OutOfProcess_authenticateLocal( |
int Socket_authenticateLocal( |
const SessionKey& sessionKey, | const SessionKey& sessionKey, |
const char* token) | const char* token) |
{ | { |
|
|
return response.status; | return response.status; |
} | } |
| |
int OutOfProcess_newSessionKey( |
int Socket_newSessionKey( |
const char username[EXECUTOR_BUFFER_SIZE], | const char username[EXECUTOR_BUFFER_SIZE], |
SessionKey& sessionKey) | SessionKey& sessionKey) |
{ | { |
|
|
return response.status; | return response.status; |
} | } |
| |
int OutOfProcess_deleteSessionKey( |
int Socket_deleteSessionKey( |
const SessionKey& sessionKey) | const SessionKey& sessionKey) |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
|
|
int Executor::ping() | int Executor::ping() |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_ping(); |
return Loopback_ping(); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_ping(); |
return Socket_ping(); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
int mode) | int mode) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_openFile(path, mode); |
return Loopback_openFile(path, mode); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_openFile(path, mode); |
return Socket_openFile(path, mode); |
#else | #else |
return NULL; | return NULL; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
const char* newPath) | const char* newPath) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_renameFile(oldPath, newPath); |
return Loopback_renameFile(oldPath, newPath); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_renameFile(oldPath, newPath); |
return Socket_renameFile(oldPath, newPath); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
const char* path) | const char* path) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_removeFile(path); |
return Loopback_removeFile(path); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_removeFile(path); |
return Socket_removeFile(path); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_startProviderAgent(sessionKey, module, |
return Loopback_startProviderAgent(sessionKey, module, |
uid, gid, pid, providerAgentSessionKey, readPipe, writePipe); | uid, gid, pid, providerAgentSessionKey, readPipe, writePipe); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_startProviderAgent(sessionKey, module, |
return Socket_startProviderAgent(sessionKey, module, |
uid, gid, pid, providerAgentSessionKey, readPipe, writePipe); | uid, gid, pid, providerAgentSessionKey, readPipe, writePipe); |
#else | #else |
providerAgentSessionKey.clear(); | providerAgentSessionKey.clear(); |
|
|
int Executor::daemonizeExecutor() | int Executor::daemonizeExecutor() |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_daemonizeExecutor(); |
return Loopback_daemonizeExecutor(); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_daemonizeExecutor(); |
return Socket_daemonizeExecutor(); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
} | } |
| |
int Executor::waitPid( |
int Executor::reapProviderAgent( |
|
const SessionKey& sessionKey, |
int pid) | int pid) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_waitPid(pid); |
return Loopback_reapProviderAgent(sessionKey, pid); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_waitPid(pid); |
return Socket_reapProviderAgent(sessionKey, pid); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
SessionKey& sessionKey) | SessionKey& sessionKey) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_authenticatePassword(username, password, sessionKey); |
return Loopback_authenticatePassword(username, password, sessionKey); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_authenticatePassword(username, password, sessionKey); |
return Socket_authenticatePassword(username, password, sessionKey); |
#else | #else |
sessionKey.clear(); | sessionKey.clear(); |
return -1; | return -1; |
|
|
const char* username) | const char* username) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_validateUser(username); |
return Loopback_validateUser(username); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_validateUser(username); |
return Socket_validateUser(username); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
return -1; | return -1; |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_challengeLocal(user, path, sessionKey); |
return Socket_challengeLocal(user, path, sessionKey); |
#else | #else |
sessionKey.clear(); | sessionKey.clear(); |
return -1; | return -1; |
|
|
return -1; | return -1; |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_authenticateLocal(sessionKey, challengeResponse); |
return Socket_authenticateLocal(sessionKey, challengeResponse); |
#else | #else |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
|
SessionKey& sessionKey) | SessionKey& sessionKey) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return -1; |
{ |
|
sessionKey.clear(); |
|
return 0; |
|
} |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_newSessionKey(username, sessionKey); |
return Socket_newSessionKey(username, sessionKey); |
#else | #else |
sessionKey.clear(); |
return -1; |
return 0; |
|
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
} | } |
| |
|
|
const SessionKey& sessionKey) | const SessionKey& sessionKey) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return -1; |
return 0; |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_deleteSessionKey(sessionKey); |
return Socket_deleteSessionKey(sessionKey); |
#else | #else |
return 0; | return 0; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |