Skip to content

useradd: Only apply USRSKEL if the default SKEL is used - #1716

Open
jubalh wants to merge 1 commit into
shadow-maint:masterfrom
jubalh:skel
Open

useradd: Only apply USRSKEL if the default SKEL is used#1716
jubalh wants to merge 1 commit into
shadow-maint:masterfrom
jubalh:skel

Conversation

@jubalh

@jubalh jubalh commented Aug 10, 2026

Copy link
Copy Markdown
Member

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")

Comment thread src/useradd.c Outdated
Comment thread src/useradd.c Outdated
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>
@alejandro-colomar

Copy link
Copy Markdown
Collaborator

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).

@hallyn

hallyn commented Aug 18, 2026 via email

Copy link
Copy Markdown
Member

@alejandro-colomar

alejandro-colomar commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants