version 1.1.2.4, 2007/01/11 20:48:24
|
version 1.2, 2007/05/25 18:35:07
|
|
|
#include "Defines.h" | #include "Defines.h" |
#include "Fatal.h" | #include "Fatal.h" |
#include "Path.h" | #include "Path.h" |
#include "File.h" |
|
#include "Log.h" | #include "Log.h" |
#include "User.h" | #include "User.h" |
| |
|
|
const char* path, | const char* path, |
int uid, | int uid, |
int gid, | int gid, |
int sock, |
int sock) |
const char* repositoryDir) |
|
{ | { |
char sockStr[EXECUTOR_BUFFER_SIZE]; | char sockStr[EXECUTOR_BUFFER_SIZE]; |
char username[EXECUTOR_BUFFER_SIZE]; | char username[EXECUTOR_BUFFER_SIZE]; |
char** execArgv; | char** execArgv; |
| |
/* Build argument list, adding "-x <sock>" option if sock non-negative. */ |
/* Build argument list, adding "--executor-socket <sock>" option if |
|
* sock non-negative. |
|
*/ |
| |
execArgv = (char**)malloc(sizeof(char*) * (argc + 3)); | execArgv = (char**)malloc(sizeof(char*) * (argc + 3)); |
memcpy(execArgv + 3, argv + 1, sizeof(char*) * argc); | memcpy(execArgv + 3, argv + 1, sizeof(char*) * argc); |
|
|
sprintf(sockStr, "%d", sock); | sprintf(sockStr, "%d", sock); |
| |
execArgv[0] = CIMSERVERMAIN; | execArgv[0] = CIMSERVERMAIN; |
execArgv[1] = "-x"; |
execArgv[1] = "--executor-socket"; |
execArgv[2] = strdup(sockStr); | execArgv[2] = strdup(sockStr); |
| |
/* Check whether repository directory exists. */ |
|
|
|
if (AccessDir(repositoryDir) != 0) |
|
Fatal(FL, |
|
"failed to access repository directory: %s", repositoryDir); |
|
|
|
/* |
|
* Change ownership of Pegasus repository directory (it should be owned |
|
* by same user that owns CIMSERVERMAIN). |
|
*/ |
|
|
|
ChangeDirOwnerRecursive(repositoryDir, uid, gid); |
|
|
|
Log(LL_TRACE, "Pegasus repositoryDir is \"%s\"", repositoryDir); |
|
|
|
/* | /* |
* Downgrade privileges by setting the UID and GID of this process. Use | * Downgrade privileges by setting the UID and GID of this process. Use |
* the owner of the CIMSERVERMAIN program obtained above. | * the owner of the CIMSERVERMAIN program obtained above. |