]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
server: Distinguish between normal and admin users
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 24 Aug 2017 18:51:35 +0000 (20:51 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 24 Aug 2017 18:51:35 +0000 (20:51 +0200)
server/novaboot-server
tests/server.wv

index d406ac58ea55665e757b56c078433d28ad671e23..c23937466f1f41aa5ebd8aa74c6c1b6291744977 100755 (executable)
@@ -17,9 +17,14 @@ Target commands:
 - rsync ...
 
 Management commands:
-- add-key
 - help
 EOF
+
+    if [ "$NB_ADMIN" ]; then
+       cat <<EOF
+- add-key
+EOF
+    fi
     exit 0
 }
 
@@ -95,10 +100,12 @@ main() {
     if [ "$1" = "-c" ]; then shift
     else die "Permission denied"; fi
 
+    NB_ADMIN=
     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
     fi
 
index 2325a3d1fe24c9aa12bb65c7bf30ae4f054b61a5..e69bed5e50b8ddd172989dfc9efde5efd31fceed 100755 (executable)
@@ -27,6 +27,7 @@ trap 'kill "$COPROC_PID"' EXIT
 WVSTART Help subcommand
 run_server help > log
 WVPASS grep 'Target commands:' log
+WVFAIL grep 'add-key' log
 
 WVSTART Help is printed without any arguments
 run_server > log
@@ -52,6 +53,10 @@ coproc console2 { username=another_username exec_server console; }
 WVPASS sed -e '/my_cool_username/q0' <&${console2[0]}
 kill $console1_PID $console2_PID; wait
 
+WVSTART Admin sees help for admin subcommands
+admin=1 run_server help > log
+WVPASS grep 'add-key' log
+
 WVSTART 'Cannot reset when somebody else is connected to console'
 coproc exec_server console
 sed -e '/novaboot-server: Connected/q0' <&${COPROC[0]}