Alan T. DeKok [Fri, 18 Apr 2025 12:40:11 +0000 (08:40 -0400)]
hoist tmpls
if a tmpl is asked to parse %{...}. then the result is TMPL_TYPE_XLAT.
However, if the contents of that xlat are identically a tmpl, e.g.
User-Name, then there is no reason to keep the xlat. Instead, we
hoist the tmpl we really want, and discard the intermediate xlat
this simplifies the internal data structures, and allows for
additional optimizations. It also means that we do less work
at run-time in order to expand the tmpl.
Alan T. DeKok [Thu, 17 Apr 2025 19:53:41 +0000 (15:53 -0400)]
remove backticks from tests
And clean up corresponding use of exec module. We hoist it to
unit_test_module.conf, and then replace any module-specific
configuration with a module-specific instant of exec
More fixes for OpenSSL's questionable design decisions
Always drain the thread local error stack before calling SSL_read() and SSL_write() to prevent stale errors from masking SSL_ERROR_WANT_* return codes from SSL_get_error().
Alan T. DeKok [Wed, 16 Apr 2025 15:58:19 +0000 (11:58 -0400)]
add "exceed_mtu" configuration flag for UDP sockets.
which defaults to "yes".
When set to "yes", clears the "don't fragment" bit in the IP
packet header.
When set to "no", it uses the OS definition for the DF bit.
Note that we do NOT set the DF bit. OSX supports IP_DONTFRAG
only for raw sockets. Linux always sets the DF flag for UDP
sockets.
No matter what this flag is set to, there are some situations
where UDP packets will silently disappear in the network.
When DF is set, "too large" packets might get an ICMP error
to the OS, which the server will currently ignore.
When DF is clear, "too large" packets might be silently discarded
by some other network element.
Alan T. DeKok [Mon, 14 Apr 2025 11:23:30 +0000 (07:23 -0400)]
allow dict to be NULL when setting the function
if so, also set needs_resolving.
Because an xlat can be parsed from a module configuration, where
the dictionary is unknown. Until such time as all of the modules
are converted to use call_env, this is likely the best approach.
Alan T. DeKok [Sun, 13 Apr 2025 15:17:03 +0000 (11:17 -0400)]
clean up attr_filter and map_to_vp()
only attr_filter passes comparison operators to map_to_vp()
we should arguably forbid comparison operators, as allowing them
could break other modules.
Also disallow comparison operators in map_to_request, as nothing
uses them.
Alan T. DeKok [Sat, 12 Apr 2025 17:30:31 +0000 (13:30 -0400)]
there's no need for INPUT_ARGS
there's now only one type of function, as opposed to the
transitional MONO and INPUT_ARGS. So we remove the redundant
field and update the associated checks
Alan T. DeKok [Fri, 11 Apr 2025 12:03:21 +0000 (08:03 -0400)]
Update xlat expression parser to avoid a bounce through tmpls
the expression parser now calls the xlat_tokenize_word(). That
function returns xlat groups for strings, and not tmpls.
Update the %cast() function to always create its arguments as groups.
This helps when "foo%{User-Name}" is now parsed as an xlat group,
and not as an xlat which is pointing to a tmpl
xlat_process_arg_list() now calls a separate function to escape
and stringify its output
Add "is_argv" flag to xlat_exp_head_t. This tells the xlat eval
code to NOT concatenate strings, as the function argument parser
will do that, with escaping.
various cleanups in xlat_tokenize_word()
Hoist constant strings after calling xlat_tokenize_input(). This
code should arguably be moved to xlat_tokenize_input().
xlat_argv tests now also print strings with the enclosing quotes.
Nick Porter [Fri, 11 Apr 2025 16:28:51 +0000 (17:28 +0100)]
We never incref on the pythonconf_dict
The reference count is increased when the dictionary is added to the
module, and automatically removed when the module is freed as the
interpreter is freed.
Nick Porter [Fri, 11 Apr 2025 16:14:34 +0000 (17:14 +0100)]
With m_size = -1, freeradius module doesn't clear up correctly
Each module instance is getting it's own copy of the module, whereas
m_size = -1 implies it is global and causes a crash on exit when there
are multiple interpreters.
Alan T. DeKok [Wed, 9 Apr 2025 20:40:32 +0000 (16:40 -0400)]
remove bounce through tmpl code for %{...}
Instead, we create an XLAT_GROUP to hold the child xlat.
We then also create a "hoist" flag, which only exists for a
group node, and isn't in the flags.
update the debug printer to match.
Update the evaluation code to look for the "hoist' flag,
and then hoist the result instead of creating a value-box group.
Note that the result may be empty. In which case nothing is
added to the output dcursor. For xlat function arguments, this
highlights the need to have each argument expanded into its own
group.
Alan T. DeKok [Tue, 8 Apr 2025 22:29:12 +0000 (18:29 -0400)]
we don't allow unresolved xlats
it helps to return errors when there are error cases.
Disallow "foo." for list existence. Arguably "foo.[*]" is better.
the xlat condition / expression parser already replaces a bare
existence check with a %exists() wrapper. So the run-time code
doesn't need to expand the entire thing.
Alan T. DeKok [Sun, 6 Apr 2025 20:09:12 +0000 (16:09 -0400)]
we no longer need a macro for escape
rearrange the code so that the escaping is done first.
but we do assert that the value-boxes are not groups, in preparation
for updating the expression parser. Those changes mean that a
string which contains an xlat expansion will result in a group
of the component pieces. We can then escape each component piece
individually, before concatenating them into the resulting string.