(file) Return to SystemUnix.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/SystemUnix.cpp between version 1.48 and 1.66

version 1.48, 2002/09/03 13:29:14 version 1.66, 2003/08/27 01:38:18
Line 27 
Line 27 
 //              Sushma Fernandes (sushma_fernandes@hp.com) //              Sushma Fernandes (sushma_fernandes@hp.com)
 //              Nag Boranna (nagaraja_boranna@hp.com) //              Nag Boranna (nagaraja_boranna@hp.com)
 // //
   // Modified By: Dave Rosckes (rosckes@us.ibm.com)
   //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #ifdef PEGASUS_OS_HPUX #ifdef PEGASUS_OS_HPUX
Line 35 
Line 37 
 # include <dll.h> # include <dll.h>
 #elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) #elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
 #  include <fcntl.h> #  include <fcntl.h>
 #  include <mih/rslvsp.h>            /* rslvsp()                       */  #  include <qycmutiltyUtility.H>
 #  include <mih/micommon.h>          /* _AUTH_EXECUTE                  */  
 #  include <mih/miobjtyp.h>          /* WLI_SRVPGM                     */  
 #  include <pointer.h>               /* _SYSPTR                        */  
 #  include <qusec.h>                 /* Qus_EC_t                       */  
 #  include <qleawi.h>                /* QleActBndPgm(),QleGetExp()     */  
 #  include <unistd.cleinc> #  include <unistd.cleinc>
   #  include "qycmmsgclsMessage.H" // ycmMessage class
   #  include "OS400SystemState.h"  // OS400LoadDynamicLibrary, etc
   #include "OS400ConvertChar.h"
 #else #else
 # include <dlfcn.h> # include <dlfcn.h>
 #endif #endif
Line 54 
Line 54 
 #include <crypt.h> #include <crypt.h>
 #endif #endif
  
   #ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
   #include <arpa/inet.h>
   #endif
   
   #if defined(PEGASUS_USE_SYSLOGS)
   #include <syslog.h>
   #endif
   
 #include <sys/stat.h> #include <sys/stat.h>
 #include <sys/types.h> #include <sys/types.h>
 #include <cstdio> #include <cstdio>
Line 71 
Line 79 
 Boolean System::bindVerbose = false; Boolean System::bindVerbose = false;
 #endif #endif
  
 #if defined(PEGASUS_OS_OS400)  #ifdef PEGASUS_OS_OS400
 char os400ExceptionID[8] = {0};  typedef struct os400_pnstruct
   {
     Qlg_Path_Name_T qlg_struct;
     char * pn;
   } OS400_PNSTRUCT;
 #endif #endif
  
 inline void sleep_wrapper(Uint32 seconds) inline void sleep_wrapper(Uint32 seconds)
Line 106 
Line 118 
  
 Boolean System::exists(const char* path) Boolean System::exists(const char* path)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgAccess((Qlg_Path_Name_T *)&pathname, F_OK) == 0;
   #else
     return access(path, F_OK) == 0;     return access(path, F_OK) == 0;
   #endif
 } }
  
 Boolean System::canRead(const char* path) Boolean System::canRead(const char* path)
 { {
   
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgAccess((Qlg_Path_Name_T *)&pathname, R_OK) == 0;
   #else
     return access(path, R_OK) == 0;     return access(path, R_OK) == 0;
   #endif
 } }
  
 Boolean System::canWrite(const char* path) Boolean System::canWrite(const char* path)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgAccess((Qlg_Path_Name_T *)&pathname, W_OK) == 0;
   #else
     return access(path, W_OK) == 0;     return access(path, W_OK) == 0;
   #endif
 } }
  
 Boolean System::getCurrentDirectory(char* path, Uint32 size) Boolean System::getCurrentDirectory(char* path, Uint32 size)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgGetcwd((Qlg_Path_Name_T *)&pathname, size) == 0;
   #else
     return getcwd(path, size) != NULL;     return getcwd(path, size) != NULL;
   #endif
 } }
  
 Boolean System::isDirectory(const char* path) Boolean System::isDirectory(const char* path)
 { {
     struct stat st;     struct stat st;
  
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       if (QlgStat((Qlg_Path_Name_T *)&pathname, &st) != 0)
           return false;
   #else
     if (stat(path, &st) != 0)     if (stat(path, &st) != 0)
         return false;         return false;
   #endif
     return S_ISDIR(st.st_mode);     return S_ISDIR(st.st_mode);
 } }
  
 Boolean System::changeDirectory(const char* path) Boolean System::changeDirectory(const char* path)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgChdir((Qlg_Path_Name_T *)&pathname) == 0;
   #else
     return chdir(path) == 0;     return chdir(path) == 0;
   #endif
 } }
  
 Boolean System::makeDirectory(const char* path) Boolean System::makeDirectory(const char* path)
 { {
   
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgMkdir((Qlg_Path_Name_T *)&pathname, 0777) == 0;
   #else
     return mkdir(path, 0777) == 0;     return mkdir(path, 0777) == 0;
   #endif
   
 } }
  
 Boolean System::getFileSize(const char* path, Uint32& size) Boolean System::getFileSize(const char* path, Uint32& size)
 { {
     struct stat st;     struct stat st;
  
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       if (QlgStat((Qlg_Path_Name_T *)&pathname, &st) != 0)
           return false;
   #else
     if (stat(path, &st) != 0)     if (stat(path, &st) != 0)
         return false;         return false;
   #endif
  
     size = st.st_size;     size = st.st_size;
     return true;     return true;
Line 157 
Line 301 
  
 Boolean System::removeDirectory(const char* path) Boolean System::removeDirectory(const char* path)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgRmdir((Qlg_Path_Name_T *)&pathname) == 0;
   #else
     return rmdir(path) == 0;     return rmdir(path) == 0;
   #endif
 } }
  
 Boolean System::removeFile(const char* path) Boolean System::removeFile(const char* path)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       return QlgUnlink((Qlg_Path_Name_T *)&pathname) == 0;
   #else
     return unlink(path) == 0;     return unlink(path) == 0;
   #endif
 } }
  
 Boolean System::renameFile(const char* oldPath, const char* newPath) Boolean System::renameFile(const char* oldPath, const char* newPath)
 { {
   #if defined(PEGASUS_OS_OS400)
       OS400_PNSTRUCT oldpathname;
       memset((void*)&oldpathname, 0x00, sizeof(OS400_PNSTRUCT));
       oldpathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(oldpathname.qlg_struct.Country_ID,"US",2);
       memcpy(oldpathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       oldpathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       oldpathname.qlg_struct.Path_Length = strlen(oldPath);
       oldpathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       oldpathname.pn = (char *)oldPath;
   
       OS400_PNSTRUCT newpathname;
       memset((void*)&newpathname, 0x00, sizeof(OS400_PNSTRUCT));
       newpathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(newpathname.qlg_struct.Country_ID,"US",2);
       memcpy(newpathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       newpathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       newpathname.qlg_struct.Path_Length = strlen(newPath);
       newpathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       newpathname.pn = (char *)newPath;
   
       if (QlgLink((Qlg_Path_Name_T *)&oldpathname,
                   (Qlg_Path_Name_T *)&newpathname) != 0)
       {
           return false;
       }
   
       return QlgUnlink((Qlg_Path_Name_T *)&oldpathname) == 0;
   #else
   
     if (link(oldPath, newPath) != 0)     if (link(oldPath, newPath) != 0)
         return false;         return false;
  
     return unlink(oldPath) == 0;     return unlink(oldPath) == 0;
   #endif
 } }
  
 DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName) DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName)
Line 204 
Line 415 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
     return DynamicLibraryHandle(dllload(fileName));     return DynamicLibraryHandle(dllload(fileName));
 #elif defined(PEGASUS_OS_OS400) #elif defined(PEGASUS_OS_OS400)
     // Activate the service program.  
   
     // Parse out the library and srvpgm names.  
     // Note: the fileName passed in must be in OS/400 form - library/srvpgm  
     if (fileName == NULL || strlen(fileName) == 0 || strlen(fileName) >= 200)  
        return 0;  
   
     // More checking here!  
     char name[200];  
     strcpy(name, fileName);  
   
     char* lib = strtok(name, "/");  
     if (lib == NULL || strlen(lib) == 0)  
        return 0;  
   
     char* srvpgm = strtok(NULL,"/");  
     if (srvpgm == NULL || strlen(srvpgm) == 0)  
        return 0;  
   
     /*----------------------------------------------------------------*/  
     /* Resolve to the service program                                 */  
     /*----------------------------------------------------------------*/  
     _OBJ_TYPE_T objectType = WLI_SRVPGM;  
     _SYSPTR sysP = rslvsp(objectType, srvpgm, lib, _AUTH_NONE);  
   
     /*----------------------------------------------------------------*/  
     /* Activate the service program                                   */  
     /*----------------------------------------------------------------*/  
     Qle_ABP_Info_t activationInfo;  
     int actInfoLen = sizeof(activationInfo);  
     int hdl;  
   
     Qus_EC_t os400ErrorCode = {0};  
     os400ErrorCode.Bytes_Provided = sizeof(Qus_EC_t);  
     os400ErrorCode.Bytes_Available = 0;  
   
     QleActBndPgm(&sysP,  
                 &hdl,  
                 &activationInfo,  
                 &actInfoLen,  
                 &os400ErrorCode);  
   
     if (os400ErrorCode.Bytes_Available)  
     {  
        // Got an error.  
        memset(os400ExceptionID, '\0', 8);  
        strncpy(os400ExceptionID, os400ErrorCode.Exception_Id, 7);  
        Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2,  
                   "Error activating service program. Exception Id = %s", os400ExceptionID);  
        return 0;  
     }  
   
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
     return DynamicLibraryHandle(hdl);      return DynamicLibraryHandle(OS400_LoadDynamicLibrary(fileName));
   
 #else #else
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
     return DynamicLibraryHandle(dlopen(fileName, RTLD_NOW | RTLD_GLOBAL));     return DynamicLibraryHandle(dlopen(fileName, RTLD_NOW | RTLD_GLOBAL));
Line 269 
Line 427 
 void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle) void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle)
 { {
     // ATTN: Should this method indicate success/failure?     // ATTN: Should this method indicate success/failure?
 #ifdef PEGASUS_OS_LINUX  #if defined(PEGASUS_OS_LINUX) || defined(PEGASUS_OS_SOLARIS)
     dlclose(libraryHandle);     dlclose(libraryHandle);
 #endif #endif
  
Line 278 
Line 436 
     // multiple times.  No reference count is kept.     // multiple times.  No reference count is kept.
     int ignored = shl_unload(reinterpret_cast<shl_t>(libraryHandle));     int ignored = shl_unload(reinterpret_cast<shl_t>(libraryHandle));
 #endif #endif
   
   #ifdef PEGASUS_OS_OS400
      OS400_UnloadDynamicLibrary((int)libraryHandle);
   #endif
   
   #ifdef PEGASUS_OS_AIX
       dlclose(libraryHandle);
   #endif
   
 } }
  
 String System::dynamicLoadError() { String System::dynamicLoadError() {
Line 289 
Line 456 
 #elif defined(PEGASUS_OS_ZOS) #elif defined(PEGASUS_OS_ZOS)
     return String();     return String();
 #elif defined(PEGASUS_OS_OS400) #elif defined(PEGASUS_OS_OS400)
     return String(os400ExceptionID);      return String(OS400_DynamicLoadError());
 #else #else
     String dlerr = dlerror();     String dlerr = dlerror();
     return dlerr;     return dlerr;
Line 326 
Line 493 
                                (char*)symbolName));                                (char*)symbolName));
  
 #elif defined(PEGASUS_OS_OS400) #elif defined(PEGASUS_OS_OS400)
    /*----------------------------------------------------------------*/      return DynamicSymbolHandle(OS400_LoadDynamicSymbol((int)libraryHandle,
    /* Get procedure pointer and return it to caller                  */                                 symbolName));
    /*----------------------------------------------------------------*/  
   
     Qus_EC_t os400ErrorCode = {0};  
     os400ErrorCode.Bytes_Provided = sizeof(Qus_EC_t);  
     os400ErrorCode.Bytes_Available = 0;  
   
     int exportType;  
     int hdl = (int)libraryHandle;  
     void * procAddress = NULL;  
   
     QleGetExp(&hdl,  
              0,  
              0,  
              (char *)symbolName,  
              &procAddress,  
              &exportType,  
              &os400ErrorCode);  
   
     if (os400ErrorCode.Bytes_Available)  
     {  
       // Got an error.  
        memset(os400ExceptionID, '\0', 8);  
        strncpy(os400ExceptionID, os400ErrorCode.Exception_Id, 7);  
        Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2,  
                   "Error getting export. Exception Id = %s", os400ExceptionID);  
        return 0;  
     }  
   
     return DynamicSymbolHandle(procAddress);  
   
 #else #else
  
     return DynamicSymbolHandle(dlsym(libraryHandle, (char*)symbolName));     return DynamicSymbolHandle(dlsym(libraryHandle, (char*)symbolName));
Line 370 
Line 507 
     static char hostname[64];     static char hostname[64];
  
     if (!*hostname)     if (!*hostname)
       {
         gethostname(hostname, sizeof(hostname));         gethostname(hostname, sizeof(hostname));
   #if defined(PEGASUS_OS_OS400)
 #ifdef PEGASUS_PLATFORM_AIX_RS_IBMCXX          EtoA(hostname);
     char *dot = strchr(hostname, '.');  
     if (dot != NULL) *dot = '\0';  
 #endif #endif
       }
  
     return hostname;     return hostname;
 } }
Line 432 
Line 569 
     // Get wbem-local port from /etc/services     // Get wbem-local port from /etc/services
     //     //
 #if !defined(PEGASUS_OS_OS400) #if !defined(PEGASUS_OS_OS400)
   #ifdef PEGASUS_OS_SOLARIS
   #define SERV_BUFF_SIZE  1024
       struct servent      serv_result;
       char                buf[SERV_BUFF_SIZE];
   
       if ( (serv = getservbyname_r(serviceName, TCP, &serv_result,
                                   buf, SERV_BUFF_SIZE)) != NULL )
   #else // PEGASUS_OS_SOLARIS
     if ( (serv = getservbyname(serviceName, TCP)) != NULL )     if ( (serv = getservbyname(serviceName, TCP)) != NULL )
 #else  #endif // PEGASUS_OS_SOLARIS
   #else  // !PEGASUS_OS_OS400
       // Note - serviceName came from Constants.h - no need to
       // convert to EBCDIC
     // Need to cast on OS/400     // Need to cast on OS/400
     if ( (serv = getservbyname((char *)serviceName, TCP)) != NULL )     if ( (serv = getservbyname((char *)serviceName, TCP)) != NULL )
 #endif  #endif  // !PEGASUS_OS_OS400
     {     {
 #ifndef PEGASUS_PLATFORM_LINUX_IX86_GNU  
         localPort = serv->s_port;  
 #else  
         localPort = htons((uint16_t)serv->s_port);         localPort = htons((uint16_t)serv->s_port);
 #endif  
     }     }
     else     else
     {     {
Line 470 
Line 614 
     String userName = String::EMPTY;     String userName = String::EMPTY;
     struct passwd*   pwd = NULL;     struct passwd*   pwd = NULL;
  
   #if defined(PEGASUS_OS_SOLARIS) || \
       defined(PEGASUS_OS_HPUX) || \
       defined(PEGASUS_OS_LINUX)
   
       const unsigned int PWD_BUFF_SIZE = 1024;
       struct passwd       local_pwd;
       char                buf[PWD_BUFF_SIZE];
       if(getpwuid_r(geteuid(), &local_pwd, buf, PWD_BUFF_SIZE, &pwd)) {
           pwd = (struct passwd *)NULL;
       }
   #else
     //     //
     //  get the currently logged in user's UID.     //  get the currently logged in user's UID.
     //     //
     pwd = getpwuid(geteuid());     pwd = getpwuid(geteuid());
   #endif
     if ( pwd == NULL )     if ( pwd == NULL )
     {     {
         //ATTN: Log a message         //ATTN: Log a message
Line 481 
Line 637 
     }     }
     else     else
     {     {
   #if defined(PEGASUS_OS_OS400)
           EtoA(pwd->pw_name);
   #endif
         //         //
         //  get the user name         //  get the user name
         //         //
Line 502 
Line 661 
  
 Boolean System::isSystemUser(const char* userName) Boolean System::isSystemUser(const char* userName)
 { {
   #if defined(PEGASUS_OS_OS400)
       AtoE((char *)userName);
   #endif
   
   #if defined(PEGASUS_OS_SOLARIS) || \
       defined(PEGASUS_OS_HPUX) || \
       defined(PEGASUS_OS_LINUX)
   
       const unsigned int PWD_BUFF_SIZE = 1024;
       struct passwd   pwd;
       struct passwd   *result;
       char            pwdBuffer[PWD_BUFF_SIZE];
   
       if (getpwnam_r(userName, &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0)
   #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)
           EtoA((char *)userName);
   #endif
         return false;         return false;
     }     }
   #if defined(PEGASUS_OS_OS400)
       EtoA((char *)userName);
   #endif
     return true;     return true;
 } }
  
Line 517 
Line 698 
     //     //
     // Check if the given user is a privileged user     // Check if the given user is a privileged user
     //     //
   #if !defined(PEGASUS_OS_OS400)
     struct passwd   pwd;     struct passwd   pwd;
     struct passwd   *result;     struct passwd   *result;
     char            pwdBuffer[1024];     char            pwdBuffer[1024];
Line 529 
Line 711 
         }         }
     }     }
     return false;     return false;
   #else
       CString user = userName.getCString();
       const char * tmp = (const char *)user;
       AtoE((char *)tmp);
       return ycmCheckUserCmdAuthorities(tmp);
   #endif
 } }
  
 String System::getPrivilegedUserName() String System::getPrivilegedUserName()
Line 538 
Line 726 
     if (userName == String::EMPTY)     if (userName == String::EMPTY)
     {     {
         struct passwd*   pwd = NULL;         struct passwd*   pwd = NULL;
   #if defined(PEGASUS_OS_SOLARIS) || \
       defined(PEGASUS_OS_HPUX) || \
       defined(PEGASUS_OS_LINUX)
           const unsigned int PWD_BUFF_SIZE = 1024;
           struct passwd   local_pwd;
           char            buf[PWD_BUFF_SIZE];
           if(getpwuid_r(0, &local_pwd, buf, PWD_BUFF_SIZE, &pwd)) {
                   pwd = (struct passwd *)NULL;
           }
   #else
         //         //
         //  get the privileged user's UID.         //  get the privileged user's UID.
         //         //
           //  (on OS/400, this is QSECOFR)
         pwd = getpwuid(0);         pwd = getpwuid(0);
   #endif
         if ( pwd != NULL )         if ( pwd != NULL )
         {         {
   #if defined(PEGASUS_OS_OS400)
               EtoA(pwd->pw_name);
   #endif
             //             //
             //  get the user name             //  get the user name
             //             //
Line 576 
Line 778 
 #if !defined(PEGASUS_OS_OS400) #if !defined(PEGASUS_OS_OS400)
     return (truncate(path, newSize) == 0);     return (truncate(path, newSize) == 0);
 #else #else
     int fd = open(path, O_WRONLY);      OS400_PNSTRUCT pathname;
       memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
       pathname.qlg_struct.CCSID = 1208;
   #pragma convert(37)
       memcpy(pathname.qlg_struct.Country_ID,"US",2);
       memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
   #pragma convert(0)
       pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
       pathname.qlg_struct.Path_Length = strlen(path);
       pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
       pathname.pn = (char *)path;
   
       int fd = QlgOpen((Qlg_Path_Name_T *)&pathname, O_WRONLY);
     if (fd != -1)     if (fd != -1)
     {     {
        int rc = ftruncate(fd, newSize);        int rc = ftruncate(fd, newSize);
Line 588 
Line 802 
 #endif #endif
 } }
  
   // Is absolute path?
   Boolean System::is_absolute_path(const char *path)
   {
     if (path == NULL)
       return false;
   
     if (path[0] == '/')
       return true;
   
     return false;
   }
   
   void System::openlog(const String ident)
   {
   #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
   
       // ATTN: Hard-code the "cimserver" identifier until the infrastructure
       // is set up to pass this as the "ident" string.
       //::openlog(ident.getCString(), LOG_PID|LOG_CONS, LOG_DAEMON);
       ::openlog("cimserver", LOG_PID|LOG_CONS, LOG_DAEMON);
   
   #endif
   
       return;
   }
   
   void System::syslog(Uint32 severity, const char *data)
   {
   #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
   
       // FUTURE-SF-P3-20020517 : Use the Syslog on HP-UX. Eventually only
       // certain messages will go to the Syslog and others to the
       // Pegasus Logger.
       Uint32 syslogLevel = LOG_DEBUG;
   
       // Map the log levels.
       if (severity & Logger::TRACE) syslogLevel =       LOG_DEBUG;
       if (severity & Logger::INFORMATION) syslogLevel = LOG_INFO;
       if (severity & Logger::WARNING) syslogLevel =     LOG_WARNING;
       if (severity & Logger::SEVERE) syslogLevel =      LOG_ERR;
       if (severity & Logger::FATAL) syslogLevel =       LOG_CRIT;
   
       ::syslog(syslogLevel, "%s", data);
   
   #elif defined(PEGASUS_OS_OS400)
   
       std::string replacementData = data;
       // All messages will go to the joblog. In the future
       // some messages may go to other message queues yet
       // to be determined.
       if ((severity & Logger::TRACE) ||
           (severity & Logger::INFORMATION))
       {
   
           // turn into ycmMessage so we can put it in the job log
           ycmMessage theMessage(msgCPxDF80,
                                 CPIprefix,
                                 replacementData,
   #pragma convert(37)
                                 "Logger",
   #pragma convert(0)
                             ycmCTLCIMID,
                                 utf8);
   
           // put the message in the joblog
           theMessage.joblogIt(UnitOfWorkError,
                               ycmMessage::Informational);
       }
   
       if ((severity & Logger::WARNING) ||
           (severity & Logger::SEVERE)  ||
           (severity & Logger::FATAL))
       {
           // turn into ycmMessage so we can put it in the job log
           ycmMessage theMessage(msgCPxDF82,
                                 CPDprefix,
                                 replacementData,
   #pragma convert(37)
                                 "Logger",
   #pragma convert(0)
                             ycmCTLCIMID,
                                 utf8);
   
           // put the message in the joblog
           theMessage.joblogIt(UnitOfWorkError,
                               ycmMessage::Diagnostic);
       }
   
   #endif
   
       return;
   }
   
   void System::closelog()
   {
   #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
   
       ::closelog();
   
   #endif
   
       return;
   }
   
   // System ID constants for Logger::put and Logger::trace
   #if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
   const String System::CIMSERVER = "qycmcimom";  // Server system ID
   #else
   const String System::CIMSERVER = "cimserver";  // Server system ID
   #endif
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.48  
changed lines
  Added in v.1.66

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2