From 1fe983df4fafa5a4a8eafe206e4abfaec2418da1 Mon Sep 17 00:00:00 2001 From: Jakub Darmach Date: Thu, 27 Jan 2022 14:39:54 +0100 Subject: Ensure set_configs sets execute bit on directories While handling permissions for directories, set_configs.py configures them same as for files - i.e. 0640 set in config.json which works fine for file will cause any potential subdirectories to lack traverse permission. Check and permission change was added to handle_permissions function to add +x if +r is present for user, group, others. Change-Id: Ic6e3ae4ff40c6ce5a5c0646ed309a2938903f6c0 --- docker/base/set_configs.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docker') diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index 0cb0e414c..e624f29ba 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -20,6 +20,7 @@ import logging import os import pwd import shutil +import stat import sys @@ -369,6 +370,15 @@ def handle_permissions(config): perm = ''.join([perm[:1], 'o', perm[1:]]) perm = int(perm, base=0) + # Ensure execute bit on directory if read bit is set + if os.path.isdir(path): + if perm & stat.S_IRUSR: + perm |= stat.S_IXUSR + if perm & stat.S_IRGRP: + perm |= stat.S_IXGRP + if perm & stat.S_IROTH: + perm |= stat.S_IXOTH + try: os.chmod(path, perm) except OSError: -- cgit v1.2.3