本文整理汇总了PHP中posix_geteuid函数的典型用法代码示例。如果您正苦于以下问题:PHP posix_geteuid函数的具体用法?PHP posix_geteuid怎么用?PHP posix_geteuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了posix_geteuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_mail_sender
function test_mail_sender($to = "[email protected]")
{
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
示例16: testChangeGroup
public function testChangeGroup()
{
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$this->markTestSkipped("chown tests don't work on Windows");
}
$userinfo = posix_getpwuid(posix_geteuid());
$username = $userinfo['name'];
//we may change the group only if we belong to it
//so find a group that we are in
$group = null;
foreach (array('users', 'www-data', 'cdrom') as $groupname) {
$grpinfo = posix_getgrnam($groupname);
if ($grpinfo['gid'] == $userinfo['gid']) {
//current group id, the file has that group anyway
continue;
}
if (in_array($username, $grpinfo['members'])) {
$group = $grpinfo;
break;
}
}
if ($group === null) {
$this->markTestSkipped('found no group we can change ownership to');
}
$this->project->setUserProperty('targetuser', $username . '.' . $group['name']);
$this->executeTarget(__FUNCTION__);
$a = stat(PHING_TEST_BASE . '/etc/tasks/system/tmp/chowntestA');
$b = stat(PHING_TEST_BASE . '/etc/tasks/system/tmp/chowntestB');
$this->assertNotEquals($group['gid'], $a['gid'], 'chowntestA group should not have changed');
$this->assertEquals($group['gid'], $b['gid'], 'chowntestB group should have changed');
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:31,代码来源:ChownTaskTest.php
示例17: show_about
/**
* @version $Id: footer.php 107 2008-07-22 17:27:12Z soeren $
* @package eXtplorer
* @copyright soeren 2007
* @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
* @author The The QuiX project (http://quixplorer.sourceforge.net)
*
* @license
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU General Public License Version 2 or later (the "GPL"), in
* which case the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this file
* under either the MPL or the GPL."
*
* Shows the About Box!
*/
function show_about()
{
// footer for html-page
echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\r\n\t<img src=\"" . _EXT_URL . "/images/MangosWeb_small.png\" align=\"middle\" alt=\"Mangosweb Enhanced Logo\" />\r\n\t<br />\r\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\r\n\t<br />\r\n (<a href=\"http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\r\n\t\r\n\t";
if (function_exists("disk_free_space")) {
$size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']);
$free = parse_file_size($size);
} elseif (function_exists("diskfreespace")) {
$size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']);
$free = parse_file_size($size);
} else {
$free = "?";
}
echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n";
if (extension_loaded("posix")) {
$owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' ';
if (ext_isFTPMode()) {
$my_user_info = posix_getpwnam($_SESSION['ftp_login']);
$my_group_info = posix_getgrgid($my_user_info['gid']);
} else {
$my_user_info = posix_getpwuid(posix_geteuid());
$my_group_info = posix_getgrgid(posix_getegid());
}
$owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')';
echo $owner_info;
}
echo "\r\n\t</div>";
}
开发者ID:BACKUPLIB,项目名称:mwenhanced,代码行数:59,代码来源:footer.php
示例18: setCache
/**
* Initializes the identifier prefix when setting the cache.
*
* @param t3lib_cache_frontend_Frontend $cache The frontend for this backend
* @return void
* @author Robert Lemke <[email protected]>
*/
public function setCache(t3lib_cache_frontend_Frontend $cache)
{
parent::setCache($cache);
$processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
$pathHash = t3lib_div::shortMD5(PATH_site . $processUser['name'], 12);
$this->identifierPrefix = 'TYPO3_' . $pathHash;
}
开发者ID:zsolt-molnar,项目名称:TYPO3-4.5-trunk,代码行数:14,代码来源:class.t3lib_cache_backend_apcbackend.php
示例19: isRoot
/**
* Check is current user ROOT
*
* @return bool
*/
public static function isRoot()
{
if (self::isFunc('posix_geteuid')) {
return posix_geteuid() === 0;
}
return false;
// @codeCoverageIgnore
}
开发者ID:jbzoo,项目名称:utils,代码行数:13,代码来源:Sys.php
示例20: ExitIfNotRoot
/**
* Ensures that the user is running this PHP script with root
* permissions. If not running with root permissions, causes the
* script to exit.
*/
public static function ExitIfNotRoot()
{
// Need to check that we are superuser before running this.
if (posix_geteuid() != 0) {
echo "Must be root user.\n";
exit(1);
}
}
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:13,代码来源:AirtimeInstall.php
注:本文中的posix_geteuid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论