version 1.199, 2007/05/25 18:35:21
|
version 1.200, 2007/06/05 10:22:40
|
|
|
#include <Service/ServerShutdownClient.h> | #include <Service/ServerShutdownClient.h> |
#include <Service/ServerRunStatus.h> | #include <Service/ServerRunStatus.h> |
| |
#if defined(PEGASUS_OS_OS400) |
|
# include "vfyptrs.cinc" |
|
# include "OS400ConvertChar.h" |
|
#endif |
|
|
|
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) | #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
#include <Service/ARM_zOS.h> | #include <Service/ARM_zOS.h> |
# ifdef PEGASUS_ZOS_SECURITY | # ifdef PEGASUS_ZOS_SECURITY |
|
|
#endif | #endif |
| |
#if defined(PEGASUS_OS_TYPE_UNIX) | #if defined(PEGASUS_OS_TYPE_UNIX) |
# if defined(PEGASUS_OS_OS400) |
|
# include <unistd.cleinc> |
|
# else |
|
# include <unistd.h> | # include <unistd.h> |
# endif |
|
# include <sys/types.h> | # include <sys/types.h> |
# include <sys/stat.h> | # include <sys/stat.h> |
# include <fcntl.h> | # include <fcntl.h> |
|
|
setlocale(LC_ALL, ""); | setlocale(LC_ALL, ""); |
#endif | #endif |
| |
#ifdef PEGASUS_OS_OS400 |
|
|
|
VFYPTRS_INCDCL; // VFYPTRS local variables |
|
|
|
// verify pointers |
|
#pragma exception_handler (qsyvp_excp_hndlr,qsyvp_excp_comm_area,\ |
|
0,_C2_MH_ESCAPE) |
|
for( int arg_index = 1; arg_index < argc; arg_index++ ){ |
|
VFYPTRS(VERIFY_SPP_NULL(argv[arg_index])); |
|
} |
|
#pragma disable_handler |
|
|
|
// Convert the args to ASCII |
|
for(Uint32 i = 0;i< argc;++i) |
|
{ |
|
EtoA(argv[i]); |
|
} |
|
|
|
// Initialize Pegasus home to the shipped OS/400 directory. |
|
pegasusHome = OS400_DEFAULT_PEGASUS_HOME; |
|
#endif |
|
|
|
|
|
#ifndef PEGASUS_OS_TYPE_WINDOWS | #ifndef PEGASUS_OS_TYPE_WINDOWS |
// | // |
// Get environment variables: | // Get environment variables: |
// | // |
#ifdef PEGASUS_OS_OS400 |
|
#pragma convert(37) |
|
const char* tmp = getenv("PEGASUS_HOME"); |
|
#pragma convert(0) |
|
char home[256] = {0}; |
|
if (tmp && strlen(tmp) < 256) |
|
{ |
|
strcpy(home, tmp); |
|
EtoA(home); |
|
pegasusHome = home; |
|
} |
|
#else |
|
#if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS) | #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS) |
pegasusHome = AIX_RELEASE_PEGASUS_HOME; | pegasusHome = AIX_RELEASE_PEGASUS_HOME; |
#elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) | #elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
|
|
pegasusHome = tmp; | pegasusHome = tmp; |
} | } |
#endif | #endif |
#endif |
|
| |
FileSystem::translateSlashes(pegasusHome); | FileSystem::translateSlashes(pegasusHome); |
#else | #else |
|
|
configManager = ConfigManager::getInstance(); | configManager = ConfigManager::getInstance(); |
configManager->useConfigFiles = true; | configManager->useConfigFiles = true; |
| |
#ifdef PEGASUS_OS_OS400 |
|
// In a special startup case for IBM OS400, when the server is |
|
// automatically started when the machine starts up the config |
|
// file cannot be read because of access restrictions for the |
|
// user starting the server. In this case, we need to skip |
|
// reading the config options and therefore any use of the config |
|
// manager also. To make this determinations we will check to see |
|
// if the daemon flag is set to true. If so, then there will be a |
|
// series of checks to bracket all the calls to the configManager |
|
// which would otherwise fail. All this will only be done for |
|
// IBM OS400. |
|
|
|
Boolean os400StartupOption = false; |
|
// loop through args to check for daemon=true |
|
for (int i=1; i < argc; i++) |
|
if (strcmp(argv[i], "daemon=true") == 0) |
|
{ |
|
os400StartupOption = true; |
|
daemonOption = true; |
|
} |
|
|
|
if (!os400StartupOption) |
|
{ |
|
// If this is the server job, then set the job |
|
// to save the job log. |
|
system ("QSYS/CHGJOB JOB(*) LOG(4 00 *SECLVL)"); |
|
} |
|
#endif |
|
|
|
// | // |
// Get options (from command line and from configuration file); this | // Get options (from command line and from configuration file); this |
// removes corresponding options and their arguments from the command | // removes corresponding options and their arguments from the command |
|
|
// | // |
try | try |
{ | { |
#ifdef PEGASUS_OS_OS400 |
|
if (os400StartupOption == false) |
|
#endif |
|
// If current process is "cimserver -s" (shutdown option = true) the contents | // If current process is "cimserver -s" (shutdown option = true) the contents |
// of current config should not be overwriten by planned config | // of current config should not be overwriten by planned config |
GetOptions(configManager, argc, argv, shutdownOption); | GetOptions(configManager, argc, argv, shutdownOption); |
|
|
"src.Server.cimserver.SERVER_NOT_STARTED", | "src.Server.cimserver.SERVER_NOT_STARTED", |
"cimserver not started: $0", e.getMessage()); | "cimserver not started: $0", e.getMessage()); |
| |
#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()); | "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); |
#endif |
|
| |
return(1); | return(1); |
} | } |
|
|
MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath( | MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath( |
ConfigManager::getInstance()->getCurrentValue("messageDir"))); | ConfigManager::getInstance()->getCurrentValue("messageDir"))); |
| |
#ifdef PEGASUS_OS_OS400 |
|
// Still need to declare and set the connection variables. |
|
// Will initialize to false since they are fixed at false for OS400. |
|
|
|
// NOTE: OS400 is a LOCAL_DOMAIN_SOCKET, so a few lines down |
|
// the test will not be compiled in. If OS400 ever turns off that |
|
// define, then we will need to change this code path to insure that |
|
// one of the variables is true. |
|
Boolean enableHttpConnection = false; |
|
Boolean enableHttpsConnection = false; |
|
|
|
if (os400StartupOption == false) |
|
{ |
|
enableHttpConnection = ConfigManager::parseBooleanValue( |
|
configManager->getCurrentValue("enableHttpConnection")); |
|
enableHttpsConnection = ConfigManager::parseBooleanValue( |
|
configManager->getCurrentValue("enableHttpsConnection")); |
|
} |
|
#else |
|
Boolean enableHttpConnection = ConfigManager::parseBooleanValue( | Boolean enableHttpConnection = ConfigManager::parseBooleanValue( |
configManager->getCurrentValue("enableHttpConnection")); | configManager->getCurrentValue("enableHttpConnection")); |
Boolean enableHttpsConnection = ConfigManager::parseBooleanValue( | Boolean enableHttpsConnection = ConfigManager::parseBooleanValue( |
configManager->getCurrentValue("enableHttpsConnection")); | configManager->getCurrentValue("enableHttpsConnection")); |
#endif |
|
| |
// Make sure at least one connection is enabled | // Make sure at least one connection is enabled |
#ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
|
|
daemonOption = ConfigManager::parseBooleanValue( | daemonOption = ConfigManager::parseBooleanValue( |
configManager->getCurrentValue("daemon")); | configManager->getCurrentValue("daemon")); |
| |
#ifdef PEGASUS_OS_OS400 |
|
if (os400StartupOption == false) |
|
{ |
|
#endif |
|
#if !defined(PEGASUS_USE_SYSLOGS) | #if !defined(PEGASUS_USE_SYSLOGS) |
logsDirectory = | logsDirectory = |
ConfigManager::getHomedPath(configManager->getCurrentValue("logdir")); | ConfigManager::getHomedPath(configManager->getCurrentValue("logdir")); |
#endif | #endif |
#ifdef PEGASUS_OS_OS400 |
|
} // end if (os400StartupOption == false) |
|
#endif |
|
| |
// Set up the Logger. This does not open the logs | // Set up the Logger. This does not open the logs |
// Might be more logical to clean before set. | // Might be more logical to clean before set. |
// ATTN: Need tool to completely disable logging. | // ATTN: Need tool to completely disable logging. |
| |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \ | #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \ |
!defined(PEGASUS_OS_OS400) && !defined(PEGASUS_USE_SYSLOGS) |
!defined(PEGASUS_USE_SYSLOGS) |
Logger::setHomeDirectory(logsDirectory); | Logger::setHomeDirectory(logsDirectory); |
#endif | #endif |
| |
|
|
ServerShutdownClient serverShutdownClient(&_serverRunStatus); | ServerShutdownClient serverShutdownClient(&_serverRunStatus); |
serverShutdownClient.shutdown(timeoutValue); | serverShutdownClient.shutdown(timeoutValue); |
| |
#ifdef PEGASUS_OS_OS400 |
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"src.Server.cimserver.SERVER_STOPPED", |
|
"CIM Server stopped."); |
|
cimserver_exitRC(0); |
|
#else |
|
MessageLoaderParms parms( | MessageLoaderParms parms( |
"src.Server.cimserver.SERVER_STOPPED", | "src.Server.cimserver.SERVER_STOPPED", |
"CIM Server stopped."); | "CIM Server stopped."); |
| |
cout << MessageLoader::getMessage(parms) << endl; | cout << MessageLoader::getMessage(parms) << endl; |
return(0); | return(0); |
#endif |
|
} | } |
| |
#if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS) | #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS) |
|
|
System::CIMSERVER, | System::CIMSERVER, |
Logger::SEVERE, | Logger::SEVERE, |
e.getMessage()); | e.getMessage()); |
#ifndef PEGASUS_OS_OS400 |
|
cout << e.getMessage() << endl; | cout << e.getMessage() << endl; |
#endif |
|
} | } |
catch (Exception& ex) | catch (Exception& ex) |
{ | { |
|
|
System::CIMSERVER, | System::CIMSERVER, |
Logger::SEVERE, | Logger::SEVERE, |
ex.getMessage()); | ex.getMessage()); |
#ifndef PEGASUS_OS_OS400 |
|
cout << ex.getMessage() << endl; | cout << ex.getMessage() << endl; |
#endif |
|
exit(1); | exit(1); |
} | } |
| |
|
|
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()); | "cimserver not started: $0", e.getMessage()); |
#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()); | "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); |
#endif |
|
exit(1); | exit(1); |
} | } |
} | } |
|
|
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()); | "cimserver not started: $0", e.getMessage()); |
#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()); | "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); |
#endif |
|
exit(1); | exit(1); |
} | } |
} | } |
|
|
if (daemonOption) | if (daemonOption) |
{ | { |
if(-1 == _cimServerProcess->cimserver_fork()) | if(-1 == _cimServerProcess->cimserver_fork()) |
# ifndef PEGASUS_OS_OS400 |
|
return(-1); |
|
# else |
|
return(-1); | return(-1); |
else | else |
return(0); | return(0); |
# endif |
|
} | } |
| |
// l10n | // l10n |
|
|
e.getMessage()); | e.getMessage()); |
} | } |
| |
|
|
|
|
#ifdef PEGASUS_OS_OS400 |
|
// Special server initialization code for OS/400. |
|
if (cimserver_initialize() != 0) |
|
{ |
|
// do some logging here! |
|
//l10n |
|
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
//"CIM Server failed to initialize"); |
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
"src.Server.cimserver.SERVER_FAILED_TO_INITIALIZE", |
|
"CIM Server failed to initialize"); |
|
return(-1); |
|
} |
|
#endif |
|
|
|
#ifndef PEGASUS_OS_TYPE_WINDOWS | #ifndef PEGASUS_OS_TYPE_WINDOWS |
umask(S_IRWXG|S_IRWXO); | umask(S_IRWXG|S_IRWXO); |
#endif | #endif |
|
|
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()); | "cimserver not started: $0", e.getMessage()); |
|
|
#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()); | "cimserver not started: $0", e.getMessage()); |
| |
cerr << MessageLoader::getMessage(parms) << endl; | cerr << MessageLoader::getMessage(parms) << endl; |
#endif |
|
| |
// | // |
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |
|
|
Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, | Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
"src.Server.cimserver.ERROR", | "src.Server.cimserver.ERROR", |
"Error: $0", e.getMessage()); | "Error: $0", e.getMessage()); |
#ifndef PEGASUS_OS_OS400 |
|
MessageLoaderParms parms("src.Server.cimserver.ERROR", | MessageLoaderParms parms("src.Server.cimserver.ERROR", |
"Error: $0", e.getMessage()); | "Error: $0", e.getMessage()); |
PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl); |
#endif |
|
// | // |
// notify parent process (if there is a parent process) to terminate | // notify parent process (if there is a parent process) to terminate |
// | // |