/** * Change directory owners. * * @param Domain $domain * * @return bool */ protected function _changeDirectoryOwner(Domain $domain) { $fs = new Filesystem(); try { $fs->chown($domain->getPath(), self::_root); // Domain Root $fs->chgrp($domain->getPath(), $domain->getUser()->getGroupname(), true); // Domain Root + Child // Child directories $fs->chown($this->_getDefaultDirs($domain->getPath()), $domain->getUser()->getName(), true); } catch (IOException $e) { return false; } return true; }
/** * ErrorLog * * @return string */ public function getErrorLog() { return $this->domain->getPath() . self::_log_error; }
/** * Remove obsolete auth-user files. * * @param Domain $domain */ public function removeObsoleteAuthUserFiles(Domain $domain) { $finder = new Finder(); $fs = new Filesystem(); $files = array(); $ids = array(); foreach ($domain->getProtection() as $protection) { /** @var Protection $protection */ $ids[] = $protection->getId(); } $finder->in($domain->getPath() . '/conf')->name('authuser_*.passwd')->depth(0)->files(); foreach ($finder as $file) { /** @var SplFileInfo $file */ $id = $this->getIdFromFilename($file->getFilename()); if ($id === null) { continue; } if (!in_array($id, $ids)) { // Obsolete file. $files[] = $file->getPathname(); } } if (count($files) > 0) { $fs->remove($files); } }