Skip to content

Commit

Permalink
test and fix supplementVendorAttriute
Browse files Browse the repository at this point in the history
update manpage
  • Loading branch information
Fabian Mauchle committed Apr 18, 2019
1 parent aef43ea commit 3e6bd73
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
7 changes: 7 additions & 0 deletions radsecproxy.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,13 @@ the attribute is not yet present on the message. The format of \fIvalue\fR is
the same as for \fBaddAttribute\fR above.
.RE

.BI "SupplementVendorAttribute " vendor \fR: subattribute \fR: value
.RS
Add a vendor attribute to the radius message only if the \fIsubattribute\fR of
this \fIvendor\fR is not yet present on the message. The format of is the same
as for \fBaddVendorAttribute\fR above.
.RE

.BI "ModifyAttribute " attribute \fR:/ regex \fR/ replace \fR/
.RS
Modify the given \fIattribute\fR using the \fIregex\fR \fIreplace\fR pattern. As
Expand Down
4 changes: 2 additions & 2 deletions rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,13 @@ int dorewritesup(struct radmsg *msg, struct list *supattrs) {
exist = 1;
break;
} else if (supattr->t == RAD_Attr_Vendor_Specific && attr->t == RAD_Attr_Vendor_Specific &&
memcmp (supattr->v, attr->v, 4)) {
memcmp (supattr->v, attr->v, 4)==0) {
if (!attrvalidate(attr->v+4, attr->l-4)) {
debug(DBG_INFO, "dorewritesup: vendor attribute validation failed, no rewrite");
return 0;
}
vendortype = (uint8_t *)supattr->v+4;
for (v=attr->v+4; v < attr->v + attr->l; v += *(v+1) + 2){
for (v=attr->v+4; v < attr->v + attr->l; v += *(v+1)){
if (*v == *vendortype) {
exist = 1;
break;
Expand Down
22 changes: 21 additions & 1 deletion tests/t_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void _reset_rewrite(struct rewrite *rewrite) {
int
main (int argc, char *argv[])
{
int testcount = 22;
int testcount = 23;
struct list *origattrs, *expectedattrs;
struct rewrite rewrite;
char *username = "user@realm";
Expand Down Expand Up @@ -298,6 +298,26 @@ main (int argc, char *argv[])
_reset_rewrite(&rewrite);
}

/* test supplement vendor*/
{
uint8_t value = 42;
uint8_t vendor_long1_in[] = {0,0,0,42,2,3,0,1,3,0};

list_push(rewrite.supattrs, makevendortlv(42, maketlv(1, 1, &value)));
list_push(rewrite.supattrs, makevendortlv(42, maketlv(3, 1, &value)));
list_push(origattrs, maketlv(26, sizeof(vendor_long1_in), vendor_long1_in));
list_push(expectedattrs, maketlv(26, sizeof(vendor_long1_in), vendor_long1_in));
list_push(expectedattrs, makevendortlv(42, maketlv(3, 1, &value)));

if (_check_rewrite(origattrs, &rewrite, expectedattrs, 0))
printf("not ");
printf("ok %d - suppattrs vendor\n", testcount++);

_list_clear(origattrs);
_list_clear(expectedattrs);
_reset_rewrite(&rewrite);
}

/* test modify no match*/
{
char *value = "hello world";
Expand Down
2 changes: 1 addition & 1 deletion tests/t_rewrite_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ main (int argc, char *argv[])

expected = maketlv(1,5,expectedvalue);

addrewrite(rewritename, NULL, NULL, addattrs,
addrewrite(rewritename, 0, NULL, NULL, addattrs,
NULL, NULL, NULL, NULL);

result = getrewrite(rewritename, NULL);
Expand Down

0 comments on commit 3e6bd73

Please sign in to comment.