version 1.1.2.8, 2007/01/11 16:01:23
|
version 1.1.2.9, 2007/01/11 20:48:24
|
|
|
#include "Log.h" | #include "Log.h" |
#include "Policy.h" | #include "Policy.h" |
#include "Macro.h" | #include "Macro.h" |
|
#include "Assert.h" |
| |
/* | /* |
**============================================================================== | **============================================================================== |
** | ** |
** GetServerUser | ** GetServerUser |
** | ** |
** Determine which user to run cimservermain as. |
** Determine which user to run CIMSERVERMAIN as. |
** | ** |
** Note: this algorithm is no longer in use. | ** Note: this algorithm is no longer in use. |
** | ** |
|
|
if (GetUserInfo(username, uid, gid) != 0) | if (GetUserInfo(username, uid, gid) != 0) |
{ | { |
Fatal(FL, | Fatal(FL, |
"The cimservermain user does not exist: \"%s\". Please create " |
"The %s user does not exist: \"%s\". Please create " |
"a system user with that name or use an OpenPegasus build that " | "a system user with that name or use an OpenPegasus build that " |
"disables privilege separation.", username); |
"disables privilege separation.", CIMSERVERMAIN, username); |
} | } |
| |
return -1; | return -1; |
|
|
**============================================================================== | **============================================================================== |
*/ | */ |
| |
void ExecShutdown(int argc, char** argv) |
void ExecShutdown() |
{ | { |
char* tmpArgv[3]; | char* tmpArgv[3]; |
char cimshutdownPath[EXECUTOR_BUFFER_SIZE]; |
const char* cimshutdownPath; |
char shutdownTimeout[EXECUTOR_BUFFER_SIZE]; |
const char* shutdownTimeout; |
| |
/* Get shutdownTimeout configuration parameter. */ | /* Get shutdownTimeout configuration parameter. */ |
| |
if (GetConfigParam(argc, argv, "shutdownTimeout", shutdownTimeout) != 0) |
if ((shutdownTimeout = FindMacro("shutdownTimeout")) == NULL) |
Strlcpy(shutdownTimeout, "5", sizeof(shutdownTimeout)); |
Fatal(FL, "failed to resolve shutdownTimeout"); |
| |
/* Get absolute cimshutdown program name. */ |
/* Get absolute CIMSHUTDOWN program name. */ |
| |
if (GetInternalPegasusProgramPath(CIMSHUTDOWN, cimshutdownPath) != 0) |
if ((cimshutdownPath = FindMacro("cimshutdownPath")) == NULL) |
Fatal(FL, "Failed to locate Pegasus program: %s", CIMSHUTDOWN); |
Fatal(FL, "failed to resolve cimshutdownPath"); |
| |
/* Create argument list. */ | /* Create argument list. */ |
| |
tmpArgv[0] = CIMSHUTDOWN; | tmpArgv[0] = CIMSHUTDOWN; |
tmpArgv[1] = shutdownTimeout; |
tmpArgv[1] = (char*)shutdownTimeout; |
tmpArgv[2] = 0; | tmpArgv[2] = 0; |
| |
/* Exec CIMSHUTDOWN program. */ | /* Exec CIMSHUTDOWN program. */ |
|
|
DefineMacro("internalBinDir", path); | DefineMacro("internalBinDir", path); |
} | } |
| |
|
/* Define ${cimservermain} */ |
|
|
|
DefineMacro("cimservermain", CIMSERVERMAIN); |
|
|
|
/* Define ${cimprovagt} */ |
|
|
|
DefineMacro("cimprovagt", CIMPROVAGT); |
|
|
|
/* Define ${cimshutdown} */ |
|
|
|
DefineMacro("cimshutdown", CIMSHUTDOWN); |
|
|
|
/* Define ${cimservera} */ |
|
|
|
DefineMacro("cimservera", CIMSERVERA); |
|
|
/* Define ${cimservermainPath} */ | /* Define ${cimservermainPath} */ |
{ | { |
char path[EXECUTOR_BUFFER_SIZE]; | char path[EXECUTOR_BUFFER_SIZE]; |
| |
if (ExpandMacros("${internalBinDir}/cimservermain", path) != 0) |
if (ExpandMacros("${internalBinDir}/${cimservermain}", path) != 0) |
Fatal(FL, "failed to resolve cimserver main path"); |
Fatal(FL, "failed to resolve cimservermainPath"); |
| |
DefineMacro("cimservermainPath", path); | DefineMacro("cimservermainPath", path); |
} | } |
|
|
{ | { |
char path[EXECUTOR_BUFFER_SIZE]; | char path[EXECUTOR_BUFFER_SIZE]; |
| |
if (ExpandMacros("${internalBinDir}/cimprovagt", path) != 0) |
if (ExpandMacros("${internalBinDir}/${cimprovagt}", path) != 0) |
Fatal(FL, "failed to resolve cimserver main path"); |
Fatal(FL, "failed to resolve cimprovagtPath"); |
| |
DefineMacro("cimprovagtPath", path); | DefineMacro("cimprovagtPath", path); |
} | } |
| |
|
/* Define ${cimshutdownPath} */ |
|
{ |
|
char path[EXECUTOR_BUFFER_SIZE]; |
|
|
|
if (ExpandMacros("${internalBinDir}/${cimshutdown}", path) != 0) |
|
Fatal(FL, "failed to resolve cimshutdownPath"); |
|
|
|
DefineMacro("cimshutdownPath", path); |
|
} |
|
|
/* Define ${cimserveraPath} */ | /* Define ${cimserveraPath} */ |
{ | { |
char path[EXECUTOR_BUFFER_SIZE]; | char path[EXECUTOR_BUFFER_SIZE]; |
| |
if (ExpandMacros("${internalBinDir}/cimservera", path) != 0) |
if (ExpandMacros("${internalBinDir}/${cimservera}", path) != 0) |
Fatal(FL, "failed to resolve cimserver main path"); |
Fatal(FL, "failed to resolve cimserveraPath"); |
| |
DefineMacro("cimserveraPath", path); | DefineMacro("cimserveraPath", path); |
} | } |
| |
|
/* Define ${shutdownTimeout} */ |
|
|
|
{ |
|
char buffer[EXECUTOR_BUFFER_SIZE]; |
|
|
|
if (GetConfigParam("shutdownTimeout", buffer) != 0) |
|
Strlcpy(buffer, "5", sizeof(buffer)); |
|
|
|
DefineMacro("shutdownTimeout", buffer); |
|
} |
|
|
/* Define ${currentConfigFilePath} */ | /* Define ${currentConfigFilePath} */ |
{ | { |
char path[EXECUTOR_BUFFER_SIZE]; | char path[EXECUTOR_BUFFER_SIZE]; |
|
|
| |
int main(int argc, char** argv) | int main(int argc, char** argv) |
{ | { |
int i; |
const char* cimservermainPath; |
char cimservermainPath[EXECUTOR_BUFFER_SIZE]; |
|
int pair[2]; | int pair[2]; |
char username[EXECUTOR_BUFFER_SIZE]; | char username[EXECUTOR_BUFFER_SIZE]; |
int childPid; | int childPid; |
int perror; | int perror; |
long shutdownTimeout; |
|
const char* repositoryDir; | const char* repositoryDir; |
| |
/* Save as global so it can be used in error and log messages. */ | /* Save as global so it can be used in error and log messages. */ |
|
|
globals.argc = argc; | globals.argc = argc; |
globals.argv = argv; | globals.argv = argv; |
| |
/* If shuting down, then run "cimshutdown" client. */ |
|
|
|
if (TestFlagOption(&argc, &argv, "-s", 0) == 0) |
|
ExecShutdown(argc, argv); |
|
|
|
/* Define macros needed by the executor. */ | /* Define macros needed by the executor. */ |
| |
DefineExecutorMacros(); | DefineExecutorMacros(); |
| |
|
/* If shuting down, then run CIMSHUTDOWN client. */ |
|
|
|
if (TestFlagOption(&argc, &argv, "-s", 0) == 0) |
|
ExecShutdown(); |
|
|
/* Check for --dump-policy option. */ | /* Check for --dump-policy option. */ |
| |
if (TestFlagOption(&argc, &argv, "--dump-policy", 0) == 0) | if (TestFlagOption(&argc, &argv, "--dump-policy", 0) == 0) |
|
|
exit(0); | exit(0); |
} | } |
| |
/* Get absolute cimservermain program name. */ |
/* Get absolute CIMSERVERMAIN program name. */ |
| |
if (GetInternalPegasusProgramPath(CIMSERVERMAIN, cimservermainPath) != 0) |
if ((cimservermainPath = FindMacro("cimservermainPath")) == NULL) |
Fatal(FL, "Failed to locate Pegasus program: %s", CIMSERVERMAIN); |
Fatal(FL, "Failed to locate %s program", CIMSERVERMAIN); |
| |
/* If CIMSERVERMAIN is already running, warn and exit now. */ | /* If CIMSERVERMAIN is already running, warn and exit now. */ |
| |
|
|
{ | { |
char buffer[EXECUTOR_BUFFER_SIZE]; | char buffer[EXECUTOR_BUFFER_SIZE]; |
| |
if (GetConfigParam(argc, argv, "enableAuthentication", buffer) == 0 && |
if (GetConfigParam("enableAuthentication", buffer) == 0 && |
strcasecmp(buffer, "true") == 0) | strcasecmp(buffer, "true") == 0) |
{ | { |
globals.enableAuthentication = 1; | globals.enableAuthentication = 1; |
|
|
Log(LL_TRACE, "running as %s (uid=%d, gid=%d)", | Log(LL_TRACE, "running as %s (uid=%d, gid=%d)", |
username, (int)getuid(), (int)getgid()); | username, (int)getuid(), (int)getgid()); |
| |
/* Determine user for running cimservermain. */ |
/* Determine user for running CIMSERVERMAIN. */ |
| |
GetServerUser(&globals.childUid, &globals.childGid); | GetServerUser(&globals.childUid, &globals.childGid); |
| |