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

packages 2 install - harden sudo command execution

parent 46b6a16e
No related branches found
No related tags found
1 merge request!197packages 2 install - harden sudo command execution
...@@ -25,11 +25,12 @@ ...@@ -25,11 +25,12 @@
# rename package manager functions # rename package manager functions
# 2022-10-21 v1.11 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2022-10-21 v1.11 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> update help; rename to getSecurityCount # 2023-08-24 v1.12 <axel.hahn@unibe.ch> update help; rename to getSecurityCount
# 2023-10-20 v1.13 ah harden sudo command execution
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPVERSION=1.12 self_APPVERSION=1.13
readonly iWarnDefault=1 readonly iWarnDefault=1
readonly iCriticalDefault=200 readonly iCriticalDefault=200
...@@ -229,6 +230,9 @@ fi ...@@ -229,6 +230,9 @@ fi
. "${dir_pkg}/${pkgmanager}.sh" || exit 2 . "${dir_pkg}/${pkgmanager}.sh" || exit 2
packagemanOut=$( ${pkgmanager}.getUpdates ) packagemanOut=$( ${pkgmanager}.getUpdates )
if grep "sudo: " <<< "$packagemanOut" >/dev/null; then
ph.abort "No sudo permissions on ${pkgmanager}?"
fi
if [ -z "$packagemanOut" ]; then if [ -z "$packagemanOut" ]; then
ph.setStatus "critical" ph.setStatus "critical"
......
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
# 2022-06-07 v1.1 ah remove text "Nothing to install" # 2022-06-07 v1.1 ah remove text "Nothing to install"
# rename functions # rename functions
# 2022-10-21 v1.3 ah remove grep: warning: stray \ before white space # 2022-10-21 v1.3 ah remove grep: warning: stray \ before white space
# 2023-10-20 v1.4 ah harden sudo command execution
# =============================================================== # ===============================================================
# --------------------------------------------------------------- # ---------------------------------------------------------------
# command to list of updates # command to list of updates
function apt.getUpdates(){ function apt.getUpdates(){
sudo apt-get -u upgrade --assume-no sudo -n apt-get -u upgrade --assume-no
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
......
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
# ah <axel.hahn@iml.unibe.ch> # ah <axel.hahn@iml.unibe.ch>
# 2022-06-03 v1.0 ah first version # 2022-06-03 v1.0 ah first version
# 2022-06-07 v1.1 ah rename functions # 2022-06-07 v1.1 ah rename functions
# 2023-10-20 v1.2 ah harden sudo command execution
# =============================================================== # ===============================================================
# --------------------------------------------------------------- # ---------------------------------------------------------------
# command to list of updates # command to list of updates
function pamac.getUpdates(){ function pamac.getUpdates(){
pamac checkupdates sudo -n pamac checkupdates
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
......
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
# 2023-08-24 v1.4 ah centos9: update getStatusLine() + getSecurityCount # 2023-08-24 v1.4 ah centos9: update getStatusLine() + getSecurityCount
# 2023-08-25 v1.5 ah centos9: fix package lists # 2023-08-25 v1.5 ah centos9: fix package lists
# 2023-09-12 v1.6 ah almalinux9: fix package lists # 2023-09-12 v1.6 ah almalinux9: fix package lists
# 2023-10-20 v1.7 ah harden sudo command execution
# =============================================================== # ===============================================================
# --------------------------------------------------------------- # ---------------------------------------------------------------
# command to list of updates # command to list of updates
function yum.getUpdates(){ function yum.getUpdates(){
sudo /usr/bin/yum -y check-update sudo -n /usr/bin/yum -y check-update
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment