Patch from Steve Langasek <corlon@netexpress.net>
[samba.git] / source3 / pam_smbpass / pam_smb_auth.c
index e5cc12e2f6d40bc4a095ca5ef2ee13b22dcf3139..f4cbb59af31e4fe6c2632fbf08c2b13d84e93bdc 100644 (file)
@@ -36,6 +36,8 @@
 
 #define AUTH_RETURN                                            \
 do {                                                           \
+       /* Restore application signal handler */                \
+       CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);       \
        if(ret_data) {                                          \
                *ret_data = retval;                             \
                pam_set_data( pamh, "smb_setcred_return"        \
@@ -65,6 +67,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
     SAM_ACCOUNT *sampass = NULL;
     extern BOOL in_client;
     const char *name;
+    void (*oldsig_handler)(int);
     BOOL found;
 
     /* Points to memory managed by the PAM library. Do not free. */
@@ -93,6 +96,10 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
         _log_err( LOG_DEBUG, "username [%s] obtained", name );
     }
 
+    /* Getting into places that might use LDAP -- protect the app
+       from a SIGPIPE it's not expecting */
+    oldsig_handler = CatchSignal(SIGPIPE, SIGNAL_CAST SIG_IGN);
+
     if (!initialize_password_db(True)) {
         _log_err( LOG_ALERT, "Cannot access samba password database" );
         retval = PAM_AUTHINFO_UNAVAIL;