added permissions checks

This commit is contained in:
Matthew Saunders Brown 2021-03-25 15:37:50 -07:00
parent d8eaaaf47a
commit 856f0cccff
2 changed files with 10 additions and 2 deletions

View File

@ -24,6 +24,14 @@ if (!is_writable("/var/vmail/$virtualhost")) {
$roundcubemail = array(); $roundcubemail = array();
if (!is_readable('/usr/local/etc/vmail-db-info.conf')) {
$user = posix_getpwuid(posix_geteuid());
$username = $user['name'];
echo "/var/vmail/$virtualhost is not writable by this user ($username).\n";
echo "re-run this script as user vmail or root or another user that can read the /usr/local/etc/vmail-db-info.conf config file\n";
exit;
}
$dbHost = trim(`grep -m 1 host /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); $dbHost = trim(`grep -m 1 host /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`);
$dbDatabase = trim(`grep -m 1 database /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); $dbDatabase = trim(`grep -m 1 database /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`);
$dbUser = trim(`grep -m 1 user /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`); $dbUser = trim(`grep -m 1 user /usr/local/etc/vmail-db-info.conf |cut -d = -f 2|cut -d ' ' -f 2`);

View File

@ -9,8 +9,8 @@ if ($virtualhost == "") {
exit; exit;
} }
if (!is_file("/var/vmail/$virtualhost/roundcubemail")) { if (!is_readable("/var/vmail/$virtualhost/roundcubemail")) {
echo "$virtualhost roundcubemail file does not exist\n"; echo "$virtualhost roundcubemail file does not exist or is not readable by you\n";
exit; exit;
} }