From: Axel Burri <axel@tty0.ch>
To: linux-btrfs@vger.kernel.org
Subject: btrfs-progs: separated binaries with elevated privileges (proof-of-concept)
Date: Fri, 6 May 2016 18:31:52 +0200 [thread overview]
Message-ID: <61dd446f-2201-e22c-452e-0e4702da8fbf@tty0.ch> (raw)
(see links to patchset at end of mail)
While btrfs-progs offer the all-inclusive "btrfs" command, it gets
pretty cumbersome to restrict privileges to the subcommands. Common
approaches are to either setuid root for "/sbin/btrfs" (which is not
recommended at all), or to write special sudo rules for each subcommand
needed.
As a sysadmin, I like to see separate binaries for each task, so that I
can easily set elevated privileges (capabilities or setuid) on each of
them. A typical use case where this is needed is when it comes to
automated scripts, in my case creating snapshots and send/receive them
via ssh (automated by btrbk).
I hacked a little proof-of-concept on top of btrfs-progs, which adds
some extra binaries for specific tasks, with the result looking like this:
# ls -l /usr/bin/btrfs-*
-rwxr-x--- 1 root btrfs [...] /usr/bin/btrfs-receive
-rwxr-x--- 1 root btrfs [...] /usr/bin/btrfs-send
-rwxr-x--- 1 root btrfs [...] /usr/bin/btrfs-subvolume-list
-rwxr-x--- 1 root btrfs [...] /usr/bin/btrfs-subvolume-show
-rwxr-x--- 1 root btrfs [...] /usr/bin/btrfs-subvolume-snapshot
# getcap /usr/bin/btrfs-*
/usr/bin/btrfs-receive =
cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_sys_admin,cap_mknod+ep
/usr/bin/btrfs-send = cap_dac_read_search,cap_sys_admin+ep
/usr/bin/btrfs-subvolume-list = cap_dac_read_search,cap_sys_admin+ep
/usr/bin/btrfs-subvolume-show = cap_dac_read_search,cap_sys_admin+ep
/usr/bin/btrfs-subvolume-snapshot =
cap_dac_override,cap_dac_read_search,cap_fowner,cap_sys_admin+ep
On the remote hosts I now simply need to install these binaries (e.g.
"btrfs-subvolume-snapshot" and "btrfs-send" for backup sources), and
make sure the user calling them is in the 'btrfs' group. This gives me a
good feeling of a simple and secure system.
The patch needed to achieve this is pretty straight-forward, and if you
are interested I will gladly work on a clean implementation for btrfs-progs.
The patchset (proof-of-concept) is here:
https://github.com/digint/btrfs-progs/tree/separated_executables
Complete diff to v4.5.2 here:
https://github.com/digint/btrfs-progs/compare/master...digint:separated_executables
A (also very experimental) gentoo ebuild for this is available in
digint-overlay, "sys-fs/btrfs-progs-suid":
git://dev.tty0.ch/portage/digint-overlay.git
reply other threads:[~2016-05-06 16:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=61dd446f-2201-e22c-452e-0e4702da8fbf@tty0.ch \
--to=axel@tty0.ch \
--cc=linux-btrfs@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).