mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-22 05:15:29 +09:00
Refactor Storage::recommendUmask() into Storage::getServerUID()
This commit is contained in:
parent
5f83192e5d
commit
30cdf63b77
1 changed files with 34 additions and 22 deletions
|
|
@ -772,7 +772,7 @@ class Storage
|
||||||
/**
|
/**
|
||||||
* Determine the best umask for this installation of Rhymix.
|
* Determine the best umask for this installation of Rhymix.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function recommendUmask()
|
public static function recommendUmask()
|
||||||
{
|
{
|
||||||
|
|
@ -786,27 +786,7 @@ class Storage
|
||||||
$file_uid = fileowner(__FILE__);
|
$file_uid = fileowner(__FILE__);
|
||||||
|
|
||||||
// Get the UID of the current PHP process.
|
// Get the UID of the current PHP process.
|
||||||
if (function_exists('posix_geteuid'))
|
$php_uid = self::getServerUID();
|
||||||
{
|
|
||||||
$php_uid = posix_geteuid();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$testfile = \RX_BASEDIR . 'files/cache/uidcheck';
|
|
||||||
if (self::exists($testfile))
|
|
||||||
{
|
|
||||||
self::delete($testfile);
|
|
||||||
}
|
|
||||||
if (self::write($testfile, 'TEST'))
|
|
||||||
{
|
|
||||||
$php_uid = fileowner($testfile);
|
|
||||||
self::delete($testfile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$php_uid = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If both UIDs are the same, set the umask to 0022.
|
// If both UIDs are the same, set the umask to 0022.
|
||||||
if ($file_uid == $php_uid)
|
if ($file_uid == $php_uid)
|
||||||
|
|
@ -820,4 +800,36 @@ class Storage
|
||||||
return '0000';
|
return '0000';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the UID of the server process.
|
||||||
|
*
|
||||||
|
* @return int|false
|
||||||
|
*/
|
||||||
|
public static function getServerUID()
|
||||||
|
{
|
||||||
|
if (function_exists('posix_geteuid'))
|
||||||
|
{
|
||||||
|
return posix_geteuid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$testfile = \RX_BASEDIR . 'files/cache/uidcheck_' . time();
|
||||||
|
if (self::exists($testfile))
|
||||||
|
{
|
||||||
|
self::delete($testfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::write($testfile, 'TEST'))
|
||||||
|
{
|
||||||
|
$uid = fileowner($testfile);
|
||||||
|
self::delete($testfile);
|
||||||
|
return $uid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue