]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
server: Add experimental support for the ssh sub-command
authorMichal Sojka <michal.sojka@cvut.cz>
Thu, 24 Oct 2019 07:18:46 +0000 (09:18 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 24 Oct 2019 07:18:46 +0000 (09:18 +0200)
server/novaboot-shell

index 69fd78a319ca4f833f1141eedcee1650f0facf80..1842d7ae0201653f0d5a0196c1685259b4cdf692 100755 (executable)
@@ -16,6 +16,7 @@ Target commands:
 - off
 - rsync ...
 - get-config
+- ssh [options]
 
 Management commands:
 - help
@@ -114,6 +115,12 @@ run_subcommand() {
            eval exec "${on_cmd:?}";;
        "off")
            eval exec "${off_cmd:?}";;
+       "ssh"|"ssh "*)
+           shift
+           # TODO: sanitize ssh arguments
+           exec ssh "$@" "${ssh_dest:?}";;
+       *)
+           die "Unsupported command";;
     esac
 }
 
@@ -157,7 +164,7 @@ main() {
        # to the console. "The same user" means that we were executed by
        # the same sshd process that has the lock. This is ensured by
        # using SSH connection sharing on client side.
-       reset | rsync | on | off)
+       reset | rsync | on | off | ssh)
            ALLOWED_PPID=$(cat $RUN_DIR/ppid 2>/dev/null || :)
            if [ "$PPID" -eq "${ALLOWED_PPID:-0}" ]; then run=unlocked; else run=locked; fi
            $run $0 "$@";;