Commit 1be934f5 authored by Tomáš Szaniszlo's avatar Tomáš Szaniszlo
Browse files

Better superuser permissions check

Check superuser permissions not using sudo but using EUID.

Also check for superuser permissions when in live mode since that may
trigger debugfs mounting which requires them.
parent 85c2155b
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1824,9 +1824,12 @@ sub worker
### Check command line arguments
check_args();

### Check if debugfs is mounted
if ($mode eq "live" || $mode eq "trace")
{
        ### Check if superuser permissions
        if ($> != 0) { die("ERROR: You need to have superuser permissions to collect all necessary data.  Please run from a privileged account."); }

        ### Check if debugfs is mounted
        mount_debugfs();
}

@@ -1838,10 +1841,6 @@ if($mode eq 'trace')
        my $pid=-1;
        #my $cpu_affinity=0;

        ### Check if sudo permissions
        `sudo -v`;
        if($? != 0 ) { die("ERROR: You need to have sudo permissions to collect all necessary data.  Please run from a privilaged account."); }

        ### Save fdisk info
        print "Running fdisk\n" if ($DEBUG);
        my $fdisk_version = `fdisk -v`;