Alan T. DeKok [Sun, 20 Aug 2023 14:33:52 +0000 (10:33 -0400)]
add immutable flag, and check it most places
the main purpose of immutable flags is to prevent users from
modifying values that the server wants to keep around.
As a result, the main checks for immutable values are in the
various editing routines:
src/lib/util/calc.c - cannot store results to immutable leaves
src/lib/util/edit.c - cannot edit immutable values
or delete immutable leaves from lists
src/lib/unlang/edit.c - cannot store to immutable leaves
Many of the internal value box / pair APIs will ignore the
immutable flag, and happily over-write values. This behavior
is likely good enough for now. The intention is to stop admins
from doing stupid things, and not to prevent the internal code
from doing what makes sense.
There is currently no flag in structural VPs which says "contains
an immutable child". The edit code therefore has to check each
time by walking the list recursively. That's fine for now.
There is as yet no code to set the immutable flag, or unit tests.
The goal is to have the decoders set the immutable flag as necessary,
which means that they don't need to save / restore attributes with
special meaning.
James Jones [Thu, 17 Aug 2023 19:34:23 +0000 (14:34 -0500)]
Switch from ntohs() to fr_nbo_to_uint16() (CID #1243443)
Takes advantage of coverity thinking fr_nbo_to_foo() taints
the passed pointer, which here is it's only use, while the
returned value is used several times.
So we change the "accounting" type to Interim-Update, and add
a unit test which verifies that any attempt to read Alive will
result in the server printing Interim-Update
Humans can figure out that
FR_DBUFF_REMAINING_RETURN(&foo, bar);
implies that one can safely write bar bytes to the dbuff foo,
but coverity can't. There's another use, in fr_tacacs_encode(),
but the following operations using the dbuff are checked there.
"my_peap_test" contains all the attributes we want to send
"my_peap_test_conf" contains the eapol test config
"my_peap_test_expected' contains the attributes we want to see , and whether it'll be an Access-Accept or Access-Reject
the python script needs to implement something similar to raduat, with how the test files are laid out
it needs to take "my_peap_test", "my_peap_test_conf", and figure out how to pass them to eapol_test (maybe using the radict)
i.e. how to get the attributes out of "my_peap_test" and pass them in a format eapol_test wants
passing the config and when eapol_test finishes, checking to see if the attributes it returned match "my_peap_test_expected"
Alan T. DeKok [Tue, 15 Aug 2023 12:26:07 +0000 (08:26 -0400)]
clear out old resume function and rctx
when we have two xlats in a row, the first one might need to be
resumed, so it pushes a resume ctx onto the stack. It then returns
"done", and the xlat evaluator goes to the next xlat node.
However, the next xlat node might _not_ push a resume function onto
the stack. So when the evaluator resumes, it will see the first
resume function and rctx, and call it again. Cue boom.
The solution is on DONE, replace the resume function / rctx with
a NULL one which does nothing.
Alan T. DeKok [Fri, 11 Aug 2023 13:33:27 +0000 (09:33 -0400)]
delay commas until necessary
we have a host of stopping conditions, which can be nested.
As a result, a simple `next != NULL` check isn't enough to
determine if we need to write out a comma. Instead, we delay
the comma until necessary.
Alan T. DeKok [Tue, 8 Aug 2023 14:30:04 +0000 (10:30 -0400)]
unify "attribute" and "pair" commands
the "attribute" command parsed a pair or a list of pairs, as did
the "pair" command. But the "pair" command did it manually, which
meant that it was unable to correctly deal with structural attributes
Alan T. DeKok [Mon, 7 Aug 2023 13:10:21 +0000 (09:10 -0400)]
add and use fr_pair_list_print()
so that we can hoist the "nested or not" debug printing into
this function. Which also lets this function peek ahead, and
print attributes as if they were nested when they really aren't
These are in calc_{string, octet}(), where coercion results stored
in locals must be cleared before returning. Currently coverity claims
that the value box's type is not set. One would think that modeling
fr_value_box_cast() to say it writes the destination on success would
suffice, but that might not be the case, so we will initialize the
value boxes just as we have done with some local buffers used in
sbuffs.