NYCPHP Meetup

NYPHP.org

[nycphp-talk] Determining if cmd line script is running as root?

Jon Baer jonbaer at jonbaer.com
Thu Jul 26 20:39:22 EDT 2007


One possible way ...

<?php $user = `whoami`; echo $user; ?>

$php whoami.php
jonbaer
$sudo php whoami.php
root

- Jon

On Jul 26, 2007, at 8:29 PM, Michael B Allen wrote:

> Hi,
>
> 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.
>
> Any other ways?
>
> Mike



More information about the talk mailing list