]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix for Coredump in Tools when PAM fails to start.
authorVMware, Inc <>
Mon, 26 Sep 2011 18:35:42 +0000 (11:35 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 26 Sep 2011 18:35:42 +0000 (11:35 -0700)
Whenever PAM fails to start for any reason (i.e., pam_start() returns with error), calling pam_end() after that causes tools to coredump. For all other pam calls, if there is any failure pam_end() should be called.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/auth/authPosix.c

index 1d9a89a5b9fff66c3e6d569ef5639080318f7d74..f4e773e177c0b2df1916a5ba6b94f23334b8e343 100644 (file)
@@ -27,6 +27,7 @@
 #include "posix.h"
 #include "auth.h"
 #include "str.h"
+#include "log.h"
 
 #ifdef USE_PAM
 #  include "file.h"
@@ -63,6 +64,7 @@ static typeof(&pam_end) dlpam_end;
 static typeof(&pam_authenticate) dlpam_authenticate;
 static typeof(&pam_setcred) dlpam_setcred;
 static typeof(&pam_acct_mgmt) dlpam_acct_mgmt;
+static typeof(&pam_strerror) dlpam_strerror;
 #if 0  /* These three functions are not used yet */
 static typeof(&pam_open_session) dlpam_open_session;
 static typeof(&pam_close_session) dlpam_close_session;
@@ -286,6 +288,9 @@ Auth_AuthenticateUser(const char *user,  // IN:
        */
 
 #define PAM_BAIL if (pam_error != PAM_SUCCESS) { \
+                  Log_Error("%s:%d: PAM failure - %s (%d)\n", \
+                            __FUNCTION__, __LINE__, \
+                            dlpam_strerror(pamh, pam_error), pam_error); \
                   dlpam_end(pamh, pam_error); \
                   return NULL; \
                  }
@@ -299,8 +304,11 @@ Auth_AuthenticateUser(const char *user,  // IN:
       pam_error = dlpam_start("vmware-authd", PAM_username, &PAM_conversation,
                               &pamh);
 #endif
+      if (pam_error != PAM_SUCCESS) {
+         Log("Failed to start PAM (error = %d).\n", pam_error);
+         return NULL;
+      }
 
-      PAM_BAIL;
       pam_error = dlpam_authenticate(pamh, 0);
       PAM_BAIL;
       pam_error = dlpam_acct_mgmt(pamh, 0);