mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
Use mutex with pam auth, because pam is not thread safe
This commit is contained in:
parent
8e820b28c0
commit
4cb43b438f
@ -12,7 +12,7 @@ Kirill Lopuchov <lopuchov@mail.ru>
|
|||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
|
|
||||||
|
|
||||||
|
pthread_mutex_t pam_mutex;
|
||||||
|
|
||||||
static int already_loaded = 0;
|
static int already_loaded = 0;
|
||||||
|
|
||||||
@ -89,9 +89,10 @@ static int pamfunc(struct clientparam *param)
|
|||||||
/*start process auth */
|
/*start process auth */
|
||||||
conv.appdata_ptr = (char *) param->password;
|
conv.appdata_ptr = (char *) param->password;
|
||||||
|
|
||||||
|
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);
|
||||||
@ -110,6 +111,7 @@ static int pamfunc(struct clientparam *param)
|
|||||||
retval = pam_end (pamh, retval);
|
retval = pam_end (pamh, retval);
|
||||||
if (retval != PAM_SUCCESS)
|
if (retval != PAM_SUCCESS)
|
||||||
{ pamh = NULL; }
|
{ pamh = NULL; }
|
||||||
|
pthread_mutex_unlock(&pam_mutex);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -130,6 +132,7 @@ int start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
|
|||||||
|
|
||||||
already_loaded = 1;
|
already_loaded = 1;
|
||||||
|
|
||||||
|
pthread_mutex_init(&pam_mutex, NULL);
|
||||||
pamauth.authenticate = pamfunc;
|
pamauth.authenticate = pamfunc;
|
||||||
pamauth.authorize = pluginlink->checkACL;
|
pamauth.authorize = pluginlink->checkACL;
|
||||||
pamauth.desc = "pam";
|
pamauth.desc = "pam";
|
||||||
|
Loading…
Reference in New Issue
Block a user