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


PHP posix_geteuid函数代码示例

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


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

示例1: test_mail_sender

function test_mail_sender($to = "viktor@szepe.net")
{
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    if (function_exists('posix_getuid')) {
        $uid = posix_getuid();
    } else {
        $uid = '??';
    }
    if (function_exists('posix_geteuid')) {
        $euid = posix_geteuid();
    } else {
        $euid = '??';
    }
    if (function_exists('posix_getpwuid')) {
        $real_user = posix_getpwuid($uid);
        $effective_user = posix_getpwuid($euid);
    } else {
        $real_user = $uid;
        $effective_user = $euid;
    }
    if (function_exists('posix_getcwd')) {
        $cwd = posix_getcwd();
    } else {
        $cwd = getcwd();
    }
    $subject = sprintf("[Default mail sender] First mail from %s", $_SERVER['SERVER_NAME']);
    $message = sprintf("SAPI: %s\nreal user: %s\neffective user: %s\ncurrent dir: %s\nPHP version: %s", var_export(php_sapi_name(), true), var_export($real_user, true), var_export($effective_user, true), var_export($cwd, true), var_export(phpversion(), true));
    $headers = sprintf("X-Mailer: PHP/%s", phpversion());
    $mail = mail($to, $subject, $message, $headers);
    printf("mail() returned: %s", var_export($mail, true));
}
开发者ID:vrkansagara,项目名称:wordpress-plugin-construction,代码行数:32,代码来源:php-mail-sender.php

示例2: doExecute

 private function doExecute(Manager $args) : Generator
 {
     if (posix_geteuid() !== 0) {
         throw new AcmeException("Please run this script as root!");
     }
     $server = $args->get("server");
     $protocol = substr($server, 0, strpos("://", $server));
     if (!$protocol || $protocol === $server) {
         $server = "https://" . $server;
     } elseif ($protocol !== "https") {
         throw new \InvalidArgumentException("Invalid server protocol, only HTTPS supported");
     }
     $keyPair = $this->checkRegistration($args);
     $acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair);
     $this->logger->info("Revoking certificate ...");
     $pem = (yield get($args->get("cert")));
     $cert = new Certificate($pem);
     if ($cert->getValidTo() < time()) {
         $this->logger->warning("Certificate did already expire, no need to revoke it.");
         return;
     }
     $this->logger->info("Certificate was valid for: " . implode(", ", $cert->getNames()));
     (yield $acme->revokeCertificate($pem));
     $this->logger->info("Certificate has been revoked.");
 }
开发者ID:PeeHaa,项目名称:acme-client,代码行数:25,代码来源:Revoke.php

示例3: get

 function get($s = '')
 {
     $this->sessionState(0);
     $bits = explode('/', $s);
     if (empty($bits[0]) || empty($bits[1]) || !isset($this->types[$bits[0]])) {
         $this->jerr("invalid url");
     }
     $s = str_replace('/', '-', $bits[1]);
     $ui = posix_getpwuid(posix_geteuid());
     $ff = HTML_FlexyFramework::get();
     $compile = session_save_path() . '/' . $ui['name'] . '-' . $ff->project . '-' . $ff->version . '-' . $bits[0] . 'compile';
     $fn = $compile . '/' . $s . '.' . $bits[0];
     if (!file_exists($fn)) {
         header('Content-Type: ' . $this->types[$bits[0]]);
         echo "// compiled file not found = {$fn}";
         exit;
     }
     $last_modified_time = filemtime($fn);
     if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == md5($fn)) {
         header("HTTP/1.1 304 Not Modified");
         exit;
     }
     header('Content-Type: ' . $this->types[$bits[0]]);
     header("Pragma: public");
     header('Content-Length: ' . filesize($fn));
     header('Cache-Control: max-age=2592000, public');
     header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 2592000));
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', $last_modified_time));
     header('Etag: ' . md5($fn));
     $fh = fopen($fn, 'r');
     fpassthru($fh);
     fclose($fh);
     exit;
 }
开发者ID:roojs,项目名称:Pman.Core,代码行数:34,代码来源:Asset.php

示例4: getLog

 public static function getLog()
 {
     if (!self::$log) {
         $path = PhabricatorEnv::getEnvConfig('log.ssh.path');
         $format = PhabricatorEnv::getEnvConfig('log.ssh.format');
         $format = nonempty($format, "[%D]\t%p\t%h\t%r\t%s\t%S\t%u\t%C\t%U\t%c\t%T\t%i\t%o");
         // NOTE: Path may be null. We still create the log, it just won't write
         // anywhere.
         $data = array('D' => date('r'), 'h' => php_uname('n'), 'p' => getmypid(), 'e' => time());
         $sudo_user = PhabricatorEnv::getEnvConfig('phd.user');
         if (strlen($sudo_user)) {
             $data['S'] = $sudo_user;
         }
         if (function_exists('posix_geteuid')) {
             $system_uid = posix_geteuid();
             $system_info = posix_getpwuid($system_uid);
             $data['s'] = idx($system_info, 'name');
         }
         $client = getenv('SSH_CLIENT');
         if (strlen($client)) {
             $remote_address = head(explode(' ', $client));
             $data['r'] = $remote_address;
         }
         $log = id(new PhutilDeferredLog($path, $format))->setFailQuietly(true)->setData($data);
         self::$log = $log;
     }
     return self::$log;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:28,代码来源:PhabricatorSSHLog.php

示例5: getSystemUser

 /**
  * Get the system user.
  *
  * @return string
  */
 protected function getSystemUser()
 {
     if (str_contains(strtolower(php_uname()), 'windows')) {
         return getenv('USERNAME');
     }
     return posix_getpwuid(posix_geteuid())['name'];
 }
开发者ID:SerdarSanri,项目名称:laracli,代码行数:12,代码来源:ConfigurationParser.php

示例6: setCache

 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\FLOW3\Cache\Frontend\FrontendInterface $cache
  * @return void
  */
 public function setCache(\TYPO3\FLOW3\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
     $pathHash = substr(md5(FLOW3_PATH_WEB . PHP_SAPI . $processUser['name'] . $this->context), 0, 12);
     $this->identifierPrefix = 'FLOW3_' . $pathHash;
 }
开发者ID:nxpthx,项目名称:FLOW3,代码行数:13,代码来源:ApcBackend.php

示例7: obtain

 public function obtain()
 {
     if (function_exists('posix_geteuid') && function_exists('posix_getegid')) {
         $this->myuid = posix_geteuid();
         $this->mygid = posix_getegid();
     } else {
         $randName = '/tmp/rutorrent-' . rand() . '.tmp';
         @file_put_contents($randName, '');
         $ss = @stat($randName);
         if ($ss) {
             $this->mygid = $ss['gid'];
             $this->myuid = $ss['uid'];
             @unlink($randName);
         }
     }
     $req = new rXMLRPCRequest(new rXMLRPCCommand("to_kb", floatval(1024)));
     if ($req->run()) {
         $this->linkExist = true;
         if (!$req->fault) {
             $this->badXMLRPCVersion = false;
         }
         $req = new rXMLRPCRequest(array(new rXMLRPCCommand("get_directory"), new rXMLRPCCommand("get_session"), new rXMLRPCCommand("system.client_version"), new rXMLRPCCommand("system.library_version"), new rXMLRPCCommand("set_xmlrpc_size_limit", 67108863)));
         if ($req->run() && !$req->fault) {
             $this->directory = $req->val[0];
             $this->session = $req->val[1];
             $this->version = $req->val[2];
             $this->libVersion = $req->val[3];
             $parts = explode('.', $this->version);
             $this->iVersion = 0;
             for ($i = 0; $i < count($parts); $i++) {
                 $this->iVersion = ($this->iVersion << 8) + $parts[$i];
             }
             if (is_dir($this->session) && isLocalMode()) {
                 $ss = @stat($this->session . 'rtorrent.lock');
                 if (!$ss) {
                     $ss = @stat($this->session . 'rtorrent.dht_cache');
                 }
                 if (!$ss) {
                     $ss = @stat($this->session);
                 }
                 if ($ss) {
                     $this->gid = $ss['gid'];
                     $this->uid = $ss['uid'];
                     if (!empty($this->directory) && $this->directory[0] == '~') {
                         if (function_exists('posix_getpwuid')) {
                             $ui = posix_getpwuid($this->uid);
                             $this->directory = $ui["dir"] . substr($this->directory, 1);
                         } else {
                             $req = new rXMLRPCRequest(new rXMLRPCCommand("execute_capture", array("echo", "~")));
                             if ($req->run() && !$req->fault) {
                                 $this->directory = trim($req->val[0]) . substr($this->directory, 1);
                             }
                         }
                     }
                 }
             }
             $this->store();
         }
     }
 }
开发者ID:johnymarek,项目名称:eboda-hd-for-all-500,代码行数:60,代码来源:settings.php

示例8: check_file

function check_file($f)
{
    echo "\nFile {$f}\n";
    echo '1.' . (file_exists($f) ? ' exists' : ' does NOT exist') . " \n";
    if (!file_exists($f)) {
        echo 'Remaining checks skipped' . " \n";
        return;
    }
    echo '2. is' . (is_file($f) ? '' : ' NOT') . " a file\n";
    echo '3. is' . (is_readable($f) ? '' : ' NOT') . " readable\n";
    echo '4. is' . (is_writable($f) ? '' : ' NOT') . " writable\n";
    echo '5. has permissions ' . substr(sprintf('%o', fileperms($f)), -4) . "\n";
    echo '6. owner id ' . fileowner($f) . " (0 on Windows, blank if not permitted)\n";
    if (function_exists('posix_geteuid')) {
        $details = posix_getpwuid(posix_geteuid());
        echo '6. owner name ' . $details['name'] . " \n";
        echo '6. owner gid ' . $details['gid'] . " \n";
        $details = posix_getgrgid($details['gid']);
        echo '6. group name ' . $details['name'] . " \n";
    }
    echo '7. group id ' . filegroup($f) . " (0 on Windows, blank if not permitted)\n";
    if (function_exists('posix_getegid')) {
        $details = posix_getgrgid(posix_getegid());
        echo '7. group name ' . $details['name'] . " \n";
    }
}
开发者ID:bklein01,项目名称:Project-Pier,代码行数:26,代码来源:help.php

示例9: GetExpectedPerms_file

 public static function GetExpectedPerms_file($file)
 {
     if (!self::HasFunctions()) {
         return '666';
     }
     //if user id's match
     $puid = posix_geteuid();
     $suid = self::file_uid($file);
     if ($suid !== false && $puid == $suid) {
         return '644';
     }
     //if group id's match
     $pgid = posix_getegid();
     $sgid = self::file_group($file);
     if ($sgid !== false && $pgid == $sgid) {
         return '664';
     }
     //if user is a member of group
     $snam = self::file_owner($file);
     $pmem = self::process_members();
     if (in_array($suid, $pmem) || in_array($snam, $pmem)) {
         return '664';
     }
     return '666';
 }
开发者ID:Bouhnosaure,项目名称:Typesetter,代码行数:25,代码来源:FilePermissions.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (0 != posix_geteuid()) {
         echo "You have to be root to run this command\n";
         return 1;
     }
     $container = $this->getContainer();
     $doctrine = $container->get('doctrine');
     $em = $doctrine->getManager();
     $user = $doctrine->getRepository('BinovoElkarBackupBundle:User')->find(User::SUPERUSER_ID);
     if (!$user) {
         $user = new User();
     } else {
         if ($input->getOption('reset')) {
             echo "Admin user exists. Trying to reset to initial values.\n";
         } else {
             echo "Admin user exists and reset was not requested. Nothing to do.\n";
             return 0;
         }
     }
     $factory = $container->get('security.encoder_factory');
     $encoder = $factory->getEncoder($user);
     $user->setUsername('root');
     $user->setEmail('root@localhost');
     $user->setRoles(array('ROLE_ADMIN'));
     $user->setSalt(md5(uniqid(null, true)));
     $password = $encoder->encodePassword('root', $user->getSalt());
     $user->setPassword($password);
     $em->persist($user);
     $em->flush();
     return 0;
 }
开发者ID:xezpeleta,项目名称:elkarbackup,代码行数:32,代码来源:CreateAdminUserCommand.php

示例11: setCache

 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache
  * @return void
  */
 public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
     $pathHash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(PATH_site . $processUser['name'] . $this->context, 12);
     $this->identifierPrefix = 'TYPO3_' . $pathHash;
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:13,代码来源:ApcBackend.php

示例12: handleLaunchEvent

 private function handleLaunchEvent(PhutilEvent $event)
 {
     $id = $event->getValue('id');
     $current_user = posix_getpwuid(posix_geteuid());
     $daemon = id(new PhabricatorDaemonLog())->setDaemonID($id)->setDaemon($event->getValue('daemonClass'))->setHost(php_uname('n'))->setPID(getmypid())->setRunningAsUser($current_user['name'])->setStatus(PhabricatorDaemonLog::STATUS_RUNNING)->setArgv($event->getValue('argv'))->setExplicitArgv($event->getValue('explicitArgv'))->save();
     $this->daemons[$id] = $daemon;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorDaemonEventListener.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         if (!$input->getOption('allow-root')) {
             $aProcessUser = posix_getpwuid(posix_geteuid());
             if ($aProcessUser['name'] == 'root') {
                 throw new \InvalidArgumentException('You can however run a command with ' . 'sudo using --allow-root option');
             }
         }
         DaemonUtils::configCheck();
         //Check daemons
         $daemons = DaemonUtils::getDaemonsFromConfig();
         foreach ($daemons as $daemon) {
             if (!$daemon instanceof DaemonizerInterface) {
                 throw new \Exception('Invalid [cli-daemonizer.php] file: file contain not-implementer ' . 'DaemonizerInterface class');
             }
             DaemonUtils::checkScheduleItem($daemon->getSchedule(), get_class($daemon));
         }
         $id = mt_rand(1, 100000);
         shell_exec(DAEMON_FILE . " internal:master --id={$id} > /dev/null 2>&1 &");
         $output->writeln("<info>Daemon started</info>");
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }
开发者ID:pilat,项目名称:daemonizer,代码行数:25,代码来源:Start.php

示例14: checkPermissions

 public function checkPermissions()
 {
     // Check we have permissions to create project and run system events
     if (posix_geteuid() != 0) {
         throw new Project_Creation_Exception("You need to be root to create a project for import");
     }
 }
开发者ID:ansarbek,项目名称:tuleap,代码行数:7,代码来源:SystemEventRunner.class.php

示例15: main

 /**
  * Вход в управление сервисом Pinger.
  * 
  * @param array $argv Копия массива <code>$argv</code> с аргументами вызова скрипта.
  * @access public
  * @static
  */
 public static function main($argv)
 {
     if ('cli' !== PHP_SAPI) {
         echo "CLI only!\n";
         exit(1);
     }
     if (0 !== posix_geteuid()) {
         echo "Error: Pinger Service must be launched as root!\n";
         exit(1);
     }
     $argv += array_fill(0, 4, null);
     switch ($argv[1]) {
         case 'start':
             static::cmdStart();
             break;
         case 'stop':
             static::cmdStop();
             break;
         case 'restart':
             static::cmdRestart();
             break;
         case 'reload':
             static::cmdReload();
             break;
         case 'status':
             static::cmdStatus();
             break;
         case 'help':
         default:
             static::cmdHelp($argv[1], $argv[2]);
             break;
     }
     exit(0);
 }
开发者ID:Ganzal,项目名称:php-pinger-service,代码行数:41,代码来源:PingerService.php


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