Skip to content

Commit 95affef

Browse files
committed
Limit the selectable options for php and chroot per client.
1 parent e11f5dd commit 95affef

File tree

8 files changed

+501
-424
lines changed

8 files changed

+501
-424
lines changed

install/sql/ispconfig3.sql

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ CREATE TABLE `client` (
7777
`default_webserver` int(11) NOT NULL default '1',
7878
`limit_web_ip` text,
7979
`limit_web_domain` int(11) NOT NULL default '-1',
80+
`web_php_options` varchar(255) NOT NULL default 'no,fast-cgi,cgi,mod,suphp',
8081
`limit_web_subdomain` int(11) NOT NULL default '-1',
8182
`limit_web_aliasdomain` int(11) NOT NULL default '-1',
8283
`limit_ftp_user` int(11) NOT NULL default '-1',
8384
`limit_shell_user` int(11) NOT NULL default '0',
85+
`ssh_chroot` varchar(255) NOT NULL DEFAULT 'no,jailkit,ssh-chroot',
8486
`default_dnsserver` int(10) unsigned NOT NULL default '1',
8587
`limit_dns_zone` int(11) NOT NULL default '-1',
8688
`limit_dns_record` int(11) NOT NULL default '-1',
@@ -92,49 +94,49 @@ CREATE TABLE `client` (
9294
`password` varchar(255) default NULL,
9395
`language` varchar(255) NOT NULL default 'en',
9496
`usertheme` varchar(255) NOT NULL default 'default',
95-
`template_master` bigint(20) NOT NULL default '0',
97+
`template_master` bigint(20) NOT NULL default '0',
9698
`template_additional` varchar(255) NOT NULL default '',
9799
PRIMARY KEY (`client_id`)
98100
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
99101

100102
-- --------------------------------------------------------
101103

102-
--
103-
-- Table structure for table `client_template`
104-
--
105-
106-
CREATE TABLE `client_template` (
107-
`template_id` bigint(20) NOT NULL auto_increment,
108-
`template_name` varchar(50) NOT NULL,
109-
`template_type` varchar(1) NOT NULL default 'm',
110-
`limit_maildomain` int(11) NOT NULL default '-1',
111-
`limit_mailbox` int(11) NOT NULL default '-1',
112-
`limit_mailalias` int(11) NOT NULL default '-1',
113-
`limit_mailforward` int(11) NOT NULL default '-1',
114-
`limit_mailcatchall` int(11) NOT NULL default '-1',
115-
`limit_mailrouting` int(11) NOT NULL default '0',
116-
`limit_mailfilter` int(11) NOT NULL default '-1',
117-
`limit_fetchmail` int(11) NOT NULL default '-1',
118-
`limit_mailquota` int(11) NOT NULL default '-1',
119-
`limit_spamfilter_wblist` int(11) NOT NULL default '0',
120-
`limit_spamfilter_user` int(11) NOT NULL default '0',
121-
`limit_spamfilter_policy` int(11) NOT NULL default '0',
122-
`limit_web_ip` text,
123-
`limit_web_domain` int(11) NOT NULL default '-1',
124-
`limit_web_subdomain` int(11) NOT NULL default '-1',
125-
`limit_web_aliasdomain` int(11) NOT NULL default '-1',
126-
`limit_ftp_user` int(11) NOT NULL default '-1',
127-
`limit_shell_user` int(11) NOT NULL default '0',
128-
`limit_dns_zone` int(11) NOT NULL default '-1',
129-
`limit_dns_record` int(11) NOT NULL default '-1',
130-
`limit_database` int(11) NOT NULL default '-1',
104+
--
105+
-- Table structure for table `client_template`
106+
--
107+
108+
CREATE TABLE `client_template` (
109+
`template_id` bigint(20) NOT NULL auto_increment,
110+
`template_name` varchar(50) NOT NULL,
111+
`template_type` varchar(1) NOT NULL default 'm',
112+
`limit_maildomain` int(11) NOT NULL default '-1',
113+
`limit_mailbox` int(11) NOT NULL default '-1',
114+
`limit_mailalias` int(11) NOT NULL default '-1',
115+
`limit_mailforward` int(11) NOT NULL default '-1',
116+
`limit_mailcatchall` int(11) NOT NULL default '-1',
117+
`limit_mailrouting` int(11) NOT NULL default '0',
118+
`limit_mailfilter` int(11) NOT NULL default '-1',
119+
`limit_fetchmail` int(11) NOT NULL default '-1',
120+
`limit_mailquota` int(11) NOT NULL default '-1',
121+
`limit_spamfilter_wblist` int(11) NOT NULL default '0',
122+
`limit_spamfilter_user` int(11) NOT NULL default '0',
123+
`limit_spamfilter_policy` int(11) NOT NULL default '0',
124+
`limit_web_ip` text,
125+
`limit_web_domain` int(11) NOT NULL default '-1',
126+
`limit_web_subdomain` int(11) NOT NULL default '-1',
127+
`limit_web_aliasdomain` int(11) NOT NULL default '-1',
128+
`limit_ftp_user` int(11) NOT NULL default '-1',
129+
`limit_shell_user` int(11) NOT NULL default '0',
130+
`limit_dns_zone` int(11) NOT NULL default '-1',
131+
`limit_dns_record` int(11) NOT NULL default '-1',
132+
`limit_database` int(11) NOT NULL default '-1',
131133
`limit_client` int(11) NOT NULL default '0',
132-
`sys_userid` int(11) NOT NULL default '0',
133-
`sys_groupid` int(11) NOT NULL default '0',
134-
`sys_perm_user` varchar(5) default NULL,
135-
`sys_perm_group` varchar(5) default NULL,
136-
`sys_perm_other` varchar(5) default NULL,
137-
PRIMARY KEY (`template_id`)
134+
`sys_userid` int(11) NOT NULL default '0',
135+
`sys_groupid` int(11) NOT NULL default '0',
136+
`sys_perm_user` varchar(5) default NULL,
137+
`sys_perm_group` varchar(5) default NULL,
138+
`sys_perm_other` varchar(5) default NULL,
139+
PRIMARY KEY (`template_id`)
138140
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
139141

140142
-- --------------------------------------------------------

interface/lib/classes/tform.inc.php

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,45 @@ function getDatasourceData($field, $record) {
252252
return $values;
253253

254254
}
255+
256+
//* If the parameter 'valuelimit' is set
257+
function applyValueLimit($limit,$values) {
258+
259+
global $app;
260+
261+
$limit_parts = explode(':',$limit);
262+
263+
//* values are limited to a comma separated list
264+
if($limit_parts[0] == 'list') {
265+
$allowed = explode(',',$limit_parts[1]);
266+
}
267+
268+
//* values are limited to a field in the client settings
269+
if($limit_parts[0] == 'client') {
270+
if($_SESSION["s"]["user"]["typ"] == 'admin') {
271+
return $values;
272+
} else {
273+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
274+
$client = $app->db->queryOneRecord("SELECT ".$limit_parts[1]." as lm FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
275+
$allowed = explode(',',$client['lm']);
276+
}
277+
}
278+
279+
//* values are limited to a field in the system settings
280+
if($limit_parts[0] == 'system') {
281+
$app->uses('getconf');
282+
$tmp_conf = $app->getconf->get_global_config($limit_parts[1]);
283+
$tmp_key = $limit_parts[2];
284+
$allowed = $tmp_conf[$tmp_key];
285+
}
286+
287+
$values_new = array();
288+
foreach($values as $key => $val) {
289+
if(in_array($key,$allowed)) $values_new[$key] = $val;
290+
}
291+
292+
return $values_new;
293+
}
255294

256295

257296
/**
@@ -281,6 +320,11 @@ function getHTML($record, $tab, $action = 'NEW') {
281320
if(isset($field['datasource']) && is_array($field['datasource'])) {
282321
$field["value"] = $this->getDatasourceData($field, $record);
283322
}
323+
324+
// If a limitation for the values is set
325+
if(isset($field['valuelimit']) && is_array($field["value"])) {
326+
$field["value"] = $this->applyValueLimit($field['valuelimit'],$field["value"]);
327+
}
284328

285329
switch ($field['formtype']) {
286330
case 'SELECT':
@@ -340,7 +384,7 @@ function getHTML($record, $tab, $action = 'NEW') {
340384
$out .= "<span class=\"wf_oneChoice\">\r\n
341385
<input type=\"checkbox\" value=\"$k\" id=\"".$key."[]\" name=\"".$key."[]\" $checked>\r\n
342386
<label for=\"".$key."[]\" id=\"".$key."[]-L\" class=\"wf_postField\">$v</label>\r\n
343-
</span><br />\r\n";
387+
</span>\r\n";
344388
}
345389
}
346390
$new_record[$key] = $out;
@@ -373,8 +417,13 @@ function getHTML($record, $tab, $action = 'NEW') {
373417

374418
// If Datasource is set, get the data from there
375419
if(@is_array($field['datasource'])) {
376-
$field["value"] = $this->getDatasourceData($field, $record);
420+
$field["value"] = $this->getDatasourceData($field, $record);
377421
}
422+
423+
// If a limitation for the values is set
424+
if(isset($field['valuelimit']) && is_array($field["value"])) {
425+
$field["value"] = $this->applyValueLimit($field['valuelimit'],$field["value"]);
426+
}
378427

379428
switch ($field['formtype']) {
380429
case 'SELECT':
@@ -431,7 +480,7 @@ function getHTML($record, $tab, $action = 'NEW') {
431480
$out .= "<span class=\"wf_oneChoice\">\r\n
432481
<input type=\"checkbox\" value=\"$k\" id=\"".$key."[]\" name=\"".$key."[]\" $checked>\r\n
433482
<label for=\"".$key."[]\" id=\"".$key."[]-L\" class=\"wf_postField\">$v</label>\r\n
434-
</span><br />\r\n";
483+
</span>\r\n";
435484
}
436485
}
437486
$new_record[$key] = $out;
@@ -486,7 +535,7 @@ function encode($record,$tab) {
486535
switch ($field['datatype']) {
487536
case 'VARCHAR':
488537
if(!@is_array($record[$key])) {
489-
$new_record[$key] = (isset($record[$key]))?$app->db->quote($record[$key]):'';
538+
$new_record[$key] = (isset($record[$key]))?$app->db->quote($record[$key]):'';
490539
} else {
491540
$new_record[$key] = implode($field['separator'],$record[$key]);
492541
}

interface/web/client/form/client.tform.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@
515515
'rows' => '',
516516
'cols' => ''
517517
),
518+
'web_php_options' => array (
519+
'datatype' => 'VARCHAR',
520+
'formtype' => 'CHECKBOXARRAY',
521+
'default' => '',
522+
'separator' => ',',
523+
'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
524+
),
518525
'limit_web_aliasdomain' => array (
519526
'datatype' => 'INTEGER',
520527
'formtype' => 'TEXT',
@@ -571,6 +578,13 @@
571578
'rows' => '',
572579
'cols' => ''
573580
),
581+
'ssh_chroot' => array (
582+
'datatype' => 'VARCHAR',
583+
'formtype' => 'CHECKBOXARRAY',
584+
'default' => '',
585+
'separator' => ',',
586+
'value' => array('no' => 'None', 'jailkit' => 'Jailkit', 'ssh-chroot' => 'SSH Chroot')
587+
),
574588
'default_dnsserver' => array (
575589
'datatype' => 'INTEGER',
576590
'formtype' => 'SELECT',

interface/web/client/lib/lang/en_client.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,6 @@ $wb["limit_database_error_notint"] = 'The database limit must be a number.';
8181
$wb["username_error_regex"] = 'The Username contains invalid chracaters.';
8282
$wb["template_master_txt"] = 'Master';
8383
$wb["template_additional_txt"] = 'Addon';
84+
$wb["ssh_chroot_txt"] = 'SSH-Chroot Options';
85+
$wb["web_php_options_txt"] = 'PHP Options';
8486
?>

interface/web/client/templates/client_edit_limits.htm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
7777
<span class="wf_oneField">
7878
<label for="limit_web_domain" class="wf_preField">{tmpl_var name='limit_web_domain_txt'}</label>
7979
<input type="text" id="limit_web_domain" name="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10">
80+
</span>
81+
<span class="wf_oneField">
82+
<label for="web_php_options" class="wf_preField">{tmpl_var name='web_php_options_txt'}</label>
83+
{tmpl_var name='web_php_options'}
8084
</span>
8185
<span class="wf_oneField">
8286
<label for="limit_web_aliasdomain" class="wf_preField">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
@@ -93,6 +97,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
9397
<span class="wf_oneField">
9498
<label for="limit_shell_user" class="wf_preField">{tmpl_var name='limit_shell_user_txt'}</label>
9599
<input type="text" id="limit_shell_user" name="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10">
100+
</span>
101+
<span class="wf_oneField">
102+
<label for="ssh_chroot" class="wf_preField">{tmpl_var name='ssh_chroot_txt'}</label>
103+
{tmpl_var name='ssh_chroot'}
96104
</span>
97105
<span class="wf_oneField">
98106
<label for="default_dnsserver" class="wf_preField">{tmpl_var name='default_dnsserver_txt'}</label>

interface/web/client/tools.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function applyClientTemplates($clientId){
7777
*/
7878
$update = '';
7979
foreach($limits as $k => $v){
80-
if (strpos($k, 'limit') !== false){
80+
if (strpos($k, 'limit') !== false && !is_array($v)){
8181
if ($update != '') $update .= ', ';
8282
$update .= '`' . $k . "`='" . $v . "'";
8383
}

interface/web/sites/form/shell_user.tform.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
'datatype' => 'VARCHAR',
110110
'formtype' => 'SELECT',
111111
'default' => '',
112-
'value' => array('' => 'None', 'jailkit' => 'Jailkit', 'ssh-chroot' => 'SSH Chroot')
112+
'valuelimit' => 'client:ssh_chroot',
113+
'value' => array('no' => 'None', 'jailkit' => 'Jailkit', 'ssh-chroot' => 'SSH Chroot')
113114
),
114115
'quota_size' => array (
115116
'datatype' => 'INTEGER',

0 commit comments

Comments
 (0)