(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.53 and 1.62.2.1

version 1.53, 2005/05/20 21:09:45 version 1.62.2.1, 2006/04/21 17:33:34
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 85 
Line 87 
     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 191 
Line 203 
  
 String System::getHostName() String System::getHostName()
 { {
     static char hostname[PEGASUS_MAXHOSTNAMELEN];      static char hostname[PEGASUS_MAXHOSTNAMELEN + 1];
  
     if (!*hostname)     if (!*hostname)
       {
         gethostname(hostname, sizeof(hostname));         gethostname(hostname, sizeof(hostname));
       }
       hostname[sizeof(hostname)-1] = 0;
  
     return 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 213 
Line 228 
         {         {
             return String::EMPTY;             return String::EMPTY;
         }         }
         strcpy(FQHostName, hostEnt->h_name);          strncpy(FQHostName, hostEnt->h_name, sizeof(FQHostName)-1);
     }     }
  
     return FQHostName;     return FQHostName;
Line 330 
Line 345 
 #if (_MSC_VER >= 1300) || defined(PEGASUS_WINDOWS_SDK_HOME) #if (_MSC_VER >= 1300) || defined(PEGASUS_WINDOWS_SDK_HOME)
  
         //Bug 3076 fix         //Bug 3076 fix
         char fullUserName[UNLEN+1];          wchar_t fullUserName[UNLEN+1];
         DWORD userNameSize = sizeof(fullUserName);          DWORD userNameSize = sizeof(fullUserName)/sizeof(fullUserName[0]);
         char computerName[MAX_COMPUTERNAME_LENGTH+1];          wchar_t computerName[MAX_COMPUTERNAME_LENGTH+1];
     DWORD computerNameSize = sizeof(computerName);      DWORD computerNameSize = sizeof(computerName)/sizeof(computerName[0]);
         char userName[UNLEN+1];          wchar_t userName[UNLEN+1];
     char userDomain[UNLEN+1];      wchar_t userDomain[UNLEN+1];
         String userId;         String userId;
  
         if (!GetUserNameEx(NameSamCompatible, fullUserName, &userNameSize))          if (!GetUserNameExW(NameSamCompatible, fullUserName, &userNameSize))
         {         {
                 return String();                 return String();
         }         }
  
         char* index = strchr(fullUserName, '\\');          wchar_t* index = wcschr(fullUserName, '\\');
         *index = '\0';          *index = 0;
         strcpy(userDomain, fullUserName);          wcscpy(userDomain, fullUserName);
         strcpy(userName, index + 1);          wcscpy(userName, index + 1);
  
         //The above function will return the system name as the domain if         //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         //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         //our windows user functions work.  What if the system name and the domain
         //name are the same?         //name are the same?
     GetComputerName(computerName, &computerNameSize);      GetComputerNameW(computerName, &computerNameSize);
  
         if (strcmp(computerName, userDomain) != 0)          if (wcscmp(computerName, userDomain) != 0)
           {
           //userId.append(userDomain);
           Uint32 n = wcslen(userDomain);
           for(unsigned long i = 0; i < n; i++)
         {         {
                 userId.append(userDomain);              userId.append(Char16(userDomain[i]));
           }
                 userId.append("\\");                 userId.append("\\");
                 userId.append(userName);                  //userId.append(userName);
           n = wcslen(userName);
           for(unsigned long i = 0; i < n; i++)
           {
               userId.append(Char16(userName[i]));
           }
   
         } else         } else
         {         {
                 userId.append(userName);                  //userId.append(userName);
           Uint32 n = wcslen(userName);
           for(unsigned long i = 0; i < n; i++)
           {
               userId.append(Char16(userName[i]));
           }
   
         }         }
  
         return userId;         return userId;
Line 371 
Line 403 
     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 #endif
 } }
  
Line 400 
Line 439 
     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];
Line 420 
Line 477 
     // Make a copy of the specified username, it cannot be used directly because it's     // Make a copy of the specified username, it cannot be used directly because it's
     // declared as const and strchr() may modify the string.     // declared as const and strchr() may modify the string.
     strncpy(tUserName, userName, sizeof(tUserName) - 1);     strncpy(tUserName, userName, sizeof(tUserName) - 1);
     tUserName[sizeof(tUserName)] = '\0';      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(tUserName, '\\')))     if (NULL != (pbs = strchr(tUserName, '\\')))
Line 781 
Line 838 
     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(
       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


Legend:
Removed from v.1.53  
changed lines
  Added in v.1.62.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2