PAM allows to use sufficent
and required
for some logic, like
auth sufficient pam_a.so
auth required pam_b.so
auth required pam_c.so
which would mean "either a is true, or b must be true and then c must be true".
Is it possible to do more complex operations? like "(a or b) and (c or d)" or "(a and b) or (c and d)"? Possibly with even more layers of parenthesis.
Yes, there is logic for being able to skip over arbitrary numbers of lines. There are no "grouping brackets" or anything of the sort, but if you combine the logic that you just mentioned with the ability to skip over lines, you can selectively exclude behavior.
Here's an example from my personal server:
I don't really need two-factor authentication if the source IP is coming from my local network, so I'm using the outcome of the
pam_access.so
check to skip exactly one line on success. If the check fails, nothing happens and the next line is checked.You can find more about this in the
pam.conf
manpage. Search for "value1". The section starts off like so:Keep in mind that this logic is much more complex, and if people edit your PAM configurations without noting the presence of line skipping they can cause all kinds of chaos by adding or removing lines in the wrong places.