version 1.1.2.9, 2007/01/07 21:39:01
|
version 1.1.2.11, 2007/01/09 17:46:28
|
|
|
int uid, | int uid, |
int gid, | int gid, |
int& pid, | int& pid, |
|
SessionKey& providerAgentSessionKey, |
AnonymousPipe*& readPipe, | AnonymousPipe*& readPipe, |
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
|
|
| |
// Initialize output parameters in case of error. | // Initialize output parameters in case of error. |
| |
|
providerAgentSessionKey.clear(); |
pid = -1; | pid = -1; |
readPipe = 0; | readPipe = 0; |
writePipe = 0; | writePipe = 0; |
|
|
int uid, | int uid, |
int gid, | int gid, |
int& pid, | int& pid, |
|
SessionKey& providerAgentSessionKey, |
AnonymousPipe*& readPipe, | AnonymousPipe*& readPipe, |
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
| |
|
providerAgentSessionKey.clear(); |
readPipe = 0; | readPipe = 0; |
writePipe = 0; | writePipe = 0; |
| |
|
|
if (_recv(_getSock(), &response, sizeof(response)) != sizeof(response)) | if (_recv(_getSock(), &response, sizeof(response)) != sizeof(response)) |
return -1; | return -1; |
| |
|
// Get the session key. |
|
|
|
Strlcpy((char*)providerAgentSessionKey.data(), |
|
response.key, providerAgentSessionKey.size()); |
|
|
// Check response status and pid. | // Check response status and pid. |
| |
if (response.status != 0) | if (response.status != 0) |
|
|
{ | { |
AutoMutex autoMutex(_mutex); | AutoMutex autoMutex(_mutex); |
| |
|
sessionKey.clear(); |
|
|
// _send request header: | // _send request header: |
| |
ExecutorRequestHeader header; | ExecutorRequestHeader header; |
|
|
return response.status; | return response.status; |
} | } |
| |
|
int OutOfProcess_newSessionKey( |
|
const char username[EXECUTOR_BUFFER_SIZE], |
|
SessionKey& sessionKey) |
|
{ |
|
AutoMutex autoMutex(_mutex); |
|
|
|
sessionKey.clear(); |
|
|
|
// _send request header: |
|
|
|
ExecutorRequestHeader header; |
|
header.code = EXECUTOR_NEW_SESSION_KEY_MESSAGE; |
|
|
|
if (_send(_getSock(), &header, sizeof(header)) != sizeof(header)) |
|
return -1; |
|
|
|
// _send request body. |
|
|
|
ExecutorNewSessionKeyRequest request; |
|
memset(&request, 0, sizeof(request)); |
|
Strlcpy(request.username, username, sizeof(request.username)); |
|
|
|
if (_send(_getSock(), &request, sizeof(request)) != sizeof(request)) |
|
return -1; |
|
|
|
// Receive the response |
|
|
|
ExecutorNewSessionKeyResponse response; |
|
|
|
if (_recv(_getSock(), &response, sizeof(response)) != sizeof(response)) |
|
return -1; |
|
|
|
Strlcpy((char*)sessionKey.data(), response.key, sessionKey.size()); |
|
|
|
return response.status; |
|
} |
|
|
|
int OutOfProcess_deleteSessionKey( |
|
const SessionKey& sessionKey) |
|
{ |
|
AutoMutex autoMutex(_mutex); |
|
|
|
// Send request header: |
|
|
|
ExecutorRequestHeader header; |
|
header.code = EXECUTOR_DELETE_SESSION_KEY_MESSAGE; |
|
|
|
if (_send(_getSock(), &header, sizeof(header)) != sizeof(header)) |
|
return -1; |
|
|
|
// Send request body. |
|
|
|
ExecutorDeleteSessionKeyRequest request; |
|
memset(&request, 0, sizeof(request)); |
|
Strlcpy(request.key, sessionKey.data(), sizeof(request.key)); |
|
|
|
if (_send(_getSock(), &request, sizeof(request)) != sizeof(request)) |
|
return -1; |
|
|
|
// Receive the response |
|
|
|
ExecutorDeleteSessionKeyResponse response; |
|
|
|
if (_recv(_getSock(), &response, sizeof(response)) != sizeof(response)) |
|
return -1; |
|
|
|
return response.status; |
|
} |
|
|
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
|
|
int uid, | int uid, |
int gid, | int gid, |
int& pid, | int& pid, |
|
SessionKey& providerAgentSessionKey, |
AnonymousPipe*& readPipe, | AnonymousPipe*& readPipe, |
AnonymousPipe*& writePipe) | AnonymousPipe*& writePipe) |
{ | { |
if (_getSock() == -1) | if (_getSock() == -1) |
return InProcess_startProviderAgent( |
return InProcess_startProviderAgent(sessionKey, module, |
sessionKey, module, uid, gid, pid, readPipe, writePipe); |
uid, gid, pid, providerAgentSessionKey, readPipe, writePipe); |
| |
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_startProviderAgent( |
return OutOfProcess_startProviderAgent(sessionKey, module, |
sessionKey, module, uid, gid, pid, readPipe, writePipe); |
uid, gid, pid, providerAgentSessionKey, readPipe, writePipe); |
#else | #else |
|
providerAgentSessionKey.clear(); |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
} | } |
|
|
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_authenticatePassword(username, password, sessionKey); | return OutOfProcess_authenticatePassword(username, password, sessionKey); |
#else | #else |
|
sessionKey.clear(); |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
} | } |
|
|
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) | #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
return OutOfProcess_challengeLocal(user, path, sessionKey); | return OutOfProcess_challengeLocal(user, path, sessionKey); |
#else | #else |
|
sessionKey.clear(); |
return -1; | return -1; |
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
} | } |
|
|
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ | #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
} | } |
| |
|
int Executor::newSessionKey( |
|
const char username[EXECUTOR_BUFFER_SIZE], |
|
SessionKey& sessionKey) |
|
{ |
|
if (_getSock() == -1) |
|
return -1; |
|
|
|
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
|
return OutOfProcess_newSessionKey(username, sessionKey); |
|
#else |
|
sessionKey.clear(); |
|
return 0; |
|
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
} |
|
|
|
int Executor::deleteSessionKey( |
|
const SessionKey& sessionKey) |
|
{ |
|
if (_getSock() == -1) |
|
return -1; |
|
|
|
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
|
return OutOfProcess_deleteSessionKey(sessionKey); |
|
#else |
|
return 0; |
|
#endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */ |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |