]> git.ipfire.org Git - thirdparty/shadow.git/commit
passwd: Unify (un)locking routines
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 15 Dec 2025 16:08:05 +0000 (17:08 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Tue, 16 Dec 2025 12:22:43 +0000 (13:22 +0100)
commit5719f1ec5397e4634f1ca1f714f2dfa3eb914fde
treeea4f9240af01d1dce8f038b4f956e7894dc50c12
parent969698a55d17914df68ea9798c9895a4087aa20f
passwd: Unify (un)locking routines

Make sure that passwd and shadow are always opened in the correct
order to avoid possible dead locks with other tools:

- Lock passwd first, then shadow
- Unlock shadow first, then passwd

The passwd utility may work without a shadow entry. In that case, it
operates on the passwd file. But to figure this out, the shadow file
must have been opened and thus locked already. Unconditionally open the
passwd file first, even though it's not needed most of the time.

Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/passwd.c