Skip to content

Commit d33714a

Browse files
committed
Strip single quotes in container command output
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 2f86e86 commit d33714a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

single_kernel_postgresql/utils/filesystem.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ def has_correct_ownership_and_permissions(
4646
True if the file or directory has the correct ownership and permissions, False otherwise.
4747
"""
4848
if container is not None:
49-
owner = container.exec(["stat", "-c", "'%U'", path]).wait_output()[0].strip()
49+
owner = container.exec(["stat", "-c", "'%U'", path]).wait_output()[0].strip().strip("'")
5050
logger.debug(f"Owner of {path} in container is '{owner}'")
5151
# Check ownership.
5252
if owner != user:
5353
return False
5454
# Check permissions (convert to the octal base).
55-
permissions_str = container.exec(["stat", "-c", "'%a'", path]).wait_output()[0].strip()
55+
permissions_str = (
56+
container.exec(["stat", "-c", "'%a'", path]).wait_output()[0].strip().strip("'")
57+
)
5658
logger.debug(f"Permissions of {path} in container are '{permissions_str}'")
5759
return int(permissions_str, 8) == mode
5860

0 commit comments

Comments
 (0)