[nycphp-talk] Determining if cmd line script is running as root?
Steve Manes
smanes at magpie.com
Sat Jul 28 10:04:28 EDT 2007
Michael B Allen wrote:
> How does one determine if a command line PHP script is being executed as
> root?
>
> If there's no posix extension there's no posix_getuid and if the user
> did 'su' and not 'su -' then the USER environment variable may not be
> root.
If you don't have PHP's POSIX extensions you can get it from the shell
with the 'id -u' command. If it returns the string '0' then the user is
effectively superuser.
% man -S1 id
More information about the talk
mailing list