1
0
mirror of https://github.com/speed47/spectre-meltdown-checker synced 2024-11-19 04:22:22 +01:00

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
This commit is contained in:
Thibault Nélis 2018-01-08 01:22:14 +01:00
parent 96dfa03c00
commit 1aaca63dcf

View File

@ -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