URI: 
       New option for using sudo/doas on remote server - drist - a remote deployment tool
  HTML git clone git://bitreich.org/drist/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/drist/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit c9735fd7d912dbca6e03c2725456d4eeb6d9487b
   DIR parent 723d94faa06c4597f88ccfdcf7821154bf889138
  HTML Author: Solene Rapenne <solene@perso.pw>
       Date:   Thu, 29 Nov 2018 08:20:10 +0100
       
       New option for using sudo/doas on remote server
       
       Diffstat:
         M drist                               |      46 +++++++++++++++++++++++++------
         M drist.1                             |      14 ++++++++++++--
       
       2 files changed, 49 insertions(+), 11 deletions(-)
       ---
   DIR diff --git a/drist b/drist
       @@ -1,8 +1,36 @@
        #!/bin/sh
        
       +usage() {
       +        echo "$0 [-s [-e sudo|doas]] server"
       +        exit 0
       +}
       +
       +
       +while getopts se: arg; do
       +        case ${arg} in
       +                s) SUDO=1 ;;
       +                e) SUDO_BIN="${OPTARG}" ;;
       +                *) usage ;;
       +        esac
       +done
       +shift $((OPTIND - 1))
       +
       +# allow to use a privilege escalation program
       +if [ "$SUDO" -eq 1 ]
       +then
       +        # defaulting to sudo
       +        if [ -z "$SUDO_BIN" ]
       +        then
       +                SUDO_BIN=sudo
       +        fi
       +        EXEC="$SUDO_BIN"
       +else
       +        EXEC=""
       +fi
       +
       +# check if host exists
        if [ "$#" -ne 1 ]; then
       -        echo "You should pass a server as a parameter"
       -        exit 1
       +        usage
        else
                HOSTNAME=$(ssh "$1" "uname -n")
                if [ "$?" -ne 0 ]; then
       @@ -22,7 +50,7 @@ copy_files() {
                        then
                                printf 'Copying files:\n'
                                find "${1}"/ -type f | cut -d '/' -f 2- | tee "${LIST}"
       -                        rsync -lD --files-from="${LIST}" "${1}/" "${2}":/
       +                        rsync --rsync-path="${EXEC} rsync" -lD --files-from="${LIST}" "${1}/" "${2}":/
                                rm "$LIST"
                        fi
                fi
       @@ -34,11 +62,11 @@ remote_script() {
                if [ -f "${1}" ]
                then
                        printf 'Executing script\n'
       -                ssh "${2}" 'DRIST=$(mktemp /tmp/drist.XXXXXXXXXXXX) &&
       -                    cat - > "$DRIST" &&
       -                    chmod u+x "$DRIST" &&
       -                    "$DRIST" ;
       -                    rm "$DRIST"' < "$1"
       +                ssh "${2}" "DRIST=$(mktemp /tmp/drist.XXXXXXXXXXXX) &&
       +                    cat - > \$DRIST &&
       +                    chmod u+x \$DRIST &&
       +                    ${EXEC} \$DRIST ;
       +                    rm \$DRIST" < "$1"
                fi
        }
        
       @@ -54,7 +82,7 @@ delete_files() {
                                printf 'Removing files:\n' 
                                find "$1" -type f | sed 's/"/\\&/' | \
                                        awk -v path="${1}" '{ printf "\"%s\" ",substr($0,length(path)+1)}' > "${LIST}"
       -                        test -s "$LIST" && ssh "$2" "rm -v $(cat $LIST)"
       +                        test -s "$LIST" && ssh "$2" "${EXEC} rm -v $(cat $LIST)"
                        fi
                fi
        }
   DIR diff --git a/drist.1 b/drist.1
       @@ -6,7 +6,18 @@
        .Nd dumb remote installer shell tool, a remote deployment tool
        .Sh SYNOPSIS
        .Nm
       +.Op Fl s Op Fl e Ar sudo|doas
        .Ar server
       +.Sh OPTIONS
       +.Op Fl s
       +use a program to execute a command as root on the remote server.
       +Default is sudo.
       +
       +.Op Fl e Ar binary
       +binary to use for executing the commands as root.
       +This flag is only useful when used with
       +.Fl s .
       +
        .Sh DESCRIPTION
        .Nm
        is a tool to configure remote servers using
       @@ -14,8 +25,7 @@ is a tool to configure remote servers using
        and
        .Xr rsync 1 .
        .Nm
       -has been designed to be simple, so it may not offer all the features
       -you want.
       +has been designed to be simple, so it may not offer all the features you want.
        .Pp
        When you run
        .Nm