Skip to content

Commit 73daa94

Browse files
author
Till Brehm
committed
Merge branch 'stable-3.0.5' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.0.5
2 parents fedbcaf + 401870f commit 73daa94

File tree

13 files changed

+287
-60
lines changed

13 files changed

+287
-60
lines changed

install/lib/install.lib.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,23 @@ function removeLine($filename, $search_pattern, $strict = 0) {
666666
}
667667
}
668668

669+
function hasLine($filename, $search_pattern, $strict = 0) {
670+
if($lines = @file($filename)) {
671+
foreach($lines as $line) {
672+
if($strict == 0) {
673+
if(stristr($line, $search_pattern)) {
674+
return true;
675+
}
676+
} else {
677+
if(trim($line) == $search_pattern) {
678+
return true;
679+
}
680+
}
681+
}
682+
}
683+
return false;
684+
}
685+
669686
function is_installed($appname) {
670687
exec('which '.escapeshellcmd($appname).' 2> /dev/null', $out, $returncode);
671688
if(isset($out[0]) && stristr($out[0], $appname) && $returncode == 0) {

install/lib/installer_base.lib.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,15 @@ public function configure_apache() {
12251225
replaceLine('/etc/apache2/ports.conf', 'Listen 443', 'Listen 443', 1);
12261226
}
12271227

1228+
if(is_file('/etc/apache2/apache.conf')) {
1229+
if(hasLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 1) == false) {
1230+
if(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.conf', 1) == false) {
1231+
replaceLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 'Include sites-enabled/', 1, 1);
1232+
} elseif(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 1) == false) {
1233+
replaceLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 'IncludeOptional sites-enabled/*.vhost', 1, 1);
1234+
}
1235+
}
1236+
}
12281237

12291238
//* Copy the ISPConfig configuration include
12301239
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];

interface/lib/classes/ispcmail.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ private function detectHelo() {
223223
elseif(isset($_SERVER['SERVER_NAME'])) $this->smtp_helo = $_SERVER['SERVER_NAME'];
224224
else $this->smtp_helo = php_uname('n');
225225
if($this->smtp_helo == '') $this->smtp_helo = 'localhost';
226+
return $this->smtp_helo;
226227
}
227228

228229

interface/lib/classes/remoting.inc.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,69 @@ public function server_get_functions($session_id, $server_id)
199199
}
200200
}
201201

202+
/**
203+
* set record permissions in any table
204+
* @param string session_id
205+
* @param string index_field
206+
* @param string index_value
207+
* @param array permissions
208+
* @author "ispcomm", improved by M. Cramer <m.cramer@pixcept.de>
209+
*/
210+
public function update_record_permissions($tablename, $index_field, $index_value, $permissions) {
211+
global $app;
212+
213+
if(!$this->checkPerm($session_id, 'admin_record_permissions')) {
214+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
215+
return false;
216+
}
217+
218+
foreach($permissions as $key => $value) { // make sure only sys_ fields are updated
219+
switch($key) {
220+
case 'sys_userid':
221+
// check if userid is valid
222+
$check = $app->db->queryOneRecord('SELECT userid FROM sys_user WHERE userid = ' . $app->functions->intval($value));
223+
if(!$check || !$check['userid']) {
224+
$this->server->fault('invalid parameters', $value . ' is no valid sys_userid.');
225+
return false;
226+
}
227+
$permissions[$key] = $app->functions->intval($value);
228+
break;
229+
case 'sys_groupid':
230+
// check if groupid is valid
231+
$check = $app->db->queryOneRecord('SELECT groupid FROM sys_group WHERE groupid = ' . $app->functions->intval($value));
232+
if(!$check || !$check['groupid']) {
233+
$this->server->fault('invalid parameters', $value . ' is no valid sys_groupid.');
234+
return false;
235+
}
236+
$permissions[$key] = $app->functions->intval($value);
237+
break;
238+
case 'sys_perm_user':
239+
case 'sys_perm_group':
240+
// check if permissions are valid
241+
$value = strtolower($value);
242+
if(!preg_match('/^[riud]+$/', $value)) {
243+
$this->server->fault('invalid parameters', $value . ' is no valid permission string.');
244+
return false;
245+
}
246+
247+
$newvalue = '';
248+
if(strpos($value, 'r') !== false) $newvalue .= 'r';
249+
if(strpos($value, 'i') !== false) $newvalue .= 'i';
250+
if(strpos($value, 'u') !== false) $newvalue .= 'u';
251+
if(strpos($value, 'd') !== false) $newvalue .= 'd';
252+
$permissions[$key] = $newvalue;
253+
unset($newvalue);
254+
255+
break;
256+
default:
257+
$this->server->fault('invalid parameters', 'Only sys_userid, sys_groupid, sys_perm_user and sys_perm_group parameters can be changed with this function.');
258+
break;
259+
}
260+
}
261+
262+
return $app->db->datalogUpdate( $tablename, $permissions, $index_field, $index_value ) ;
263+
}
264+
202265
/**
203266
Gets the ISPconfig version of the server
204267
@param int session_id
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

33
$function_list['server_get,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_add,server_ip_update,server_ip_delete'] = 'Server functions';
4+
$function_list['admin_record_permissions'] = 'Record permission changes';
45

56
?>

server/conf/apache_apps.vhost.master

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,46 @@
44
# for the ISPConfig apps vhost
55
######################################################
66

7-
{vhost_port_listen} Listen {apps_vhost_port}
8-
# NameVirtualHost *:{apps_vhost_port}
7+
{tmpl_var name='vhost_port_listen'} Listen {tmpl_var name='apps_vhost_port'}
8+
# NameVirtualHost *:{tmpl_var name='apps_vhost_port'}
99

10-
<VirtualHost {apps_vhost_ip}:{apps_vhost_port}>
10+
<VirtualHost {tmpl_var name='apps_vhost_ip'}:{tmpl_var name='apps_vhost_port'}>
1111
ServerAdmin webmaster@localhost
12-
{apps_vhost_servername}
12+
{tmpl_var name='apps_vhost_servername'}
1313

1414
<FilesMatch "\.ph(p3?|tml)$">
1515
SetHandler None
1616
</FilesMatch>
1717

1818
<IfModule mod_php5.c>
19-
DocumentRoot {apps_vhost_dir}
19+
DocumentRoot {tmpl_var name='apps_vhost_dir'}
2020
AddType application/x-httpd-php .php
21-
<Directory {apps_vhost_dir}>
22-
Options FollowSymLinks
23-
AllowOverride None
24-
Order allow,deny
25-
Allow from all
21+
<Directory {tmpl_var name='apps_vhost_dir'}>
22+
Options FollowSymLinks
23+
AllowOverride None
24+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
25+
Require all granted
26+
{tmpl_else}
27+
Order allow,deny
28+
Allow from all
29+
{/tmpl_if}
2630
</Directory>
2731
</IfModule>
2832

2933
<IfModule mod_fcgid.c>
30-
DocumentRoot {apps_vhost_dir}
34+
DocumentRoot {tmpl_var name='apps_vhost_dir'}
3135
SuexecUserGroup ispapps ispapps
32-
<Directory {apps_vhost_dir}>
33-
Options Indexes FollowSymLinks MultiViews +ExecCGI
34-
AllowOverride AuthConfig Indexes Limit Options FileInfo
35-
AddHandler fcgid-script .php
36-
FCGIWrapper {apps_vhost_basedir}/php-fcgi-scripts/apps/.php-fcgi-starter .php
37-
Order allow,deny
38-
Allow from all
36+
<Directory {tmpl_var name='apps_vhost_dir'}>
37+
Options Indexes FollowSymLinks MultiViews +ExecCGI
38+
AllowOverride AuthConfig Indexes Limit Options FileInfo
39+
AddHandler fcgid-script .php
40+
FCGIWrapper {tmpl_var name='apps_vhost_basedir'}/php-fcgi-scripts/apps/.php-fcgi-starter .php
41+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
42+
Require all granted
43+
{tmpl_else}
44+
Order allow,deny
45+
Allow from all
46+
{/tmpl_if}
3947
</Directory>
4048
</IfModule>
4149

server/conf/apache_ispconfig.conf.master

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,100 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m
88

99
<Directory /var/www/clients>
1010
AllowOverride None
11-
Order Deny,Allow
12-
Deny from all
11+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
12+
Require all deny
13+
{tmpl_else}
14+
Order Deny,Allow
15+
Deny from all
16+
{/tmpl_if}
1317
</Directory>
1418

1519
# Do not allow access to the root file system of the server for security reasons
1620
<Directory />
1721
AllowOverride None
18-
Order Deny,Allow
19-
Deny from all
22+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
23+
Require all deny
24+
{tmpl_else}
25+
Order Deny,Allow
26+
Deny from all
27+
{/tmpl_if}
2028
</Directory>
2129

2230
<Directory /var/www/conf>
2331
AllowOverride None
24-
Order Deny,Allow
25-
Deny from all
32+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
33+
Require all deny
34+
{tmpl_else}
35+
Order Deny,Allow
36+
Deny from all
37+
{/tmpl_if}
2638
</Directory>
2739

2840
# Except of the following directories that contain website scripts
2941
<Directory /usr/share/phpmyadmin>
42+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
43+
Require all granted
44+
{tmpl_else}
3045
Order allow,deny
3146
Allow from all
47+
{/tmpl_if}
3248
</Directory>
3349

3450
<Directory /usr/share/phpMyAdmin>
51+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
52+
Require all granted
53+
{tmpl_else}
3554
Order allow,deny
3655
Allow from all
56+
{/tmpl_if}
3757
</Directory>
3858

3959
<Directory /usr/share/squirrelmail>
60+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
61+
Require all granted
62+
{tmpl_else}
4063
Order allow,deny
4164
Allow from all
65+
{/tmpl_if}
4266
</Directory>
4367

4468
# Allow access to mailman on OpenSuSE
4569
<Directory /usr/lib/mailman/cgi-bin>
46-
AllowOverride All
47-
order allow,deny
48-
allow from all
70+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
71+
Require all granted
72+
{tmpl_else}
73+
Order allow,deny
74+
Allow from all
75+
{/tmpl_if}
4976
</Directory>
5077

5178
<Directory /usr/lib/mailman/icons>
52-
order allow,deny
53-
allow from all
79+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
80+
Require all granted
81+
{tmpl_else}
82+
Order allow,deny
83+
Allow from all
84+
{/tmpl_if}
5485
</Directory>
5586

5687
<Directory /var/lib/mailman/archives/>
5788
Options +FollowSymLinks
58-
order allow,deny
59-
allow from all
89+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
90+
Require all granted
91+
{tmpl_else}
92+
Order allow,deny
93+
Allow from all
94+
{/tmpl_if}
6095
</Directory>
6196

6297
# allow path to awstats and alias for awstats icons
6398
<Directory /usr/share/awstats>
99+
{tmpl_if name='apache_version' op='>' value='2.2' format='version'}
100+
Require all granted
101+
{tmpl_else}
64102
Order allow,deny
65103
Allow from all
104+
{/tmpl_if}
66105
</Directory>
67106

68107
Alias /awstats-icon "/usr/share/awstats/icon"

0 commit comments

Comments
 (0)