aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibault Nélis <tnelis@stammed.net>2018-01-08 01:22:14 +0100
committerThibault Nélis <tnelis@stammed.net>2018-01-08 01:22:14 +0100
commit1aaca63dcf3f343842ff83463fa9d2dde3b25426 (patch)
tree54022693f7c2496cf75721eca80d5d05aa2f05b4
parent96dfa03c000052e9d69ba00c62327caa83aa34bf (diff)
downloadspectre-meltdown-checker-1aaca63dcf3f343842ff83463fa9d2dde3b25426.tar.lz
spectre-meltdown-checker-1aaca63dcf3f343842ff83463fa9d2dde3b25426.tar.xz
spectre-meltdown-checker-1aaca63dcf3f343842ff83463fa9d2dde3b25426.zip
Improve "running as root" check
Small issue with the USER environment variable: $ echo $USER thib $ sudo sh -c 'echo $USER' thib $ sudo -i sh -c 'echo $USER' root Rather than recommending users to use sudo --login / -i, use the (very widespread/portable) id program to retrieve the effective user ID instead and don't change the recommendation. $ id -u 1000 $ sudo id -u 0 $ sudo -i id -u 0
-rwxr-xr-xspectre-meltdown-checker.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh
index b0ac923..c52d3d0 100755
--- a/spectre-meltdown-checker.sh
+++ b/spectre-meltdown-checker.sh
@@ -256,7 +256,7 @@ fi
/bin/echo
-if [ "$USER" != root ]; then
+if [ "$(id -u)" -ne 0 ]; then
/bin/echo "Note that you should launch this script with root privileges to get accurate information"
/bin/echo "You can try the following command: sudo $0"
fi