mirror of
				https://github.com/3proxy/3proxy.git
				synced 2025-11-04 15:52:39 +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>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
pthread_mutex_t pam_mutex;
 | 
			
		||||
 | 
			
		||||
static int         already_loaded = 0;
 | 
			
		||||
 | 
			
		||||
@ -89,9 +89,10 @@ static int pamfunc(struct clientparam *param)
 | 
			
		||||
  /*start process auth */  
 | 
			
		||||
  conv.appdata_ptr = (char *) param->password;
 | 
			
		||||
 | 
			
		||||
  pthread_mutex_lock(&pam_mutex);
 | 
			
		||||
  if (!pamh)
 | 
			
		||||
    {
 | 
			
		||||
      retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
 | 
			
		||||
	retval = pam_start ((char *)service, "3proxy@" , &conv, &pamh);
 | 
			
		||||
    }
 | 
			
		||||
   if (retval == PAM_SUCCESS)
 | 
			
		||||
       retval = pam_set_item (pamh, PAM_USER, param->username); 
 | 
			
		||||
@ -110,6 +111,7 @@ static int pamfunc(struct clientparam *param)
 | 
			
		||||
      retval = pam_end (pamh, retval);
 | 
			
		||||
   if (retval != PAM_SUCCESS)
 | 
			
		||||
      {  pamh = NULL;   }
 | 
			
		||||
  pthread_mutex_unlock(&pam_mutex);
 | 
			
		||||
 | 
			
		||||
  return rc;
 | 
			
		||||
 | 
			
		||||
@ -130,6 +132,7 @@ int start(struct pluginlink * pluginlink, int argc, unsigned char** argv)
 | 
			
		||||
 | 
			
		||||
 already_loaded = 1;
 | 
			
		||||
    
 | 
			
		||||
 pthread_mutex_init(&pam_mutex, NULL);
 | 
			
		||||
 pamauth.authenticate = pamfunc;
 | 
			
		||||
 pamauth.authorize = pluginlink->checkACL;
 | 
			
		||||
 pamauth.desc = "pam";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user