Skip to content
Snippets Groups Projects
Commit 46b6a16e authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

onevm + onehost: harden sudo command execution

parent d1ffd8f3
No related branches found
No related tags found
1 merge request!196onevm + onehost: harden sudo command execution
...@@ -11,12 +11,13 @@ ...@@ -11,12 +11,13 @@
# 2023-06-12 v1.1 <axel.hahn@unibe.ch> show message if no sudo permissions on onehost command exist # 2023-06-12 v1.1 <axel.hahn@unibe.ch> show message if no sudo permissions on onehost command exist
# 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements # 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements
# 2023-09-15 v1.3 <axel.hahn@unibe.ch> add detection for disabled hosts; update texts # 2023-09-15 v1.3 <axel.hahn@unibe.ch> add detection for disabled hosts; update texts
# 2023-10-20 v1.4 <axel.hahn@unibe.ch> harden sudo command execution
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPVERSION=1.3 self_APPVERSION=1.4
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# functions # functions
...@@ -68,7 +69,9 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 2 c "$@") ...@@ -68,7 +69,9 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 2 c "$@")
# --- get data # --- get data
cmdout=$( sudo onehost list --csv 2>&1 ) if ! cmdout=$( sudo -n onehost list --csv 2>&1 ); then
ph.abort "UNKNOWN: No sudo permissions to execute onehost commands."
fi
if ! grep "ID,NAME" <<< "$cmdout" >/dev/null; then if ! grep "ID,NAME" <<< "$cmdout" >/dev/null; then
ph.setStatus "unknown" ph.setStatus "unknown"
......
...@@ -35,12 +35,13 @@ ...@@ -35,12 +35,13 @@
# 2023-06-12 v1.0 <axel.hahn@unibe.ch> initial version # 2023-06-12 v1.0 <axel.hahn@unibe.ch> initial version
# 2023-06-15 v1.1 <axel.hahn@unibe.ch> fix output if no vm is running # 2023-06-15 v1.1 <axel.hahn@unibe.ch> fix output if no vm is running
# 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements # 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements
# 2023-10-20 v1.3 <axel.hahn@unibe.ch> harden sudo command execution
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPVERSION=1.2 self_APPVERSION=1.3
# new line # new line
NL=" NL="
...@@ -94,7 +95,9 @@ esac ...@@ -94,7 +95,9 @@ esac
ph.require onehost ph.require onehost
# --- get data # --- get data
cmdout=$( sudo onevm list --csv 2>&1 ) if ! cmdout=$( sudo -n onevm list --csv 2>&1 ); then
ph.abort "UNKNOWN: No sudo permissions to execute onehost commands."
fi
if ! grep "ID,USER" <<< "$cmdout" >/dev/null; then if ! grep "ID,USER" <<< "$cmdout" >/dev/null; then
ph.setStatus "unknown" ph.setStatus "unknown"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment