Skip to content

Commit

Permalink
Auto-load dictionary.vqp and dictionary.dhcp
Browse files Browse the repository at this point in the history
Conflicts:
	share/dictionary
  • Loading branch information
alandekok committed Jan 27, 2014
1 parent 3b66c4c commit 9386432
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
10 changes: 3 additions & 7 deletions share/dictionary
Expand Up @@ -260,15 +260,11 @@ $INCLUDE dictionary.yubico
$INCLUDE dictionary.zeus
$INCLUDE dictionary.zyxel

# Address Resolution Protocol
#
# This should be auto-loaded in the future.
#
$INCLUDE dictionary.arp

# DHCP dictionary for DHCP functionality and use of dhcp module
$INCLUDE dictionary.dhcp

# VQP dictionary for VMPS functionality and use of vmps module
$INCLUDE dictionary.vqp

#
# And finally the server internal attributes.
# These are attributes which NEVER go into a RADIUS packet.
Expand Down
2 changes: 1 addition & 1 deletion src/main/modcall.c
Expand Up @@ -652,7 +652,7 @@ static bool modcall_recurse(REQUEST *request, rlm_components_t component, int de
}

if (radius_get_vp(&vp, request, c->name) < 0) {
RDEBUG("Unknown Attribute \"%s\"", c->name);
RDEBUG("Unknown attribute \"%s\"", c->name);
result = RLM_MODULE_FAIL;
goto calculate_result;
}
Expand Down
55 changes: 46 additions & 9 deletions src/main/modules.c
Expand Up @@ -1239,13 +1239,33 @@ static int load_byserver(CONF_SECTION *cs)
* This is a bit of a hack...
*/
if (!found) do {
#if defined(WITH_VMPS) || defined(WITH_DHCP)
CONF_SECTION *subcs;
#ifdef WITH_DHCP
DICT_ATTR const *dattr;
DICT_ATTR const *da;
#endif

#ifdef WITH_VMPS
subcs = cf_section_sub_find(cs, "vmps");
if (subcs) {
/*
* Auto-load the DHCP dictionary.
*/
da = dict_attrbyname("VQP-Packet-Type");
if (!da) {
if (dict_read(mainconfig.dictionary_dir, "dictionary.vqp") < 0) {
ERROR("Failed reading dictionary.vqp: %s",
fr_strerror());
return -1;
}
DEBUG("Loading dictionary.vqp");

da = dict_attrbyname("VQP-Packet-Type");
if (!da) {
ERROR("No VQP-Packet-Type in dictionary.vqp");
return -1;
}
}

cf_log_module(cs, "Checking vmps {...} for more modules to load");
if (load_component_section(subcs, components,
RLM_COMPONENT_POST_AUTH) < 0) {
Expand All @@ -1257,16 +1277,33 @@ static int load_byserver(CONF_SECTION *cs)
found = 1;
break;
}
#endif

#ifdef WITH_DHCP
/*
* It's OK to not have DHCP.
*/
subcs = cf_subsection_find_next(cs, NULL, "dhcp");
dattr = dict_attrbyname("DHCP-Message-Type");
if (!dattr && subcs) {
cf_log_err_cs(subcs, "Found a 'dhcp' section, but no DHCP dictionaries have been loaded");
goto error;
}
if (!subcs) break;

/*
* Auto-load the DHCP dictionary.
*/
da = dict_attrbyname("DHCP-Message-Type");
if (!da) {
DEBUG("Loading dictionary.dhcp");
if (dict_read(mainconfig.dictionary_dir, "dictionary.dhcp") < 0) {
ERROR("Failed reading dictionary.dhcp: %s",
fr_strerror());
return -1;
}

if (!dattr) break;
da = dict_attrbyname("DHCP-Message-Type");
if (!da) {
ERROR("No DHCP-Message-Type in dictionary.dhcp");
return -1;
}
}

/*
* Handle each DHCP Message type separately.
Expand All @@ -1277,7 +1314,7 @@ static int load_byserver(CONF_SECTION *cs)
DEBUG2(" Module: Checking dhcp %s {...} for more modules to load", name2);
if (!load_subcomponent_section(NULL, subcs,
components,
dattr,
da,
RLM_COMPONENT_POST_AUTH)) {
goto error; /* FIXME: memleak? */
}
Expand Down

0 comments on commit 9386432

Please sign in to comment.