On 7/26/07, Jon Baer <[EMAIL PROTECTED]> wrote:
> One possible way ...
>
> <?php $user = `whoami`; echo $user; ?>
>
> $php whoami.php
> jonbaer
> $sudo php whoami.php
> root

Hi Guys,

Actually what I settled on was:

function is_root() {
    if (is_writable('/'))
        return TRUE;
    if (extension_loaded('posix') && posix_getuid() == 0)
        return TRUE;
    if (getenv('USER') == 'root')
        return TRUE;
    return FALSE;
}

But looking at this now I think perhaps
function_exists('posix_getuid') would be better than extension_loaded.
I'll have to change that.

Also, I guess is_writeable('/') isn't fool-proof.

Mike
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to