Skip to content

Commit 30d3ae6

Browse files
author
Till Brehm
committed
Merge branch '5539-idn-encode-domains-in-rspamd-config-file-names' into 'stable-3.1'
Resolve "IDN encode domains in Rspamd config file names" See merge request ispconfig/ispconfig3!1062
2 parents 47bc07d + 2532502 commit 30d3ae6

File tree

3 files changed

+48
-37
lines changed

3 files changed

+48
-37
lines changed

.git-scripts/syntax.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fi
2020
FILECNT=$(eval "${CMD} | wc -l") ;
2121

2222
for F in $(eval "$CMD") ; do
23-
if [[ ! -e "${F}" && -f "${F}" ]] ; then
23+
if [[ ! -e "${F}" || ! -f "${F}" ]] ; then
2424
continue ;
2525
fi
2626
R=$(php -d error_reporting=E_ALL -d display_errors=On -l "$F" 2>/dev/null) ;
@@ -64,4 +64,4 @@ if [ $WARNCNT -gt 0 ] ; then
6464
echo ""
6565
fi
6666

67-
exit $EX
67+
exit $EX

interface/lib/classes/remote.d/sites.inc.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function sites_database_get($session_id, $primary_id)
102102
$app->remoting_lib->loadFormDef('../sites/form/database.tform.php');
103103
return $app->remoting_lib->getDataRecord($primary_id);
104104
}
105-
105+
106106
/* TODO: secure queries! */
107107
//* Add a record
108108
public function sites_database_add($session_id, $client_id, $params)
@@ -130,7 +130,7 @@ public function sites_database_add($session_id, $client_id, $params)
130130

131131
$retval = $this->insertQueryExecute($sql, $params);
132132
$app->sites_database_plugin->processDatabaseInsert($this);
133-
133+
134134
// set correct values for backup_interval and backup_copies
135135
if(isset($params['backup_interval']) || isset($params['backup_copies']) || isset($params['backup_format_web']) || isset($params['backup_format_db'])){
136136
$sql_set = array();
@@ -140,7 +140,7 @@ public function sites_database_add($session_id, $client_id, $params)
140140
if(isset($params['backup_format_db'])) $sql_set[] = "backup_format_db = ".$app->functions->intval($params['backup_format_db']);
141141
$this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval, $retval, $params);
142142
}
143-
143+
144144
return $retval;
145145
}
146146

@@ -165,7 +165,7 @@ public function sites_database_update($session_id, $client_id, $primary_id, $par
165165
$this->dataRecord = $params;
166166
$app->sites_database_plugin->processDatabaseUpdate($this);
167167
$retval = $this->updateQueryExecute($sql, $primary_id, $params);
168-
168+
169169
// set correct values for backup_interval and backup_copies
170170
if(isset($params['backup_interval']) || isset($params['backup_copies']) || isset($params['backup_format_web']) || isset($params['backup_format_db'])){
171171
$sql_set = array();
@@ -175,7 +175,7 @@ public function sites_database_update($session_id, $client_id, $primary_id, $par
175175
if(isset($params['backup_format_db'])) $sql_set[] = "backup_format_db = ".$app->functions->intval($params['backup_format_db']);
176176
$this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$primary_id, $primary_id, $params);
177177
}
178-
178+
179179
return $retval;
180180
}
181181

@@ -452,7 +452,7 @@ public function sites_web_domain_update($session_id, $client_id, $primary_id, $p
452452
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
453453
return false;
454454
}
455-
455+
456456
if($params['log_retention'] == '') $params['log_retention'] = 30;
457457

458458
//* Set a few defaults for nginx servers
@@ -524,7 +524,7 @@ public function sites_web_vhost_aliasdomain_update($session_id, $client_id, $pri
524524
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
525525
return false;
526526
}
527-
527+
528528
if($params['log_retention'] == '') $params['log_retention'] = 30;
529529

530530
//* Set a few defaults for nginx servers
@@ -596,7 +596,7 @@ public function sites_web_vhost_subdomain_update($session_id, $client_id, $prima
596596
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
597597
return false;
598598
}
599-
599+
600600
if($params['log_retention'] == '') $params['log_retention'] = 30;
601601

602602
//* Set a few defaults for nginx servers
@@ -880,7 +880,7 @@ public function sites_web_domain_set_status($session_id, $primary_id, $status) {
880880
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php');
881881
$params = $app->remoting_lib->getDataRecord($primary_id);
882882
$params['active'] = $status;
883-
883+
884884
$affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', 0, $primary_id, $params);
885885
return $affected_rows;
886886
} else {
@@ -905,122 +905,122 @@ public function sites_database_get_all_by_user($session_id, $client_id)
905905
$all = $app->db->queryAllRecords($sql, $client_id);
906906
return $all;
907907
}
908-
908+
909909
//** backup functions -----------------------------------------------------------------------------------
910910
public function sites_web_domain_backup_list($session_id, $site_id = null)
911911
{
912912
global $app;
913-
913+
914914
if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) {
915915
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
916916
return false;
917917
}
918-
918+
919919
$result = $app->db->queryAllRecords("SELECT * FROM web_backup".(($site_id != null)?' WHERE parent_domain_id = ?':''), $site_id);
920920
return $result;
921921
}
922-
922+
923923
//* Backup download and restoration by Abdi Joseph
924924
public function sites_web_domain_backup($session_id, $primary_id, $action_type)
925925
{
926926
global $app;
927-
927+
928928
if(!$this->checkPerm($session_id, 'sites_web_domain_backup')) {
929929
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
930930
return false;
931931
}
932-
932+
933933
//*Set variables
934934
$backup_record = $app->db->queryOneRecord("SELECT * FROM `web_backup` WHERE `backup_id`= ?", $primary_id);
935935
$server_id = $backup_record['server_id'];
936-
936+
937937
//*Set default action state
938938
$action_state = "pending";
939939
$tstamp = time();
940-
940+
941941
//* Basic validation of variables
942942
if ($server_id <= 0) {
943943
throw new SoapFault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
944944
return false;
945945
}
946-
946+
947947
if ($action_type != 'backup_download' and $action_type != 'backup_restore' and $action_type != 'backup_delete') {
948948
throw new SoapFault('invalid_action', "Invalid action_type $action_type");
949949
return false;
950950
}
951-
951+
952952
//* Validate instance
953953
$instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`= ? and `action_type`= ? and `action_state`= ?", $primary_id, $action_type, 'pending');
954954
if ($instance_record['action_id'] >= 1) {
955955
throw new SoapFault('duplicate_action', "There is already a pending $action_type action");
956956
return false;
957957
}
958-
958+
959959
//* Save the record
960960
if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) {
961961
return true;
962962
} else {
963963
return false;
964964
}
965965
}
966-
966+
967967
//** quota functions -----------------------------------------------------------------------------------
968968
public function quota_get_by_user($session_id, $client_id)
969969
{
970970
global $app;
971971
$app->uses('quota_lib');
972-
972+
973973
if(!$this->checkPerm($session_id, 'quota_get_by_user')) {
974974
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
975975
return false;
976976
}
977-
977+
978978
return $app->quota_lib->get_quota_data($client_id, false);
979979
}
980-
980+
981981
public function trafficquota_get_by_user($session_id, $client_id, $lastdays = 0)
982982
{
983983
global $app;
984984
$app->uses('quota_lib');
985-
985+
986986
if(!$this->checkPerm($session_id, 'trafficquota_get_by_user')) {
987987
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
988988
return false;
989989
}
990990
if ($client_id != null)
991991
$client_id = $app->functions->intval($client_id);
992-
992+
993993
return $app->quota_lib->get_trafficquota_data($client_id, $lastdays);
994994
}
995-
995+
996996
public function ftptrafficquota_data($session_id, $client_id, $lastdays = 0)
997997
{
998998
global $app;
999999
$app->uses('quota_lib');
1000-
1000+
10011001
if(!$this->checkPerm($session_id, 'trafficquota_get_by_user')) {
10021002
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
10031003
return false;
10041004
}
10051005
if ($client_id != null)
10061006
$client_id = $app->functions->intval($client_id);
1007-
1007+
10081008
return $app->quota_lib->get_ftptrafficquota_data($client_id, $lastdays);
10091009
}
1010-
1010+
10111011
public function databasequota_get_by_user($session_id, $client_id)
10121012
{
10131013
global $app;
10141014
$app->uses('quota_lib');
1015-
1015+
10161016
if(!$this->checkPerm($session_id, 'databasequota_get_by_user')) {
10171017
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
10181018
return false;
10191019
}
1020-
1020+
10211021
return $app->quota_lib->get_databasequota_data($client_id, false);
10221022
}
1023-
1023+
10241024
// ----------------------------------------------------------------------------------------------------------
10251025

10261026
//* Get record details
@@ -1070,8 +1070,8 @@ public function sites_webdav_user_delete($session_id, $primary_id)
10701070
$affected_rows = $this->deleteQuery('../sites/form/webdav_user.tform.php', $primary_id);
10711071
return $affected_rows;
10721072
}
1073-
1074-
1073+
1074+
10751075
}
10761076

10771077
?>

server/plugins-available/rspamd_plugin.inc.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ function user_settings_update($event_name, $data) {
206206
return;
207207
}
208208

209+
$old_settings_name = $settings_name;
210+
$settings_name = $app->functions->idn_encode($settings_name);
211+
212+
if($old_settings_name !== $settings_name) {
213+
// we changed naming to idn-encoded form due to path check issues. Delete old file if existing.
214+
$old_settings_file = $this->users_config_dir . str_replace('@', '_', $old_settings_name) . '.conf';
215+
if(is_file($old_settings_file)) {
216+
unlink($old_settings_file);
217+
}
218+
}
219+
209220
$settings_file = $this->users_config_dir . str_replace('@', '_', $settings_name) . '.conf';
210221
//$app->log('Settings file for rspamd is ' . $settings_file, LOGLEVEL_WARN);
211222
if($mode === 'delete') {

0 commit comments

Comments
 (0)