From: Michal Sojka Date: Sun, 17 Nov 2019 15:44:23 +0000 (+0100) Subject: server: Ensure that configuration can depend on logged-in user name X-Git-Tag: 20201217~20 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/novaboot.git/commitdiff_plain/611d2c275db953c821275680b5483ba9f658d23a server: Ensure that configuration can depend on logged-in user name --- diff --git a/server/novaboot-shell b/server/novaboot-shell index bc9278c..52c70e4 100755 --- a/server/novaboot-shell +++ b/server/novaboot-shell @@ -125,7 +125,7 @@ main() { NB_ADMIN= if [ "$1" = "user" ]; then # Get user name encoded in ~/.ssh/authorized_keys - NB_USER="$2"; + export NB_USER="$2"; [ "$3" = "admin" ] && NB_ADMIN=1 set -- $SSH_ORIGINAL_COMMAND fi diff --git a/tests/server.wv b/tests/server.wv index 1c90891..94fab88 100755 --- a/tests/server.wv +++ b/tests/server.wv @@ -103,6 +103,15 @@ WVSTART "Quoting of config variables" WVPASS test -e '"file1 file2"' ) +WVSTART "Config variables can depend on user name" +( + export NOVABOOT_SHELL_CONFIG="./.novaboot-shell" + + WVPASS tee "$NOVABOOT_SHELL_CONFIG" <<<'console_cmd="echo Hello $NB_USER"' + username=asdf WVPASS run_server console | tee /dev/stderr | WVPASS grep -F "Hello asdf" + username=qwer WVPASS run_server console | tee /dev/stderr | WVPASS grep -F "Hello qwer" +) + SHELLRC="$NBT_HOME/.novaboot-shell" TFTPROOT="$NBT_HOME/tftproot" AUTH="$NBT_HOME/.ssh/authorized_keys"