From 3fdbde8ca0342f8cc2f744f25a7e9491577abedb Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 4 Jun 2020 16:09:44 +0200 Subject: op-mode: T2546: add "show login" commands --- op-mode-definitions/show-login.xml | 33 +++++++++++++++++++++++++++++++++ src/op_mode/show_current_user.sh | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 op-mode-definitions/show-login.xml create mode 100755 src/op_mode/show_current_user.sh diff --git a/op-mode-definitions/show-login.xml b/op-mode-definitions/show-login.xml new file mode 100644 index 000000000..6d8c782c4 --- /dev/null +++ b/op-mode-definitions/show-login.xml @@ -0,0 +1,33 @@ + + + + + + + Show current login credentials + + ${vyos_op_scripts_dir}/show_current_user.sh + + + + Show current login group information + + /usr/bin/id -Gn + + + + Show current login level + + if [ -n "$VYATTA_USER_LEVEL_DIR" ]; then basename $VYATTA_USER_LEVEL_DIR; fi + + + + Show current login user id + + /usr/bin/id -un + + + + + + diff --git a/src/op_mode/show_current_user.sh b/src/op_mode/show_current_user.sh new file mode 100755 index 000000000..93e6efa61 --- /dev/null +++ b/src/op_mode/show_current_user.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +echo -n "login : " ; who -m + +if [ -n "$VYATTA_USER_LEVEL_DIR" ] +then + echo -n "level : " + basename $VYATTA_USER_LEVEL_DIR +fi + +echo -n "user : " ; id -un +echo -n "groups : " ; id -Gn + +if id -Z >/dev/null 2>&1 +then + echo -n "context : " + id -Z +fi -- cgit v1.2.3