version 1.73, 2004/01/16 13:35:58
|
version 1.73.2.3, 2004/04/24 01:38:14
|
|
|
dlclose(libraryHandle); | dlclose(libraryHandle); |
#endif | #endif |
| |
|
#ifdef PEGASUS_OS_ZOS |
|
dllfree(reinterpret_cast<dllhandle *> (libraryHandle)); |
|
#endif |
} | } |
| |
String System::dynamicLoadError() { | String System::dynamicLoadError() { |
|
|
const unsigned int PWD_BUFF_SIZE = 1024; | const unsigned int PWD_BUFF_SIZE = 1024; |
struct passwd local_pwd; | struct passwd local_pwd; |
char buf[PWD_BUFF_SIZE]; | char buf[PWD_BUFF_SIZE]; |
if(getpwuid_r(geteuid(), &local_pwd, buf, PWD_BUFF_SIZE, &pwd)) { |
|
pwd = (struct passwd *)NULL; |
if(getpwuid_r(geteuid(), &local_pwd, buf, PWD_BUFF_SIZE, &pwd) != 0) |
|
{ |
|
String errorMsg = String("getpwuid_r failure : ") + |
|
String(strerror(errno)); |
|
Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
|
errorMsg); |
|
// l10n TODO - Need to add this message |
|
//Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
// errorMsg); |
|
return userName; |
} | } |
#else | #else |
// | // |
|
|
#endif | #endif |
if ( pwd == NULL ) | if ( pwd == NULL ) |
{ | { |
//ATTN: Log a message |
// l10n TODO - Need to add this message |
// "User might have been removed just after login" |
// Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
// "getpwuid_r failure, user may have been removed just after login"); |
|
Tracer::trace (TRC_OS_ABSTRACTION, Tracer::LEVEL4, |
|
"getpwuid_r failure, user may have been removed just after login"); |
} | } |
else | else |
{ | { |
|
|
char pwdBuffer[PWD_BUFF_SIZE]; | char pwdBuffer[PWD_BUFF_SIZE]; |
| |
if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0) | if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0) |
|
{ |
|
String errorMsg = String("getpwnam_r failure : ") + |
|
String(strerror(errno)); |
|
Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
|
errorMsg); |
|
// l10n TODO - Need to add this message |
|
// Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
// errorMsg); |
|
return false; |
|
} |
|
if (result == NULL) |
|
{ |
|
return false; |
|
} |
#else | #else |
// | // |
// get the password entry for the user | // get the password entry for the user |
// | // |
if ( getpwnam(userName) == NULL ) | if ( getpwnam(userName) == NULL ) |
#endif |
|
{ | { |
#if defined(PEGASUS_OS_OS400) | #if defined(PEGASUS_OS_OS400) |
EtoA((char *)userName); | EtoA((char *)userName); |
#endif | #endif |
return false; | return false; |
} | } |
|
#endif |
#if defined(PEGASUS_OS_OS400) | #if defined(PEGASUS_OS_OS400) |
EtoA((char *)userName); | EtoA((char *)userName); |
#endif | #endif |
|
|
#if !defined(PEGASUS_OS_OS400) | #if !defined(PEGASUS_OS_OS400) |
struct passwd pwd; | struct passwd pwd; |
struct passwd *result; | struct passwd *result; |
char pwdBuffer[1024]; |
const unsigned int PWD_BUFF_SIZE = 1024; |
|
char pwdBuffer[PWD_BUFF_SIZE]; |
|
|
|
if (getpwnam_r(userName.getCString(), &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0) |
|
{ |
|
String errorMsg = String("getpwnam_r failure : ") + |
|
String(strerror(errno)); |
|
Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
|
errorMsg); |
|
// l10n TODO - Need to add this message |
|
//Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
// errorMsg); |
|
return false; |
|
} |
| |
if (getpwnam_r(userName.getCString(), &pwd, pwdBuffer, 1024, &result) == 0) |
// Check if the requested entry was found. If not return false. |
|
if ( result != NULL ) |
{ | { |
|
// Check if the uid is 0. |
if ( pwd.pw_uid == 0 ) | if ( pwd.pw_uid == 0 ) |
{ | { |
return true; | return true; |
} | } |
} | } |
return false; | return false; |
|
|
#else | #else |
CString user = userName.getCString(); | CString user = userName.getCString(); |
const char * tmp = (const char *)user; | const char * tmp = (const char *)user; |
|
|
const unsigned int PWD_BUFF_SIZE = 1024; | const unsigned int PWD_BUFF_SIZE = 1024; |
struct passwd local_pwd; | struct passwd local_pwd; |
char buf[PWD_BUFF_SIZE]; | char buf[PWD_BUFF_SIZE]; |
if(getpwuid_r(0, &local_pwd, buf, PWD_BUFF_SIZE, &pwd)) { |
|
pwd = (struct passwd *)NULL; |
if(getpwuid_r(0, &local_pwd, buf, PWD_BUFF_SIZE, &pwd) != 0) |
|
{ |
|
String errorMsg = String("getpwuid_r failure : ") + |
|
String(strerror(errno)); |
|
Tracer::PEG_TRACE_STRING (TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
|
errorMsg); |
|
// l10n TODO - Need to add this message |
|
// Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING, |
|
// errorMsg); |
|
return userName; |
} | } |
#else | #else |
// | // |
|
|
} | } |
else | else |
{ | { |
|
Tracer::trace (TRC_OS_ABSTRACTION, Tracer::LEVEL4, |
|
"Could not find entry."); |
PEGASUS_ASSERT(0); | PEGASUS_ASSERT(0); |
} | } |
} | } |
|
|
| |
void System::openlog(const String ident) | void System::openlog(const String ident) |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
|
|
// ATTN: Hard-code the "cimserver" identifier until the infrastructure | // ATTN: Hard-code the "cimserver" identifier until the infrastructure |
// is set up to pass this as the "ident" string. | // is set up to pass this as the "ident" string. |
//::openlog(ident.getCString(), LOG_PID|LOG_CONS, LOG_DAEMON); | //::openlog(ident.getCString(), LOG_PID|LOG_CONS, LOG_DAEMON); |
|
|
| |
void System::syslog(Uint32 severity, const char *data) | void System::syslog(Uint32 severity, const char *data) |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
| |
// FUTURE-SF-P3-20020517 : Use the Syslog on HP-UX. Eventually only | // FUTURE-SF-P3-20020517 : Use the Syslog on HP-UX. Eventually only |
// certain messages will go to the Syslog and others to the | // certain messages will go to the Syslog and others to the |
|
|
| |
void System::closelog() | void System::closelog() |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
| |
::closelog(); | ::closelog(); |
| |