diff options
| author | Michal Arbet <michal.arbet@ultimum.io> | 2026-05-16 15:05:48 +0200 |
|---|---|---|
| committer | Michal Arbet <michal.arbet@ultimum.io> | 2026-07-01 18:11:49 +0200 |
| commit | 505428fd51f3801c39850437f908fcf106a8fc94 (patch) | |
| tree | 57381e569d3ab3be7992bae58337acdb3137a684 /docker | |
| parent | 108660d64406067b5d066c612f5de882d45b0e24 (diff) | |
| download | kolla-505428fd51f3801c39850437f908fcf106a8fc94.tar.gz kolla-505428fd51f3801c39850437f908fcf106a8fc94.zip | |
Fix parsing of permissions with special bits
kolla_set_configs currently fails to parse permissions
such as 2775 because only legacy values like 0755 are
converted to Python octal notation.
Accept standard UNIX permission notation for
permissions with special mode bits such as SGID, SUID,
and sticky bit.
Change-Id: I5937a17b0d70f9c1db4b2617854d0180c37fe2c0
Closes-Bug: #2154269
Needed-By: https://review.opendev.org/c/openstack/kolla-ansible/+/989850
Signed-off-by: Michal Arbet <michal.arbet@ultimum.io>
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/base/set_configs.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index 542537e4c..c0a4af76c 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -410,11 +410,20 @@ def handle_permissions(config): path, uid, gid) if perm: - # NOTE(Jeffrey4l): py3 need '0oXXX' format for octal literals, - # and py2 support such format too. - if len(perm) == 4 and perm[1] != 'o': - perm = ''.join([perm[:1], 'o', perm[1:]]) - perm = int(perm, base=0) + # Accept valid UNIX permission notation + # (e.g. 644, 0600, 1777, 2755) + # or equivalent Python octal literals + # (e.g. 0o644, 0o1777, 0o2755). + if re.fullmatch(r'[0-7]{3,4}', perm): + perm = int(perm, 8) + elif re.fullmatch(r'0o[0-7]{3,4}', perm): + perm = int(perm, 0) + else: + raise ValueError( + f"Invalid permission '{perm}'. Expected a valid UNIX " + "permission (e.g. 644, 0600, 2755) or a Python octal " + "literal (e.g. 0o644, 0o0600, 0o2755)." + ) # Ensure execute bit on directory if read bit is set if os.path.isdir(path): |
