• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP posix_getgrnam函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


示例2: preUp

 public function preUp()
 {
     $this->needed_group_name = 'codendiadm';
     $codendi_ugroup = posix_getgrnam($this->needed_group_name);
     $this->codendi_ugroup_id = $codendi_ugroup['gid'];
     $this->needed_access_right = '0755';
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:201504171343_restore_FRS_owner_group.php


示例3: import

 public function import($id_)
 {
     Logger::debug('main', 'UserGroupDB::unix::import(' . $id_ . ')');
     $tab = posix_getgrnam($id_);
     if (is_array($tab)) {
         $id = '';
         $name = '';
         $description = '';
         $published = true;
         $members = null;
         if (isset($tab['name'])) {
             $id = $tab['name'];
             $name = $tab['name'];
         }
         if (isset($tab['members'])) {
             $members = $tab['members'];
         }
         $ug = new UsersGroup($id, $name, $description, $published);
         if (is_array($members)) {
             $ug->extras = array('member' => $members);
         }
         if ($this->isOK($ug)) {
             return $ug;
         }
     }
     return NULL;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:27,代码来源:unix.php


示例4: setUsersGid

 protected function setUsersGid()
 {
     // figure out the GID for "users" for tests
     $this->usersGid = 1000;
     // default
     if (posix_geteuid() === 0 && function_exists('posix_getgrnam')) {
         $info = posix_getgrnam('users');
         $this->usersGid = $info['gid'];
     }
 }
开发者ID:alex-fang,项目名称:Archive,代码行数:10,代码来源:v7_tar_test.php


示例5: __construct

 /**
  * 构造方法
  */
 public function __construct($setting)
 {
     $this->config = $setting['config'];
     $this->cronPath = $setting['cron_path'];
     if (isset($setting['group'])) {
         $groupinfo = posix_getpwnam($setting['group']);
         posix_setgid($groupinfo['gid']);
     }
     if (isset($setting['user'])) {
         $userinfo = posix_getgrnam($setting['user']);
         posix_setuid($groupinfo['uid']);
     }
     include __DIR__ . '/ParseCrontab.php';
     include __DIR__ . '/ParseInterval.php';
 }
开发者ID:Corzcode,项目名称:php-crontab,代码行数:18,代码来源:Cron.php


示例6: chgrp

 /**
  * Change the group of an array of files or directories.
  *
  * @param string|array|\Traversable $files     A filename, an array of files, or a \Traversable instance to change group
  * @param string                    $group     The group name
  * @param bool                      $recursive Whether change the group recursively or not
  *
  * @throws IOException When the change fail
  */
 public function chgrp($files, $group, $recursive = false)
 {
     foreach ($this->toIterator($files) as $file) {
         if ($recursive && is_dir($file) && !is_link($file)) {
             $this->chgrp(new \FilesystemIterator($file), $group, true);
         }
         if (is_link($file) && function_exists('lchgrp')) {
             if (true !== @lchgrp($file, $group) || defined('HHVM_VERSION') && !posix_getgrnam($group)) {
                 throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
             }
         } else {
             if (true !== @chgrp($file, $group)) {
                 throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
             }
         }
     }
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:26,代码来源:Filesystem.php


示例7: setUser

 public static function setUser($user, $group = null)
 {
     if (false === ($info = posix_getpwnam($user))) {
         throw new Exception("Does not exist operating system user: {$user}");
     }
     $uid = $info['uid'];
     if ($group) {
         if (false === ($info = posix_getgrnam($group))) {
             throw new Exception("Does not exist operating system group: {$group}");
         } else {
             $gid = $info['gid'];
         }
     } else {
         $gid = $info['gid'];
     }
     static::setUid($uid, $gid);
 }
开发者ID:panlatent,项目名称:aurora,代码行数:17,代码来源:Posix.php


示例8: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasParameter('uecode.daemon')) {
         return;
     }
     $config = $container->getParameter('uecode.daemon');
     // merges each configured daemon with default configs
     // and makes sure the pid directory is writable
     $filesystem = new Filesystem();
     foreach ($config['daemons'] as $name => $cnf) {
         if (null == $cnf) {
             $cnf = array();
         }
         try {
             $pidDir = $cnf['appPidDir'];
             $filesystem->mkdir($pidDir, 0777);
         } catch (\Exception $e) {
             echo 'UecodeDaemonBundle exception: ', $e->getMessage(), "\n";
         }
         if (isset($cnf['appUser']) || isset($cnf['appGroup'])) {
             if (isset($cnf['appUser']) && function_exists('posix_getpwnam')) {
                 $user = posix_getpwnam($cnf['appUser']);
                 if ($user) {
                     $cnf['appRunAsUID'] = $user['uid'];
                 }
             }
             if (isset($cnf['appGroup']) && function_exists('posix_getgrnam')) {
                 $group = posix_getgrnam($cnf['appGroup']);
                 if ($group) {
                     $cnf['appRunAsGID'] = $group['gid'];
                 }
             }
             if (!isset($cnf['appRunAsGID'])) {
                 $user = posix_getpwuid($cnf['appRunAsUID']);
                 $cnf['appRunAsGID'] = $user['gid'];
             }
         }
         $cnf['logLocation'] = rtrim($cnf['logDir'], '/') . '/' . $cnf['appName'] . 'Daemon.log';
         $cnf['appPidLocation'] = rtrim($cnf['appPidDir'], '/') . '/' . $cnf['appName'] . '/' . $cnf['appName'] . '.pid';
         unset($cnf['logDir'], $cnf['appPidDir']);
         $container->setParameter($name . '.daemon.options', $cnf);
     }
 }
开发者ID:uecode,项目名称:daemon-bundle,代码行数:46,代码来源:InitPass.php


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


示例10: checksADGroup

function checksADGroup($groupname)
{
    $checked = true;
    $userinfo = @posix_getgrnam($groupname);
    if (!isset($userinfo["gid"])) {
        $checked = false;
    }
    if (!is_numeric($userinfo["gid"])) {
        $checked = false;
    }
    if ($userinfo["gid"] < 1) {
        $checked = false;
    }
    $tpl = new templates();
    if (!$checked) {
        $html = $tpl->_ENGINE_parse_body("<table style='border:0px'>\n\t\t<tr>\n\t\t\t<td width=1% style='border:0px;border-left:0px;border-bottom:0px;' valign='top'><img src='img/warning-panneau-24.png'></td>\n\t\t\t<td style='border:0px;border-left:0px;border-bottom:0px;' valign='top'><strong style='font-size:12px'>{this_group_is_not_retranslated_to_the_system}</td>\n\t\t</tr>\n\t\t</table>\n\t\t");
    } else {
        $html = $tpl->_ENGINE_parse_body(count($userinfo["members"]) . " {members}");
    }
    return $html;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:21,代码来源:dansguardian2.group.all.php


示例11: __construct

 /**
  * @param Bundle\ServerBundle\EventDispatcher $dispatcher
  * @param Bundle\ServerBundle\Socket\ServerSocket $server
  * @param array $options (optional)
  *
  * @throws \InvalidArgumentException When an unsupported option is provided
  * @throws \InvalidArgumentException If provided user does not exist
  * @throws \InvalidArgumentException If provided group does not exist
  * @throws \InvalidArgumentException If an invalid socket client class is provided
  * @throws \InvalidArgumentException If an invalid socket server class is provided
  * @throws \InvalidArgumentException If an invalid socket server client class is provided
  */
 public function __construct(EventDispatcher $dispatcher, ServerSocket $server, array $options = array())
 {
     $this->dispatcher = $dispatcher;
     $this->server = $server;
     $this->console = null;
     $this->isDaemon = false;
     $this->clients = array();
     $this->shutdown = false;
     // @see Resources/config/server.xml
     $this->options = array('pid_file' => null, 'user' => null, 'group' => null, 'umask' => null, 'environment' => 'dev', 'debug' => true, 'kernel_environment' => 'prod', 'kernel_debug' => false, 'address' => '*', 'port' => 1962, 'max_clients' => 100, 'max_requests_per_child' => 1000, 'document_root' => null, 'timeout' => 90, 'keepalive_timeout' => 15);
     // check option names
     if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
         throw new \InvalidArgumentException(sprintf('The Server does not support the following options: \'%s\'.', implode('\', \'', $diff)));
     }
     $this->options = array_merge($this->options, $options);
     // convert user name to user id
     if (null !== $this->options['user'] && !is_int($this->options['user'])) {
         $user = posix_getpwnam($this->options['user']);
         if (false === $user) {
             throw new \InvalidArgumentException(sprintf('User "%s" does not exist', $this->options['user']));
         }
         $this->options['user'] = $user['uid'];
     }
     // convert group name to group id
     if (null !== $this->options['group'] && !is_int($this->options['group'])) {
         $group = posix_getgrnam($this->options['group']);
         if (false === $group) {
             throw new \InvalidArgumentException(sprintf('Group "%s" does not exist', $this->options['group']));
         }
         $this->options['group'] = $group['gid'];
     }
     if (null !== $this->options['umask']) {
         umask($this->options['umask']);
     }
     declare (ticks=1);
     // pcntl signal handlers
     pcntl_signal(SIGHUP, array($this, 'signalHandler'));
     pcntl_signal(SIGINT, array($this, 'signalHandler'));
     pcntl_signal(SIGTERM, array($this, 'signalHandler'));
 }
开发者ID:avalanche123,项目名称:ServerBundle,代码行数:52,代码来源:Server.php


示例12: setUserAndGroup

 /**
  * Set unix user and group for current process.
  * @return void
  */
 public function setUserAndGroup()
 {
     // Get uid.
     $user_info = posix_getpwnam($this->user);
     if (!$user_info) {
         return self::log("Waring: User {$this->user} not exsits", true);
     }
     $uid = $user_info['uid'];
     // Get gid.
     if ($this->group) {
         $group_info = posix_getgrnam($this->group);
         if (!$group_info) {
             return self::log("Waring: Group {$this->group} not exsits", true);
         }
         $gid = $group_info['gid'];
     } else {
         $gid = $user_info['gid'];
     }
     // Set uid and gid.
     if ($uid != posix_getuid() || $gid != posix_getgid()) {
         if (!posix_setgid($gid) || !posix_initgroups($user_info['name'], $gid) || !posix_setuid($uid)) {
             self::log("Waring: change gid or uid fail.", true);
         }
     }
 }
开发者ID:TongJiankang,项目名称:Workerman,代码行数:29,代码来源:Worker.php


示例13: ___init_userGroup

 /**
  * Check and chdir to $_workDir
  *
  * @return   void
  */
 private function ___init_userGroup()
 {
     $this->_debug("-----> " . __CLASS__ . '::' . __FUNCTION__ . '()', 9);
     // Get current uid and gid
     $uid_cur = posix_getuid();
     $gid_cur = posix_getgid();
     // If not root, skip the rest of this procedure
     if ($uid_cur != 0) {
         $this->_log("Skipping the setUid/setGid part, because we are not root");
         return;
     }
     // Get desired uid/gid
     $r = posix_getpwnam($this->_user);
     if ($r === false) {
         throw new A2o_AppSrv_Exception("Unable to get uid for user: {$this->_user}");
     }
     $userData = $r;
     $r = posix_getgrnam($this->_group);
     if ($r === false) {
         throw new A2o_AppSrv_Exception("Unable to get gid for group: {$this->_group}");
     }
     $groupData = $r;
     $uid_desired = $userData['uid'];
     $gid_desired = $groupData['gid'];
     // Change effective uid/gid if required
     if ($gid_cur != $gid_desired) {
         $r = posix_setgid($gid_desired);
         if ($r === false) {
             throw new A2o_AppSrv_Exception("Unable to setgid: {$gid_cur} -> {$gid_desired}");
         }
         $this->_debug("Group (GID) changed to {$this->_group} ({$gid_desired})");
     }
     if ($uid_cur != $uid_desired) {
         $r = posix_setuid($uid_desired);
         if ($r === false) {
             throw new A2o_AppSrv_Exception("Unable to setuid: {$uid_cur} -> {$uid_desired}");
         }
         $this->_debug("User (UID) changed to {$this->_user} ({$uid_desired})");
     }
     $this->_debug("Setuid/setgid complete");
 }
开发者ID:bostjanskufca,项目名称:PHP-application-server,代码行数:46,代码来源:Master.php


示例14: posix_getgrnam

 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 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";
开发者ID:pombredanne,项目名称:fossology-test,代码行数:31,代码来源:migratetest.php


示例15: testFork_CloneEmptyToSpecifiedPath

 public function testFork_CloneEmptyToSpecifiedPath()
 {
     if (posix_getgrnam('gitolite') == false) {
         echo "testFork_CloneEmptyToSpecifiedPath: Cannot test 'cause there is no 'gitolite' user on server (CI)";
     } else {
         $name = 'tulip';
         $new_ns = 'repos/new/repo/';
         $old_ns = 'repos/';
         $old_root_dir = $this->repoDir . '/' . $old_ns . $name . '.git';
         $new_root_dir = $this->repoDir . '/' . $new_ns . $name . '.git';
         mkdir($old_root_dir, 0770, true);
         exec('GIT_DIR=' . $old_root_dir . ' git init --bare --shared=group');
         exec('cd ' . $old_root_dir . ' && touch hooks/gitolite_hook.sh');
         $this->assertTrue($this->driver->fork($name, $old_ns, $new_ns));
         $this->assertRepoIsClonedWithHooks($new_root_dir);
         $this->assertWritableByGroup($new_root_dir, 'gitolite');
         $this->assertNameSpaceFileHasBeenInitialized($new_root_dir, $new_ns, 'gitolite');
     }
 }
开发者ID:blestab,项目名称:tuleap,代码行数:19,代码来源:Git_GitoliteDriverTest.php


示例16: changeUser

 function changeUser()
 {
     $username = common_config('daemon', 'user');
     if ($username) {
         $user_info = posix_getpwnam($username);
         if (!$user_info) {
             common_log(LOG_WARNING, 'Ignoring unknown user for daemon: ' . $username);
         } else {
             common_log(LOG_INFO, "Setting user to " . $username);
             posix_setuid($user_info['uid']);
         }
     }
     $groupname = common_config('daemon', 'group');
     if ($groupname) {
         $group_info = posix_getgrnam($groupname);
         if (!$group_info) {
             common_log(LOG_WARNING, 'Ignoring unknown group for daemon: ' . $groupname);
         } else {
             common_log(LOG_INFO, "Setting group to " . $groupname);
             posix_setgid($group_info['gid']);
         }
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:23,代码来源:daemon.php


示例17: run


//.........这里部分代码省略.........
          *      should be made portable, but the requirement on the POSIX
          *      extension prevents this, so this is okay for now.
          */
         $stdin = fopen('/dev/null', 'r');
         $stdout = fopen('/dev/null', 'w');
         $stderr = fopen('/dev/null', 'w');
         if (defined('SIGUSR1')) {
             posix_kill($parent, SIGUSR1);
         }
         $logger->info($translator->gettext('Successfully started in the background'));
     }
     try {
         /// @TODO: Check the interface or something like that.
         $identd = $dic->get('identd');
     } catch (\InvalidArgumentException $e) {
         $identd = null;
     }
     try {
         /// @TODO: Check the interface or something like that.
         $prompt = $dic->get('prompt');
     } catch (\InvalidArgumentException $e) {
         $prompt = null;
     }
     // Change group identity if necessary.
     if ($parsed->options['group'] !== null && $parsed->options['group'] != '') {
         if (!$hasPosix) {
             $logger->warning($translator->gettext('The posix extension is needed in order ' . 'to change group identity.'));
         } elseif (posix_getuid() !== 0) {
             $logger->warning($translator->gettext('Only root can change group identity! ' . 'Your current UID is %(uid)d'), array('uid' => posix_getuid()));
         } else {
             if (ctype_digit($parsed->options['group'])) {
                 $info = posix_getgrgid((int) $parsed->options['group']);
             } else {
                 $info = posix_getgrnam($parsed->options['group']);
             }
             if ($info === false) {
                 $logger->error($translator->gettext('No such group "%(group)s"'), array('group' => $parsed->options['group']));
                 exit(1);
             }
             if (!posix_setgid($info['gid'])) {
                 $logger->error($translator->gettext('Could not set group identity ' . 'to "%(name)s" (%(id)d)'), array('id' => $info['gid'], 'name' => $info['name']));
                 exit(1);
             }
             $logger->debug($translator->gettext('Successfully changed group identity ' . 'to "%(name)s" (%(id)d)'), array('name' => $info['name'], 'id' => $info['gid']));
         }
     }
     // Change user identity if necessary.
     if ($parsed->options['user'] !== null || $parsed->options['user'] != '') {
         if (!$hasPosix) {
             $logger->warning($translator->gettext('The posix extension is needed in order ' . 'to change user identity.'));
         } elseif (posix_getuid() !== 0) {
             $logger->warning($translator->gettext('Only root can change user identity! ' . 'Your current UID is %(uid)d'), array('uid' => posix_getuid()));
         } else {
             if (ctype_digit($parsed->options['user'])) {
                 $info = posix_getpwuid((int) $parsed->options['user']);
             } else {
                 $info = posix_getpwnam($parsed->options['user']);
             }
             if ($info === false) {
                 $logger->error($translator->gettext('No such user "%(user)s"'), array('user' => $parsed->options['user']));
                 exit(1);
             }
             if (!posix_setuid($info['uid'])) {
                 $logger->error($translator->gettext('Could not set user identity ' . 'to "%(name)s" (%(id)d)'), array('name' => $info['name'], 'id' => $info['uid']));
                 exit(1);
             }
开发者ID:erebot,项目名称:erebot,代码行数:67,代码来源:CLI.php


示例18: setGroup

 /**
  * Sets the current filesystem object group, updates $_group property on success.
  *
  * For POSIX systems.
  *
  * Asserts that group exists before process if posix_ functions are available.
  *
  * @param string|int $group New group name or ID
  * @param bool $recursive Apply group to directory contents flag.
  * @return CFile|bool Current CFile object on success, 'False' on fail.
  * @throws CFileException When the given group is not found, if posix_ functions are available.
  */
 public function setGroup($group, $recursive = False)
 {
     if (function_exists('posix_getgrnam') && function_exists('posix_getgrgid')) {
         if (posix_getgrnam($group) == False xor is_numeric($group) && posix_getgrgid($group) == False) {
             throw new CFileException('Unable to set group for filesystem object. Group "' . $group . '" is not found.');
         }
     }
     if ($this->getExists()) {
         $success = @chgrp($this->_realpath, $group);
         if ($success) {
             $this->_group = $group;
         }
         if ($success && $this->getIsDir() && $recursive) {
             $contents = $this->getContents(True);
             foreach ($contents as $filepath) {
                 if (!@chgrp($filepath, $group)) {
                     $this->addLog('Unable to set group for "' . $filepath . '" to "' . $group . '"');
                     $success = False;
                 }
             }
         }
         if ($success) {
             return $this;
         }
     }
     $this->addLog('Unable to set group for filesystem object to "' . $group . '"');
     return False;
 }
开发者ID:idlesign,项目名称:ist-yii-cfile,代码行数:40,代码来源:CFile.php


示例19: posix_getgrnam

 /**
  * Return info about a group by name
  *
  */
 function posix_getgrnam($group)
 {
     if (!function_exists('posix_getgrnam')) {
         $group_datei = $this->server_conf['group_datei'];
         $cmd = 'grep -m 1 "^' . $group . ':" ' . $group_datei;
         exec($cmd, $output, $return_var);
         if ($return_var != 0 || !$output[0]) {
             return false;
         }
         list($f1, $f2, $f3, $f4) = explode(':', $output[0]);
         $f2 = trim($f2);
         $f3 = trim($f3);
         $f4 = trim($f4);
         if ($f4 != '') {
             $members = explode(',', $f4);
         } else {
             $members = array();
         }
         $group_details = array('name' => $group, 'passwd' => $f2, 'members' => $members, 'gid' => $f3);
         return $group_details;
     } else {
         return posix_getgrnam($group);
     }
 }
开发者ID:istrwei,项目名称:ISPCluster,代码行数:28,代码来源:system.inc.php


示例20: changeGroup

 /**
  * Will attempt to change the group of the given file system path (*nix only)
  *
  * @param string $path           The path to change the group of.
  * @param string $group          The new group name.
  * @param bool   $recursive      If the path is a directory, whether to recursively change the group of the child
  *                               files and folders.
  * @param bool   $suppressErrors Whether to suppress any PHP Notices/Warnings/Errors (usually permissions related).
  *
  * @return bool 'true' if successful, 'false' if not, or the given path does not exist.
  */
 public static function changeGroup($path, $group, $recursive = false, $suppressErrors = false)
 {
     $path = static::normalizePathSeparators($path);
     if (posix_getgrnam($group) == false xor is_numeric($group) && posix_getgrgid($group) == false) {
         Craft::log('Tried to change the group of ' . $path . ', but the group name "' . $group . '" does not exist.', LogLevel::Error);
         return false;
     }
     if (static::fileExists($path, $suppressErrors) || static::folderExists($path, $suppressErrors)) {
         $success = $suppressErrors ? @chgrp($path, $group) : chgrp($path, $group);
         if ($success && static::folderExists($path, $suppressErrors) && $recursive) {
             $contents = static::getFolderContents($path, true, null, false, $suppressErrors);
             foreach ($contents as $path) {
                 $path = static::normalizePathSeparators($path);
                 if ($suppressErrors ? !@chgrp($path, $group) : chgrp($path, $group)) {
                     $success = false;
                 }
             }
         }
         if (!$success) {
             Craft::log('Tried to change the group of ' . $path . ', but could not.', LogLevel::Error);
             return false;
         }
         return true;
     } else {
         Craft::log('Tried to change group of ' . $path . ', but that path does not exist.', LogLevel::Error);
     }
     return false;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:39,代码来源:IOHelper.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP posix_getgroups函数代码示例发布时间:2022-05-15
下一篇:
PHP posix_getgrgid函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap