mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
pam_auth: Authenticate all users in single session
This commit is contained in:
parent
4cb43b438f
commit
438a5bac9b
@ -13,6 +13,7 @@ Kirill Lopuchov <lopuchov@mail.ru>
|
|||||||
|
|
||||||
|
|
||||||
pthread_mutex_t pam_mutex;
|
pthread_mutex_t pam_mutex;
|
||||||
|
pam_handle_t *pamh = NULL;
|
||||||
|
|
||||||
static int already_loaded = 0;
|
static int already_loaded = 0;
|
||||||
|
|
||||||
@ -69,7 +70,6 @@ static void lower (char *string)
|
|||||||
/* --------------------------------------------------------------------------*/
|
/* --------------------------------------------------------------------------*/
|
||||||
static int pamfunc(struct clientparam *param)
|
static int pamfunc(struct clientparam *param)
|
||||||
{
|
{
|
||||||
pam_handle_t *pamh = NULL;
|
|
||||||
int retval;
|
int retval;
|
||||||
int rc=0;
|
int rc=0;
|
||||||
|
|
||||||
@ -91,9 +91,7 @@ static int pamfunc(struct clientparam *param)
|
|||||||
|
|
||||||
pthread_mutex_lock(&pam_mutex);
|
pthread_mutex_lock(&pam_mutex);
|
||||||
if (!pamh)
|
if (!pamh)
|
||||||
{
|
|
||||||
retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
|
retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
|
||||||
}
|
|
||||||
if (retval == PAM_SUCCESS)
|
if (retval == PAM_SUCCESS)
|
||||||
retval = pam_set_item (pamh, PAM_USER, param->username);
|
retval = pam_set_item (pamh, PAM_USER, param->username);
|
||||||
/*fprintf(stderr,"pam_set_item1 rc=%d\n",retval);*/
|
/*fprintf(stderr,"pam_set_item1 rc=%d\n",retval);*/
|
||||||
@ -104,15 +102,11 @@ static int pamfunc(struct clientparam *param)
|
|||||||
retval = pam_authenticate (pamh, 0);
|
retval = pam_authenticate (pamh, 0);
|
||||||
/*fprintf(stderr,"pam_authenticate rc=%d\n",retval);*/
|
/*fprintf(stderr,"pam_authenticate rc=%d\n",retval);*/
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&pam_mutex);
|
||||||
|
|
||||||
if (retval == PAM_SUCCESS) { /*auth OK*/ rc=0; }
|
if (retval == PAM_SUCCESS) { /*auth OK*/ rc=0; }
|
||||||
else { /*auth ERR*/ rc=5; }
|
else { /*auth ERR*/ rc=5; }
|
||||||
|
|
||||||
if (pamh)
|
|
||||||
retval = pam_end (pamh, retval);
|
|
||||||
if (retval != PAM_SUCCESS)
|
|
||||||
{ pamh = NULL; }
|
|
||||||
pthread_mutex_unlock(&pam_mutex);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user