Skip to content

Commit b779128

Browse files
committed
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 (cherry picked from commit 1fe983d)
1 parent 9a60b64 commit b779128

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docker/base/set_configs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import os
2121
import pwd
2222
import shutil
23+
import stat
2324
import sys
2425

2526

@@ -369,6 +370,15 @@ def set_perms(path, uid, gid, perm):
369370
perm = ''.join([perm[:1], 'o', perm[1:]])
370371
perm = int(perm, base=0)
371372

373+
# Ensure execute bit on directory if read bit is set
374+
if os.path.isdir(path):
375+
if perm & stat.S_IRUSR:
376+
perm |= stat.S_IXUSR
377+
if perm & stat.S_IRGRP:
378+
perm |= stat.S_IXGRP
379+
if perm & stat.S_IROTH:
380+
perm |= stat.S_IXOTH
381+
372382
try:
373383
os.chmod(path, perm)
374384
except OSError:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes set_configs.py configuring same permission for directories and files,
5+
causing directories lacking execute permission if not set for files.

0 commit comments

Comments
 (0)