[BACK] Return to PAMBasicAuthenticatorUnix.cpp CVS log [TXT][DIR] Up to [Pegasus] / pegasus / src / Pegasus / Security / Authentication

Diff for /pegasus/src/Pegasus/Security/Authentication/PAMBasicAuthenticatorUnix.cpp between version 1.34.4.1 and 1.34.4.2

version 1.34.4.1, 2007/04/04 11:04:52 version 1.34.4.2, 2008/01/04 20:13:02
Line 26 
Line 26 
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com) // Author: Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
 // //
 // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com) // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 //            : Sushma Fernandes, Hewlett-Packard Company  //            : Sushma Fernandes, Hewlett-Packard Company
 //                (sushma_fernandes@hp.com) //                (sushma_fernandes@hp.com)
 //                Josephine Eskaline Joyce (jojustin@in.ibm.com) for PEP#101 //                Josephine Eskaline Joyce (jojustin@in.ibm.com) for PEP#101
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
  // NOCHKSRC
  
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Config/ConfigManager.h> #include <Pegasus/Config/ConfigManager.h>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/Signal.h> #include <Pegasus/Common/Signal.h>
  
 #if defined (PEGASUS_OS_HPUX) #if defined (PEGASUS_OS_HPUX)
 #include <prot.h> #include <prot.h>
 #endif #endif
  
 #if defined (PEGASUS_USE_PAM_STANDALONE_PROC) #if defined (PEGASUS_USE_PAM_STANDALONE_PROC)
 #include <Pegasus/Common/Logger.h> #include <Pegasus/Common/Logger.h>
 #include <pwd.h> #include <pwd.h>
 #include <sys/stat.h> #include <sys/stat.h>
 #include <unistd.h> #include <unistd.h>
Line 375 
Line 377 
     else      else
     {     {
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
         return PAM_CONV_ERR;         return PAM_CONV_ERR;
     }     }
  
     for ( Sint32 i = 0; i < num_msg; i++ )      for ( Sint32 i = 0; i < num_msg; i++ )
     {     {
         switch ( msg[i]->msg_style )          switch ( msg[i]->msg_style )
         {         {
             case PAM_PROMPT_ECHO_OFF:             case PAM_PROMPT_ECHO_OFF:
                 //                  //
                 // copy the user password                 // copy the user password
                 //                  //
                 resp[i]->resp = (char *)malloc(PAM_MAX_MSG_SIZE);                 resp[i]->resp = (char *)malloc(PAM_MAX_MSG_SIZE);
                 strcpy(resp[i]->resp, mydata->userPassword);                 strncpy(resp[i]->resp, mydata->userPassword, PAM_MAX_MSG_SIZE);
                  resp[i]->resp[PAM_MAX_MSG_SIZE - 1] = 0;
                 resp[i]->resp_retcode = 0;                 resp[i]->resp_retcode = 0;
                 break;                 break;
  
             default:             default:
                PEG_METHOD_EXIT();                PEG_METHOD_EXIT();
                return PAM_CONV_ERR;                return PAM_CONV_ERR;
         }         }
     }     }
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
  
     return PAM_SUCCESS;     return PAM_SUCCESS;
 } }
  
 /** Routines to access PAM Authentication via a standalone process **/ /** Routines to access PAM Authentication via a standalone process **/
Line 541 
Line 544 
     {     {
         if (_readString() == PAM_OPERATION_SUCCESS)         if (_readString() == PAM_OPERATION_SUCCESS)
         {         {
             authenticated = true;             authenticated = true;
             printed_err_since_success = false;             printed_err_since_success = false;
         }         }
     }     }
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
     return (authenticated);     return (authenticated);
 } }
  
 PAMBasicAuthenticatorStandAlone::_Status  PAMBasicAuthenticatorStandAlone::_Status
          PAMBasicAuthenticatorStandAlone::_writeString(const String& text)          PAMBasicAuthenticatorStandAlone::_writeString(const String& text)
 { {
     char        line[BUFFERLEN]; 
     int         n, ret_code; 
     PAMBasicAuthenticatorStandAlone::_Status    status =      PAMBasicAuthenticatorStandAlone::_Status    status =
                         PAMBasicAuthenticatorStandAlone::SUCCESS;                         PAMBasicAuthenticatorStandAlone::SUCCESS;
  
     CString copy_of_text=text.getCString();     CString copy_of_text=text.getCString();
     n = strlen(copy_of_text);     int stringLength = strlen(copy_of_text);
  
      if (stringLength > BUFFERLEN - 1)
      {
          stringLength = BUFFERLEN - 1;
      }
  
     sprintf(line, "%4u%s", n, (const char*)copy_of_text);     char header[5];
     n = strlen(line);     sprintf(header, "%04u", stringLength);
  
     continue_PAMauthentication = true;     continue_PAMauthentication = true;
     ret_code = write(fd_1[1], line, n); 
  
     if (ret_code != n)     if ((write(fd_1[1], header, 4) != 4) ||
          (write(fd_1[1], copy_of_text, stringLength) != stringLength))
     {     {
         continue_PAMauthentication = false;         continue_PAMauthentication = false;
         status = PAMBasicAuthenticatorStandAlone::OTHER_ERROR;         status = PAMBasicAuthenticatorStandAlone::OTHER_ERROR;
  
         if (errno == EPIPE)         if (errno == EPIPE)
         {         {
             status = PAMBasicAuthenticatorStandAlone::BROKEN_CONNECTION;             status = PAMBasicAuthenticatorStandAlone::BROKEN_CONNECTION;
         }         }
         if (printed_err_since_success == false)         if (printed_err_since_success == false)
         {         {
             printed_err_since_success = true;             printed_err_since_success = true;
             Logger::put(Logger::ERROR_LOG, System::CIMSERVER,              Logger::put(Logger::ERROR_LOG, System::CIMSERVER,
                         Logger::SEVERE,                         Logger::SEVERE,
                        "Error processing PAM Authentication request (write).");                        "Error processing PAM Authentication request (write).");
         }         }


Legend:
Removed from v.1.34.4.1 
changed lines
 Added in v.1.34.4.2