From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 60890@debbugs.gnu.org
Subject: bug#60890: least-authority-wrapper and make-forkexec-constructor composition problem
Date: Thu, 19 Jan 2023 18:04:18 +0100 [thread overview]
Message-ID: <87pmba8nhp.fsf@gnu.org> (raw)
In-Reply-To: <87zgahyn5w.fsf@gmail.com> (Maxim Cournoyer's message of "Tue, 17 Jan 2023 14:30:03 -0500")
Hello!
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
> It was found that using something like:
>
> (make-forkexec-constructor
> (least-authority
> (list (file-append coreutils "/bin/true"))
> (mappings (delq 'user %namespaces))
> #:user "nobody"
> #:group "nobody"))
>
> Would fail with EPERM, because in order to be able to drop the user
> namespace, the CAP_SYS_ADMIN capability is required, but in the above
> case, make-forkexec-constructor has already changed the user to
> "nobody", which lacks such capability.
Thanks for the reminder!
I guess the problem is limited to cases where you need the program to
run in the global user namespace.
For example, Tor does not need to run in the global user namespace, and
thus does the following:
--8<---------------cut here---------------start------------->8---
(define (tor-shepherd-service config)
"Return a <shepherd-service> running Tor."
(let* ((torrc (tor-configuration->torrc config))
(tor (least-authority-wrapper
(file-append (tor-configuration-tor config) "/bin/tor")
#:name "tor"
#:mappings (list …)
#:namespaces (delq 'net %namespaces))))
(list (shepherd-service
(provision '(tor))
;; …
(start #~(make-forkexec-constructor
(list #$tor "-f" #$torrc)
#:user "tor" #:group "tor"))
(stop #~(make-kill-destructor))
(actions (list (shepherd-configuration-action torrc)))
(documentation "Run the Tor anonymous network overlay.")))))
--8<---------------cut here---------------end--------------->8---
Here ‘make-forkexec-constructor’ calls setuid/setgid before it invokes
the wrapped program, and everything’s fine.
Ludo’.
next prev parent reply other threads:[~2023-01-19 17:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 19:30 bug#60890: least-authority-wrapper and make-forkexec-constructor composition problem Maxim Cournoyer
2023-01-19 17:04 ` Ludovic Courtès [this message]
2023-01-20 13:42 ` Maxim Cournoyer
2024-11-12 5:54 ` Maxim Cournoyer
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=87pmba8nhp.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=60890@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.