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
This commit is contained in:
Jakub Darmach 2022-01-27 14:39:54 +01:00 committed by Michal Nasiadka
parent d7dde02653
commit 1fe983df4f
2 changed files with 15 additions and 0 deletions

View File

@ -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:

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes set_configs.py configuring same permission for directories and files,
causing directories lacking execute permission if not set for files.