[Samba] pam_winbind problem

Timo Benk tik at talicom.de
Mon Aug 5 06:09:02 GMT 2002


Hi,

I noticed the following problem in samba 2.2.5:

the pam winbind module floods the system with
sockets under some circumstances how a look at 
the output of lsof shows.

I attached a simple program to explain
the problem. The problem only occurs with
pam_winbind, with pam_unix everything works
fine.

Does anybody can tell me if this is a problem
in my code or a bug in pam_winbind?

Thanks in advance,
-timo

-------------- next part --------------
// leider fehlt bei den SuSE 7.3 PAM header Dateien die extern Anweisung
extern "C" {
#include <security/pam_appl.h>
#include <security/pam_misc.h>
}
#include <iostream>

// der Service f?r PAM (der Name der Datei in /etc/pam.d/)
#define SERVICE "cdsrv"

/**
 * die conversation function f?r PAM (_authenticate()) 
 */
int own_conv(int num_msg, const pam_message *msg[], pam_response *response[], void *appdata_ptr)
{
	pam_response *reply    = new pam_response[num_msg];     

	for( int x = 0; x < num_msg; x++ )
	{
		reply[x].resp_retcode = 0;
		reply[x].resp         = strdup((char*)appdata_ptr);
	}

	response[0] = reply;

	return PAM_SUCCESS;
}

/**
 * pr?ft gegen PAM ob das user/password pair stimmt und gibt
 * true zur?ck wenn es stimmt, ansonsten false.
 *
 * (Ist auf KEINEN Fall geeignet um generelle PAM Unterst?tzung
 * zu integrieren, lediglich zur simplen user/passwd 
 * authentifizierung. F?r erweiterte Authentifizierungs-Mechanismen
 * wie z.B.: Chipkarten m?sste der Code entsprechend erweitert 
 * werden. Funktioniert nur gegen die shadow Datei wenn die Berechtigungen
 * stimmen, funktioniert allerdings problemlos gegen winbindd)
 *
 * damit libpam.so von der java engine geladen werden kann muss LD_PRELOAD 
 * gesetzt sein:
 * export LD_PRELOAD=/usr/lib/libpam.so
 */
bool _authenticate( char *user, char *passwd )
{
	pam_handle_t *pamh = NULL;

	/* das password f?r die conversation function setzen */
	pam_conv conv;
	conv.appdata_ptr = (void*)passwd;
	conv.conv        = own_conv;

	/* PAM session initialisieren */
	int retval = pam_start(SERVICE, user, &conv, &pamh);

	/* user authentifizieren */
	if (retval == PAM_SUCCESS)
	{
		retval = pam_authenticate(pamh, 0);    
	}
	
	/* pam session schliessen */
	/* TODO: was ist wenn die session nicht wieder geschlossen werden kann */
	int t = pam_end(pamh,retval);

	if( retval == PAM_SUCCESS )
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

void main(int argc, char ** argv)
{
	while( true )
	{
		if( _authenticate( argv[1], argv[2] ) )
		{
			cout << argv[1] << ":" << argv[2] << " is authenticated" << endl;
		}
		else
		{
			cout << argv[1] << ":" << argv[2] << " is not authenticated" << endl;
		}
	}
}	
-------------- next part --------------
#%PAM-1.0
auth		required	pam_winbind.so
#account		required	pam_warn.so	debug
#account		required	pam_deny.so	debug
#session		required	pam_warn.so	debug
#session		required	pam_deny.so	debug
#password	required	pam_warn.so	debug
#password	required	pam_deny.so	debug



More information about the samba mailing list