Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
840a770a
Commit
840a770a
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
smartstatus - harden sudo command execution
parent
0344f134
No related branches found
No related tags found
1 merge request
!198
smartstatus - harden sudo command execution
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_smartstatus
+10
-4
10 additions, 4 deletions
check_smartstatus
with
10 additions
and
4 deletions
check_smartstatus
+
10
−
4
View file @
840a770a
...
@@ -37,15 +37,15 @@
...
@@ -37,15 +37,15 @@
# 2021-04-07 v1.2 <axel.hahn@iml.unibe.ch> update message if sudo smartctl -H fails
# 2021-04-07 v1.2 <axel.hahn@iml.unibe.ch> update message if sudo smartctl -H fails
# 2021-10-28 v1.3 <axel.hahn@iml.unibe.ch> detect -d param for smartctl
# 2021-10-28 v1.3 <axel.hahn@iml.unibe.ch> detect -d param for smartctl
# 2022-07-08 v1.4 <axel.hahn@iml.unibe.ch> remove pipe in status line
# 2022-07-08 v1.4 <axel.hahn@iml.unibe.ch> remove pipe in status line
# 2023-10-20 v1.5 <axel.hahn@unibe.ch> harden sudo command execution
# ======================================================================
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
typeset
-i
iFound
=
0
typeset
-i
iFound
=
0
typeset
-i
iErrors
=
0
typeset
-i
iErrors
=
0
sOut
=
sOut
=
sDetails
=
tmpDetailsfile
=
/tmp/smartstatus-all.log
tmpDetailsfile
=
/tmp/smartstatus-all.log
# fix for v0.5
# fix for v0.5
...
@@ -61,7 +61,7 @@ function detectParam(){
...
@@ -61,7 +61,7 @@ function detectParam(){
local
_moreparam
local
_moreparam
grep
'^# PARAM'
$0
|
cut
-f
2-
-d
':'
|
while
read
_moreparam
grep
'^# PARAM'
$0
|
cut
-f
2-
-d
':'
|
while
read
_moreparam
do
do
sudo
smartctl
-H
$_mydevice
$_moreparam
>
/dev/null 2>&1
&&
echo
"
$_moreparam
"
sudo
-n
smartctl
-H
$_mydevice
$_moreparam
>
/dev/null 2>&1
&&
echo
"
$_moreparam
"
done
done
echo
"
$_moreparam
"
echo
"
$_moreparam
"
}
}
...
@@ -132,7 +132,13 @@ ph.require smartctl
...
@@ -132,7 +132,13 @@ ph.require smartctl
rm
-f
$tmpDetailsfile
2>/dev/null
rm
-f
$tmpDetailsfile
2>/dev/null
for
mydevice
in
`
ls
-1
/dev/sd
*
|
grep
-v
"[0-9]"
`
# --- pre check for sudo permissions on smartctl
if
!
sudo
-n
smartctl
-h
>
/dev/null 2>&1
;
then
ph.abort
"UNKNOWN: No sudo permissions to execute smartctl."
fi
# --- loop over sd devices
for
mydevice
in
$(
ls
-1
/dev/sd
*
|
grep
-v
"[0-9]"
)
do
do
iFound
=
$iFound
+1
iFound
=
$iFound
+1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment