Created
September 8, 2013 06:36
-
-
Save derky1202/6482445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(function_exists('posix_geteuid')){ | |
// use posix to get current uid and gid | |
$uid = posix_geteuid(); | |
$usr = posix_getpwuid($uid); | |
$user = $usr['name']; | |
$gid = posix_getegid(); | |
$grp = posix_getgrgid($gid); | |
$group = $grp['name']; | |
}else{ | |
// try to create a file and read it's ids | |
$tmp = tempnam ('/tmp', 'check'); | |
$uid = fileowner($tmp); | |
$gid = filegroup($tmp); | |
// try to run ls on it | |
$out = `ls -l $tmp`; | |
$lst = explode(' ',$out); | |
$user = $lst[2]; | |
$group = $lst[3]; | |
unlink($tmp); | |
} | |
echo "Your PHP process seems to run with the UID $uid ($user) and the GID $gid ($group)\n"; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment