Can't use "ok = 1" outside of a module call.
authorAlan T. DeKok <aland@freeradius.org>
Fri, 20 Jun 2014 02:13:45 +0000 (22:13 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 20 Jun 2014 02:13:45 +0000 (22:13 -0400)
Only modules can have their return codes updated.  Sections can't.

src/main/modcall.c
src/tests/keywords/if-rcode-error [new file with mode: 0644]

index 9f222bd..cf9fe6b 100644 (file)
@@ -180,6 +180,8 @@ const FR_NAME_NUMBER mod_rcode_table[] = {
 };
 
 
+static char const *group_name[];
+
 /*
  *     Compile action && rcode for later use.
  */
@@ -192,6 +194,12 @@ static int compile_action(modcallable *c, CONF_PAIR *cp)
        value = cf_pair_value(cp);
        if (!value) return 0;
 
+       if (c->type != MOD_SINGLE) {
+               ERROR("%s[%d] Invalid return code assigment inside of a %s section",
+                     cf_pair_filename(cp), cf_pair_lineno(cp), group_name[c->type]);
+               return 0;
+       }
+
        if (!strcasecmp(value, "return"))
                action = MOD_ACTION_RETURN;
 
diff --git a/src/tests/keywords/if-rcode-error b/src/tests/keywords/if-rcode-error
new file mode 100644 (file)
index 0000000..fed8a49
--- /dev/null
@@ -0,0 +1,11 @@
+# PRE: if
+#
+#  return code in an "if" section.
+#
+if (User-Name == "bob") {
+       update reply {
+               Filter-Id := "filter"
+       }
+
+       ok = reject     # ERROR
+}