#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
+#include <freeradius-devel/rad_assert.h>
/*
* Define a structure for our module configuration.
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
+static int rlm_example_cmp(UNUSED void *instance, REQUEST *request, UNUSED VALUE_PAIR *thing, VALUE_PAIR *check,
+ UNUSED VALUE_PAIR *check_pairs, UNUSED VALUE_PAIR **reply_pairs)
+{
+ rad_assert(check->da->type == PW_TYPE_STRING);
+
+ RINFO("Example-Paircmp called with \"%s\"", check->vp_strvalue);
+
+ if (strcmp(check->vp_strvalue, "yes") == 0) return 0;
+ return 1;
+}
/*
* Do any per-module initialization that is separate to each
static int mod_instantiate(CONF_SECTION *conf, void *instance)
{
rlm_example_t *inst = instance;
+ ATTR_FLAGS flags;
+ memset(&flags, 0, sizeof(flags));
/*
* Do more work here
*/
return -1;
}
+ if (dict_addattr("Example-Paircmp", -1, 0, PW_TYPE_STRING, flags) < 0) {
+ ERROR("Failed creating paircmp attribute", fr_strerror());
+
+ return -1;
+ }
+
+ paircompare_register(dict_attrbyname("Example-Paircmp"), dict_attrbyvalue(PW_USER_NAME, 0), false,
+ rlm_example_cmp, inst);
+
return 0;
}
/*
* Look for the 'state' attribute.
*/
- state = pairfind(request->packet->vps, PW_STATE, 0, TAG_ANY);
+ state = pairfind(request->packet->vps, PW_STATE, 0, TAG_ANY);
if (state != NULL) {
RDEBUG("Found reply to access challenge");
return RLM_MODULE_OK;
--- /dev/null
+#
+# PRE: update if
+#
+update {
+ control:Cleartext-Password := 'hello'
+ reply:Filter-Id := 'filter'
+}
+
+#
+# Paircmp
+#
+
+#
+# Passing 'yes' causes the example paircmp to return match
+# Passing 'no' causes the example paircmp to return a non-match
+#
+if (&Example-Paircmp != 'yes') {
+ update reply {
+ Filter-Id += 'fail 1'
+ }
+}
+
+if (&Example-Paircmp == 'no') {
+ update reply {
+ Filter-Id += 'fail 2'
+ }
+}