You are not logged in.

#1 2009-09-20 14:34:48

rwd
Member
Registered: 2009-02-08
Posts: 671

Has ROOT_UID environment variable become obsolete?

I used to have this in bash scripts to check for root privileges:

if [ "$UID" -ne "$ROOT_UID" ] ; then
    echo "You must be root to do that!"
    exit 1
fi

However recently (since a few weeks?) it seems ROOT_UID is no longer set : env | grep ROOT_UID results nothing. I could of course just check for UID 0 instead but I wonder why ROOT_UID does no longer exist. Has it become obsolete? I couldn't find anything on the forum or wiki about this.

Offline

#2 2009-09-20 14:59:14

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Has ROOT_UID environment variable become obsolete?

You can use the value of $EUID or $UID directly (0 == root) or the output of "whoami" (root == root)

Or you can just export ROOT_UID=0 (asuming you haven't set root's uid to something silly) somewhere at startup...but I don't know the answer to your question (why it's no longer set)

Last edited by moljac024 (2009-09-20 15:03:33)


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

Board footer

Powered by FluxBB