useradd: Only apply USRSKEL if the default SKEL is used - #1716
Conversation
Historically useradd(8) copied skeleton files from the directory specified by SKEL. Since 74c17c7 (release 4.14.0) it also copies files from USRSKEL. If an admin explicitly specifies an alternative skeleton directory using -k (for instance, to create an empty home directory with `-k /var/lib/empty`), the files from USRSKEL are still unconditionally merged in. If the user has explicitly requested an alternative skeleton directory we shouldn't silently merge in files from USRSKEL behind their back. However if they specify `-k /etc/skel` (explicitly requesting the default skeleton), they most likely still expect USRSKEL to be merged. With this commit we only copy the USRSKEL files when the selected skeleton directory matches the default. Resolves: https://bugzilla.suse.com/show_bug.cgi?id=1191490 Fixes: 74c17c7 (2022-11-09; "Add support for skeleton files from /usr/etc/skel") Signed-off-by: Michael Vetter <jubalh@iodoru.org>
|
Thanks! The source code LGTM. I prefer if @hallyn could have a look at it too, since he was involved in the original patch (the one we're fixing). |
|
On Tue, Aug 18, 2026 at 03:11:09AM -0700, Alejandro Colomar wrote:
alejandro-colomar left a comment (shadow-maint/shadow#1716)
Thanks! The source code LGTM.
I prefer if @hallyn could have a look at it too, since he was involved in the original patch (the one we're fixing).
How about just checking kflg? I know the user could enter
the default as kflg option, but then who knows what they
really meant in that case anyway.
I mainly think checking kflg will be easier to understand
to future readers.
|
I'm not sure I understand. Would you mind showing some diff? (Or maybe using more/different words to clarify it?) |
Historically useradd(8) copied skeleton files from the directory specified by SKEL.
Since 74c17c7 (release 4.14.0) it also copies files from USRSKEL.
If an admin explicitly specifies an alternative skeleton directory using -k (for instance, to create an empty home directory with
-k /var/lib/empty), the files from USRSKEL are still unconditionally merged in.If the user has explicitly requested an alternative skeleton directory we shouldn't silently merge in files from USRSKEL behind their back.
However if they specify
-k /etc/skel(explicitly requesting the default skeleton), they most likely still expect USRSKEL to be merged.With this commit we only copy the USRSKEL files when the selected skeleton directory matches the default.
Resolves: https://bugzilla.suse.com/show_bug.cgi?id=1191490
Fixes: 74c17c7 (2022-11-09; "Add support for skeleton files from /usr/etc/skel")