At 1:09 PM -0400 10/26/02, Mark Knipfer wrote:
On 10/26/02 11:55 AM, Mark Knipfer wrote:
How do you check for root level access in Perl 5.6.0 in Mac OS X?
After browsing and reading through part of the O'Rielly - Programming Perl 2nd Edition book, I came up with this routine:

$login = (getpwuid($>));
if (!$login == "root")
{
die "\nYou cannot run this Perl script as user \"$login\", must be ROOT!\n\n";
}
Of course that only works if the 'root' user is named 'root', and not 'administrator' or etc. And it doesn't allow someone to run your script from sudo.

But you may find more assistance in perldoc -f getpwuid

-Jeff Lowrey


Reply via email to