Bug 53262 - Syntax-Error in /etc/freeradius/3.0/mods-available/ldap when admin password contains "
Syntax-Error in /etc/freeradius/3.0/mods-available/ldap when admin password c...
Status: NEW
Product: UCS
Classification: Unclassified
Component: Radius
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UCS maintainers
UCS maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-05-16 07:37 CEST by Raoul Borenius
Modified: 2021-05-29 17:38 CEST (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raoul Borenius 2021-05-16 07:37:18 CEST
During Install of "unvention-radius" the LDAP admin password is written to /etc/freeradius/3.0/mods-available/ldap

In our case the password contains a " character, the resulting entry in
/etc/freeradius/3.0/mods-available/ldap looks like this:

password = "somecharacters"somemorecharacters"

which is not a valid syntax. Freeradius generates the following startup error:

freeradius[12462]: /etc/freeradius/3.0/mods-enabled/ldap[42]: Syntax error: Expected comma after 'somecharacters': somemorecharacters"

Workaround: manually change to

password = 'somecharacters"somemorecharacters'

 (but will be reversed by "ucr commit ldap")
Comment 1 Raoul Borenius 2021-05-29 09:52:43 CEST
My suggested fix is of course not working if the generated machine.secret turns out to
contain a ' instead of an ".

So the better fix is to not allow the "-character as part of the machine secret.

Unfortunately create_machine_password () in /usr/share/univention-lib/base.sh does
not exclude that character. And it does not honour the UCR variable password/quality/forbidden/chars so there is currently no work around except modifying
/usr/share/univention-lib/base.sh
Comment 2 Raoul Borenius 2021-05-29 14:59:22 CEST
instead of editing /usr/share/univention-lib/base.sh you can redefine create_machine_password () in an own file:

#
# /usr/share/univention-lib/zz-bug-53262.sh
#
create_machine_password () {
        local length="$(/usr/sbin/univention-config-registry get machine/password/length)"
        local compl="$(/usr/sbin/univention-config-registry get machine/password/complexity)"

        if [ -z "$length" ]; then
                length=20
        fi
        if [ -z "$compl" ]; then
                compl="scn"
        fi

        pwgen -1 -${compl} ${length} -r\" | tr -d '\n'
}
Comment 3 Philipp Hahn univentionstaff 2021-05-29 17:38:35 CEST
create_machine_password() is used in many places, where each use would further limit the set of allowed characters.

Instead of limiting the character set do proper string escaping as documented in <https://freeradius.org/radiusd/man/unlang.html>.