public static function sudo(callable $callable, array $arguments = array())
    {
        // don't do anything under Windows
        if (FileSystem::getOsIdentifier() === FileSystem::OS_IDENTIFIER_WIN) {
            return call_user_func_array($callable, $arguments);
        }

        // get the current user user pair (super user and effective user)
        $currentUserId = (integer) posix_geteuid();
        $superUserId = (integer) posix_getuid();

        // temporarily switch to the super user
        posix_seteuid($superUserId);

        // execute the callable
        $result = call_user_func_array($callable, $arguments);

        // switch back to the effective user
        posix_seteuid($currentUserId);

        return $result;
    }
public static function sudo(callable $callable, array $arguments = array())
    {
        // don't do anything under Windows
        if (FileSystem::getOsIdentifier() === FileSystem::OS_IDENTIFIER_WIN) {
            return call_user_func_array($callable, $arguments);
        }

        // get the current user user pair (super user and effective user)
        $currentUserId = (integer) posix_geteuid();
        $superUserId = (integer) posix_getuid();

        // temporarily switch to the super user
        posix_seteuid($superUserId);

        // execute the callable
        $result = call_user_func_array($callable, $arguments);

        // switch back to the effective user
        posix_seteuid($currentUserId);

        return $result;
    }
public static function sudo ( callable $ callable , array $ arguments = array ( ) ) { // don't do anything under Windows if ( FileSystem :: getOsIdentifier ( ) === FileSystem :: OS_IDENTIFIER_WIN ) { return call_user_func_array ( $ callable , $ arguments ) ; } // get the current user user pair (super user and effective user) $ currentUserId = ( integer ) posix_geteuid ( ) ; $ superUserId = ( integer ) posix_getuid ( ) ; // temporarily switch to the super user posix_seteuid ( $ superUserId ) ; // execute the callable $ result = call_user_func_array ( $ callable , $ arguments ) ; // switch back to the effective user posix_seteuid ( $ currentUserId ) ; return $ result ; }
Helper method which allows to execute a callable as the super user the server got started by.

@param callable $callable  The callable to run
@param array    $arguments Arguments to pass to the callable

@return mixed The callables result
Helper method which allows to execute a callable as the super user the server got started by .