X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=contrib%2Fslapd-modules%2Fpasswd%2Fradius.c;h=3a6bf249456df874ebc4a5ffd8e1309c01c15282;hb=001f14965402aa86f3d7cd364fc781caeb603719;hp=57b216c61bc58f7e7fdd53a77694ba2ea8b4d3d9;hpb=864e276981648abf89f0bb974b56144a7e248619;p=openldap
diff --git a/contrib/slapd-modules/passwd/radius.c b/contrib/slapd-modules/passwd/radius.c
index 57b216c61b..3a6bf24945 100644
--- a/contrib/slapd-modules/passwd/radius.c
+++ b/contrib/slapd-modules/passwd/radius.c
@@ -1,6 +1,7 @@
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2006 The OpenLDAP Foundation.
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -12,11 +13,14 @@
* .
*/
+#include "portable.h"
+
#include
#include
#include /* BER_BVC definition */
#include "lutil.h"
+#include
#include
#include
@@ -25,6 +29,7 @@
static LUTIL_PASSWD_CHK_FUNC chk_radius;
static const struct berval scheme = BER_BVC("{RADIUS}");
static char *config_filename;
+static ldap_pvt_thread_mutex_t libradius_mutex;
static int
chk_radius(
@@ -58,8 +63,11 @@ chk_radius(
return LUTIL_PASSWD_ERR; /* passwd must behave like a string */
}
+ ldap_pvt_thread_mutex_lock( &libradius_mutex );
+
h = rad_auth_open();
if ( h == NULL ) {
+ ldap_pvt_thread_mutex_unlock( &libradius_mutex );
return LUTIL_PASSWD_ERR;
}
@@ -79,16 +87,37 @@ chk_radius(
goto done;
}
- if ( rad_send_request( h ) == RAD_ACCESS_ACCEPT ) {
+ switch ( rad_send_request( h ) ) {
+ case RAD_ACCESS_ACCEPT:
rc = LUTIL_PASSWD_OK;
+ break;
+
+ case RAD_ACCESS_REJECT:
+ rc = LUTIL_PASSWD_ERR;
+ break;
+
+ case RAD_ACCESS_CHALLENGE:
+ rc = LUTIL_PASSWD_ERR;
+ break;
+
+ case -1:
+ /* no valid response is received */
+ break;
}
done:;
rad_close( h );
+ ldap_pvt_thread_mutex_unlock( &libradius_mutex );
return rc;
}
+int
+term_module()
+{
+ return ldap_pvt_thread_mutex_destroy( &libradius_mutex );
+}
+
int
init_module( int argc, char *argv[] )
{
@@ -109,5 +138,7 @@ init_module( int argc, char *argv[] )
}
}
+ ldap_pvt_thread_mutex_init( &libradius_mutex );
+
return lutil_passwd_add( (struct berval *)&scheme, chk_radius, NULL );
}