当前位置: 首页>>代码示例>>PHP>>正文


PHP getmyuid函数代码示例

本文整理汇总了PHP中getmyuid函数的典型用法代码示例。如果您正苦于以下问题:PHP getmyuid函数的具体用法?PHP getmyuid怎么用?PHP getmyuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getmyuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: has_different_permissions

function has_different_permissions($file)
{
    if (!file_exists($file)) {
        return false;
    }
    return fileowner($file) != getmyuid();
}
开发者ID:subashemphasize,项目名称:test_site,代码行数:7,代码来源:cron.php

示例2: testRedefine

 /**
  * Tests mocking a previously mocked function again.
  *
  * @test
  * @depends testMockFunctionWithoutParameters
  */
 public function testRedefine()
 {
     $this->mockFunction(__NAMESPACE__, "getmyuid", function () {
         return 5;
     });
     $this->assertEquals(5, getmyuid());
 }
开发者ID:OndraM,项目名称:php-mock,代码行数:13,代码来源:AbstractMockTest.php

示例3: _initAutoload

 protected function _initAutoload()
 {
     $options = $this->getOptions();
     // TODO: This should probably be someone else...
     $log = $options['resources']['log']['stream']['writerParams']['stream'];
     $logFolder = dirname(realpath($log));
     $dataFolder = realpath($logFolder . '/../');
     if (is_writable($dataFolder) && !is_dir($logFolder)) {
         mkdir($logFolder);
     }
     $logFolderIsWritable = is_writable($logFolder);
     $isSameUser = posix_getuid() === getmyuid();
     if (!$logFolderIsWritable && is_readable($logFolder) && $isSameUser) {
         // TODO: this needs to be the UID of the logFolder, not php process
         if (posix_getuid() === getmyuid()) {
             chmod($logFolder, 0777);
         }
     }
     if (!$logFolderIsWritable) {
         die('Please make this writable: ' . $dataFolder);
     }
     $autoloader = new Zend_Application_Module_Autoloader(array('namespace' => 'Default_', 'basePath' => dirname(__FILE__)));
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->registerNamespace('ZendTickets_');
     return $autoloader;
 }
开发者ID:joseph-montanez,项目名称:ZendTickets,代码行数:26,代码来源:Bootstrap.php

示例4: getRuntimeDir

 public function getRuntimeDir($strict = true)
 {
     if ($runtimeDir = getenv('XDG_RUNTIME_DIR')) {
         return $runtimeDir;
     }
     if ($strict) {
         throw new \RuntimeException('XDG_RUNTIME_DIR was not set');
     }
     $fallback = sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::RUNTIME_DIR_FALLBACK . getenv('USER');
     $create = false;
     if (!is_dir($fallback)) {
         mkdir($fallback, 0700, true);
     }
     $st = lstat($fallback);
     # The fallback must be a directory
     if (!$st['mode'] & self::S_IFDIR) {
         rmdir($fallback);
         $create = true;
     } elseif ($st['uid'] != getmyuid() || $st['mode'] & (self::S_IRWXG | self::S_IRWXO)) {
         rmdir($fallback);
         $create = true;
     }
     if ($create) {
         mkdir($fallback, 0700, true);
     }
     return $fallback;
 }
开发者ID:dnoegel,项目名称:php-xdg-base-dir,代码行数:27,代码来源:Xdg.php

示例5: _execTest

 /**
  * Checks the UID of the PHP process to make sure it is above PHPSECINFO_MIN_SAFE_UID
  *
  * @see PHPSECINFO_MIN_SAFE_UID
  */
 function _execTest()
 {
     if (getmyuid() >= PHPSECINFO_MIN_SAFE_UID) {
         return PHPSECINFO_TEST_RESULT_OK;
     }
     return PHPSECINFO_TEST_RESULT_WARN;
 }
开发者ID:rhertzog,项目名称:lcs,代码行数:12,代码来源:uid.php

示例6: sendPHPInfo

 /**
  * @param CommandSender $sender
  */
 public function sendPHPInfo(CommandSender $sender)
 {
     $info = ["CWD" => getcwd(), "GID" => getmygid(), "PID" => getmypid(), "UID" => getmyuid(), "Memory-usage" => memory_get_usage(true), "Memory-peak-usage" => memory_get_peak_usage(true), "PHP-version" => phpversion(), "Zend-version" => zend_version()];
     foreach ($info as $key => $value) {
         $sender->sendMessage($key . ": " . $value);
     }
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:10,代码来源:PHPUtils.php

示例7: trustedFile

function trustedFile($file)
{
    // only trust local files owned by ourselves
    if (!eregi("^([a-z]+)://", $file) && fileowner($file) == getmyuid()) {
        return true;
    }
    return false;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:8,代码来源:test.php

示例8: mount

 public function mount()
 {
     $this->runCommand("sudo mount -t tmpfs -o size={$this->getSizeMb()}m tmpfs {$this->ram_disk_path}");
     $uid = getmyuid();
     $gid = getmygid();
     $this->runCommand("sudo chown {$uid}:{$gid} {$this->ram_disk_path}");
     $this->runCommand("chmod 0755 {$this->ram_disk_path}");
 }
开发者ID:eileenmcnaughton,项目名称:amp,代码行数:8,代码来源:LinuxRamDisk.php

示例9: sd_pid_notify_with_fds

/**
 * sd_pid_notify_with_fds PHP implementation
 *
 * @param int    $pid FIXME currently not usable!
 * @param bool   $unset_environment
 * @param string $state
 * @param array  $fds
 *
 * @return int
 *
 * @link https://github.com/systemd/systemd/blob/master/src/libsystemd/sd-daemon/sd-daemon.c
 */
function sd_pid_notify_with_fds($pid, $unset_environment, $state, array $fds)
{
    $state = trim($state);
    if ('' === $state) {
        $r = -EINVAL;
        goto finish;
    }
    $e = getenv('NOTIFY_SOCKET');
    if (!$e) {
        return 0;
    }
    /* Must be an abstract socket, or an absolute path */
    if (strlen($e) < 2 || strpos($e, '@') !== 0 && strpos($e, '/') !== 0) {
        $r = -EINVAL;
        goto finish;
    }
    $fd = socket_create(AF_UNIX, SOCK_DGRAM, 0);
    if (!$fd) {
        $r = -1 * socket_last_error();
        goto finish;
    }
    $msghdr = ['name' => ['path' => $e], 'iov' => [$state . "\n"], 'control' => []];
    if (strpos($msghdr['name']['path'], '@') === 0) {
        $msghdr['name'][0] = "";
    }
    $pid = (int) $pid;
    $have_pid = $pid && getmypid() !== $pid;
    if (count($fds) > 0 || $have_pid) {
        if (count($fds)) {
            $msghdr['control'][] = ['level' => SOL_SOCKET, 'type' => SCM_RIGHTS, 'data' => $fds];
        }
        if ($have_pid) {
            $msghdr['control'][] = ['level' => SOL_SOCKET, 'type' => SCM_CREDENTIALS, 'data' => ['pid' => $pid, 'uid' => getmyuid(), 'gid' => getmygid()]];
        }
    }
    /* First try with fake ucred data, as requested */
    if (@socket_sendmsg($fd, $msghdr, MSG_NOSIGNAL) !== false) {
        $r = 1;
        goto finish;
    }
    /* If that failed, try with our own ucred instead */
    if ($have_pid) {
        $msghdr['control'] = [];
        if (@socket_sendmsg($fd, $msghdr, MSG_NOSIGNAL) !== false) {
            $r = 1;
            goto finish;
        }
    }
    $r = -1 * socket_last_error($fd);
    finish:
    if (isset($fd) && $fd) {
        socket_close($fd);
    }
    if ($unset_environment) {
        putenv('NOTIFY_SOCKET');
    }
    return $r;
}
开发者ID:mekras,项目名称:php-systemd,代码行数:70,代码来源:functions.php

示例10: url_stat

 public function url_stat($path)
 {
     $mode = 0666;
     $uid = 0;
     $gid = 0;
     $len = strlen('fiemulate://');
     $type = substr($path, $len, 1);
     switch (substr($path, $len, 1)) {
         case 'u':
             $uid = getmyuid();
             $gid = getmygid() + 1;
             switch (substr($path, $len + 2)) {
                 case 'not_readable':
                     $mode &= ~0400;
                     break;
                 case 'not_writable':
                     $mode &= ~0200;
                     break;
             }
             break;
         case 'g':
             $uid = getmyuid() + 1;
             $gid = getmygid();
             switch (substr($path, $len + 2)) {
                 case 'not_readable':
                     $mode &= ~0440;
                     break;
                 case 'not_writable':
                     $mode &= ~0220;
                     break;
             }
             break;
         case 'o':
             $uid = getmyuid() + 1;
             $gid = getmygid() + 1;
             switch (substr($path, $len + 2)) {
                 case 'not_readable':
                     $mode &= ~0444;
                     break;
                 case 'not_writable':
                     $mode &= ~0222;
                     break;
             }
             break;
         case 'a':
             $uid = getmyuid();
             $gid = getmygid();
             break;
     }
     $keys = array('dev', 'ino', 'mode', 'nlink', 'uid', 'gid', 'rdev', 'size', 'atime', 'mtime', 'ctime', 'blksize', 'blocks');
     $values = array(0, 0, $mode, 0, $uid, $gid, 0, 0, 0, 0, 0, 0, 0);
     foreach ($keys as $index => $key) {
         $values[$key] = $values[$index];
     }
     return $values;
 }
开发者ID:kylekatarnls,项目名称:sbp,代码行数:56,代码来源:utilsTest.php

示例11: randomBytes

function randomBytes($length = 16, $secure = true, $raw = true, $startEntropy = "", &$rounds = 0, &$drop = 0)
{
    static $lastRandom = "";
    $output = "";
    $length = abs((int) $length);
    $secureValue = "";
    $rounds = 0;
    $drop = 0;
    while (!isset($output[$length - 1])) {
        //some entropy, but works ^^
        $weakEntropy = array(is_array($startEntropy) ? implode($startEntropy) : $startEntropy, serialize(stat(__FILE__)), __DIR__, PHP_OS, microtime(), (string) lcg_value(), (string) PHP_MAXPATHLEN, PHP_SAPI, (string) PHP_INT_MAX . "." . PHP_INT_SIZE, serialize($_SERVER), serialize(get_defined_constants()), get_current_user(), serialize(ini_get_all()), (string) memory_get_usage() . "." . memory_get_peak_usage(), php_uname(), phpversion(), extension_loaded("gmp") ? gmp_strval(gmp_random(4)) : microtime(), zend_version(), (string) getmypid(), (string) getmyuid(), (string) mt_rand(), (string) getmyinode(), (string) getmygid(), (string) rand(), function_exists("zend_thread_id") ? (string) zend_thread_id() : microtime(), var_export(@get_browser(), true), function_exists("getrusage") ? @implode(getrusage()) : microtime(), function_exists("sys_getloadavg") ? @implode(sys_getloadavg()) : microtime(), serialize(get_loaded_extensions()), sys_get_temp_dir(), (string) disk_free_space("."), (string) disk_total_space("."), uniqid(microtime(), true), file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : microtime());
        shuffle($weakEntropy);
        $value = hash("sha512", implode($weakEntropy), true);
        $lastRandom .= $value;
        foreach ($weakEntropy as $k => $c) {
            //mixing entropy values with XOR and hash randomness extractor
            $value ^= hash("sha256", $c . microtime() . $k, true) . hash("sha256", mt_rand() . microtime() . $k . $c, true);
            $value ^= hash("sha512", (string) lcg_value() . $c . microtime() . $k, true);
        }
        unset($weakEntropy);
        if ($secure === true) {
            $strongEntropyValues = array(is_array($startEntropy) ? hash("sha512", $startEntropy[($rounds + $drop) % count($startEntropy)], true) : hash("sha512", $startEntropy, true), file_exists("/dev/urandom") ? fread(fopen("/dev/urandom", "rb"), 64) : str_repeat("", 64), (function_exists("openssl_random_pseudo_bytes") and version_compare(PHP_VERSION, "5.3.4", ">=")) ? openssl_random_pseudo_bytes(64) : str_repeat("", 64), function_exists("mcrypt_create_iv") ? mcrypt_create_iv(64, MCRYPT_DEV_URANDOM) : str_repeat("", 64), $value);
            $strongEntropy = array_pop($strongEntropyValues);
            foreach ($strongEntropyValues as $value) {
                $strongEntropy = $strongEntropy ^ $value;
            }
            $value = "";
            //Von Neumann randomness extractor, increases entropy
            $bitcnt = 0;
            for ($j = 0; $j < 64; ++$j) {
                $a = ord($strongEntropy[$j]);
                for ($i = 0; $i < 8; $i += 2) {
                    $b = ($a & 1 << $i) > 0 ? 1 : 0;
                    if ($b != (($a & 1 << $i + 1) > 0 ? 1 : 0)) {
                        $secureValue |= $b << $bitcnt;
                        if ($bitcnt == 7) {
                            $value .= chr($secureValue);
                            $secureValue = 0;
                            $bitcnt = 0;
                        } else {
                            ++$bitcnt;
                        }
                        ++$drop;
                    } else {
                        $drop += 2;
                    }
                }
            }
        }
        $output .= substr($value, 0, min($length - strlen($output), $length));
        unset($value);
        ++$rounds;
    }
    $lastRandom = hash("sha512", $lastRandom, true);
    return $raw === false ? bin2hex($output) : $output;
}
开发者ID:Kengaming1st,项目名称:Secure-PHP-Random-Bytes,代码行数:56,代码来源:randomBytes.php

示例12: matchingLetter

 public static function matchingLetter($file)
 {
     if (fileowner($file) === getmyuid()) {
         return 'u';
     }
     if (filegroup($file) === getmygid()) {
         return 'g';
     }
     return 'o';
 }
开发者ID:kylekatarnls,项目名称:sbp,代码行数:10,代码来源:FileHelper.php

示例13: pull_project

 public function pull_project()
 {
     if (!is_cli()) {
         echo 'This controller must run from command line interface only.' . PHP_EOL;
         return;
     }
     exec('git pull');
     exec('chown ' . getmyuid() . ':' . getmygid() . ' ' . FCPATH . '.. -R');
     exec('chmod 0777 ' . APPPATH . 'cache');
     exec('chmod 0777 ' . APPPATH . 'logs');
 }
开发者ID:paranic,项目名称:codeigniter-skeleton,代码行数:11,代码来源:Shell.php

示例14: __construct

 public function __construct()
 {
     $this->config = array('filename' => basename(__FILE__), 'username' => '', 'password' => '', 'interpreter' => 'shell_exec', 'current_user' => get_current_user(), 'hostname' => function_exists('gethostname') ? gethostname() : $_SERVER['HTTP_HOST'], 'server_address' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1', 'server_port' => $_SERVER['SERVER_PORT'], 'request_time' => $_SERVER['REQUEST_TIME'], 'php_owner_uid' => getmyuid(), 'php_owner_gid' => getmygid(), 'php_process_id' => getmypid(), 'inode_script' => getmyinode(), 'last_page_modification' => getlastmod(), 'cwd' => getcwd());
     if (isset($_SESSION['interpreter'])) {
         $this->config['interpreter'] = $_SESSION['interpreter'];
     }
     if (isset($_SESSION['cwd']) && $_SESSION['cwd'] != $this->config['cwd']) {
         chdir($_SESSION['cwd']);
         $this->config['cwd'] = getcwd();
     }
     $this->config['prompt'] = $this->get_prompt();
 }
开发者ID:jaggedsoft,项目名称:phpshellgen,代码行数:12,代码来源:template.php

示例15: doTest

 /**
  * Check that we are being called via HTTPS in favor of HTTP.
  *
  * @return void
  */
 protected function doTest()
 {
     $this->setMessage('Check that the file owner matches the user executing php');
     $request = Request::createFromGlobals();
     $owning = fileowner($request->server->get('SCRIPT_FILENAME'));
     $running = getmyuid();
     if ($owning === $running) {
         $this->markSuccess();
         return;
     }
     $this->markWarning('Script is owned by uid ' . $owning . ' whereas it is being executed by uid ' . $running);
 }
开发者ID:tenside,项目名称:core,代码行数:17,代码来源:SelfTestFileOwnerMatches.php


注:本文中的getmyuid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。