Skip to content

Commit

Permalink
set recursive=False for ensure_dir when os.path.dirname(path) is "/"
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoge1001 committed Oct 17, 2024
1 parent a8f6940 commit 57113a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,11 @@ def ensure_dir(path, mode=None, user=None, group=None):
# Get non existed parent dir first before they are created.
non_existed_parent_dir = get_non_exist_parent_dir(path)
# Make the dir and adjust the mode
with SeLinuxGuard(os.path.dirname(path), recursive=True):
dir_name = os.path.dirname(path)
selinux_recursive = True
if dir_name == "/":
selinux_recursive = False
with SeLinuxGuard(dir_name, recursive=selinux_recursive):
os.makedirs(path)
chmod(path, mode)
# Change the ownership
Expand Down

0 comments on commit 57113a6

Please sign in to comment.