From: James Carter <jwcart2@gmail.com>
To: Petr Lautrbach <plautrba@redhat.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH 1/2] sandbox: Do not try to remove tmpdir twice if uid == 0
Date: Fri, 4 Nov 2022 14:38:28 -0400 [thread overview]
Message-ID: <CAP+JOzR9MTP09ZNmPPhjA2+p-MYLSDOq35VVXY+D8oRBnYJQ7w@mail.gmail.com> (raw)
In-Reply-To: <20221013132312.294095-1-plautrba@redhat.com>
On Thu, Oct 13, 2022 at 9:24 AM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> 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>
For these two patches:
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.37.3
>
next prev parent reply other threads:[~2022-11-04 18:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 13:23 [PATCH 1/2] sandbox: Do not try to remove tmpdir twice if uid == 0 Petr Lautrbach
2022-10-13 13:23 ` [PATCH 2/2] sandbox: Use temporary directory for XDG_RUNTIME_DIR Petr Lautrbach
2022-11-04 18:38 ` James Carter [this message]
2022-11-09 13:46 ` [PATCH 1/2] sandbox: Do not try to remove tmpdir twice if uid == 0 James Carter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAP+JOzR9MTP09ZNmPPhjA2+p-MYLSDOq35VVXY+D8oRBnYJQ7w@mail.gmail.com \
--to=jwcart2@gmail.com \
--cc=plautrba@redhat.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).