diff --git a/CASA/logincapture/linux/PAM/pam_sscs.c b/CASA/logincapture/linux/PAM/pam_sscs.c index e181edb4..b9f9b8b8 100644 --- a/CASA/logincapture/linux/PAM/pam_sscs.c +++ b/CASA/logincapture/linux/PAM/pam_sscs.c @@ -51,6 +51,27 @@ #include #include #include +#include + +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) @@ -141,6 +162,7 @@ void set_micasa_password(const char *user, const char *password) SSCS_CRED_TYPE_BASIC_F, &basicCredential, NULL); + if( retval != 0) { pam_sscs_log( LOG_ERR,"Setting the default credential failed.Errcode = %d\n",retval); break; @@ -149,7 +171,6 @@ void set_micasa_password(const char *user, const char *password) } while (0); seteuid(saved_uid); } - return; } @@ -190,9 +211,15 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc,const c return (retval); } + if(setjmp(tout)) { + goto clean_exit; + } + set_timeout (TIMEOUT); + /* Set the password in micasad*/ set_micasa_password(user, wkstnPasswd); +clean_exit: return PAM_SUCCESS; } @@ -250,6 +277,11 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) return (retval); } + if(setjmp(tout)) { + goto clean_exit; + } + set_timeout (TIMEOUT); + /* Set the new password in micasad*/ 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); } /* End of some other flag (Other than PAM_PRELIM_CHECK or PAM_UPDATE_AUTHTOK */ +clean_exit: return PAM_SUCCESS; } diff --git a/CASA/logincapture/linux/PAM/pam_sscs.h b/CASA/logincapture/linux/PAM/pam_sscs.h index 07065e7f..b9100353 100644 --- a/CASA/logincapture/linux/PAM/pam_sscs.h +++ b/CASA/logincapture/linux/PAM/pam_sscs.h @@ -49,6 +49,8 @@ extern void pam_sscs_log(int priority, const char *format,...); #define MICASAD_PID_SIZE 32 #define MICASAD_PID_FILE "/var/run/micasad.pid" +#define TIMEOUT 5 + #ifdef DEBUG #define PRINT_FN_NAME pam_sscs_log(LOG_DEBUG,"In function : %s\n",__func__); #else