version 1.1.2.1, 2007/01/04 04:43:33
|
version 1.1.2.2, 2007/01/07 21:38:58
|
|
|
| |
/* 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. */ |
| |
globalArg0 = argv[0]; |
globals.arg0 = argv[0]; |
| |
/* Get absolute cimservermain program name. */ | /* Get absolute cimservermain program name. */ |
| |
|
|
| |
/* If CIMSERVERMAIN is already running, warn and exit now. */ | /* If CIMSERVERMAIN is already running, warn and exit now. */ |
| |
|
|
if (TestCimServerProcess() == 0) | if (TestCimServerProcess() == 0) |
{ | { |
fprintf(stderr, | fprintf(stderr, |
"%s: cimserver is already running (the PID found in the file " | "%s: cimserver is already running (the PID found in the file " |
"\"%s\" corresponds to an existing process named \"%s\").\n\n", | "\"%s\" corresponds to an existing process named \"%s\").\n\n", |
globalArg0, PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN); |
globals.arg0, PEGASUS_CIMSERVER_START_FILE, CIMSERVERMAIN); |
| |
exit(1); | exit(1); |
} | } |
| |
|
/* Get enableAuthentication configuration option. */ |
|
|
|
{ |
|
char buffer[EXECUTOR_BUFFER_SIZE]; |
|
|
|
if (GetConfigParam(argc, argv, "enableAuthentication", buffer) == 0 && |
|
strcasecmp(buffer, "true") == 0) |
|
{ |
|
globals.enableAuthentication = 1; |
|
} |
|
} |
|
|
/* Create a socket pair for communicating with the child process. */ | /* Create a socket pair for communicating with the child process. */ |
| |
if (CreateSocketPair(pair) != 0) | if (CreateSocketPair(pair) != 0) |
|
|
if (setuid(0) != 0 || setgid(0) != 0) | if (setuid(0) != 0 || setgid(0) != 0) |
{ | { |
Log(LL_FATAL, "attempted to run program as non-root user"); | Log(LL_FATAL, "attempted to run program as non-root user"); |
fprintf(stderr, "%s: this program must be run as root\n", globalArg0); |
fprintf(stderr, "%s: this program must be run as root\n", globals.arg0); |
exit(0); | exit(0); |
} | } |
| |
|
/* Warn if authentication not enabled (strange use of executor if not). */ |
|
|
|
if (!globals.enableAuthentication) |
|
Log(LL_WARNING, "authentication is NOT enabled"); |
|
else |
|
Log(LL_INFORMATION, "authentication is enabled"); |
|
|
/* Print user info. */ | /* Print user info. */ |
| |
if (GetUserName(getuid(), username) != 0) | if (GetUserName(getuid(), username) != 0) |
|
|
/* Determine user for running cimservermain. */ | /* Determine user for running cimservermain. */ |
| |
GetServerUser( | GetServerUser( |
argc, argv, cimservermainPath, &globalChildUid, &globalChildGid); |
argc, argv, cimservermainPath, &globals.childUid, &globals.childGid); |
| |
/* Fork child process. */ | /* Fork child process. */ |
| |
|
|
/* Child. */ | /* Child. */ |
close(pair[1]); | close(pair[1]); |
Child(argc, argv, | Child(argc, argv, |
cimservermainPath, globalChildUid, globalChildGid, pair[0]); |
cimservermainPath, globals.childUid, globals.childGid, pair[0]); |
} | } |
else if (childPid > 0) | else if (childPid > 0) |
{ | { |