How to return out of a policy.d module
Is it possible to jump out of a policy.d function, without exiting the whole request? For example, suppose I have policy.d/foo which contains foo { if (..some complex condition..) { ... if (..another condition..) { ... ok /* I WANT TO RETURN FROM HERE */ } ... ... more logic ... reject } } At the place given, I want to finish processing the 'foo' policy and continue. However if I use "return", it terminates the whole enclosing authorize section: authorize { ... foo bar # "bar" is not executed if "foo" says "return" } I can possibly write the policy I want entirely as carefully written if ... elsif ... elsif ... sections, but it would give me some more options for writing it clearly if there were a way for the policy to return. I just haven't been able to work out how to do that. Thanks, Brian.
On Nov 4, 2016, at 11:34 AM, Brian Candler <b.candler@pobox.com> wrote:
Is it possible to jump out of a policy.d function, without exiting the whole request?
Unfortunately, no. For various reasons, policies aren't really functions. They're pretty much included in-line in the configuration section which uses them. It would be possible to change the "return" statement so that it's scoped. i.e. it returns out of whatever logical block it's in. But that can't be done for v3. Perhaps in v4 it's easier. Alan DeKok.
participants (2)
-
Alan DeKok -
Brian Candler