user-util: rework how we validate user names
authorLennart Poettering <lennart@poettering.net>
Sat, 4 Apr 2020 10:23:02 +0000 (12:23 +0200)
committerMichael Biebl <biebl@debian.org>
Fri, 10 Apr 2020 09:55:15 +0000 (10:55 +0100)
commit57e620cd523dc3abba8e376e2ff8431808731327
tree8af91a6ec70625db9d19c21dda6bdd243d5b269e
parentf953a7c937c0640b8269c2b8134dd4a4261373a0
user-util: rework how we validate user names

This reworks the user validation infrastructure. There are now two
modes. In regular mode we are strict and test against a strict set of
valid chars. And in "relaxed" mode we just filter out some really
obvious, dangerous stuff. i.e. strict is whitelisting what is OK, but
"relaxed" is blacklisting what is really not OK.

The idea is that we use strict mode whenever we allocate a new user
(i.e. in sysusers.d or homed), while "relaxed" mode is when we process
users registered elsewhere, (i.e. userdb, logind, …)

The requirements on user name validity vary wildly. SSSD thinks its fine
to embedd "@" for example, while the suggested NAME_REGEX field on
Debian does not even allow uppercase chars…

This effectively liberaralizes a lot what we expect from usernames.

The code that warns about questionnable user names is now optional and
only used at places such as unit file parsing, so that it doesn't show
up on every userdb query, but only when processing configuration files
that know better.

Fixes: #15149 #15090
(cherry picked from commit 7a8867abfab10e5bbca10590ec2aa40c5b27d8fb)

Gbp-Pq: Name user-util-rework-how-we-validate-user-names.patch
23 files changed:
src/basic/user-util.c
src/basic/user-util.h
src/core/dbus-execute.c
src/core/dbus-manager.c
src/core/dbus-socket.c
src/core/dbus-util.c
src/core/dbus-util.h
src/core/dynamic-user.c
src/core/load-fragment.c
src/core/unit.c
src/home/home-util.c
src/home/homectl.c
src/home/homed-manager-bus.c
src/home/pam_systemd_home.c
src/nss-systemd/nss-systemd.c
src/shared/group-record.c
src/shared/json.c
src/shared/json.h
src/shared/user-record.c
src/shared/userdb.c
src/systemd/sd-messages.h
src/sysusers/sysusers.c
src/test/test-user-util.c