/usr/bin/horde-set-perms is in php-horde 5.1.5+debian1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #!/usr/bin/php
<?php
/**
* This script will set the permissions on your Horde tree so that the files
* will be accessible by the web server.
*
* Copyright 2011-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL-2). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl LGPL-2
* @package Horde
*/
$baseFile = __DIR__ . '/../lib/Application.php';
if (file_exists($baseFile)) {
require_once $baseFile;
} else {
require_once 'PEAR/Config.php';
require_once PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php';
}
Horde_Registry::appInit('horde', array(
'authentication' => 'none',
'cli' => true
));
$cli->message('Horde directory: ' . realpath(HORDE_BASE), 'cli.message');
$owner = $cli->prompt(
'Owner of Horde files?',
null,
'root'
);
$ownerpars = posix_getpwnam($owner);
$owner = $ownerpars['uid'];
$group = $cli->prompt(
'Group under which web server/PHP runs?',
null,
'nobody'
);
$grouppars = posix_getgrnam($group);
$group = $grouppars['gid'];
$cli->writeln();
if (!$cli->prompt($cli->red('Are you sure you want to alter permissions?'), array('y' => 'Yes', 'n' => 'No'), 'n') == 'y') {
exit(0);
}
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(realpath(HORDE_BASE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($it as $key => $val) {
if ($val->getFilename() == '..' ) {
continue;
}
if ($val->getOwner() != $owner) {
$cli->message('Changing owner for ' . $key, 'cli.message');
chown($key, $owner);
}
if ($val->getGroup() != $group) {
$cli->message('Changing group for ' . $key, 'cli.message');
chgrp($key, $group);
}
$octal_perms = substr(sprintf('%o', $val->getPerms()), -4);
if ($val->isDir()) {
if (basename($key) == 'static') {
if ($octal_perms != '0770') {
$cli->message('Changing permissions for ' . $key, 'cli.message');
chmod($key, 0770);
}
} elseif ($octal_perms != '0750') {
$cli->message('Changing permissions for ' . $key, 'cli.message');
chmod($key, 0750);
}
} elseif ($val->isFile()) {
if ($octal_perms != '0640') {
$cli->message('Changing permissions for ' . $key, 'cli.message');
chmod($key, 0640);
}
}
}
|