btrbk: add backend_local_user config option

lsbtr-related
Axel Burri 2020-09-22 14:24:40 +02:00
parent 13708abd00
commit e605bc7b42
2 changed files with 19 additions and 8 deletions

11
btrbk
View File

@ -131,6 +131,7 @@ my %config_options = (
backend => { default => "btrfs-progs", accept => [ "btrfs-progs", "btrfs-progs-btrbk", "btrfs-progs-sudo" ] },
backend_local => { default => undef, accept => [ "no", "btrfs-progs", "btrfs-progs-btrbk", "btrfs-progs-sudo" ] },
backend_remote => { default => undef, accept => [ "no", "btrfs-progs", "btrfs-progs-btrbk", "btrfs-progs-sudo" ] },
backend_local_user => { default => undef, accept => [ "no", "btrfs-progs", "btrfs-progs-btrbk", "btrfs-progs-sudo" ] },
compat => { default => undef, accept => [ "no", "busybox" ] },
compat_local => { default => undef, accept => [ "no", "busybox" ] },
@ -2603,8 +2604,14 @@ sub vinfo_cmd($$@)
my $cmd = shift || die;
my @cmd_args = @_;
my $ret;
my $backend = defined($vinfo->{HOST}) ? config_key($vinfo, "backend_remote") : config_key($vinfo, "backend_local");
$backend = $backend // config_key($vinfo, "backend") // die;
my $backend;
if(defined($vinfo->{HOST})) {
$backend //= config_key($vinfo, "backend_remote");
} else {
$backend //= config_key($vinfo, "backend_local_user") if($>); # $EUID, $EFFECTIVE_USER_ID
$backend //= config_key($vinfo, "backend_local");
}
$backend //= config_key($vinfo, "backend") // die;
my $cmd_mapped = $backend_cmd_map{$backend}{$cmd};
if(defined($cmd_mapped)) {
TRACE "vinfo_cmd: found mapping for backend=$backend cmd=\"$cmd\": " . join(' ', @$cmd_mapped) if($do_trace);

View File

@ -364,27 +364,31 @@ constraints.
*backend* btrfs-progs|btrfs-progs-btrbk|btrfs-progs-sudo::
Backend filesystem utilities to be used for btrfs specific
operations. Defaults to ``btrfs-progs''.
If you want to set this option for local or remote hosts only, you
can set *backend_local* or *backend_remote*
(e.g. "backend_remote btrfs-progs-btrbk").
+
--
btrfs-progs::
*btrfs-progs*::
Default backend, btrfs commands are called as specified in
btrfs(8) (e.g. "btrfs subvolume show").
btrfs-progs-btrbk::
*btrfs-progs-btrbk*::
btrfs commands are separated by a dash instead of a whitespace
(e.g. "btrfs-subvolume-show" instead of "btrfs subvolume
show"). Useful for setting suid or file capabilities (setcap) on
specific btrfs commands, as implemented in
<https://github.com/digint/btrfs-progs-btrbk>.
btrfs-progs-sudo::
*btrfs-progs-sudo*::
btrfs commands are prefixed with "sudo -n" (e.g. "sudo -n btrfs
subvolume show" instead of "btrfs subvolume show"). Make sure to
have appropriate (root) permissions for the "btrfs" command groups
as well as the "readlink" and "test" commands in /etc/sudoers.
If you want to set this option for local or remote hosts only, set
*backend_local* or *backend_remote* (e.g. "backend_remote
btrfs-progs-btrbk").
If you want to set this option for regular (non-root) user only, set
*backend_local_user*.
--
+