From da70158c2496f6f6bd34b7d7c9770252174ded37 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Fri, 17 Mar 2017 21:22:13 +0100 Subject: [PATCH] ssh_filter_btrbk: correctly handle --sudo option --- ChangeLog | 2 ++ doc/ssh_filter_btrbk.1 | 3 ++- ssh_filter_btrbk.sh | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e8f784..935920b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ btrbk-current * MIGRATION + - If you call ssh_filter_btrbk.sh with "--sudo" option, make sure + to set "backend btrfs-progs-sudo" in btrbk.conf for this host. - If "rate_limit" is enabled, update ssh_filter_btrbk.sh on remote source hosts, and make sure the "pv" command is available there. * Allow converting backup disks to source disks (close #114). diff --git a/doc/ssh_filter_btrbk.1 b/doc/ssh_filter_btrbk.1 index 305e0c2..dc15a2b 100644 --- a/doc/ssh_filter_btrbk.1 +++ b/doc/ssh_filter_btrbk.1 @@ -89,7 +89,8 @@ Log ACCEPT and REJECT messages to the system log. .PP \-\-sudo .RS 4 -Call SSH_ORIGINAL_COMMAND using sudo. +Allow btrfs commands to be called via sudo. Enable this if you have +"backend btrfs-progs-sudo" in your btrbk configuration file. .RE .SH AVAILABILITY Please refer to the btrbk project page \fBhttp://digint.ch/btrbk/\fR diff --git a/ssh_filter_btrbk.sh b/ssh_filter_btrbk.sh index b74677c..335a0d8 100755 --- a/ssh_filter_btrbk.sh +++ b/ssh_filter_btrbk.sh @@ -89,8 +89,12 @@ reject_filtered_cmd() } -# FIXME: "--sudo" must be set before all other options! +# check for "--sudo" option before processing other options sudo_prefix= +for key; do + [[ "$key" == "--sudo" ]] && sudo_prefix="sudo -n " +done + while [[ "$#" -ge 1 ]]; do key="$1" @@ -100,7 +104,7 @@ while [[ "$#" -ge 1 ]]; do ;; --sudo) - sudo_prefix="sudo -n " + # already processed above ;; -p|--restrict-path)