Skip to content

Commit

Permalink
add config for whitelist mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Mauchle committed Apr 18, 2019
1 parent c0c1ea4 commit 7f1f481
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion radsecproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2625,24 +2625,34 @@ int confserver_cb(struct gconffile **cf, void *arg, char *block, char *opt, char
}

int confrewrite_cb(struct gconffile **cf, void *arg, char *block, char *opt, char *val) {
uint8_t whitelist_mode = 0;
char **rmattrs = NULL, **rmvattrs = NULL;
char **wlattrs = NULL, **wlvattrs = NULL;
char **addattrs = NULL, **addvattrs = NULL;
char **modattrs = NULL;
char **supattrs = NULL, **supvattrs = NULL;

debug(DBG_DBG, "confrewrite_cb called for %s", block);

if (!getgenericconfig(cf, block,
"whitelistMode", CONF_BLN, &whitelist_mode,
"removeAttribute", CONF_MSTR, &rmattrs,
"removeVendorAttribute", CONF_MSTR, &rmvattrs,
"whitelistAttribute", CONF_MSTR, &wlattrs,
"whitelistVendorAttribute", CONF_MSTR, &wlvattrs,
"addAttribute", CONF_MSTR, &addattrs,
"addVendorAttribute", CONF_MSTR, &addvattrs,
"modifyAttribute", CONF_MSTR, &modattrs,
"supplementAttribute", CONF_MSTR, &supattrs,
"supplementVendorAttriute", CONF_MSTR, &supvattrs,
NULL))
debugx(1, DBG_ERR, "configuration error");
addrewrite(val, rmattrs, rmvattrs, addattrs, addvattrs, modattrs, supattrs, supvattrs);
addrewrite(val, whitelist_mode, whitelist_mode? wlattrs : rmattrs, whitelist_mode? wlvattrs : rmvattrs,
addattrs, addvattrs, modattrs, supattrs, supvattrs);

freegconfmstr(whitelist_mode? rmattrs : wlattrs);
freegconfmstr(whitelist_mode? rmvattrs : wlvattrs);

return 1;
}

Expand Down
3 changes: 2 additions & 1 deletion rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct modattr *extractmodattr(char *nameval) {
return m;
}

void addrewrite(char *value, char **rmattrs, char **rmvattrs, char **addattrs,
void addrewrite(char *value, uint8_t whitelist_mode, char **rmattrs, char **rmvattrs, char **addattrs,
char **addvattrs, char **modattrs, char **supattrs, char** supvattrs)
{
struct rewrite *rewrite = NULL;
Expand Down Expand Up @@ -252,6 +252,7 @@ void addrewrite(char *value, char **rmattrs, char **rmvattrs, char **addattrs,
rewrite = malloc(sizeof(struct rewrite));
if (!rewrite)
debugx(1, DBG_ERR, "malloc failed");
rewrite->whitelist_mode = whitelist_mode;
rewrite->removeattrs = rma;
rewrite->removevendorattrs = rmva;
rewrite->addattrs = adda;
Expand Down
2 changes: 1 addition & 1 deletion rewrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct rewrite {
struct list *supattrs; /*struct tlv*/
};

void addrewrite(char *value, char **rmattrs, char **rmvattrs, char **addattrs,
void addrewrite(char *value, uint8_t whitelist_mode, char **rmattrs, char **rmvattrs, char **addattrs,
char **addvattrs, char **modattrs, char **supattrs, char** supvattrs);
int dorewrite(struct radmsg *msg, struct rewrite *rewrite);
struct modattr *extractmodattr(char *nameval);
Expand Down

0 comments on commit 7f1f481

Please sign in to comment.