Check if skeleton is /dev/null while creating home folder (#75948)
* Check if skeleton is /dev/null while creating home folder * Add test for linux Co-authored-by: Holger Dörner <h.doerner@bitexpert.de> Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
bugfixes:
|
||||
- modules/user.py - Add check for valid directory when creating new user homedir (allows /dev/null as skeleton) (https://github.com/ansible/ansible/issues/75063)
|
||||
|
||||
@ -1273,7 +1273,7 @@ class User(object):
|
||||
else:
|
||||
skeleton = '/etc/skel'
|
||||
|
||||
if os.path.exists(skeleton):
|
||||
if os.path.exists(skeleton) and skeleton != os.devnull:
|
||||
try:
|
||||
shutil.copytree(skeleton, path, symlinks=True)
|
||||
except OSError as e:
|
||||
|
||||
@ -134,3 +134,21 @@
|
||||
name: randomuser
|
||||
state: absent
|
||||
remove: yes
|
||||
|
||||
- name: Create user home directory with /dev/null as skeleton, https://github.com/ansible/ansible/issues/75063
|
||||
# create_homedir is mostly used by linux, rest of OSs take care of it themselves via -k option (which fails this task)
|
||||
when: ansible_system == 'Linux'
|
||||
block:
|
||||
- name: "Create user home directory with /dev/null as skeleton"
|
||||
user:
|
||||
name: withskeleton
|
||||
state: present
|
||||
skeleton: "/dev/null"
|
||||
createhome: yes
|
||||
register: create_user_with_skeleton_dev_null
|
||||
always:
|
||||
- name: "Remove test user"
|
||||
user:
|
||||
name: withskeleton
|
||||
state: absent
|
||||
remove: yes
|
||||
|
||||
Reference in New Issue
Block a user