Skip to content

Commit

Permalink
chore: set recursive=False for ensure_dir if parent path is "/" (#5816)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoge1001 authored Nov 13, 2024
1 parent fad9475 commit b3120f7
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 b3120f7

Please sign in to comment.