-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create parent dirs for useradd -m #2
Conversation
Code from pwdutils 3.2.2 with slight adaptations.
A polite ping - is this PR still of interest? |
|
||
path[0] = '\0'; | ||
bhome = strdup (user_home); | ||
++bhome; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check for strdup failure before incrementing here.
Thanks for doing this patch, sorry for the delay. Indeed it seems worth doing, although the alternative (for which there is an open debian bug) is to simply drop this functionality from shadow and have everyone switch to other implemenetations. |
Hi - one last ping; If no reply (or if you ask me to) I'll update the patch myself and apply. Thanks. |
path[0] = '\0'; | ||
bhome = strdup (user_home); | ||
++bhome; | ||
|
||
#ifdef WITH_SELINUX | ||
if (set_selinux_file_context (user_home) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more change - this set_selinux_file_context() must happen after the parent directories have been created, else it will apply to the parent directories we create.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes please, I've somewhat moved on from that code. Given my response latency, perhaps best if you roll your proposed changes in.
What's the current state of this PR? Is there still interest in adding this feature? |
Equivalent of `mkdir -p`. It will create all parent directories. Example: `useradd -d /home2/testu1 -m testu1` Based on shadow-maint#2 by Thorsten Kukuk and Thorsten Behrens which was Code from pwdutils 3.2.2 with slight adaptations.
Equivalent of `mkdir -p`. It will create all parent directories. Example: `useradd -d /home2/testu1 -m testu1` Based on shadow-maint#2 by Thorsten Kukuk and Thorsten Behrens which was Code from pwdutils 3.2.2 with slight adaptations. Adapted to so it applies to current code.
A crypt method needs to be specified before the rounds can set: #0 __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse4_2.S:227 shadow-maint#1 0x0000555555557755 in process_flags (argv=0x7fffffffe4d8, argc=3) at chgpasswd.c:188 shadow-maint#2 main (argc=3, argv=0x7fffffffe4d8) at chgpasswd.c:427 chgpasswd.c:188:42: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
A crypt method needs to be specified before the rounds can set: #0 __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse4_2.S:227 shadow-maint#1 0x0000555555557755 in process_flags (argv=0x7fffffffe4d8, argc=3) at chgpasswd.c:188 shadow-maint#2 main (argc=3, argv=0x7fffffffe4d8) at chgpasswd.c:427 chgpasswd.c:188:42: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
A crypt method needs to be specified before the rounds can set: #0 __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse4_2.S:227 shadow-maint#1 0x0000555555557755 in process_flags (argv=0x7fffffffe4d8, argc=3) at chgpasswd.c:188 shadow-maint#2 main (argc=3, argv=0x7fffffffe4d8) at chgpasswd.c:427 chgpasswd.c:188:42: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
Free the actual struct of the removed entry. Example userdel report: Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0x55b230efe857 in reallocarray (./src/userdel+0xda857) shadow-maint#1 0x55b230f6041f in mallocarray ./lib/./alloc.h:97:9 shadow-maint#2 0x55b230f6041f in commonio_open ./lib/commonio.c:563:7 shadow-maint#3 0x55b230f39098 in open_files ./src/userdel.c:555:6 shadow-maint#4 0x55b230f39098 in main ./src/userdel.c:1189:2 shadow-maint#5 0x7f9b48c64189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
A crypt method needs to be specified before the rounds can set: #0 __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse4_2.S:227 shadow-maint#1 0x0000555555557755 in process_flags (argv=0x7fffffffe4d8, argc=3) at chgpasswd.c:188 shadow-maint#2 main (argc=3, argv=0x7fffffffe4d8) at chgpasswd.c:427 chgpasswd.c:188:42: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
Free the actual struct of the removed entry. Example userdel report: Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0x55b230efe857 in reallocarray (./src/userdel+0xda857) #1 0x55b230f6041f in mallocarray ./lib/./alloc.h:97:9 #2 0x55b230f6041f in commonio_open ./lib/commonio.c:563:7 #3 0x55b230f39098 in open_files ./src/userdel.c:555:6 #4 0x55b230f39098 in main ./src/userdel.c:1189:2 #5 0x7f9b48c64189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
Code from pwdutils 3.2.2 with slight adaptations, under BSD-3-clause project license of course. Fixes the 'XXX - create missing parent directories. --marekm' problem.