Bug 14431

Summary: adduser will add a user folder with 'shadow_t'
Product: Busybox Reporter: 15256067679
Component: Standard ComplianceAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description 15256067679 2021-12-07 07:30:31 UTC
I compile the busybox with SELinux support(I tried both with 1.33.x and 1.34.1), then I try to use adduser to create a new user:

# adduser user_1
Changing password for user_1
New password:
Bad password: too weak
Retype password:
Passwords don't match
passwd: password for user_1 is unchanged
# cd /home/
# ls -Z
system_u:object_r:user_home_dir_t:s0 default
system_u:object_r:shadow_t:s0    user_1

and I check the source code in adduser.c:

the function 'selinux_preserve_fcontext(old_fd)'in 'update_passwd(bb_path_shadow_file, pw.pw_name, p, NULL);' will change the filecontext for the file that adduser make to 'shadow_t' and I can't find where to change it back.