Skip to content

Commit 15687e2

Browse files
author
Till Brehm
committed
Fixed some errors in user check of apache and nginx plugin.
1 parent 7d9346a commit 15687e2

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public function is_allowed_user($username, $restrict_names = false) {
430430
$name_blacklist = array('root','ispconfig','vmail','getmail');
431431
if(in_array($username,$name_blacklist)) return false;
432432

433-
if(preg_match('/^[\w\.\-]{0,32}$/', $username) == false) return false;
433+
if(preg_match('/^[a-zA-Z0-9\.\-]{1,32}$/', $username) == false) return false;
434434

435435
if($restrict_names == true && preg_match('/^web\d+$/', $username) == false) return false;
436436

@@ -443,7 +443,7 @@ public function is_allowed_group($groupname, $restrict_names = false) {
443443
$name_blacklist = array('root','ispconfig','vmail','getmail');
444444
if(in_array($groupname,$name_blacklist)) return false;
445445

446-
if(preg_match('/^[\w\.\-]{0,32}$/', $groupname) == false) return false;
446+
if(preg_match('/^[a-zA-Z0-9\.\-]{1,32}$/', $groupname) == false) return false;
447447

448448
if($restrict_names == true && preg_match('/^client\d+$/', $groupname) == false) return false;
449449

server/lib/classes/system.inc.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ public function is_allowed_user($username, $check_id = true, $restrict_names = f
18241824
$name_blacklist = array('root','ispconfig','vmail','getmail');
18251825
if(in_array($username,$name_blacklist)) return false;
18261826

1827-
if(preg_match('/^[\w\.\-]{0,32}$/', $username) == false) return false;
1827+
if(preg_match('/^[a-zA-Z0-9\.\-]{1,32}$/', $username) == false) return false;
18281828

18291829
if($check_id && intval($this->getuid($username)) < $this->min_uid) return false;
18301830

@@ -1833,18 +1833,18 @@ public function is_allowed_user($username, $check_id = true, $restrict_names = f
18331833
return true;
18341834
}
18351835

1836-
public function is_allowed_group($groupname, $restrict_names = false) {
1836+
public function is_allowed_group($groupname, $check_id = true, $restrict_names = false) {
18371837
global $app;
1838-
1838+
echo 1;
18391839
$name_blacklist = array('root','ispconfig','vmail','getmail');
18401840
if(in_array($groupname,$name_blacklist)) return false;
1841-
1842-
if(preg_match('/^[\w\.\-]{0,32}$/', $groupname) == false) return false;
1843-
1844-
if(intval($this->getgid($groupname)) < $this->min_gid) return false;
1845-
1841+
echo 2;
1842+
if(preg_match('/^[a-zA-Z0-9\.\-]{1,32}$/', $groupname) == false) return false;
1843+
echo 3;
1844+
if($check_id && intval($this->getgid($groupname)) < $this->min_gid) return false;
1845+
echo 4;
18461846
if($restrict_names == true && preg_match('/^client\d+$/', $groupname) == false) return false;
1847-
1847+
echo 5;
18481848
return true;
18491849
}
18501850

server/plugins-available/apache2_plugin.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ function update($event_name, $data) {
344344
if($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain') $app->log('document_root not set', LOGLEVEL_WARN);
345345
return 0;
346346
}
347-
if(!$app->system->is_allowed_user($data['new']['system_user'], false, true)
348-
|| !$app->system->is_allowed_group($data['new']['system_group'], false, true)) {
349-
$app->log('Websites cannot be owned by the root user or group.', LOGLEVEL_WARN);
347+
if($app->system->is_allowed_user($data['new']['system_user'], $app->system->is_user($data['new']['system_user']), true) == false
348+
|| $app->system->is_allowed_group($data['new']['system_group'], $app->system->is_group($data['new']['system_group']), true) == false) {
349+
$app->log('Websites cannot be owned by the root user or group. User: '.$data['new']['system_user'].' Group: '.$data['new']['system_group'], LOGLEVEL_WARN);
350350
return 0;
351351
}
352352
if(trim($data['new']['domain']) == '') {

0 commit comments

Comments
 (0)