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


PHP posix_getpwuid函数代码示例

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


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

示例1: getHome

 /**
  * Determine HOME directory.
  *
  * @return  string                                      Home directory.
  */
 public static function getHome()
 {
     if (($home = getenv('HOME')) === '') {
         $home = posix_getpwuid(posix_getuid())['dir'];
     }
     return $home;
 }
开发者ID:octris,项目名称:cliconfig,代码行数:12,代码来源:Cliconfig.php

示例2: 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

示例3: __construct

 public function __construct()
 {
     $this->opo_search_base = new SearchBase();
     $this->opo_app_config = Configuration::load();
     $this->opo_search_config = Configuration::load($this->opo_app_config->get("search_config"));
     $this->opo_search_indexing_config = Configuration::load($this->opo_search_config->get("search_indexing_config"));
     $this->ops_webserver_user = posix_getpwuid(posix_getuid());
     $this->ops_webserver_user = $this->ops_webserver_user['name'];
     $this->opa_setting_descriptions = array();
     $this->opa_setting_names = array();
     $this->opa_setting_hints = array();
     $this->_initMessages();
     // allow overriding settings from search.conf via constant (usually defined in bootstrap file)
     // this is useful for multi-instance setups which have the same set of config files for multiple instances
     if (defined('__CA_SOLR_URL__') && strlen(__CA_SOLR_URL__) > 0) {
         $this->ops_search_solr_url = __CA_SOLR_URL__;
     } else {
         $this->ops_search_solr_url = $this->opo_search_config->get('search_solr_url');
     }
     if (defined('__CA_SOLR_HOME_DIR__') && strlen(__CA_SOLR_HOME_DIR__) > 0) {
         $this->ops_search_solr_home_dir = __CA_SOLR_HOME_DIR__;
     } else {
         $this->ops_search_solr_home_dir = $this->opo_search_config->get('search_solr_home_dir');
     }
     parent::__construct();
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:26,代码来源:SolrConfigurationSettings.php

示例4: getProcessUser

 /**
  * Get the system user of the user of the current process
  *
  * @return string
  */
 protected function getProcessUser()
 {
     // $userInfo = posix_getpwuid(posix_geteuid());
     $userInfo = posix_getpwuid(posix_getuid());
     $userName = $userInfo['name'];
     return $userName;
 }
开发者ID:JanOschii,项目名称:webird,代码行数:12,代码来源:Task.php

示例5: 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

示例6: 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

示例7: formatGroup

 /**
  * @param SplFileInfo|null $splFileInfo
  *
  * @return string
  */
 public function formatGroup(SplFileInfo $splFileInfo = null)
 {
     if ($splFileInfo) {
         return posix_getpwuid($splFileInfo->getGroup())['name'];
     }
     return '';
 }
开发者ID:peteraba,项目名称:dm-fileman,代码行数:12,代码来源:Formatter.php

示例8: listDirectory

 function listDirectory()
 {
     global $osC_Language, $toC_Json, $osC_MessageStack;
     $directory = OSC_ADMIN_FILE_MANAGER_ROOT_PATH;
     if (isset($_REQUEST['directory']) && !empty($_REQUEST['directory'])) {
         $directory .= '/' . urldecode($_REQUEST['directory']);
     } elseif (isset($_REQUEST['goto']) && !empty($_REQUEST['goto'])) {
         $directory .= '/' . urldecode($_REQUEST['goto']);
     }
     $osC_DirectoryListing = new osC_DirectoryListing($directory);
     $osC_DirectoryListing->setStats(true);
     $records = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $file_owner = function_exists('posix_getpwuid') ? posix_getpwuid($file['user_id']) : '-?-';
         $group_owner = function_exists('posix_getgrgid') ? posix_getgrgid($file['group_id']) : '-?-';
         if ($file['is_directory'] === true) {
             $entry_icon = osc_icon('folder_red.png');
             $action = array(array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         } else {
             $entry_icon = osc_icon('file.png');
             $action = array(array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit')), array('class' => 'icon-download-record', 'qtip' => $osC_Language->get('icon_download')), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         }
         $records[] = array('icon' => $entry_icon, 'file_name' => $file['name'], 'is_directory' => $file['is_directory'], 'size' => number_format($file['size']), 'permission' => osc_get_file_permissions($file['permissions']), 'file_owner' => $file_owner, 'group_owner' => $group_owner, 'writeable' => osc_icon(is_writable($osC_DirectoryListing->getDirectory() . '/' . $file['name']) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'), 'last_modified_date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($file['last_modified']), true), 'action' => $action);
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:27,代码来源:file_manager.php

示例9: sudoCommandAsDaemonUser

 /**
  * Format a command so it executes as the daemon user, if a daemon user is
  * defined. This wraps the provided command in `sudo -u ...`, roughly.
  *
  * @param   PhutilCommandString Command to execute.
  * @return  PhutilCommandString `sudo` version of the command.
  */
 public static function sudoCommandAsDaemonUser($command)
 {
     $user = PhabricatorEnv::getEnvConfig('phd.user');
     if (!$user) {
         // No daemon user is set, so just run this as ourselves.
         return $command;
     }
     // We may reach this method while already running as the daemon user: for
     // example, active and passive synchronization of clustered repositories
     // run the same commands through the same code, but as different users.
     // By default, `sudo` won't let you sudo to yourself, so we can get into
     // trouble if we're already running as the daemon user unless the host has
     // been configured to let the daemon user run commands as itself.
     // Since this is silly and more complicated than doing this check, don't
     // use `sudo` if we're already running as the correct user.
     if (function_exists('posix_getuid')) {
         $uid = posix_getuid();
         $info = posix_getpwuid($uid);
         if ($info && $info['name'] == $user) {
             return $command;
         }
     }
     // Get the absolute path so we're safe against the caller wiping out
     // PATH.
     $sudo = Filesystem::resolveBinary('sudo');
     if (!$sudo) {
         throw new Exception(pht("Unable to find 'sudo'!"));
     }
     // Flags here are:
     //
     //   -E: Preserve the environment.
     //   -n: Non-interactive. Exit with an error instead of prompting.
     //   -u: Which user to sudo to.
     return csprintf('%s -E -n -u %s -- %C', $sudo, $user, $command);
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:42,代码来源:PhabricatorDaemon.php

示例10: idpinstaller_hook_step5

/**
 * Hook a ejecutar antes del paso 5 de la instalación
 * Extrae cuales son las fuentes de datos principales que podría utilizarse
 *
 * @param array &$data  Los datos a utilizar por las plantillas de tipo stepn
 */
function idpinstaller_hook_step5(&$data)
{
    $data['datasources'] = getDataSources();
    $require_mods = array("saml", "idpinstaller", "modinfo", "ldap", "sqlauth", "core", "portal", "sir2skin");
    //Modulos obligatorios
    $ssphpobj = $data['ssphpobj'];
    $modules = SimpleSAML_Module::getModules();
    sort($modules);
    $perms_ko = array();
    $modules_ko = array();
    foreach ($modules as $m) {
        $f = realpath(__DIR__ . '/../../' . $m);
        if (!file_exists($f . '/default-disable') && !file_exists($f . '/default-enable') && in_array($m, $require_mods)) {
            $modules_ko[] = $f;
        } elseif (file_exists($f . '/default-disable') && !is_writable($f . '/default-disable') || file_exists($f . '/default-enable') && !is_writable($f . '/default-enable')) {
            $perms_ko[] = $f;
        } else {
            if (in_array($m, $require_mods)) {
                //PARA LOS QUE SI QUEREMOS ACTIVAR
                if (file_exists($f . '/default-disable')) {
                    @unlink($f . '/default-disable');
                    @touch($f . '/default-enable');
                    if (!file_exists($f . '/default-enable')) {
                        $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
                    }
                }
            } else {
                //PARA LOS QUE QUEREMOS DESACTIVAR
                if (file_exists($f . '/default-enable')) {
                    @unlink($f . '/default-enable');
                    @touch($f . '/default-disable');
                    if (!file_exists($f . '/default-disable')) {
                        $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
                    }
                }
            }
        }
    }
    if (count($modules_ko) > 0) {
        $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
    } elseif (count($perms_ko) > 0) {
        if (function_exists('posix_getgrnam')) {
            $aux = "<br/>" . $ssphpobj->t('{idpinstaller:idpinstaller:step4_perms_ko}');
            $filename = $perms_ko[0];
            $file_owner = posix_getpwuid(fileowner($filename));
            $group = posix_getgrgid(posix_getgid());
            $recursive = is_dir($filename) ? "-R" : "";
            $aux .= "<pre>&gt; chown {$recursive} " . $file_owner['name'] . ":" . $group['name'] . " {$filename}\n&gt; chmod {$recursive} g+w " . $filename . "</pre>";
        }
        $data['errors'][] = $aux;
        $data['errors'][] = $ssphpobj->t("{idpinstaller:idpinstaller:step1_remember_change_perms}");
    }
    if (count($data['errors']) == 0) {
        $data['info'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_all_ok}');
    }
    /*else {
          $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
      }*/
    return true;
}
开发者ID:rediris-es,项目名称:simplesamlphp-module-idpinstaller,代码行数:66,代码来源:hook_step5.php

示例11: 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

示例12: walkdir

function walkdir($path, $exclusions, &$array)
{
    global $root_length;
    $rs = @opendir($path);
    if (!$rs) {
        exit(3);
    }
    while ($file = readdir($rs)) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $current_path = "{$path}/{$file}";
        if (is_excluded($current_path)) {
            continue;
        }
        $stat = stat($current_path);
        $group_entry = posix_getgrgid($stat['gid']);
        $user_entry = posix_getpwuid($stat['uid']);
        $group = $group_entry['name'];
        $user = $user_entry['name'];
        $relative_path = substr($current_path, $root_length + 1);
        $array[] = $relative_path . ';' . $stat['mode'] . ';' . $stat['nlink'] . ';' . $stat['uid'] . ';' . $user . ';' . $stat['gid'] . ';' . $group . ';' . $stat['size'] . ';' . $stat['atime'] . ';' . $stat['mtime'] . ';' . $stat['ctime'];
        if (is_dir($current_path)) {
            walkdir($current_path, $exclusions, $array);
        }
    }
    closedir($rs);
}
开发者ID:wuthering-bytes,项目名称:php-tools,代码行数:28,代码来源:findfiles.php

示例13: paloConfig

 function paloConfig($directorio, $archivo, $separador = "", $separador_regexp = "", $usuario_proceso = NULL)
 {
     $this->directorio = $directorio;
     $this->archivo = $archivo;
     $this->separador = $separador;
     $this->separador_regexp = $separador_regexp;
     if (!is_null($usuario_proceso)) {
         $this->usuario_proceso = $usuario_proceso;
     } else {
         $arr_user = posix_getpwuid(posix_getuid());
         if (is_array($arr_user) && array_key_exists("name", $arr_user)) {
             $this->usuario_proceso = $arr_user['name'];
         }
     }
     //Debo setear el usuario de sistema y el grupo dependiendo del usuario y grupo propietario del archivo
     $ruta_archivo = $directorio . "/" . $archivo;
     if (file_exists($ruta_archivo)) {
         $arr_usuario = posix_getpwuid(fileowner($ruta_archivo));
         if (is_array($arr_usuario)) {
             $this->usuario_sistema = $arr_usuario['name'];
         }
         $arr_grupo = posix_getgrgid(filegroup($ruta_archivo));
         if (is_array($arr_grupo)) {
             $this->grupo_sistema = $arr_grupo['name'];
         }
     }
     /*
     echo "ruta_archivo=".$ruta_archivo."<br>usuario_sistema=".$this->usuario_sistema."<br>grupo_sistema=".
          $this->grupo_sistema."<br>usuario_proceso= ".$this->usuario_proceso."<br>";
     echo "<script>alert('alto =)');</script>";
     */
 }
开发者ID:lordbasex,项目名称:elastix-gui,代码行数:32,代码来源:paloSantoConfig.class.php

示例14: configure

 protected function configure()
 {
     parent::configure();
     $info = posix_getpwuid(posix_getuid());
     $home = isset($info['dir']) ? $info['dir'] : '/tmp';
     $this->setName('site:backup')->addOption('directory', null, InputOption::VALUE_REQUIRED, "Target directory where backups should be stored", $home)->setDescription('Backup a site');
 }
开发者ID:janich,项目名称:joomla-console-backup,代码行数:7,代码来源:Backup.php

示例15: user_home_directory

 public static function user_home_directory()
 {
     // Gets the system user's home directory
     static $userhome = null;
     if ($userhome == null) {
         if (function_exists('posix_getpwuid') && function_exists('posix_getuid')) {
             $userinfo = posix_getpwuid(posix_getuid());
             $userhome = $userinfo['dir'];
         } else {
             if ($home = pts_client::read_env('HOME')) {
                 $userhome = $home;
             } else {
                 if ($home = pts_client::read_env('HOMEPATH')) {
                     $userhome = pts_client::read_env('HOMEDRIVE') . $home;
                 } else {
                     if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
                         $userhome = PTS_USER_PATH;
                     } else {
                         if (!is_writable('/')) {
                             echo PHP_EOL . 'ERROR: Cannot find home directory.' . PHP_EOL;
                         }
                         $userhome = null;
                     }
                 }
             }
         }
         $userhome = pts_strings::add_trailing_slash($userhome);
     }
     return $userhome;
 }
开发者ID:pacificIT,项目名称:phoronix-test-suite,代码行数:30,代码来源:pts-core.php


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