From 1aaca63dcf3f343842ff83463fa9d2dde3b25426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20N=C3=A9lis?= Date: Mon, 8 Jan 2018 01:22:14 +0100 Subject: [PATCH] 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 --- spectre-meltdown-checker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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