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


PHP posix_getgid函数代码示例

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


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

示例1: check_writable_relative

function check_writable_relative($dir)
{
    $uid = posix_getuid();
    $gid = posix_getgid();
    $user_info = posix_getpwuid($uid);
    $user = $user_info['name'];
    $group_info = posix_getgrgid($gid);
    $group = $group_info['name'];
    $fix_cmd = '. ' . _("To fix that, execute following commands as root") . ':<br><br>' . "cd " . getcwd() . "<br>" . "mkdir -p {$dir}<br>" . "chown {$user}:{$group} {$dir}<br>" . "chmod 0700 {$dir}";
    if (!is_dir($dir)) {
        $config_nt = array('content' => _("Required directory " . getcwd() . "{$dir} does not exist") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
    if (!($stat = stat($dir))) {
        $config_nt = array('content' => _("Could not stat configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
    // 2 -> file perms (must be 0700)
    // 4 -> uid (must be the apache uid)
    // 5 -> gid (must be the apache gid)
    if ($stat[2] != 16832 || $stat[4] !== $uid || $stat[5] !== $gid) {
        $config_nt = array('content' => _("Invalid perms for configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
}
开发者ID:AntBean,项目名称:alienvault-ossim,代码行数:31,代码来源:view.php

示例2: _getCurrentGroup

 private function _getCurrentGroup()
 {
     if (function_exists('posix_getgid')) {
         return posix_getgid();
     }
     return '';
 }
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:7,代码来源:SugarFileUtilsTest.php

示例3: doRepositoryTest

 function doRepositoryTest($repo)
 {
     if ($repo->accessType != "ssh") {
         return -1;
     }
     $basePath = "../../../plugins/access.ssh/";
     // Check file exists
     if (!file_exists($basePath . "class.sshAccessDriver.php") || !file_exists($basePath . "class.SSHOperations.php") || !file_exists($basePath . "manifest.xml") || !file_exists($basePath . "showPass.php") || !file_exists($basePath . "sshActions.xml")) {
         $this->failedInfo .= "Missing at least one of the plugin files (class.sshDriver.php, class.SSHOperations.php, manifest.xml, showPass.php, sshActions.xml).\nPlease reinstall from lastest release.";
         return FALSE;
     }
     // Check if showPass is executable from ssh
     $stat = stat($basePath . "showPass.php");
     $mode = $stat['mode'] & 0x7fff;
     // We don't care about the type
     if (!is_executable($basePath . 'showPass.php') && ($mode & 0x40 && $stat['uid'] == posix_getuid()) && ($mode & 0x8 && $stat['gid'] == posix_getgid()) && $mode & 0x1) {
         chmod($basePath . 'showPass.php', 0555);
         if (!is_executable($basePath . 'showPass.php')) {
             $this->failedInfo .= "showPass.php must be executable. Please log in on your server and set showPass.php as executable (chmod u+x showPass.php).";
             return FALSE;
         }
     }
     // Check if ssh is accessible
     $handle = popen("ssh 2>&1", "r");
     $usage = fread($handle, 30);
     pclose($handle);
     if (strpos($usage, "usage") === FALSE) {
         $this->failedInfo .= "Couldn't find or execute 'ssh' on your system. Please install latest SSH client.";
         return FALSE;
     }
     return TRUE;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:32,代码来源:test.sshAccess.php

示例4: setUp

 public function setUp()
 {
     $this->uid = function_exists('posix_getuid') ? posix_getuid() : 0;
     $this->gid = function_exists('posix_getgid') ? posix_getgid() : 0;
     @$na['n/a'];
     //putting error in known state
 }
开发者ID:mathroc,项目名称:php-vfs,代码行数:7,代码来源:WrapperTest.php

示例5: fingerprint

function fingerprint($params = array())
{
    $profile = array('os' => PHP_OS, 'system_name' => php_uname('s'), 'system_release' => php_uname('r'), 'system_version' => php_uname('v'), 'machine_type' => php_uname('m'), 'host_name' => php_uname('n'), 'php_server_api' => php_sapi_name(), 'php_version' => phpversion(), 'uid' => posix_getuid(), 'gid' => posix_getgid(), 'cwd' => getcwd(), 'disk_free_space' => disk_free_space('/'), 'disk_total_space' => disk_total_space('/'));
    switch ($profile['php_server_api']) {
        case 'apache':
            $profile['apache_version'] = apache_get_version();
            break;
    }
    return $profile;
}
开发者ID:ronin-ruby,项目名称:ronin-ruby.github.io,代码行数:10,代码来源:server.php

示例6: getOption

 protected function getOption($name, $user = "", $pass = "")
 {
     $opt = $this->options[$name];
     $opt = str_replace("AJXP_USER", $user, $opt);
     $opt = str_replace("AJXP_PASS", "'{$pass}'", $opt);
     $opt = str_replace("AJXP_SERVER_UID", posix_getuid(), $opt);
     $opt = str_replace("AJXP_SERVER_GID", posix_getgid(), $opt);
     if (stristr($opt, "AJXP_REPOSITORY_PATH") !== false) {
         $repo = ConfService::getRepository();
         $path = $repo->getOption("PATH");
         $opt = str_replace("AJXP_REPOSITORY_PATH", $path, $opt);
     }
     return $opt;
 }
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:14,代码来源:class.FilesystemMounter.php

示例7: start

 function start($argv)
 {
     $appName = $this->appName;
     if (file_exists($this->command_file())) {
         unlink($this->command_file());
     }
     if (array_search("--background", $argv)) {
         System_Daemon::setOption("appName", $appName);
         System_Daemon::setOption("appRunAsUID", posix_getuid());
         System_Daemon::setOption("appRunAsGID", posix_getgid());
         System_Daemon::setOption("logLocation", getenv('WSETCDIR') . "/logs/{$appName}");
         System_Daemon::setOption("appPidLocation", getenv('WSETCDIR') . "/pushd/{$appName}/{$appName}.pid");
         System_Daemon::setOption('logPhpErrors', true);
         System_Daemon::setOption('logFilePosition', true);
         System_Daemon::setOption('logLinePosition', true);
         System_Daemon::start();
     }
 }
开发者ID:jamespaulmuir,项目名称:MIT-Mobile-Framework,代码行数:18,代码来源:DaemonWrapper.php

示例8: handle

 /**
  * Handle an event.
  *
  * @param \League\Event\EventInterface $event The triggering event
  *
  * @return void
  * @see \League\Event\ListenerInterface::handle()
  */
 public function handle(EventInterface $event)
 {
     try {
         // load the application server instance
         /** @var \AppserverIo\Appserver\Core\Interfaces\ApplicationServerInterface $applicationServer */
         $applicationServer = $this->getApplicationServer();
         // write a log message that the event has been invoked
         $applicationServer->getSystemLogger()->info($event->getName());
         // don't do anything under Windows
         if (FileSystem::getOsIdentifier() === 'WIN') {
             $applicationServer->getSystemLogger()->info('Don\'t switch UID to \'%s\' because OS is Windows');
             return;
         }
         // initialize the variable for user/group
         $uid = 0;
         $gid = 0;
         // throw an exception if the POSIX extension is not available
         if (extension_loaded('posix') === false) {
             throw new \Exception('Can\'t switch user, because POSIX extension is not available');
         }
         // print a message with the old UID/EUID
         $applicationServer->getSystemLogger()->info("Running as " . posix_getuid() . "/" . posix_geteuid());
         // extract the user and group name as variables
         extract(posix_getgrnam($applicationServer->getSystemConfiguration()->getGroup()));
         extract(posix_getpwnam($applicationServer->getSystemConfiguration()->getUser()));
         // switch the effective GID to the passed group
         if (posix_setegid($gid) === false) {
             $applicationServer->getSystemLogger()->error(sprintf('Can\'t switch GID to \'%s\'', $gid));
         }
         // print a message with the new GID/EGID
         $applicationServer->getSystemLogger()->info("Running as group" . posix_getgid() . "/" . posix_getegid());
         // switch the effective UID to the passed user
         if (posix_seteuid($uid) === false) {
             $applicationServer->getSystemLogger()->error(sprintf('Can\'t switch UID to \'%s\'', $uid));
         }
         // print a message with the new UID/EUID
         $applicationServer->getSystemLogger()->info("Running as user " . posix_getuid() . "/" . posix_geteuid());
     } catch (\Exception $e) {
         $applicationServer->getSystemLogger()->error($e->__toString());
     }
 }
开发者ID:jinchunguang,项目名称:appserver,代码行数:49,代码来源:SwitchUserListener.php

示例9: check_writable_relative

function check_writable_relative($dir)
{
    $uid = posix_getuid();
    $gid = posix_getgid();
    $user_info = posix_getpwuid($uid);
    $user = $user_info['name'];
    $group_info = posix_getgrgid($gid);
    $group = $group_info['name'];
    $fix_cmd = '. ' . _("To fix that, execute following commands as root") . ':<br><br>' . "cd " . getcwd() . "<br>" . "mkdir -p {$dir}<br>" . "chown {$user}:{$group} {$dir}<br>" . "chmod 0700 {$dir}";
    if (!is_dir($dir)) {
        die(_("Required directory " . getcwd() . "{$dir} does not exist") . $fix_cmd);
    }
    $fix_cmd .= $fix_extra;
    if (!($stat = stat($dir))) {
        die(_("Could not stat configs dir") . $fix_cmd);
    }
    // 2 -> file perms (must be 0700)
    // 4 -> uid (must be the apache uid)
    // 5 -> gid (must be the apache gid)
    if ($stat[2] != 16832 || $stat[4] !== $uid || $stat[5] !== $gid) {
        die(_("Invalid perms for configs dir") . $fix_cmd);
    }
}
开发者ID:jhbsz,项目名称:ossimTest,代码行数:23,代码来源:view.php

示例10: changeIdentity

 /**
  * Method to change the identity of the daemon process and resources.
  *
  * @return  boolean  True if identity successfully changed
  *
  * @since   11.1
  * @see     posix_setuid()
  */
 protected function changeIdentity()
 {
     // Get the group and user ids to set for the daemon.
     $uid = (int) $this->config->get('application_uid', 0);
     $gid = (int) $this->config->get('application_gid', 0);
     // Get the application process id file path.
     $file = $this->config->get('application_pid_file');
     // Change the user id for the process id file if necessary.
     if ($uid && fileowner($file) != $uid && !@chown($file, $uid)) {
         JLog::add('Unable to change user ownership of the process id file.', JLog::ERROR);
         return false;
     }
     // Change the group id for the process id file if necessary.
     if ($gid && filegroup($file) != $gid && !@chgrp($file, $gid)) {
         JLog::add('Unable to change group ownership of the process id file.', JLog::ERROR);
         return false;
     }
     // Set the correct home directory for the process.
     if ($uid && ($info = posix_getpwuid($uid)) && is_dir($info['dir'])) {
         system('export HOME="' . $info['dir'] . '"');
     }
     // Change the user id for the process necessary.
     if ($uid && posix_getuid($file) != $uid && !@posix_setuid($uid)) {
         JLog::add('Unable to change user ownership of the proccess.', JLog::ERROR);
         return false;
     }
     // Change the group id for the process necessary.
     if ($gid && posix_getgid($file) != $gid && !@posix_setgid($gid)) {
         JLog::add('Unable to change group ownership of the proccess.', JLog::ERROR);
         return false;
     }
     // Get the user and group information based on uid and gid.
     $user = posix_getpwuid($uid);
     $group = posix_getgrgid($gid);
     JLog::add('Changed daemon identity to ' . $user['name'] . ':' . $group['name'], JLog::INFO);
     return true;
 }
开发者ID:raquelsa,项目名称:Joomla,代码行数:45,代码来源:daemon.php

示例11: getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider

 /**
  * Dataprovider for getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser test
  *
  * @return array group, filemode and expected result
  */
 public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider()
 {
     $data = array();
     // On some OS, the posix_* functions do not exits
     if (function_exists('posix_getgid')) {
         $data = array('current group, readable/writable' => array(posix_getgid(), 48, array('r' => TRUE, 'w' => TRUE)), 'current group, readable/not writable' => array(posix_getgid(), 32, array('r' => TRUE, 'w' => FALSE)), 'current group, not readable/not writable' => array(posix_getgid(), 0, array('r' => FALSE, 'w' => FALSE)));
     }
     $data = array_merge_recursive($data, array('arbitrary group, readable/writable' => array(vfsStream::GROUP_USER_1, 6, array('r' => TRUE, 'w' => TRUE)), 'arbitrary group, readable/not writable' => array(vfsStream::GROUP_USER_1, 436, array('r' => TRUE, 'w' => FALSE)), 'arbitrary group, not readable/not writable' => array(vfsStream::GROUP_USER_1, 432, array('r' => FALSE, 'w' => FALSE))));
     return $data;
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:15,代码来源:LocalDriverTest.php

示例12: getGid

 public function getGid()
 {
     if (null === $this->_gid) {
         if (function_exists('posix_getgid')) {
             $this->_gid = posix_getgid();
         } else {
             // Find another way to do it?
             $this->_gid = false;
         }
     }
     return $this->_gid;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:12,代码来源:System.php

示例13: posix_getgid

<?php

echo "Basic test of POSIX getgid and getgrid fucntions\n";
$gid = posix_getgid();
$groupinfo = posix_getgrgid($gid);
print_r($groupinfo);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:posix_getgrgid_basic.php

示例14: posix_getgrgid

		<?php 
if (!$cfg->error) {
    ?>
			<form action="step1.php">
				<input type="submit" value="Go to step one: Pre flight check" />
			</form>
		<?php 
} else {
    if (!$cfg->cacheCheck) {
        ?>
				<div class="error">
					The template compile dir must be writable.<br />A quick solution is to run:	<br />
					<?php 
        echo 'chmod 777 ' . SMARTY_DIR . 'templates_c';
        if (extension_loaded('posix') && strtolower(substr(PHP_OS, 0, 3)) !== 'win') {
            $group = posix_getgrgid(posix_getgid());
            echo '<br /><br />Another solution is to run:<br />chown -R YourUnixUserName:' . $group['name'] . ' ' . nZEDb_ROOT . '<br />Then give your user access to the group:<br />usermod -a -G ' . $group['name'] . ' YourUnixUserName' . '<br />Finally give read/write access to your user/group:<br />chmod -R 774 ' . nZEDb_ROOT;
        }
        ?>
				</div>
			<?php 
    } else {
        ?>
				<div class="error">Installation Locked! If reinstalling, please remove www/install/install.lock.</div>
			<?php 
    }
}
?>
	</div>

	<div class="footer">
开发者ID:EeGgSs,项目名称:nZEDb,代码行数:31,代码来源:index.php

示例15: posix_getgrnam

 You should have received a copy of the GNU General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ***********************************************************/
/**
 * @file migratetest.php
 * @brief Test migration function
 *
 * @return 0 for success, 1 for failure.
 **/
/* User must be in group fossy! */
$GID = posix_getgrnam("fossy");
posix_setgid($GID['gid']);
$Group = `groups`;
if (!preg_match("/\\sfossy\\s/", $Group) && posix_getgid() != $GID['gid']) {
    print "FATAL: You must be in group 'fossy' to update the FOSSology database.\n";
    exit(1);
}
/* Initialize the program configuration variables */
$SysConf = array();
// fo system configuration variables
$PG_CONN = 0;
// Database connection
$Plugins = array();
/* defaults */
$Verbose = false;
$DatabaseName = "fossology";
$UpdateLiceneseRef = false;
$sysconfdir = '/usr/local/etc/fossology';
/* Set SYSCONFDIR and set global (for backward compatibility) */
开发者ID:pombredanne,项目名称:fossology-test,代码行数:30,代码来源:migratetest.php


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