version 1.191, 2006/11/29 22:09:32
|
version 1.191.2.5, 2006/12/29 22:22:04
|
|
|
# include <fcntl.h> | # include <fcntl.h> |
#endif | #endif |
| |
|
#ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION |
|
# include <Pegasus/ExecutorClient/ExecutorClient.h> |
|
# define PEGASUS_PROCESS_NAME "cimservermain"; |
|
#else |
|
# define PEGASUS_PROCESS_NAME "cimserver"; |
|
#endif |
|
|
PEGASUS_USING_PEGASUS; | PEGASUS_USING_PEGASUS; |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
#define PEGASUS_PROCESS_NAME "cimserver"; |
|
|
|
//Windows service variables are not defined elsewhere in the product | //Windows service variables are not defined elsewhere in the product |
//enable ability to override these | //enable ability to override these |
#ifndef PEGASUS_SERVICE_NAME | #ifndef PEGASUS_SERVICE_NAME |
|
|
} | } |
} | } |
| |
|
#ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION |
|
extern bool pegasusClientAuthenticatorShutdownInProgress; |
|
#endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */ |
|
|
void shutdownCIMOM(Uint32 timeoutValue) | void shutdownCIMOM(Uint32 timeoutValue) |
{ | { |
|
#ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION |
|
|
|
// Let the client authenticator module know that a shutdown is in progress |
|
// so that it will attempt to authenticate as root for the purposes of |
|
// shutdown (with the help of the executor). |
|
|
|
pegasusClientAuthenticatorShutdownInProgress = true; |
|
|
|
#endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */ |
|
|
// | // |
// Create CIMClient object | // Create CIMClient object |
// | // |
|
|
} | } |
catch(Exception&) | catch(Exception&) |
{ | { |
|
cerr << "Shutdown failed" << endl; |
// | // |
// This may mean that the CIM Server has terminated, causing this | // This may mean that the CIM Server has terminated, causing this |
// client to get a "Empty HTTP response message" exception. It may | // client to get a "Empty HTTP response message" exception. It may |
|
|
return; | return; |
} | } |
| |
|
#ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION |
|
|
|
static void _checkForExecutor(const char* arg0) |
|
{ |
|
if (!getenv("PEGASUS_EXECUTOR_SOCKET")) |
|
{ |
|
fprintf(stderr, "%s: do not run this program directly. " |
|
"It is part of the cimserver program.\n", arg0); |
|
exit(1); |
|
} |
|
} |
|
|
|
#endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */ |
| |
///////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////// |
// MAIN | // MAIN |
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// |
int main(int argc, char** argv) | int main(int argc, char** argv) |
{ | { |
|
#ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION |
|
_checkForExecutor(argv[0]); |
|
#endif |
|
|
String pegasusHome = String::EMPTY; | String pegasusHome = String::EMPTY; |
Boolean shutdownOption = false; | Boolean shutdownOption = false; |
Boolean debugOutputOption = false; | Boolean debugOutputOption = false; |
|
|
{ | { |
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, | Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
"src.Server.cimserver.SERVER_NOT_STARTED", | "src.Server.cimserver.SERVER_NOT_STARTED", |
"cimserver not started: $0", e.getMessage()); |
"MEB:T2 cimserver not started: $0", e.getMessage()); |
| |
#if !defined(PEGASUS_OS_OS400) | #if !defined(PEGASUS_OS_OS400) |
MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED", | MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED", |
"cimserver not started: $0", e.getMessage()); |
"MEB:T3 cimserver not started: $0", e.getMessage()); |
| |
PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms) | PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms) |
<< PEGASUS_STD(endl); | << PEGASUS_STD(endl); |
|
|
// Get the parent's PID before forking | // Get the parent's PID before forking |
_cimServerProcess->set_parent_pid(System::getPID()); | _cimServerProcess->set_parent_pid(System::getPID()); |
| |
// do we need to run as a daemon ? |
// Do not fork when using privilege separation (executor will daemonize itself |
|
// later). |
if (daemonOption) | if (daemonOption) |
{ | { |
if(-1 == _cimServerProcess->cimserver_fork()) | if(-1 == _cimServerProcess->cimserver_fork()) |
#ifndef PEGASUS_OS_OS400 | #ifndef PEGASUS_OS_OS400 |
{ |
|
return(-1); | return(-1); |
} |
|
#else | #else |
{ |
|
return(-1); | return(-1); |
} |
|
else | else |
{ |
|
return(0); | return(0); |
} |
|
#endif | #endif |
|
|
} | } |
| |
// l10n | // l10n |
|
|
} | } |
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |
// so user knows that there is cimserver ready to serve CIM requests. | // so user knows that there is cimserver ready to serve CIM requests. |
|
#if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) |
|
if (daemonOption) |
|
ExecutorClient::daemonizeExecutor(); |
|
#else |
if (daemonOption) | if (daemonOption) |
_cimServerProcess->notify_parent(0); | _cimServerProcess->notify_parent(0); |
|
#endif |
| |
time_t last = 0; | time_t last = 0; |
| |
|
|
#endif | #endif |
| |
| |
|
/* |
|
ATTN:MEB: |
|
*/ |
| |
// | // |
// Loop to call CIMServer's runForever() method until CIMServer | // Loop to call CIMServer's runForever() method until CIMServer |
|
|
deleteCIMServer(); | deleteCIMServer(); |
return 0; | return 0; |
} | } |
|
|
|
|
|
|
|
|