]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
server: Fix handling of multi-word commands (rsync) without authorized_keys command...
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 3 Sep 2017 14:22:39 +0000 (16:22 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 3 Sep 2017 14:25:36 +0000 (16:25 +0200)
server/novaboot-shell
tests/server.wv

index 1fad21b347cd6cdd918ae8b629a5296a7d29b99a..22f4b54455214e14d8b5f45a4e555d0907e55b70 100755 (executable)
@@ -111,13 +111,15 @@ run_subcommand() {
 }
 
 main() {
-    if [ "$1" = "-c" ]; then shift
-    else die "Permission denied"; fi
+    if [ "$1" = "-c" ]; then
+       set -- $2
+    elif [ $# -gt 0 ]; then
+       die "Permission denied"
+    fi
 
     NB_ADMIN=
-    if [ "${1%% *}" = "user" ]; then
+    if [ "$1" = "user" ]; then
        # Get user name encoded in ~/.ssh/authorized_keys
-       set -- $1
        NB_USER="$2";
        [ "$3" = "admin" ] && NB_ADMIN=1
        set -- $SSH_ORIGINAL_COMMAND
index 68ce06d7fee1703e865d73e3145a035de0ef9a18..e3f989532fa3b5c0d31c96c9b05ec0cb040d42fc 100755 (executable)
@@ -22,18 +22,26 @@ function exec_server() {
 }
 
 WVSTART Help subcommand
-run_server help > log
+WVPASS run_server help | WVPASS tee log
 WVPASS grep 'Target commands:' log
 WVFAIL grep 'add-key' log
 
 WVSTART Help is printed without any arguments
-run_server > log
+# Invocation with SSH_ORIGINAL_COMMAND
+WVPASS run_server help | WVPASS tee log
 WVPASS grep 'Target commands:' log
+# Invocation without SSH_ORIGINAL_COMMAND
+WVPASS $WV_BASE_DIR/../server/novaboot-shell | WVPASS tee log2
+WVPASS grep 'Target commands:' log2
 
 WVSTART Get-config command works
 run_server get-config > log
 WVPASS grep -e '^--prefix=asdf$' log
 
+WVSTART "Multi-word commands work when user not specified"
+WVPASS $WV_BASE_DIR/../server/novaboot-shell -c "help xxx" | WVPASS tee log
+WVPASS grep 'Target commands:' log
+
 WVSTART "Console prints a 'connected' message"
 coproc exec_server console
 WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${COPROC[0]}
@@ -182,3 +190,5 @@ WVSTART "add-key requires username"
 WVPASS cp $AUTH auth
 WVFAIL ssh novaboot-test@localhost add-key < /dev/null
 WVPASS diff -u $AUTH auth
+
+# Hi-lock: (("^.*\\(?:WVSTART\\).*$" (0 (quote hi-black-b) t)))