(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.78 and 1.79

version 1.78, 2004/04/30 07:54:31 version 1.79, 2004/04/30 23:25:20
Line 53 
Line 53 
 #include <dirent.h> #include <dirent.h>
 #include <pwd.h> #include <pwd.h>
  
   #include <errno.h>
   #if defined(PEGASUS_OS_SOLARIS)
   #  include <string.h>
   #endif
   
 #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) #if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && !defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)
 #include <crypt.h> #include <crypt.h>
 #endif #endif
Line 657 
Line 662 
     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 - This message needs to be added.
           //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
           //                          errorMsg);
     }     }
 #else #else
     //     //
Line 668 
Line 681 
 #endif #endif
     if ( pwd == NULL )     if ( pwd == NULL )
     {     {
         //ATTN: Log a message           // L10N TODO - This message needs to be added.
         // "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
     {     {
Line 711 
Line 727 
     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 - This message needs to be added.
           //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
           //                          errorMsg);
       }
       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
   
     return true;     return true;
 } }
  
Line 737 
Line 767 
 #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 - This message needs to be added.
           //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
           //                          errorMsg);
       }
  
     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;
     AtoE((char *)tmp);     AtoE((char *)tmp);
     return ycmCheckUserCmdAuthorities(tmp);     return ycmCheckUserCmdAuthorities(tmp);
 #endif #endif
   
 } }
  
 String System::getPrivilegedUserName() String System::getPrivilegedUserName()
Line 768 
Line 815 
         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 - This message needs to be added.
               //Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::WARNING,
               //                      errorMsg);
         }         }
 #else #else
         //         //
Line 790 
Line 845 
         }         }
         else         else
         {         {
               Tracer::trace (TRC_OS_ABSTRACTION, Tracer::LEVEL4,
                          "Could not find entry.");
             PEGASUS_ASSERT(0);             PEGASUS_ASSERT(0);
         }         }
     }     }


Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2