Skip to content

Commit 02e7eaf

Browse files
author
Marius Cramer
committed
- backported patches
1 parent c2419b0 commit 02e7eaf

File tree

9 files changed

+58
-23
lines changed

9 files changed

+58
-23
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public function escape($sString) {
483483
$cur_encoding = mb_detect_encoding($sString);
484484
if($cur_encoding != "UTF-8") {
485485
if($cur_encoding != 'ASCII') {
486-
$app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_INFO);
486+
if(is_object($app) && method_exists($app, 'log')) $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_INFO);
487487
if($cur_encoding) $sString = mb_convert_encoding($sString, 'UTF-8', $cur_encoding);
488488
else $sString = mb_convert_encoding($sString, 'UTF-8');
489489
}

interface/web/dns/dns_soa_edit.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,14 @@ function onBeforeUpdate () {
273273

274274
//* Check if the server has been changed
275275
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
276-
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
276+
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord['origin'])) {
277277
//* We do not allow users to change a domain which has been created by the admin
278278
$rec = $app->db->queryOneRecord("SELECT origin from dns_soa WHERE id = ?", $this->id);
279-
$drOrigin = (isset($this->dataRecord['origin']))
280-
? $app->functions->idn_encode($this->dataRecord['origin'])
281-
: false;
279+
$drOrigin = $app->functions->idn_encode($this->dataRecord['origin']);
282280

283281
if($rec['origin'] !== $drOrigin && $app->tform->checkPerm($this->id, 'u')) {
284282
//* Add a error message and switch back to old server
285-
$app->tform->errorMessage .= $app->lng('The Zone (soa) can not be changed. Please ask your Administrator if you want to change the Zone name.');
283+
$app->tform->errorMessage .= $app->tform->wordbook["soa_cannot_be_changed_txt"];
286284
$this->dataRecord["origin"] = $rec['origin'];
287285
}
288286
unset($rec);

interface/web/dns/lib/lang/de_dns_soa.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ $wb['expire_range_error'] = 'Min. Expire ist 60 Sekunden.';
3535
$wb['minimum_range_error'] = 'Min. Minimum ist 60 Sekunden.';
3636
$wb['ttl_range_error'] = 'Min. TTL ist 60 Sekunden.';
3737
$wb['xfer_error_regex'] = 'Zonentransfer: Verwenden Sie eine oder mehrere durch Komma getrennte IP Adressen oder das Wort: any.';
38+
$wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
3839
?>

interface/web/dns/lib/lang/en_dns_soa.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ $wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3636
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3737
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
3838
$wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
39+
$wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
3940
?>

interface/web/mail/form/mail_relay_recipient.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
'formtype' => 'SELECT',
6464
'default' => '',
6565
'datasource' => array ( 'type' => 'SQL',
66-
'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_servr_id = 0 AND {AUTHSQL} ORDER BY server_name',
66+
'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
6767
'keyfield'=> 'server_id',
6868
'valuefield'=> 'server_name'
6969
),

server/lib/classes/db_mysql.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public function escape($sString) {
447447
$cur_encoding = mb_detect_encoding($sString);
448448
if($cur_encoding != "UTF-8") {
449449
if($cur_encoding != 'ASCII') {
450-
$app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_INFO);
450+
if(is_object($app) && method_exists($app, 'log')) $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_INFO);
451451
if($cur_encoding) $sString = mb_convert_encoding($sString, 'UTF-8', $cur_encoding);
452452
else $sString = mb_convert_encoding($sString, 'UTF-8');
453453
}

server/plugins-available/apache2_plugin.inc.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ function update($event_name, $data) {
14051405
* PHP-FPM
14061406
*/
14071407
// Support for multiple PHP versions
1408-
if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
1408+
if($data['new']['php'] == 'php-fpm'){
14091409
if(trim($data['new']['fastcgi_php_version']) != ''){
14101410
$default_php_fpm = false;
14111411
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
@@ -2855,20 +2855,28 @@ private function hhvm_update($data, $web_config) {
28552855
file_put_contents('/etc/init.d/hhvm_' . $data['new']['system_user'], $content);
28562856
exec('chmod +x /etc/init.d/hhvm_' . $data['new']['system_user'] . ' >/dev/null 2>&1');
28572857
exec('/usr/sbin/update-rc.d hhvm_' . $data['new']['system_user'] . ' defaults >/dev/null 2>&1');
2858-
exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' start >/dev/null 2>&1');
2858+
exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' restart >/dev/null 2>&1');
28592859

2860-
$monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content);
2861-
file_put_contents('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'], $monit_content);
2862-
exec('/etc/init.d/monit restart >/dev/null 2>&1');
2860+
if(is_dir('/etc/monit/conf.d')){
2861+
$monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content);
2862+
file_put_contents('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'], $monit_content);
2863+
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])) unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
2864+
exec('/etc/init.d/monit restart >/dev/null 2>&1');
2865+
}
28632866

28642867
} elseif($data['new']['php'] != 'hhvm' && $data['old']['php'] == 'hhvm') {
28652868
exec('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' stop >/dev/null 2>&1');
28662869
exec('/usr/sbin/update-rc.d hhvm_' . $data['old']['system_user'] . ' remove >/dev/null 2>&1');
28672870
unlink('/etc/init.d/hhvm_' . $data['old']['system_user']);
28682871
if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini');
28692872

2870-
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){
2871-
unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
2873+
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']) || is_file('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'])){
2874+
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){
2875+
unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
2876+
}
2877+
if(is_file('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'])){
2878+
unlink('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user']);
2879+
}
28722880
exec('/etc/init.d/monit restart >/dev/null 2>&1');
28732881
}
28742882
}

server/plugins-available/nginx_plugin.inc.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ function update($event_name, $data) {
950950
$default_php_fpm = true;
951951
}
952952
*/
953-
if($data['new']['php'] != 'no'){
953+
if($data['new']['php'] == 'php-fpm'){
954954
if(trim($data['new']['fastcgi_php_version']) != ''){
955955
$default_php_fpm = false;
956956
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
@@ -2424,18 +2424,26 @@ private function hhvm_update($data, $web_config) {
24242424
exec('/usr/sbin/update-rc.d hhvm_' . $data['new']['system_user'] . ' defaults >/dev/null 2>&1');
24252425
exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' restart >/dev/null 2>&1');
24262426

2427-
$monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content);
2428-
file_put_contents('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'], $monit_content);
2429-
exec('/etc/init.d/monit restart >/dev/null 2>&1');
2427+
if(is_dir('/etc/monit/conf.d')){
2428+
$monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content);
2429+
file_put_contents('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'], $monit_content);
2430+
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])) unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
2431+
exec('/etc/init.d/monit restart >/dev/null 2>&1');
2432+
}
24302433

24312434
} elseif($data['new']['php'] != 'hhvm' && $data['old']['php'] == 'hhvm') {
24322435
exec('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' stop >/dev/null 2>&1');
24332436
exec('/usr/sbin/update-rc.d hhvm_' . $data['old']['system_user'] . ' remove >/dev/null 2>&1');
24342437
unlink('/etc/init.d/hhvm_' . $data['old']['system_user']);
24352438
if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini');
24362439

2437-
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){
2438-
unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
2440+
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']) || is_file('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'])){
2441+
if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){
2442+
unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']);
2443+
}
2444+
if(is_file('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user'])){
2445+
unlink('/etc/monit/conf.d/00-hhvm_' . $data['new']['system_user']);
2446+
}
24392447
exec('/etc/init.d/monit restart >/dev/null 2>&1');
24402448
}
24412449
}
@@ -2454,7 +2462,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
24542462
$default_php_fpm = true;
24552463
}
24562464
*/
2457-
if($data['new']['php'] != 'no'){
2465+
if($data['new']['php'] == 'php-fpm'){
24582466
if(trim($data['new']['fastcgi_php_version']) != ''){
24592467
$default_php_fpm = false;
24602468
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
@@ -2475,7 +2483,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
24752483
$app->uses("getconf");
24762484
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
24772485

2478-
if($data['new']['php'] == 'no'){
2486+
if($data['new']['php'] != 'php-fpm'){
24792487
if(@is_file($pool_dir.$pool_name.'.conf')){
24802488
$app->system->unlink($pool_dir.$pool_name.'.conf');
24812489
//$reload = true;

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ function insert($event_name, $data) {
149149
$app->system->chown(escapeshellcmd($homedir).'/.bash_history', $data['new']['username']);
150150
$app->system->chgrp(escapeshellcmd($homedir).'/.bash_history', $data['new']['pgroup']);
151151

152+
//* Create .profile file
153+
$app->system->touch(escapeshellcmd($homedir).'/.profile');
154+
$app->system->chmod(escapeshellcmd($homedir).'/.profile', 0644);
155+
$app->system->chown(escapeshellcmd($homedir).'/.profile', $data['new']['username']);
156+
$app->system->chgrp(escapeshellcmd($homedir).'/.profile', $data['new']['pgroup']);
157+
152158
//* Disable shell user temporarily if we use jailkit
153159
if($data['new']['chroot'] == 'jailkit') {
154160
$command = 'usermod -s /bin/false -L '.escapeshellcmd($data['new']['username']).' 2>/dev/null';
@@ -214,6 +220,9 @@ function update($event_name, $data) {
214220

215221
// Check if the user that we want to update exists, if not, we insert it
216222
if($app->system->is_user($data['old']['username'])) {
223+
//* Remove webfolder protection
224+
$app->system->web_folder_protection($web['document_root'], false);
225+
217226
/*
218227
$command = 'usermod';
219228
$command .= ' --home '.escapeshellcmd($data['new']['dir']);
@@ -270,7 +279,17 @@ function update($event_name, $data) {
270279
$app->system->chown(escapeshellcmd($homedir).'/.bash_history', escapeshellcmd($data['new']['username']));
271280
$app->system->chgrp(escapeshellcmd($homedir).'/.bash_history', escapeshellcmd($data['new']['pgroup']));
272281
}
282+
283+
//* Create .profile file
284+
if(!is_file($data['new']['dir']).'/.profile') {
285+
$app->system->touch(escapeshellcmd($homedir).'/.profile');
286+
$app->system->chmod(escapeshellcmd($homedir).'/.profile', 0644);
287+
$app->system->chown(escapeshellcmd($homedir).'/.profile', escapeshellcmd($data['new']['username']));
288+
$app->system->chgrp(escapeshellcmd($homedir).'/.profile', escapeshellcmd($data['new']['pgroup']));
289+
}
273290

291+
//* Add webfolder protection again
292+
$app->system->web_folder_protection($web['document_root'], true);
274293
} else {
275294
// The user does not exist, so we insert it now
276295
$this->insert($event_name, $data);

0 commit comments

Comments
 (0)