]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
vipw: Set correct pattern for fmkomstemp
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 14 Jan 2026 21:58:51 +0000 (22:58 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Wed, 14 Jan 2026 22:41:40 +0000 (23:41 +0100)
The fmkomstemp call requires a suffix of XXXXXX for correct operation.
Do so in TCB case as well.

Note: If something fails and the file resides in this directory, it
could be interpreted as a username. Use the ',' character as an illegal
character to prevent shadow tools from erroneously accessing this file
and assuming that the user actually exists.

Fixes: a5b3d56e2902 (2026-01-09; "vipw: Use fmkomstemp for temporary file")
Reported-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/vipw.c

index 05850423e7f2688b52822600ed6e3faf2271d006..cf574c9dba3301f58bc1a8570ff40c2a6f29b495 100644 (file)
@@ -426,7 +426,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
                if (stat (file, &st1) != 0) {
                        vipwexit (_("failed to stat edited file"), errno, 1);
                }
-               to_rename = aprintf("%s+", file);
+               to_rename = aprintf("%s,XXXXXX", file);
                if (to_rename == NULL)
                        vipwexit (_("aprintf() failed"), errno, 1);