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

Diff for /pegasus/src/Pegasus/Common/SystemWindows.cpp between version 1.46 and 1.75

version 1.46, 2005/02/23 23:16:30 version 1.75, 2007/05/30 20:41:28
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 27 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Brasher (mbrasher@bmc.com)  
 //  
 // Modified By: Sushma Fernandes (sushma_fernandes@hp.com)  
 //              Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)  
 //              Bapu Patil (bapu_patil@hp.com)  
 //  
 // Modified By: Dave Rosckes (rosckes@us.ibm.com)  
 //              Terry Martin, Hewlett-Packard Company (terry.martin@hp.com)  
 //              Amit K Arora, IBM (amita@in.ibm.com) for Bug#1428  
 //              Seema Gupta (gseema@in.ibm.com) for Bug#1617  
 //              David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "System.h" #include "System.h"
  
 #include <windows.h>  #include "Network.h"
 #ifndef _WINSOCKAPI_  #include "Mutex.h"
 #include <winsock2.h>  
 #endif  
 #include <fcntl.h> #include <fcntl.h>
 #include <sys/types.h> #include <sys/types.h>
 #include <time.h> #include <time.h>
Line 60 
Line 47 
 #include <process.h> #include <process.h>
 #include <lm.h> #include <lm.h>
  
   #define SECURITY_WIN32
   #include <security.h>
   
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 #define PEGASUS_ACCESS_EXISTS 0 #define PEGASUS_ACCESS_EXISTS 0
Line 82 
Line 72 
     milliseconds = milliseconds / 1000;     milliseconds = milliseconds / 1000;
 } }
  
   void System::getCurrentTimeUsec(Uint32& seconds, Uint32& microseconds)
   {
       FILETIME ft;
       GetSystemTimeAsFileTime(&ft);
       ULARGE_INTEGER largeInt = { ft.dwLowDateTime, ft.dwHighDateTime };
       largeInt.QuadPart -= 0x19db1ded53e8000;
       seconds = long(largeInt.QuadPart / (10000 * 1000));
       microseconds = long((largeInt.QuadPart % (10000 * 1000)) / 10);
   }
   
 String System::getCurrentASCIITime() String System::getCurrentASCIITime()
 { {
     char tmpbuf[128];     char tmpbuf[128];
Line 164 
Line 164 
     return rename(oldPath, newPath) == 0;     return rename(oldPath, newPath) == 0;
 } }
  
 DynamicLibraryHandle System::loadDynamicLibrary(const char* fileName)  
 {  
     return DynamicLibraryHandle(LoadLibrary(fileName));  
 }  
   
 void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle)  
 {  
     FreeLibrary(HINSTANCE(libraryHandle));  
 }  
   
 String System::dynamicLoadError(void) {  
 return String();  
 }  
   
 DynamicSymbolHandle System::loadDynamicSymbol(  
     DynamicLibraryHandle libraryHandle,  
     const char* symbolName)  
 {  
     return DynamicSymbolHandle(GetProcAddress(  
     (HINSTANCE)libraryHandle, symbolName));  
 }  
   
 String System::getHostName() String System::getHostName()
 { {
     static char hostname[PEGASUS_MAXHOSTNAMELEN];      static String _hostname;
       if (0 == _hostname.size())
     if (!*hostname)      {
           char hostname[PEGASUS_MAXHOSTNAMELEN + 1];
           //initialize the buffer to handle the case where gethostname fails.
           hostname[0] = 0;
         gethostname(hostname, sizeof(hostname));         gethostname(hostname, sizeof(hostname));
           hostname[sizeof(hostname)-1] = 0;
     return hostname;          _hostname.assign(hostname);
       }
       return _hostname;
 } }
  
 String System::getFullyQualifiedHostName () String System::getFullyQualifiedHostName ()
 { {
     static char FQHostName[PEGASUS_MAXHOSTNAMELEN];      static char FQHostName[PEGASUS_MAXHOSTNAMELEN + 1];
  
     if (!*FQHostName)     if (!*FQHostName)
     {     {
Line 210 
Line 193 
         {         {
             return String::EMPTY;             return String::EMPTY;
         }         }
         strcpy(FQHostName, hostEnt->h_name);          strncpy(FQHostName, hostEnt->h_name, sizeof(FQHostName)-1);
     }     }
  
     return FQHostName;     return FQHostName;
Line 230 
Line 213 
     struct servent *serv;     struct servent *serv;
  
     //     //
     // Get wbem-local port from /etc/services      // Get the port number.
     //     //
     if (  (serv = getservbyname(serviceName, TCP)) != NULL )     if (  (serv = getservbyname(serviceName, TCP)) != NULL )
     {     {
         localPort = serv->s_port;          localPort = ntohs(serv->s_port);
     }     }
     else     else
     {     {
Line 324 
Line 307 
  
 String System::getEffectiveUserName() String System::getEffectiveUserName()
 { {
   #if (_MSC_VER >= 1300) || defined(PEGASUS_WINDOWS_SDK_HOME)
   
       //Bug 3076 fix
       wchar_t fullUserName[UNLEN+1];
       DWORD userNameSize = sizeof(fullUserName)/sizeof(fullUserName[0]);
       wchar_t computerName[MAX_COMPUTERNAME_LENGTH+1];
       DWORD computerNameSize = sizeof(computerName)/sizeof(computerName[0]);
       wchar_t userName[UNLEN+1];
       wchar_t userDomain[UNLEN+1];
       String userId;
   
       if (!GetUserNameExW(NameSamCompatible, fullUserName, &userNameSize))
       {
           return String();
       }
   
       wchar_t* index = wcschr(fullUserName, '\\');
       *index = 0;
       wcscpy(userDomain, fullUserName);
       wcscpy(userName, index + 1);
   
       //The above function will return the system name as the domain if
       //the user is not on a real domain.  Strip this out so that the rest of
       //our windows user functions work.  What if the system name and the domain
       //name are the same?
       GetComputerNameW(computerName, &computerNameSize);
   
       if (wcscmp(computerName, userDomain) != 0)
       {
           //userId.append(userDomain);
           Uint32 n = (Uint32)wcslen(userDomain);
           for (unsigned long i = 0; i < n; i++)
           {
               userId.append(Char16(userDomain[i]));
           }
           userId.append("\\");
           //userId.append(userName);
           n = (Uint32)wcslen(userName);
           for (unsigned long i = 0; i < n; i++)
           {
               userId.append(Char16(userName[i]));
           }
   
       }
       else
       {
           //userId.append(userName);
           Uint32 n = (Uint32)wcslen(userName);
           for (unsigned long i = 0; i < n; i++)
           {
               userId.append(Char16(userName[i]));
           }
   
       }
   
       return userId;
   
   #else //original getEffectiveUserName function
   
   int retcode = 0;   int retcode = 0;
  
   // UNLEN (256) is the limit, not including null   // UNLEN (256) is the limit, not including null
   char pUserName[256+1] = {0};      wchar_t pUserName[256+1] = {0};
   DWORD nSize = sizeof(pUserName);      DWORD nSize = sizeof(pUserName)/sizeof(pUserName[0]);
  
   retcode = GetUserName(pUserName, &nSize);      retcode = GetUserNameW(pUserName, &nSize);
   if (retcode == 0)   if (retcode == 0)
     {     {
       // zero is failure       // zero is failure
       return String();       return String();
     }     }
       String userId;
       Uint32 n = wcslen(pUserName);
       for (unsigned long i = 0; i < n; i++)
       {
           userId.append(Char16(pUserName[i]));
       }
  
   return String(pUserName);      return userId;
   #endif
 } }
  
 String System::encryptPassword(const char* password, const char* salt) String System::encryptPassword(const char* password, const char* salt)
Line 347 
Line 396 
   char pcSalt[3] = {0};   char pcSalt[3] = {0};
  
   strncpy(pcSalt, salt, 2);   strncpy(pcSalt, salt, 2);
   dwByteCount = strlen(password);      dwByteCount = (DWORD)strlen(password);
   memcpy(pbBuffer, password, dwByteCount);   memcpy(pbBuffer, password, dwByteCount);
   for (DWORD i=0; (i<dwByteCount) || (i>=PW_BUFF_LEN); i++)   for (DWORD i=0; (i<dwByteCount) || (i>=PW_BUFF_LEN); i++)
     (i%2 == 0) ? pbBuffer[i] ^= pcSalt[1] : pbBuffer[i] ^= pcSalt[0];     (i%2 == 0) ? pbBuffer[i] ^= pcSalt[1] : pbBuffer[i] ^= pcSalt[0];
Line 355 
Line 404 
   return String(pcSalt) + String((char *)pbBuffer);   return String(pcSalt) + String((char *)pbBuffer);
 } }
  
   String processUserName;
   Mutex processUserNameMut;
   
 Boolean System::isSystemUser(const char* userName) Boolean System::isSystemUser(const char* userName)
 { {
       if (processUserName.size() == 0)
       {
           // Lock and recheck the processUserName length in case two threads
           // enter this block simultaneously
           AutoMutex mut(processUserNameMut);
           if (processUserName.size() == 0)
           {
               processUserName = getEffectiveUserName();
           }
       }
       if (processUserName == userName)
       {
         return true;
       }
   
     Boolean isSystemUser = false;     Boolean isSystemUser = false;
  
     char mUserName[UNLEN+1];     char mUserName[UNLEN+1];
     char mDomainName[UNLEN+1];     char mDomainName[UNLEN+1];
       char tUserName[UNLEN+1];
     wchar_t wUserName[UNLEN+1];     wchar_t wUserName[UNLEN+1];
     wchar_t wDomainName[UNLEN+1];     wchar_t wDomainName[UNLEN+1];
     char* pbs;     char* pbs;
Line 371 
Line 439 
     LPUSER_INFO_1 pUserInfo = NULL;     LPUSER_INFO_1 pUserInfo = NULL;
     NET_API_STATUS nStatus = NULL;     NET_API_STATUS nStatus = NULL;
  
       // Make a copy of the specified username, it cannot be used directly
       // because it's declared as const and strchr() may modify the string.
       strncpy(tUserName, userName, sizeof(tUserName) - 1);
       tUserName[sizeof(tUserName)- 1] = '\0';
   
     //separate the domain and user name if both are present.     //separate the domain and user name if both are present.
     if (NULL != (pbs = strchr(userName, '\\')))      if (NULL != (pbs = strchr(tUserName, '\\')))
     {     {
         *pbs = '\0';         *pbs = '\0';
         strcpy(mDomainName, userName);          strcpy(mDomainName, tUserName);
         strcpy(mUserName, pbs+1);         strcpy(mUserName, pbs+1);
         usingDomain = true;         usingDomain = true;
  
     } else if ((NULL != (pbs = (strchr(userName, '@')))) ||      }
                (NULL != (pbs = (strchr(userName, '.')))))      else if ((NULL != (pbs = (strchr(tUserName, '@')))) ||
                (NULL != (pbs = (strchr(tUserName, '.')))))
     {     {
         *pbs = '\0';         *pbs = '\0';
         strcpy(mDomainName, pbs+1);         strcpy(mDomainName, pbs+1);
         strcpy(mUserName, userName);          strcpy(mUserName, tUserName);
         usingDomain = true;         usingDomain = true;
  
     } else      }
       else
     {     {
         strcpy(mDomainName, ".");         strcpy(mDomainName, ".");
         strcpy(mUserName, userName);          strcpy(mUserName, tUserName);
     }     }
  
     //convert domain name to unicode     //convert domain name to unicode
     if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))      if (!MultiByteToWideChar(
               CP_ACP, 0, mDomainName, -1, wDomainName,
               (int)(strlen(mDomainName) + 1)))
     {     {
         return false;         return false;
     }     }
  
     //convert username to unicode     //convert username to unicode
     if (!MultiByteToWideChar(CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName)+1))      if (!MultiByteToWideChar(
               CP_ACP, 0, mUserName, -1, wUserName, (int)(strlen(mUserName) + 1)))
     {     {
         return false;         return false;
     }     }
Line 411 
Line 489 
         DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName);         DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName);
         if (rc == NERR_Success)         if (rc == NERR_Success)
         {         {
             wcscpy(wDomainName, (LPWSTR) pComputerName); //this is automatically prefixed with "\\"              // this is automatically prefixed with "\\"
               wcscpy(wDomainName, (LPWSTR) pComputerName);
         }         }
         /*         /*
         else         else
         {         {
             // failover             // failover
             // ATTN: This is commented out until there is resolution on Bugzilla 2236. -hns 2/2005              // ATTN: This is commented out until there is resolution on
               // Bugzilla 2236. -hns 2/2005
             // This needs to be more thoroughly tested when we uncomment it out.             // This needs to be more thoroughly tested when we uncomment it out.
  
             PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL;             PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL;
Line 427 
Line 507 
                              mDomainName,                              mDomainName,
                              NULL,                              NULL,
                              NULL,                              NULL,
                              DS_DIRECTORY_SERVICE_REQUIRED,  //not sure what flags we want here                               //not sure what flags we want here
                                DS_DIRECTORY_SERVICE_REQUIRED,
                              &DomainControllerInfo);                              &DomainControllerInfo);
  
             if (rc == ERROR_SUCCESS && DomainControllerInfo)             if (rc == ERROR_SUCCESS && DomainControllerInfo)
Line 435 
Line 516 
                 strcpy(mDomainName, DomainControllerInfo->DomainName);                 strcpy(mDomainName, DomainControllerInfo->DomainName);
                 NetApiBufferFree(DomainControllerInfo);                 NetApiBufferFree(DomainControllerInfo);
  
                 if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))                  if (!MultiByteToWideChar(
                           CP_ACP, 0, mDomainName, -1, wDomainName,
                           strlen(mDomainName) + 1))
                 {                 {
                     return false;                     return false;
                 }                 }
Line 497 
Line 580 
         strcpy(mUserName, pbs+1);         strcpy(mUserName, pbs+1);
         usingDomain = true;         usingDomain = true;
  
     } else if ((NULL != (pbs = (strchr(userStr, '@')))) ||      }
       else if ((NULL != (pbs = (strchr(userStr, '@')))) ||
                (NULL != (pbs = (strchr(userStr, '.')))))                (NULL != (pbs = (strchr(userStr, '.')))))
     {     {
         *pbs = '\0';         *pbs = '\0';
Line 505 
Line 589 
         strcpy(mUserName, userStr);         strcpy(mUserName, userStr);
         usingDomain = true;         usingDomain = true;
  
     } else      }
       else
     {     {
         strcpy(mDomainName, ".");         strcpy(mDomainName, ".");
         strcpy(mUserName, userStr);         strcpy(mUserName, userStr);
     }     }
  
     //convert domain name to unicode     //convert domain name to unicode
     if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))      if (!MultiByteToWideChar(
               CP_ACP, 0, mDomainName, -1, wDomainName,
               (int)(strlen(mDomainName) + 1)))
     {     {
         return false;         return false;
     }     }
  
     //convert username to unicode     //convert username to unicode
     if (!MultiByteToWideChar(CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName)+1))      if (!MultiByteToWideChar(
               CP_ACP, 0, mUserName, -1, wUserName, (int)(strlen(mUserName) + 1)))
     {     {
         return false;         return false;
     }     }
Line 529 
Line 617 
         DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName);         DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName);
         if (rc == NERR_Success)         if (rc == NERR_Success)
         {         {
             wcscpy(wDomainName, (LPWSTR) pComputerName); //this is automatically prefixed with "\\"              // this is automatically prefixed with "\\"
               wcscpy(wDomainName, (LPWSTR) pComputerName);
         }         }
         /*         /*
         else         else
         {         {
             // failover             // failover
             // ATTN: This is commented out until there is resolution on Bugzilla 2236. -hns 2/2005              // ATTN: This is commented out until there is resolution on
               // Bugzilla 2236. -hns 2/2005
             // This needs to be more thoroughly tested when we uncomment it out.             // This needs to be more thoroughly tested when we uncomment it out.
  
             PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL;             PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL;
Line 545 
Line 635 
                              mDomainName,                              mDomainName,
                              NULL,                              NULL,
                              NULL,                              NULL,
                              DS_DIRECTORY_SERVICE_REQUIRED,  //not sure what flags we want here                               // not sure what flags we want here
                                DS_DIRECTORY_SERVICE_REQUIRED,
                              &DomainControllerInfo);                              &DomainControllerInfo);
  
             if (rc == ERROR_SUCCESS && DomainControllerInfo)             if (rc == ERROR_SUCCESS && DomainControllerInfo)
Line 553 
Line 644 
                 strcpy(mDomainName, DomainControllerInfo->DomainName);                 strcpy(mDomainName, DomainControllerInfo->DomainName);
                 NetApiBufferFree(DomainControllerInfo);                 NetApiBufferFree(DomainControllerInfo);
  
                 if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1))                  if (!MultiByteToWideChar(
                           CP_ACP, 0, mDomainName, -1, wDomainName,
                           strlen(mDomainName) + 1))
                 {                 {
                     return false;                     return false;
                 }                 }
Line 593 
Line 686 
     // ATTN-NB-03-20000304: Implement better way to get the privileged     // ATTN-NB-03-20000304: Implement better way to get the privileged
     // user on the system.     // user on the system.
  
     return (String("Administrator"));      return String("Administrator");
 } }
  
 Boolean System::isGroupMember(const char* userName, const char* groupName) Boolean System::isGroupMember(const char* userName, const char* groupName)
Line 607 
Line 700 
    DWORD dwEntriesRead = 0;    DWORD dwEntriesRead = 0;
    DWORD dwTotalEntries = 0;    DWORD dwTotalEntries = 0;
    NET_API_STATUS nStatus;    NET_API_STATUS nStatus;
       wchar_t wcUserName[UNLEN+1];
       wchar_t wcGroupName[UNLEN+1];
   
       //Convert user name to unicode
       if (!MultiByteToWideChar(CP_ACP,0,userName, -1, wcUserName,
           strlen(userName)+1))
       {
           return false;
       }
  
       //Convert group name to unicode
       if (!MultiByteToWideChar(CP_ACP, 0, groupName, -1, wcGroupName,
           strlen(groupName)+1))
       {
           return false;
       }
  
    //    //
    // Call the NetUserGetLocalGroups function    // Call the NetUserGetLocalGroups function
Line 617 
Line 725 
    // function should also return the names of the local    // function should also return the names of the local
    // groups in which the user is indirectly a member.    // groups in which the user is indirectly a member.
    //    //
    nStatus = NetUserGetLocalGroups(NULL,      nStatus = NetUserGetLocalGroups(
                                    (LPCWSTR)userName,          NULL,
           (LPCWSTR)wcUserName,
                                    dwLevel,                                    dwLevel,
                                    dwFlags,                                    dwFlags,
                                    (LPBYTE *) &pBuf,                                    (LPBYTE *) &pBuf,
Line 646 
Line 755 
             //             //
             // Compare the user's group name to groupName.             // Compare the user's group name to groupName.
             //             //
             if ( strcmp ((char *)pTmpBuf->lgrui0_name, groupName) == 0 )  
                   if (wcscmp(pTmpBuf->lgrui0_name, wcGroupName) == 0)
             {             {
                  // User is a member of the group.                  // User is a member of the group.
                  retVal = true;                  retVal = true;
Line 680 
Line 790 
        //        //
        // Call the NetUserGetGroups function, specifying level 0.        // Call the NetUserGetGroups function, specifying level 0.
        //        //
        nStatus = NetUserGetGroups(NULL,          nStatus = NetUserGetGroups(
                                   (LPCWSTR)userName,              NULL,
               (LPCWSTR)wcUserName,
                                   dwLevel,                                   dwLevel,
                                   (LPBYTE*)&pBuf,                                   (LPBYTE*)&pBuf,
                                   dwPrefMaxLen,                                   dwPrefMaxLen,
                                   &dwEntriesRead,                                   &dwEntriesRead,
                                   &dwTotalEntries);                                   &dwTotalEntries);
   
        //        //
        // If the call succeeds,        // If the call succeeds,
        //        //
Line 707 
Line 819 
                 //                 //
                 // Compare the user's group name to groupName.                 // Compare the user's group name to groupName.
                 //                 //
                 if ( strcmp ((char *)pTmpBuf->grui0_name, groupName) == 0 )                      if (wcscmp(pTmpBuf->grui0_name, wcGroupName) == 0)
                 {                 {
                      // User is a member of the group.                      // User is a member of the group.
                      retVal = true;                      retVal = true;
Line 730 
Line 842 
    return retVal;    return retVal;
 } }
  
 Boolean System::changeUserContext(const char* userName)  Boolean System::lookupUserId(
       const char* userName,
       PEGASUS_UID_T& uid,
       PEGASUS_GID_T& gid)
   {
       // ATTN: Implement this method to look up the specified user
       return false;
   }
   
   Boolean System::changeUserContext_SingleThreaded(
       const char* userName,
       const PEGASUS_UID_T& uid,
       const PEGASUS_GID_T& gid)
 { {
     // ATTN: Implement this method to change the process user context to the     // ATTN: Implement this method to change the process user context to the
     //       specified user     //       specified user
Line 746 
Line 870 
     const char* path,     const char* path,
     size_t newSize)     size_t newSize)
 { {
     int fd = open(path, O_RDWR);  
  
     if (fd == -1)      Boolean rv = false;
         return false;      int fd = open(path, O_RDWR);
       if (fd != -1)
     if (chsize(fd, newSize) != 0)      {
     return false;          if (chsize(fd, (long)newSize) == 0)
           {
               rv = true;
           }
  
     close(fd);     close(fd);
     return true;      }
   
       return rv;
 } }
  
 // Is absolute path? // Is absolute path?
Line 769 
Line 897 
   path_slash[_MAX_PATH-1] = '\0';   path_slash[_MAX_PATH-1] = '\0';
  
   for(p = path_slash; p < path_slash + strlen(path_slash); p++)   for(p = path_slash; p < path_slash + strlen(path_slash); p++)
     if (*p == '/') *p = '\\';        if (*p == '/')
             *p = '\\';
  
   return (strcasecmp(_fullpath( full, path_slash, _MAX_PATH ), path_slash) == 0) ? true : false;      return (strcasecmp(
           _fullpath(full, path_slash, _MAX_PATH), path_slash) == 0);
 } }
  
 // Changes file permissions on the given file. // Changes file permissions on the given file.
Line 788 
Line 918 
     return true;     return true;
 } }
  
 void System::openlog(const String ident)  void System::syslog(const String& ident, Uint32 severity, const char* message)
 { {
     return;      // Not implemented
 } }
  
 void System::syslog(Uint32 severity, const char *data)  void System::openlog(const char *ident, int logopt, int facility)
 { {
     return;      // Not implemented
 } }
  
 void System::closelog() void System::closelog()
 { {
     return;      // Not implemented
 } }
  
   
   
 // System ID constants for Logger::put and Logger::trace // System ID constants for Logger::put and Logger::trace
 const String System::CIMSERVER = "cimserver";  // Server system ID const String System::CIMSERVER = "cimserver";  // Server system ID
  
   // check if a given IP address is defined on the local network interfaces
   Boolean System::isIpOnNetworkInterface(Uint32 inIP)
   {
       SOCKET sock;
       int interfaces = 0;
       int errcode;
   
       if ( SOCKET_ERROR != ( sock  = WSASocket(AF_INET,
                            SOCK_RAW, 0, NULL, 0, 0) ) )
       {
           unsigned long *bytes_returned=0;
           char *output_buf = (char *)calloc(1, 256);
           int buf_size = 256;
   
           if ( 0 == (errcode = WSAIoctl(sock,
                                         SIO_ADDRESS_LIST_QUERY,
                                         NULL,
                                         0,
                                         output_buf,
                                         256,
                                         bytes_returned,
                                         NULL,
                                         NULL)) )
           {
               SOCKET_ADDRESS_LIST *addr_list;
               SOCKET_ADDRESS *addr;
               Uint32 ip;
               struct sockaddr_in *sin;
   
               addr_list = (SOCKET_ADDRESS_LIST *)output_buf;
               addr = addr_list->Address;
   
               sin = (struct sockaddr_in *)addr->lpSockaddr;
   
               for ( ; interfaces < addr_list->iAddressCount; interfaces++)
               {
                   ip = sin->sin_addr.s_addr;
                   addr++;
                   sin = (struct sockaddr_in *)addr->lpSockaddr;
                   if (ip == inIP)
                   {
                       free(output_buf);
                       closesocket(sock);
                       return true;
                   }
               }
           }
           else
           {
               free(output_buf);
               return false;
           }
           free(output_buf);
           closesocket(sock);
       }
       return false;
   }
   
   
   
   ///////////////////////////////////////////////////////////////////////////////
   // AutoFileLock class
   ///////////////////////////////////////////////////////////////////////////////
   
   AutoFileLock::AutoFileLock(const char* fileName)
   {
       // ATTN: Not implemented
   }
   
   AutoFileLock::~AutoFileLock()
   {
       // ATTN: Not implemented
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.46  
changed lines
  Added in v.1.75

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2