1
1
Fork 1
mirror of https://github.com/nachoparker/btrfs-sync synced 2024-04-23 08:05:04 +02:00

Check for sudo (#14)

* Ensuring bash to be used by remote user

Signed-off-by: jenszo <6693266+jenszo@users.noreply.github.com>

* missed the executable bit. my bad

Signed-off-by: jenszo <6693266+jenszo@users.noreply.github.com>

* Checking for sudo privileges for remote user up front

Signed-off-by: jenszo <6693266+jenszo@users.noreply.github.com>
This commit is contained in:
Jens Nachtigall 2021-11-01 16:07:24 +00:00 committed by GitHub
parent c4bdbf2117
commit 43f0fcb6b8
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

6
btrfs-sync Normal file → Executable file
View File

@ -132,6 +132,12 @@ ${DST_CMD[@]} test -x "$DST" &>/dev/null || {
pgrep -F /run/btrfs-sync.pid &>/dev/null && { echo "$BIN is already running"; exit 1; }
echo $$ > /run/btrfs-sync.pid
## Make sure, the user's remote shell is bash (not sh)
${DST_CMD[@]} "echo \$0 | grep bash > /dev/null" || { echo "Remote user's shell not bash. Shells other than bash are not supported at the moment"; exit 1; }
## Making sure, the remote user has sudo privileges
${DST_CMD[@]} "sudo echo &> /dev/null" || { echo "Remote user requires sudo privileges"; exit 1; }
${DST_CMD[@]} "pgrep -f btrfs\ receive &>/dev/null" && { echo "btrfs-sync already running at destination"; exit 1; }
## src checks