]> rtime.felk.cvut.cz Git - novaboot.git/blobdiff - tests/server.wv
server: Admin can get shell access
[novaboot.git] / tests / server.wv
index aa0381b14c6c6634a753635104d8ef8b11909c70..6fb3076b6f48818f39547be83305ed60bf0f001e 100755 (executable)
@@ -6,8 +6,8 @@ cd $(dirname $0)
 export WV_BASE_DIR
 export NOVABOOT_SHELL_CONFIG="$WV_BASE_DIR/.novaboot-shell"
 cat <<EOF > "$NOVABOOT_SHELL_CONFIG"
-target_console="/bin/sh -c 'while :; do sleep 0.1; date; done'"
-target_reset="touch reset"
+console_cmd="/bin/sh -c 'while :; do sleep 0.1; date; done'"
+reset_cmd="touch reset"
 target_config() echo --prefix=asdf
 EOF
 
@@ -59,6 +59,10 @@ WVSTART Admin sees help for admin subcommands
 admin=1 run_server help > log
 WVPASS grep 'add-key' log
 
+WVSTART Only admin can run shell
+WVFAIL run_server shell
+admin=1 WVPASS run_server shell < /dev/null
+
 WVSTART 'Cannot reset when somebody else is connected to console'
 coproc console1 { exec_server console; }
 WVPASS sed -e '/novaboot-shell: Connected/q0' -e '3q1' <&${console1[0]}
@@ -83,14 +87,16 @@ AUTH="$WV_BASE_DIR/home-novaboot-test/.ssh/authorized_keys"
 WVSTART "Setup SSH server's admin key"
 WVPASS ssh-add -L > keys
 WVPASS test $(wc -l < keys) -gt 0
+WVPASS mkdir -p $(dirname $AUTH)
+WVPASS chmod 700 $(dirname $AUTH)
 WVPASS echo 'command="user test admin"' $(tail -n 1 keys) > $AUTH
 
 WVSTART "Novaboot --ssh option (connect, rsync, reset)"
 WVPASS rm -rf $TFTPROOT
 TS=$(date --rfc-3339=ns)
 WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset="echo $TS > reset.stamp"
+console_cmd=cat
+reset_cmd="echo $TS > reset.stamp"
 target_config() :
 EOF
 date > file
@@ -104,8 +110,8 @@ WVPASS diff -u <(echo $TS) "$WV_BASE_DIR/home-novaboot-test/reset.stamp"
 WVSTART "Novaboot --ssh remote config"
 WVPASS rm -rf $TFTPROOT
 WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset=true
+console_cmd=cat
+reset_cmd=true
 target_config() { echo --prefix=/prefix; echo --grub2; }
 EOF
 date > file
@@ -117,9 +123,9 @@ WVPASS grep /prefix/file $TFTPROOT/grub.cfg
 
 WVSTART "Novaboot --ssh remote config fails on non-safe options"
 WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset=true
-target_config() { echo --prefix=/prefix; echo --make; }
+console_cmd=cat
+reset_cmd=true
+config() { echo --prefix=/prefix; echo --make; }
 EOF
 WVFAIL novaboot --ssh novaboot-test@localhost <<EOF
 load file < date
@@ -127,8 +133,8 @@ EOF
 
 WVSTART "Novaboot --ssh remote config fails on unknown arguments"
 WVPASS tee $SHELLRC <<EOF
-target_console=cat
-target_reset=true
+console_cmd=cat
+reset_cmd=true
 target_config() { echo --prefix=/prefix; echo blablabla; }
 EOF
 WVFAIL novaboot --ssh novaboot-test@localhost <<EOF