本文整理汇总了PHP中PFUser::getUnixHomeDir方法的典型用法代码示例。如果您正苦于以下问题:PHP PFUser::getUnixHomeDir方法的具体用法?PHP PFUser::getUnixHomeDir怎么用?PHP PFUser::getUnixHomeDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFUser
的用法示例。
在下文中一共展示了PFUser::getUnixHomeDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeSSHKeys
/**
* Write SSH authorized_keys into a user homedir
*
* @param PFUser $user
*
* @return Boolean
*/
public function writeSSHKeys(PFUser $user)
{
try {
if ($user->getUnixStatus() != 'A') {
return true;
}
$ssh_dir = $user->getUnixHomeDir() . '/.ssh';
// Subtlety: between the 2 process owner change, there is no way to
// write any logs because the process is owned by a mere user but
// the log file is only writtable by codendiadm and root. So the
// exceptions... welcome to the real world Neo.
$this->changeProcessUidGidToUser($user);
$this->createSSHDirForUser($user, $ssh_dir);
$this->writeSSHFile($user, $ssh_dir);
$this->restoreRootUidGid();
$this->backend->changeOwnerGroupMode($ssh_dir, $user->getUserName(), $user->getUserName(), 0700);
$this->backend->changeOwnerGroupMode("{$ssh_dir}/authorized_keys", $user->getUserName(), $user->getUserName(), 0600);
$this->backend->log("Authorized_keys for " . $user->getUserName() . " written.", Backend::LOG_INFO);
return true;
} catch (Exception $exception) {
$this->restoreRootUidGid();
$this->backend->log($exception->getMessage(), Backend::LOG_ERROR);
return false;
}
}
示例2: setUserHomeOwnership
/**
* Set user's uid/gid on its home directory (recursively)
*
* @param PFUser $user user to set uid/gid
*
* @return null
*/
private function setUserHomeOwnership(PFUser $user)
{
$this->recurseChownChgrp($user->getUnixHomeDir(), $user->getUserName(), $user->getUserName());
}