Fix for bug 209858.

This commit is contained in:
Cameron (Kamran) Mashayekhi 2007-02-14 21:35:56 +00:00
parent 4ad530078e
commit 4a79493d55
2 changed files with 36 additions and 1 deletions

View File

@ -51,6 +51,27 @@
#include <sys/syslog.h> #include <sys/syslog.h>
#include <security/pam_modules.h> #include <security/pam_modules.h>
#include <security/_pam_macros.h> #include <security/_pam_macros.h>
#include <setjmp.h>
static jmp_buf tout;
/* timeout signal hander */
void sig_timeout(int signum)
{
if(signum == SIGALRM )
pam_sscs_log(LOG_ERR, "micasad is not responding\n");
signal( SIGALRM, SIG_IGN );
alarm(0);
longjmp(tout, 1);
}
/* set timeout */
void set_timeout(int timeout)
{
signal(SIGALRM, (void *)sig_timeout);
alarm( timeout );
}
/* /*
* Running (micasad_status = 1) * Running (micasad_status = 1)
@ -141,6 +162,7 @@ void set_micasa_password(const char *user, const char *password)
SSCS_CRED_TYPE_BASIC_F, SSCS_CRED_TYPE_BASIC_F,
&basicCredential, &basicCredential,
NULL); NULL);
if( retval != 0) { if( retval != 0) {
pam_sscs_log( LOG_ERR,"Setting the default credential failed.Errcode = %d\n",retval); pam_sscs_log( LOG_ERR,"Setting the default credential failed.Errcode = %d\n",retval);
break; break;
@ -149,7 +171,6 @@ void set_micasa_password(const char *user, const char *password)
} while (0); } while (0);
seteuid(saved_uid); seteuid(saved_uid);
} }
return; return;
} }
@ -190,9 +211,15 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc,const c
return (retval); return (retval);
} }
if(setjmp(tout)) {
goto clean_exit;
}
set_timeout (TIMEOUT);
/* Set the password in micasad*/ /* Set the password in micasad*/
set_micasa_password(user, wkstnPasswd); set_micasa_password(user, wkstnPasswd);
clean_exit:
return PAM_SUCCESS; return PAM_SUCCESS;
} }
@ -250,6 +277,11 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv)
return (retval); return (retval);
} }
if(setjmp(tout)) {
goto clean_exit;
}
set_timeout (TIMEOUT);
/* Set the new password in micasad*/ /* Set the new password in micasad*/
set_micasa_password(user, new_passwd); set_micasa_password(user, new_passwd);
@ -259,6 +291,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv)
return (PAM_AUTH_ERR); return (PAM_AUTH_ERR);
} /* End of some other flag (Other than PAM_PRELIM_CHECK or PAM_UPDATE_AUTHTOK */ } /* End of some other flag (Other than PAM_PRELIM_CHECK or PAM_UPDATE_AUTHTOK */
clean_exit:
return PAM_SUCCESS; return PAM_SUCCESS;
} }

View File

@ -49,6 +49,8 @@ extern void pam_sscs_log(int priority, const char *format,...);
#define MICASAD_PID_SIZE 32 #define MICASAD_PID_SIZE 32
#define MICASAD_PID_FILE "/var/run/micasad.pid" #define MICASAD_PID_FILE "/var/run/micasad.pid"
#define TIMEOUT 5
#ifdef DEBUG #ifdef DEBUG
#define PRINT_FN_NAME pam_sscs_log(LOG_DEBUG,"In function : %s\n",__func__); #define PRINT_FN_NAME pam_sscs_log(LOG_DEBUG,"In function : %s\n",__func__);
#else #else