From e45a534b519914566980a2ed45bb552faf75255d Mon Sep 17 00:00:00 2001 From: pdontthink Date: Thu, 4 Dec 2008 09:35:41 +0000 Subject: [PATCH] Put info about the user/group of the web server in the configtest. Grabbing that info is implemented as a core function so plugins (such as ones that need to check SUID script permissions) can also make use of it. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13346 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/global.php | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/configtest.php | 11 +++++++++++ 2 files changed, 56 insertions(+) diff --git a/functions/global.php b/functions/global.php index acfa0625..aaf06389 100644 --- a/functions/global.php +++ b/functions/global.php @@ -769,3 +769,48 @@ function is_ssl_secured_connection() } +/** + * Endeavor to detect what user and group PHP is currently + * running as. Probably only works in non-Windows environments. + * + * @return mixed Boolean FALSE is returned if something went wrong, + * otherwise an array is returned with the following + * elements: + * uid The current process' UID (integer) + * euid The current process' effective UID (integer) + * gid The current process' GID (integer) + * egid The current process' effective GID (integer) + * name The current process' name/handle (string) + * ename The current process' effective name/handle (string) + * group The current process' group name (string) + * egroup The current process' effective group name (string) + * Note that some of these elements may have empty + * values, especially if they could not be determined. + * + * @since 1.5.2 + * + */ +function get_process_owner_info() +{ + if (!function_exists('posix_getuid')) + return FALSE; + + $process_info['uid'] = posix_getuid(); + $process_info['euid'] = posix_geteuid(); + $process_info['gid'] = posix_getgid(); + $process_info['egid'] = posix_getegid(); + + $user_info = posix_getpwuid($process_info['uid']); + $euser_info = posix_getpwuid($process_info['euid']); + $group_info = posix_getgrgid($process_info['gid']); + $egroup_info = posix_getgrgid($process_info['egid']); + + $process_info['name'] = $user_info['name']; + $process_info['ename'] = $euser_info['name']; + $process_info['group'] = $user_info['name']; + $process_info['egroup'] = $euser_info['name']; + + return $process_info; +} + + diff --git a/src/configtest.php b/src/configtest.php index 0eaa1140..dcb22e5b 100644 --- a/src/configtest.php +++ b/src/configtest.php @@ -320,6 +320,17 @@ if (ini_get('short_open_tag') == 0) { do_err($short_open_tag_warning, false); } + +/* check who the web server is running as if possible */ + +if ($process_info = get_process_owner_info()) { + echo $IND . 'Web server is running as user: ' . $process_info['name'] . ' (' . $process_info['uid'] . ")
\n"; + //echo $IND . 'Web server is running as effective user: ' . $process_info['ename'] . ' (' . $process_info['euid'] . ")
\n"; + echo $IND . 'Web server is running as group: ' . $process_info['group'] . ' (' . $process_info['gid'] . ")
\n"; + //echo $IND . 'Web server is running as effective group: ' . $process_info['egroup'] . ' (' . $process_info['egid'] . ")
\n"; +} + + /* checking paths */ echo "Checking paths...
\n"; -- 2.25.1