]> git.ipfire.org Git - thirdparty/systemd.git/commit
nsresourced: re-link GID delegation file after atomic UID file write
authorDaan De Meyer <daan@amutable.com>
Wed, 13 May 2026 10:21:10 +0000 (12:21 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 13 May 2026 22:51:41 +0000 (23:51 +0100)
commit95e7ead268736d8a0e71d2f6fb7a5e54247d82da
treee2fc7673f40e733956bbe91a510910fc206abfe3
parenta4424403153761c365d50522d075c1d0090d7503
nsresourced: re-link GID delegation file after atomic UID file write

userns_registry_remove() restores a sub-delegated UID range by writing
the previous owner's data to u<UID>.delegate with WRITE_STRING_FILE_ATOMIC.
Atomic writes go via a temp file and rename, which replaces the directory
entry with a fresh inode and severs the hardlink to g<GID>.delegate. The
stale GID side then keeps pointing at the prior inode with outdated owner
and ancestor data, so subsequent lookups via GID return wrong results.

Re-create the hardlink after the atomic write so the two views stay in
sync, matching what userns_registry_store() already does after writing
a new delegation.
src/nsresourced/userns-registry.c