Skip to content

Commit 9edea99

Browse files
author
Till Brehm
committed
- Added warning in the interface when a path for a shelluser is set that is outside of the website docroot.
- Added security settings feature to allow the root user of a server to control most aspects of whet the admin user of the controlpanel is allowed to do in system settings. This is especially useful for managed severs where the ispconfig admin user and the root user of the server are different persons.
1 parent 77edf6e commit 9edea99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+289
-29
lines changed

interface/lib/classes/auth.inc.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function is_admin() {
4646
}
4747

4848
public function is_superadmin() {
49-
if($_SESSION['s']['user']['typ'] == 'admin' && $_SESSION['s']['user']['userid'] === 1) {
49+
if($_SESSION['s']['user']['typ'] == 'admin' && $_SESSION['s']['user']['userid'] == 1) {
5050
return true;
5151
} else {
5252
return false;
@@ -136,6 +136,22 @@ public function check_module_permissions($module) {
136136
exit;
137137
}
138138
}
139+
140+
public function check_security_permissions($permission) {
141+
142+
global $app;
143+
144+
$app->uses('getconf');
145+
$security_config = $app->getconf->get_security_config('permissions');
146+
147+
$security_check = false;
148+
if($security_config[$permission] == 'yes') $security_check = true;
149+
if($security_config[$permission] == 'superadmin' && $app->auth->is_superadmin()) $security_check = true;
150+
if($security_check !== true) {
151+
$app->error($app->lng('security_check1_txt').' '.$permission.' '.$app->lng('security_check2_txt'));
152+
}
153+
154+
}
139155

140156
public function get_random_password($length = 8) {
141157
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

interface/lib/classes/getconf.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ public function get_global_config($section = '') {
5454
}
5555
return ($section == '') ? $this->config['global'] : $this->config['global'][$section];
5656
}
57+
58+
public function get_security_config($section = '') {
59+
global $app;
60+
61+
$app->uses('ini_parser');
62+
$security_config = $app->ini_parser->parse_ini_string(file_get_contents('/usr/local/ispconfig/security/security_settings.ini'));
63+
64+
return ($section == '') ? $security_config : $security_config[$section];
65+
}
5766

5867
}
5968

interface/lib/classes/validate_systemuser.inc.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,63 @@ function check_sysgroup($field_name, $field_value, $validator) {
5858
}
5959
}
6060

61+
/*
62+
Validator function to check if a given dir is ok.
63+
*/
64+
function shelluser_dir($field_name, $field_value, $validator) {
65+
global $app;
66+
67+
if($app->tform->primary_id == 0) {
68+
$errmsg = $validator['errmsg'];
69+
if(isset($app->tform->wordbook[$errmsg])) {
70+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
71+
} else {
72+
return $errmsg."<br>\r\n";
73+
}
74+
}
75+
76+
77+
$shell_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM shell_user WHERE shell_user_id = '".$app->db->quote($app->tform->primary_id)."'");
78+
if(!is_array($shell_data) || $shell_data["parent_domain_id"] < 1) {
79+
$errmsg = $validator['errmsg'];
80+
if(isset($app->tform->wordbook[$errmsg])) {
81+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
82+
} else {
83+
return $errmsg."<br>\r\n";
84+
}
85+
}
6186

87+
$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($shell_data["parent_domain_id"])."'");
88+
if(!is_array($domain_data) || $domain_data["domain_id"] < 1) {
89+
$errmsg = $validator['errmsg'];
90+
if(isset($app->tform->wordbook[$errmsg])) {
91+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
92+
} else {
93+
return $errmsg."<br>\r\n";
94+
}
95+
}
96+
97+
$doc_root = $domain_data["document_root"];
98+
$is_ok = false;
99+
if($doc_root == $field_value) $is_ok = true;
100+
101+
$doc_root .= "/";
102+
if(substr($field_value, 0, strlen($doc_root)) == $doc_root) $is_ok = true;
103+
104+
if(stristr($field_value, '..') or stristr($field_value, './') or stristr($field_value, '/.')) $is_ok = false;
105+
106+
//* Final check if docroot path of website is >= 5 chars
107+
if(strlen($doc_root) < 5) $is_ok = false;
108+
109+
if($is_ok == false) {
110+
$errmsg = $validator['errmsg'];
111+
if(isset($app->tform->wordbook[$errmsg])) {
112+
return $app->tform->wordbook[$errmsg]."<br>\r\n";
113+
} else {
114+
return $errmsg."<br>\r\n";
115+
}
116+
}
117+
}
62118

63119

64120
}

interface/lib/lang/ar.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ $wb['strength_4'] = 'Strong';
147147
$wb['strength_5'] = 'Very Strong';
148148
$wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of \\"{strength}\\".';
149149
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
150+
$wb['security_check1_txt'] = 'Check for security permission:';
151+
$wb['security_check2_txt'] = 'failed.';
150152
?>

interface/lib/lang/bg.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ $wb['strength_4'] = 'Strong';
147147
$wb['strength_5'] = 'Very Strong';
148148
$wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of \\"{strength}\\".';
149149
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
150+
$wb['security_check1_txt'] = 'Check for security permission:';
151+
$wb['security_check2_txt'] = 'failed.';
150152
?>

interface/lib/lang/br.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ $wb['strength_4'] = 'Strong';
147147
$wb['strength_5'] = 'Very Strong';
148148
$wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of \\"{strength}\\".';
149149
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
150+
$wb['security_check1_txt'] = 'Check for security permission:';
151+
$wb['security_check2_txt'] = 'failed.';
150152
?>

interface/lib/lang/cz.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ $wb['strength_4'] = 'Silná';
147147
$wb['strength_5'] = 'Velmi silná';
148148
$wb['weak_password_txt'] = 'Zvolené heslo neodpovídá požadavkům zásad pro tvorbu hesel. Heslo musí být alespoň {chars} znaků dlouhé a mající sílu \\"{strength}\\".';
149149
$wb['weak_password_length_txt'] = 'Zvolené heslo neodpovídá požadavkům zásad pro tvorbu hesel. Heslo musí být alespoň {chars} znaků dlouhé.';
150+
$wb['security_check1_txt'] = 'Check for security permission:';
151+
$wb['security_check2_txt'] = 'failed.';
150152
?>

interface/lib/lang/de.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ $wb['strength_4'] = 'Stark';
147147
$wb['strength_5'] = 'Sehr stark';
148148
$wb['weak_password_txt'] = 'Das gewählte Passwort erfüllt die Sicherheitsanforderungen nicht. Es muss mindestens {chars} Zeichen lang sein und die Stärke \\"{strength}\\" besitzen.';
149149
$wb['weak_password_length_txt'] = 'Das gewählte Passwort erfüllt die Sicherheitsanforderungen nicht. Es muss mindestens {chars} Zeichen lang sein.';
150+
$wb['security_check1_txt'] = 'Sicherheitsüberprüfung für:';
151+
$wb['security_check2_txt'] = 'fehlgeschlagen.';
150152
?>

interface/lib/lang/el.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,6 @@ $wb['strength_4'] = 'Strong';
147147
$wb['strength_5'] = 'Very Strong';
148148
$wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of \\"{strength}\\".';
149149
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
150+
$wb['security_check1_txt'] = 'Check for security permission:';
151+
$wb['security_check2_txt'] = 'failed.';
150152
?>

interface/lib/lang/en.lng

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ $wb['datalog_status_d_web_folder'] = 'Delete folder protection';
131131
$wb['datalog_status_i_web_folder_user'] = 'Create folder protection user';
132132
$wb['datalog_status_u_web_folder_user'] = 'Update folder protection user';
133133
$wb['datalog_status_d_web_folder_user'] = 'Delete folder protection user';
134-
135134
$wb['login_as_txt'] = 'Log in as';
136135
$wb["no_domain_perm"] = 'You have no permission for this domain.';
137136
$wb["no_destination_perm"] = 'You have no permission for this destination.';
@@ -149,5 +148,6 @@ $wb['strength_4'] = 'Strong';
149148
$wb['strength_5'] = 'Very Strong';
150149
$wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of "{strength}".';
151150
$wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
152-
153-
?>
151+
$wb['security_check1_txt'] = 'Check for security permission:';
152+
$wb['security_check2_txt'] = 'failed.';
153+
?>

0 commit comments

Comments
 (0)