]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: call dynamic_user_acquire() only when 'group' is non-null 14747/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Feb 2020 11:18:02 +0000 (20:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Feb 2020 12:51:07 +0000 (21:51 +0900)
commit50152bb1c5c311e97e9eeec3b09044925b6e3663
treeb44f6ce67f8708b6505787a9593d53ac7a665952
parent4c1dea42b593fdee8121c51f113e7cb2918cf264
core: call dynamic_user_acquire() only when 'group' is non-null

When unit is reloaded, and the reloaded unit has bad-setting, then
unit_patch_contexts() is not called and exec_context::user and group
may not be configured.

A minimum reproducer for the case is:
- step 1.
$ sudo systemctl edit --full hoge.service
[Service]
oneshot
ExecStart=sleep 1h

- step 2.
$ sudo systemctl start hoge.service

- step 3.
$ sudo systemctl edit --full hoge.service
[Service]
Type=oneshot
ExecStart=@bindir@/sleep 1h
DynamicUser=yes

Then pid1 crashed.

Fixes #14733.
src/core/dynamic-user.c