577b79db7e
- Rebase on upstream f56a72ac9e86 - sepolicy: fix sepolicy manpage -w - sandbox: add -R option to alternate XDG_RUNTIME_DIR - Remove dependency on the Python module distutils
36 lines
1.2 KiB
Diff
36 lines
1.2 KiB
Diff
From 0fb988c86b66ede7723e179699e29f00000fc57b Mon Sep 17 00:00:00 2001
|
|
From: Petr Lautrbach <plautrba@redhat.com>
|
|
Date: Thu, 13 Oct 2022 15:23:11 +0200
|
|
Subject: [PATCH] sandbox: Do not try to remove tmpdir twice if uid == 0
|
|
Content-type: text/plain
|
|
|
|
If the user is root, tmpdir is already wiped out.
|
|
|
|
Fixes:
|
|
# sandbox -T /root/tmp -- id
|
|
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:sandbox_t:s0:c696,c756
|
|
Failed to remove directory /tmp/.sandbox-root-KIlB59: No such file or directory
|
|
|
|
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
|
|
Acked-by: James Carter <jwcart2@gmail.com>
|
|
---
|
|
sandbox/seunshare.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/sandbox/seunshare.c b/sandbox/seunshare.c
|
|
index 8917a0f9bd42..dd1d7ddbdc89 100644
|
|
--- a/sandbox/seunshare.c
|
|
+++ b/sandbox/seunshare.c
|
|
@@ -414,7 +414,7 @@ static int cleanup_tmpdir(const char *tmpdir, const char *src,
|
|
rc++;
|
|
}
|
|
|
|
- if (rmdir(tmpdir) == -1)
|
|
+ if (pwd->pw_uid != 0 && rmdir(tmpdir) == -1)
|
|
fprintf(stderr, _("Failed to remove directory %s: %s\n"), tmpdir, strerror(errno));
|
|
if ((uid_t)setfsuid(pwd->pw_uid) != 0) {
|
|
fprintf(stderr, _("unable to switch back to user after clearing tmp dir\n"));
|
|
--
|
|
2.38.1
|
|
|