mirror of https://github.com/digint/btrbk
btrbk: fix regression: call "sudo readlink" for backend=btrfs-progs-sudo
It is possible that the subvolume path is not accessible by the user calling btrbk. When resolving mount points, "readlink" is used on the path, which also needs to be wrapped with "sudo".pull/274/head
parent
ff011d55af
commit
0e6c1f9025
4
btrbk
4
btrbk
|
@ -232,6 +232,7 @@ my %backend_cmd_map = (
|
|||
"btrfs receive" => [ "sudo", "-n", "btrfs", "receive" ],
|
||||
"btrfs filesystem usage" => [ "sudo", "-n", "btrfs", "filesystem", "usage" ],
|
||||
"btrfs qgroup destroy" => [ "sudo", "-n", "btrfs", "qgroup", "destroy" ],
|
||||
"readlink" => [ "sudo", "-n", "readlink" ],
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -1813,7 +1814,7 @@ sub system_realpath($)
|
|||
|
||||
my $path = $vol->{PATH} // die;;
|
||||
my @quiet = ($loglevel < 3) ? ('-q') : ();
|
||||
my $ret = run_cmd(cmd => [ qw(readlink), '-e', @quiet, { unsafe => $path } ],
|
||||
my $ret = run_cmd(cmd => vinfo_cmd($vol, "readlink", '-e', @quiet, { unsafe => $path } ),
|
||||
rsh => vinfo_rsh($vol),
|
||||
non_destructive => 1,
|
||||
);
|
||||
|
@ -2429,7 +2430,6 @@ sub vinfo_cmd($$@)
|
|||
}
|
||||
else {
|
||||
my @ret_cmd = split(/\s/, $cmd);
|
||||
die unless($ret_cmd[0] eq 'btrfs');
|
||||
TRACE "vinfo_cmd: no mapping found for backend=$backend cmd=\"$cmd\", assuming btrfs-progs: " . join(' ', @ret_cmd);
|
||||
$ret = [ @ret_cmd, @cmd_args ];
|
||||
}
|
||||
|
|
|
@ -345,8 +345,8 @@ btrfs-progs-btrbk::
|
|||
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 "btrfs" command groups in
|
||||
/etc/sudoers.
|
||||
have appropriate (root) permissions for the "btrfs" command groups
|
||||
and the "readlink" command in /etc/sudoers.
|
||||
--
|
||||
+
|
||||
For convenience, it is also possible to set *backend_local* or
|
||||
|
|
|
@ -163,7 +163,7 @@ done
|
|||
|
||||
allow_cmd "${sudo_prefix}btrfs subvolume show"; # subvolume queries are always allowed
|
||||
allow_exact_cmd "${sudo_prefix}btrfs subvolume list ${file_match}"; # subvolume queries are always allowed
|
||||
allow_cmd "readlink" # used to resolve mountpoints
|
||||
allow_cmd "${sudo_prefix}readlink" # used to resolve mountpoints
|
||||
allow_exact_cmd "cat /proc/self/mountinfo" # used to resolve mountpoints
|
||||
allow_exact_cmd "cat /proc/self/mounts" # legacy, for btrbk < 0.27.0
|
||||
|
||||
|
|
Loading…
Reference in New Issue