From c1f6bc44695d743aa7afcbead664b542f0c937af Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 17 Oct 2023 00:36:21 +0200 Subject: [PATCH 01/29] Add Initial Sympa support --- install/dist/conf/debian100.conf.php | 5 ++ install/dist/conf/debian110.conf.php | 5 ++ install/dist/conf/debian120.conf.php | 5 ++ install/dist/conf/debian90.conf.php | 5 ++ install/dist/conf/debiantesting.conf.php | 5 ++ install/dist/conf/ubuntu1804.conf.php | 5 ++ install/dist/conf/ubuntu2004.conf.php | 6 ++ install/dist/conf/ubuntu2204.conf.php | 5 ++ install/install.php | 8 ++ install/lib/installer_base.lib.php | 100 +++++++++++++++++++++++ install/update.php | 7 ++ server/conf/sympa.conf.master | 97 ++++++++++++++++++++++ 12 files changed, 253 insertions(+) create mode 100644 server/conf/sympa.conf.master diff --git a/install/dist/conf/debian100.conf.php b/install/dist/conf/debian100.conf.php index b23bbbf32c..2a02fb53c8 100644 --- a/install/dist/conf/debian100.conf.php +++ b/install/dist/conf/debian100.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debian110.conf.php b/install/dist/conf/debian110.conf.php index a1754722e5..e7f0507f77 100644 --- a/install/dist/conf/debian110.conf.php +++ b/install/dist/conf/debian110.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debian120.conf.php b/install/dist/conf/debian120.conf.php index bd6773c623..b2284ae78c 100644 --- a/install/dist/conf/debian120.conf.php +++ b/install/dist/conf/debian120.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debian90.conf.php b/install/dist/conf/debian90.conf.php index 64e22fea28..893ab6ec89 100644 --- a/install/dist/conf/debian90.conf.php +++ b/install/dist/conf/debian90.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/debiantesting.conf.php b/install/dist/conf/debiantesting.conf.php index 145e213d0c..d5a58b8a9a 100644 --- a/install/dist/conf/debiantesting.conf.php +++ b/install/dist/conf/debiantesting.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* mlmmj $conf['mlmmj']['installed'] = false; // will be detected automatically during installation $conf['mlmmj']['config_dir'] = '/etc/mlmmj'; diff --git a/install/dist/conf/ubuntu1804.conf.php b/install/dist/conf/ubuntu1804.conf.php index 6dc51a13c7..a2f38c0fee 100644 --- a/install/dist/conf/ubuntu1804.conf.php +++ b/install/dist/conf/ubuntu1804.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* Getmail $conf['getmail']['installed'] = false; // will be detected automatically during installation $conf['getmail']['config_dir'] = '/etc/getmail'; diff --git a/install/dist/conf/ubuntu2004.conf.php b/install/dist/conf/ubuntu2004.conf.php index a55c9a004b..fc8289e656 100644 --- a/install/dist/conf/ubuntu2004.conf.php +++ b/install/dist/conf/ubuntu2004.conf.php @@ -122,6 +122,12 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + + //* Getmail $conf['getmail']['installed'] = false; // will be detected automatically during installation $conf['getmail']['config_dir'] = '/etc/getmail'; diff --git a/install/dist/conf/ubuntu2204.conf.php b/install/dist/conf/ubuntu2204.conf.php index 050f58f69d..ec78b404fd 100644 --- a/install/dist/conf/ubuntu2204.conf.php +++ b/install/dist/conf/ubuntu2204.conf.php @@ -122,6 +122,11 @@ $conf['mailman']['installed'] = false; // will be detected automatically during $conf['mailman']['config_dir'] = '/etc/mailman'; $conf['mailman']['init_script'] = 'mailman'; +//* Sympa +$conf['sympa']['installed'] = false; // will be detected automatically during installation +$conf['sympa']['config_dir'] = '/etc/sympa'; +$conf['sympa']['init_script'] = 'sympa'; + //* Getmail $conf['getmail']['installed'] = false; // will be detected automatically during installation $conf['getmail']['config_dir'] = '/etc/getmail'; diff --git a/install/install.php b/install/install.php index 114410b53c..71380103f0 100644 --- a/install/install.php +++ b/install/install.php @@ -356,6 +356,13 @@ if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Mail $inst->configure_mailman(); } + //* Configure Sympa + $force = @($conf['sympa']['installed']) ? true : $inst->force_configure_app('Sympa', ($install_mode == 'expert')); + if($force) { + swriteln('Configuring Sympa'); + $inst->configure_sympa(); + } + //* Check for Dovecot and Courier if(!$conf['dovecot']['installed'] && !$conf['courier']['installed']) { $conf['dovecot']['installed'] = $inst->force_configure_app('Dovecot', ($install_mode == 'expert')); @@ -652,6 +659,7 @@ if($conf['courier']['installed'] == true){ } if($conf['dovecot']['installed'] == true && isset($conf['dovecot']['init_script']) && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); if($conf['mailman']['installed'] == true && isset($conf['mailman']['init_script']) && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &'); +if($conf['sympa']['installed'] == true && isset($conf['sympa']['init_script']) && $conf['sympa']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['sympa']['init_script'], 'restart').' >/dev/null 2>&1 &'); if($conf['apache']['installed'] == true && isset($conf['apache']['init_script']) && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart')); //* Reload is enough for nginx if($conf['nginx']['installed'] == true){ diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 8e6cfca07b..57ff711bd0 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -211,6 +211,7 @@ class installer_base extends stdClass { if(is_installed('postfix')) $conf['postfix']['installed'] = true; if(is_installed('postgrey')) $conf['postgrey']['installed'] = true; if(is_installed('mailman') || is_installed('mmsitepass')) $conf['mailman']['installed'] = true; + if(is_installed('sympa')) $conf['sympa']['installed'] = true; if(is_installed('apache') || is_installed('apache2') || is_installed('httpd') || is_installed('httpd2')) $conf['apache']['installed'] = true; if(is_installed('getmail')) $conf['getmail']['installed'] = true; if(is_installed('courierlogger')) $conf['courier']['installed'] = true; @@ -1031,6 +1032,105 @@ class installer_base extends stdClass { exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); } + public function configure_sympa($status = 'insert') { + global $conf; + + $data_dir = '/var/lib/sympa'; + if (($conf['sympa']['installed'] != true) && is_dir($data_dir)) { + rename($data_dir, $data_dir . '-bk'); + //* Create the mailman files + if(!is_dir('/etc/sympa')) exec('mkdir -p /etc/sympa'); + if(!is_file('/etc/sympa/transport.sympa')) touch('/etc/sympa/transport.sympa'); + exec('postmap hash:/etc/sympa/transport.sympa'); + if(!is_file('/etc/sympa/virtual.sympa')) touch('/etc/sympa/virtual.sympa'); + exec('postmap hash:/etc/sympa/virtual.sympa'); + if(!is_file('/etc/sympa/sympa_transport')) touch('/etc/sympa/sympa_transport'); + exec('chmod 644 /etc/sympa/sympa_transport'); + exec('chown sympa:sympa /etc/sympa/sympa_transport'); + exec('/usr/lib/sympa/bin/sympa_newaliases.pl'); + exec('postmap hash:/etc/sympa/sympa_transport'); + exec('chmod 640 /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); + exec('chgrp postfix /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); + } + + $config_dir = $conf['sympa']['config_dir'].'/'; + $full_file_name = $config_dir.'sympa.conf'; + //* Backup exiting file + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.'sympa.conf.master~'); + } + + // load files + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.conf.master', 'tpl/sympa.conf.master.master'); + $old_file = rf($full_file_name); + + $old_options = array(); + $lines = explode("\n", $old_file); + foreach ($lines as $line) + { + if (trim($line) != '' && substr($line, 0, 1) != '#') + { + @list($key, $value) = @explode("=", $line); + if (isset($value) && $value !== '') + { + $key = rtrim($key); + $old_options[$key] = trim($value); + } + } + } + + $virtual_domains = ''; + if($status == 'update') + { + // create virtual_domains list + $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); + + if(is_array($domainAll)) { + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } + } + } + else + $virtual_domains = "' '"; + + $content = str_replace('{hostname}', $conf['hostname'], $content); + if(!isset($old_options['DEFAULT_SERVER_LANGUAGE']) || $old_options['DEFAULT_SERVER_LANGUAGE'] == '') $old_options['DEFAULT_SERVER_LANGUAGE'] = "'en'"; + $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); + $content = str_replace('{virtual_domains}', $virtual_domains, $content); + + wf($full_file_name, $content); + + //* Write virtual_to_transport.sh script + $config_dir = $conf['mailman']['config_dir'].'/'; + $full_file_name = $config_dir.'virtual_to_transport.sh'; + + //* Backup exiting virtual_to_transport.sh script + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); + } + + if(is_dir('/etc/mailman')) { + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, $this->mailman_group); + chmod($full_file_name, 0755); + } + + //* Create aliasaes + if($status == 'install') exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); + + if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); + exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); + } + public function get_postfix_service($service, $type) { global $conf; diff --git a/install/update.php b/install/update.php index e03b5d9de1..036a59e8e0 100644 --- a/install/update.php +++ b/install/update.php @@ -469,6 +469,12 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel $inst->configure_mailman('update'); } + //** Configure Sympa + if($conf['sympa']['installed'] == true && $inst->reconfigure_app('Sympa', $reconfigure_services_answer)) { + swriteln('Configuring Sympa'); + $inst->configure_sympa('update'); + } + //** Configure Spamasassin if($inst->reconfigure_app('Spamassassin', $reconfigure_services_answer)) { swriteln('Configuring Spamassassin'); @@ -665,6 +671,7 @@ if($reconfigure_services_answer == 'yes') { } if($conf['dovecot']['installed'] == true && isset($conf['dovecot']['init_script']) && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); if($conf['mailman']['installed'] == true && isset($conf['mailman']['init_script']) && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &'); + if($conf['sympa']['installed'] == true && isset($conf['sympa']['init_script']) && $conf['sympa']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['sympa']['init_script'], 'restart').' >/dev/null 2>&1 &'); } if($conf['services']['web'] || $inst->install_ispconfig_interface) { if($conf['webserver']['server_type'] == 'apache') { diff --git a/server/conf/sympa.conf.master b/server/conf/sympa.conf.master new file mode 100644 index 0000000000..d19fa2f30d --- /dev/null +++ b/server/conf/sympa.conf.master @@ -0,0 +1,97 @@ +###\\\\ Service description ////### + +## domain +## Primary mail domain name +## Example: domain mail.example.org +domain {hostname} + +## listmaster +## Email addresses of listmasters +## Email addresses of the listmasters (users authorized to perform global +## server commands). Some error reports may also be sent to these addresses. +## Listmasters can be defined for each virtual host, however, the default +## listmasters will have privileges to manage all virtual hosts. +## Example: listmaster your_email_address@domain.tld +listmaster listmaster@hotel.phphost.ch + +###\\\\ Database related ////### + +## db_type +## Type of the database +## Possible types are "MySQL", "PostgreSQL", "Oracle" and "SQLite". +db_type mysql + +## db_host +## Hostname of the database server +## With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. +## "/var/run/postgresql" for connection with Unix domain socket. +## Example: db_host localhost +db_host localhost + +## db_port +## Port of the database server +db_port 3306 + +## db_name +## Name of the database +## With SQLite, this must be the full path to database file. +## With Oracle Database, this must be SID, net service name or easy connection +## identifier (to use net service name, db_host should be set to "none" and +## HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file). +db_name sympa + +## db_user +## User for the database connection +## Example: db_user sympa +db_user sympa + +## db_passwd +## Password for the database connection +## What ever you use a password or not, you must protect the SQL server (is it +## not a public internet service ?) +## Example: db_passwd your_passwd +db_passwd ZzK3VT8AB2NU + +###\\\\ List definition ////### + +## lang +## Language of the list +## This parameter defines the language used for the list. It is used to +## initialize a user's language preference; Sympa command reports are +## extracted from the associated message catalog. +lang {default_language} + +###\\\\ Web interface parameters ////### + +## wwsympa_url +## URL prefix of web interface +## This is used to construct URLs of web interface. The protocol (either +## https:// or http://) is required. +## Example: wwsympa_url https://web.example.org/sympa +wwsympa_url http://{hostname}/wws + +## static_content_path +## Directory for static contents +static_content_path /usr/share/sympa/static_content + +## css_path +## Directory for static style sheets (CSS) +## After an upgrade, static CSS files are upgraded with the newly installed +## "css.tt2" template. Therefore, this is not a good place to store customized +## CSS files. +css_path /var/lib/sympa/css + +## css_url +## URL for style sheets (CSS) +## To use auto-generated static CSS, HTTP server have to map it with +## "css_path". +css_url /css-sympa + +## pictures_path +## Directory for subscribers pictures +pictures_path /var/lib/sympa/pictures + +## pictures_url +## URL for subscribers pictures +## HTTP server have to map it with "pictures_path" directory. +pictures_url /pictures-sympa -- GitLab From 99876018f41d896b0731a069db41273ca92c0feb Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 17 Oct 2023 01:18:41 +0200 Subject: [PATCH 02/29] Use chmod chgrp and chown instead of exec --- install/lib/installer_base.lib.php | 45 +++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 57ff711bd0..93f9bf25a0 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1041,16 +1041,23 @@ class installer_base extends stdClass { //* Create the mailman files if(!is_dir('/etc/sympa')) exec('mkdir -p /etc/sympa'); if(!is_file('/etc/sympa/transport.sympa')) touch('/etc/sympa/transport.sympa'); - exec('postmap hash:/etc/sympa/transport.sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); if(!is_file('/etc/sympa/virtual.sympa')) touch('/etc/sympa/virtual.sympa'); - exec('postmap hash:/etc/sympa/virtual.sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); if(!is_file('/etc/sympa/sympa_transport')) touch('/etc/sympa/sympa_transport'); - exec('chmod 644 /etc/sympa/sympa_transport'); - exec('chown sympa:sympa /etc/sympa/sympa_transport'); + //exec('chmod 644 /etc/sympa/sympa_transport'); + chmod('/etc/sympa/sympa_transport', 0644); + chown('/etc/sympa/sympa_transport', 'sympa'); + chgrp('/etc/sympa/sympa_transport', 'sympa'); + //exec('chown sympa:sympa /etc/sympa/sympa_transport'); exec('/usr/lib/sympa/bin/sympa_newaliases.pl'); - exec('postmap hash:/etc/sympa/sympa_transport'); - exec('chmod 640 /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); - exec('chgrp postfix /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); + exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); + //exec('chmod 640 /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); + chmod('etc/sympa/sympa_transport', 0640); + chmod('etc/sympa/sympa_transport.db', 0640); + chgrp('/etc/sympa/sympa_transport', 'postfix'); + chgrp('/etc/sympa/sympa_transport.db', 'postfix'); + //exec('chgrp postfix /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); } $config_dir = $conf['sympa']['config_dir'].'/'; @@ -1079,6 +1086,24 @@ class installer_base extends stdClass { } } + //* Configure master.cf and add a line for deliver + if(!$this->get_postfix_service('sympa', 'unix')) { + //* backup + if(is_file($config_dir.'/master.cf')){ + copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); + } + if(is_file($config_dir.'/master.cf~2')){ + chmod($config_dir.'/master.cf~2', 0400); + } + //* Configure master.cf and add a line for deliver + $content = rf($config_dir.'/master.cf'); + $deliver_content = 'sympa unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/queue ${nexthop}'."\n"; + $deliver_content .= 'sympabounce unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/bouncequeue ${nexthop}'."\n"; + af($config_dir.'/master.cf', $deliver_content); + unset($content); + unset($deliver_content); + } + $virtual_domains = ''; if($status == 'update') { @@ -1099,14 +1124,14 @@ class installer_base extends stdClass { $virtual_domains = "' '"; $content = str_replace('{hostname}', $conf['hostname'], $content); - if(!isset($old_options['DEFAULT_SERVER_LANGUAGE']) || $old_options['DEFAULT_SERVER_LANGUAGE'] == '') $old_options['DEFAULT_SERVER_LANGUAGE'] = "'en'"; + if(!isset($old_options['DEFAULT_SERVER_LANGUAGE']) || $old_options['DEFAULT_SERVER_LANGUAGE'] == '') $old_options['DEFAULT_SERVER_LANGUAGE'] = "'en_US'"; $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); $content = str_replace('{virtual_domains}', $virtual_domains, $content); wf($full_file_name, $content); //* Write virtual_to_transport.sh script - $config_dir = $conf['mailman']['config_dir'].'/'; + $config_dir = $conf['sympa']['config_dir'].'/'; $full_file_name = $config_dir.'virtual_to_transport.sh'; //* Backup exiting virtual_to_transport.sh script @@ -1125,7 +1150,7 @@ class installer_base extends stdClass { } //* Create aliasaes - if($status == 'install') exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); + if($status == 'install') exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); -- GitLab From 751315de4b3f7c36f10897b23563bb08f1adaaca Mon Sep 17 00:00:00 2001 From: Jonas Schwarz Date: Tue, 17 Oct 2023 12:20:48 +0200 Subject: [PATCH 03/29] Finish the installer --- install/lib/installer_base.lib.php | 57 ++++++++++++++++++------------ install/tpl/list_aliases.tt2 | 0 2 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 install/tpl/list_aliases.tt2 diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 93f9bf25a0..109ce25023 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1035,36 +1035,33 @@ class installer_base extends stdClass { public function configure_sympa($status = 'insert') { global $conf; + # https://www.sympa.community/manual/install/configure-mail-server-postfix.html $data_dir = '/var/lib/sympa'; if (($conf['sympa']['installed'] != true) && is_dir($data_dir)) { rename($data_dir, $data_dir . '-bk'); - //* Create the mailman files + //* Create the Sympa files if(!is_dir('/etc/sympa')) exec('mkdir -p /etc/sympa'); if(!is_file('/etc/sympa/transport.sympa')) touch('/etc/sympa/transport.sympa'); - exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); if(!is_file('/etc/sympa/virtual.sympa')) touch('/etc/sympa/virtual.sympa'); - exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); if(!is_file('/etc/sympa/sympa_transport')) touch('/etc/sympa/sympa_transport'); - //exec('chmod 644 /etc/sympa/sympa_transport'); chmod('/etc/sympa/sympa_transport', 0644); chown('/etc/sympa/sympa_transport', 'sympa'); chgrp('/etc/sympa/sympa_transport', 'sympa'); - //exec('chown sympa:sympa /etc/sympa/sympa_transport'); - exec('/usr/lib/sympa/bin/sympa_newaliases.pl'); - exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); - //exec('chmod 640 /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); + exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); + exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); + ## exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); chmod('etc/sympa/sympa_transport', 0640); chmod('etc/sympa/sympa_transport.db', 0640); chgrp('/etc/sympa/sympa_transport', 'postfix'); chgrp('/etc/sympa/sympa_transport.db', 'postfix'); - //exec('chgrp postfix /etc/sympa/sympa_transport /etc/sympa/sympa_transport.db'); } $config_dir = $conf['sympa']['config_dir'].'/'; $full_file_name = $config_dir.'sympa.conf'; //* Backup exiting file if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.'sympa.conf.master~'); + copy($full_file_name, $config_dir.'sympa.conf~'); } // load files @@ -1130,30 +1127,27 @@ class installer_base extends stdClass { wf($full_file_name, $content); - //* Write virtual_to_transport.sh script + //* Write list_aliases.tt2 script $config_dir = $conf['sympa']['config_dir'].'/'; - $full_file_name = $config_dir.'virtual_to_transport.sh'; + $full_file_name = $config_dir.'list_aliases.tt2'; - //* Backup exiting virtual_to_transport.sh script + //* Backup exiting list_aliases.tt2 file if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); + copy($full_file_name, $config_dir.'list_aliases.tt2~'); } - if(is_dir('/etc/mailman')) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + if(is_dir('/etc/sympa')) { + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/list_aliases.tt2')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/list_aliases.tt2', $full_file_name); } else { - copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + copy('tpl/list_aliases.tt2', $full_file_name); } - chgrp($full_file_name, $this->mailman_group); - chmod($full_file_name, 0755); + chgrp($full_file_name, 'sympa'); + chmod($full_file_name, 0644); } //* Create aliasaes if($status == 'install') exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); - - if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); - exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); } public function get_postfix_service($service, $type) { @@ -1419,6 +1413,23 @@ class installer_base extends stdClass { if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); + //* Create the Sympa files + if(!is_dir('/etc/sympa')) exec('mkdir -p /etc/sympa'); + if(!is_file('/etc/sympa/transport.sympa')) touch('/etc/sympa/transport.sympa'); + if(!is_file('/etc/sympa/virtual.sympa')) touch('/etc/sympa/virtual.sympa'); + if(!is_file('/etc/sympa/sympa_transport')) touch('/etc/sympa/sympa_transport'); + chmod('/etc/sympa/sympa_transport', 0644); + chown('/etc/sympa/sympa_transport', 'sympa'); + chgrp('/etc/sympa/sympa_transport', 'sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); + exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); + exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); + ## exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); + chmod('etc/sympa/sympa_transport', 0640); + chmod('etc/sympa/sympa_transport.db', 0640); + chgrp('/etc/sympa/sympa_transport', 'postfix'); + chgrp('/etc/sympa/sympa_transport.db', 'postfix'); + //* Create auxillary postfix conf files $configfile = 'helo_access'; if(is_file($config_dir.'/'.$configfile)) { diff --git a/install/tpl/list_aliases.tt2 b/install/tpl/list_aliases.tt2 new file mode 100644 index 0000000000..e69de29bb2 -- GitLab From 6a4a83a1b15f07afa840d3db165f2796a0573290 Mon Sep 17 00:00:00 2001 From: Jonas Schwarz Date: Tue, 17 Oct 2023 14:31:24 +0200 Subject: [PATCH 04/29] Add Apache and Postfix config --- install/tpl/apache_ispconfig.conf.master | 24 ++++++++++++++++++++++++ install/tpl/debian_postfix.conf.master | 8 ++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/install/tpl/apache_ispconfig.conf.master b/install/tpl/apache_ispconfig.conf.master index c968abf367..96ad9eab20 100644 --- a/install/tpl/apache_ispconfig.conf.master +++ b/install/tpl/apache_ispconfig.conf.master @@ -136,6 +136,30 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m Alias /awstats-icon "/usr/share/awstats/icon" +# Sympa Configuration + + Alias /static-sympa /usr/share/sympa/static_content + + Require all granted + + + Alias /css-sympa /var/lib/sympa/css + + Require all granted + + + Alias /pictures-sympa /var/lib/sympa/pictures + + Require all granted + + + + SetHandler "proxy:unix:/run/sympa/wwsympa.socket|fcgi://" + Require all granted + + + + NameVirtualHost *:80 NameVirtualHost *:443 diff --git a/install/tpl/debian_postfix.conf.master b/install/tpl/debian_postfix.conf.master index 8bd34f6928..bc76e7bbf7 100644 --- a/install/tpl/debian_postfix.conf.master +++ b/install/tpl/debian_postfix.conf.master @@ -1,9 +1,9 @@ alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases virtual_alias_domains = proxy:mysql:{config_dir}/mysql-virtual_alias_domains.cf -virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, proxy:mysql:{config_dir}/mysql-virtual_alias_maps.cf, proxy:mysql:{config_dir}/mysql-virtual_email2email.cf -virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf -virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf +virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, proxy:mysql:{config_dir}/mysql-virtual_alias_maps.cf, proxy:mysql:{config_dir}/mysql-virtual_email2email.cf, hash:/etc/sympa/virtual.sympa +virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf, hash:/etc/sympa/transport.sympa +virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf, hash:/etc/sympa/transport.sympa, hash:/etc/sympa/sympa_transport, hash:/etc/sympa/virtual.sympa virtual_mailbox_base = {vmail_mailbox_base} virtual_uid_maps = proxy:mysql:/etc/postfix/mysql-virtual_uids.cf virtual_gid_maps = proxy:mysql:/etc/postfix/mysql-virtual_gids.cf @@ -20,7 +20,7 @@ smtpd_use_tls = yes smtpd_tls_security_level = may smtpd_tls_cert_file = {config_dir}/smtpd.cert smtpd_tls_key_file = {config_dir}/smtpd.key -transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf +transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf, hash:/etc/sympa/transport.sympa, hash:/etc/sympa/sympa_transport relay_domains = proxy:mysql:{config_dir}/mysql-virtual_relaydomains.cf relay_recipient_maps = proxy:mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf smtpd_sender_login_maps = proxy:mysql:{config_dir}/mysql-virtual_sender_login_maps.cf -- GitLab From 87b42402120bdae9463fb1f72cc8f36483aadcd5 Mon Sep 17 00:00:00 2001 From: Jonas Schwarz Date: Tue, 17 Oct 2023 14:48:00 +0200 Subject: [PATCH 05/29] Add nginx conf and initial sympa_plugin --- install/tpl/nginx_apps.vhost.master | 35 ++++ server/conf/apache_ispconfig.conf.master | 23 +++ server/conf/nginx_apps.vhost.master | 35 ++++ .../server_services_plugin.inc.php | 2 +- server/plugins-available/sympa_plugin.inc.php | 182 ++++++++++++++++++ 5 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 server/plugins-available/sympa_plugin.inc.php diff --git a/install/tpl/nginx_apps.vhost.master b/install/tpl/nginx_apps.vhost.master index 181f4c807e..ed58d5f0ba 100644 --- a/install/tpl/nginx_apps.vhost.master +++ b/install/tpl/nginx_apps.vhost.master @@ -209,6 +209,41 @@ server { autoindex on; } + location /sympa { + include fastcgi_params; + + fastcgi_pass unix:/var/run/sympa-fastcgi; + + # If you changed wwsympa_url in sympa.conf, change this regex too! + fastcgi_split_path_info ^(/sympa)(.*)$; + + fastcgi_param SCRIPT_FILENAME $document_root/wwsympa.fcgi; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param USERID sympa; + + # According to RFC3875 (https://tools.ietf.org/html/rfc3875#section-4.1.14) in SERVER_NAME + # we should put an actual hostname user came to. For nginx it is in $host + # This will allow to run sympa multihost instances + fastcgi_param SERVER_NAME $host; + } + + location /static-sympa/css { + alias /var/lib/sympa/css; + } + + location /static-sympa/pictures { + alias /var/lib/sympa/pictures; + } + + location /static-sympa { + alias /usr/share/sympa/static_content; + } + + location ^~ /css-sympa/ { + alias /var/lib/sympa/css/; + access_log off; + } + {use_rspamd}location /rspamd/ { {use_rspamd}proxy_pass http://127.0.0.1:11334/; {use_rspamd}rewrite ^//(.*) /$1; diff --git a/server/conf/apache_ispconfig.conf.master b/server/conf/apache_ispconfig.conf.master index 2b6038c54a..48fd6cf2d0 100644 --- a/server/conf/apache_ispconfig.conf.master +++ b/server/conf/apache_ispconfig.conf.master @@ -136,6 +136,29 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m Alias /awstats-icon "/usr/share/awstats/icon" +# Sympa Configuration + + Alias /static-sympa /usr/share/sympa/static_content + + Require all granted + + + Alias /css-sympa /var/lib/sympa/css + + Require all granted + + + Alias /pictures-sympa /var/lib/sympa/pictures + + Require all granted + + + + SetHandler "proxy:unix:/run/sympa/wwsympa.socket|fcgi://" + Require all granted + + + NameVirtualHost *:80 NameVirtualHost *:443 diff --git a/server/conf/nginx_apps.vhost.master b/server/conf/nginx_apps.vhost.master index 181f4c807e..ed58d5f0ba 100644 --- a/server/conf/nginx_apps.vhost.master +++ b/server/conf/nginx_apps.vhost.master @@ -209,6 +209,41 @@ server { autoindex on; } + location /sympa { + include fastcgi_params; + + fastcgi_pass unix:/var/run/sympa-fastcgi; + + # If you changed wwsympa_url in sympa.conf, change this regex too! + fastcgi_split_path_info ^(/sympa)(.*)$; + + fastcgi_param SCRIPT_FILENAME $document_root/wwsympa.fcgi; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param USERID sympa; + + # According to RFC3875 (https://tools.ietf.org/html/rfc3875#section-4.1.14) in SERVER_NAME + # we should put an actual hostname user came to. For nginx it is in $host + # This will allow to run sympa multihost instances + fastcgi_param SERVER_NAME $host; + } + + location /static-sympa/css { + alias /var/lib/sympa/css; + } + + location /static-sympa/pictures { + alias /var/lib/sympa/pictures; + } + + location /static-sympa { + alias /usr/share/sympa/static_content; + } + + location ^~ /css-sympa/ { + alias /var/lib/sympa/css/; + access_log off; + } + {use_rspamd}location /rspamd/ { {use_rspamd}proxy_pass http://127.0.0.1:11334/; {use_rspamd}rewrite ^//(.*) /$1; diff --git a/server/plugins-available/server_services_plugin.inc.php b/server/plugins-available/server_services_plugin.inc.php index c3eb78f194..8ee401eeb4 100644 --- a/server/plugins-available/server_services_plugin.inc.php +++ b/server/plugins-available/server_services_plugin.inc.php @@ -38,7 +38,7 @@ class server_services_plugin { var $services = array('mail_server', 'web_server', 'dns_server', 'db_server', 'vserver_server', 'xmpp_server'); - var $mail_plugins = array('getmail_plugin', 'mail_plugin', 'mail_plugin_dkim', 'mailman_plugin', 'postfix_filter_plugin', 'postfix_server_plugin'); + var $mail_plugins = array('getmail_plugin', 'mail_plugin', 'mail_plugin_dkim', 'mailman_plugin', 'sympa_plugin', 'postfix_filter_plugin', 'postfix_server_plugin'); var $courier_plugins = array('maildrop_plugin'); var $dovecot_plugins = array('maildeliver_plugin'); diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php new file mode 100644 index 0000000000..070838d08e --- /dev/null +++ b/server/plugins-available/sympa_plugin.inc.php @@ -0,0 +1,182 @@ +plugins->registerEvent('mail_mailinglist_insert', 'sympa_plugin', 'insert'); + $app->plugins->registerEvent('mail_mailinglist_update', 'sympa_plugin', 'update'); + $app->plugins->registerEvent('mail_mailinglist_delete', 'sympa_plugin', 'delete'); + + + + } + + function insert($event_name, $data) { + global $app, $conf; + + $this->update_config(); + + $pid = $app->system->exec_safe("nohup /usr/lib/mailman/bin/newlist -u ? -e ? ? ? ? >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $data["new"]["domain"], $data["new"]["listname"], $data["new"]["email"], $data["new"]["password"]); + // wait for /usr/lib/mailman/bin/newlist-call + $running = true; + do { + exec('ps -p '.intval($pid), $out); + if (count($out) ==1) $running=false; else sleep(1); + unset($out); + } while ($running); + unset($out); + if(is_file('/etc/mailman/virtual-mailman') && !is_link('/var/lib/mailman/data/virtual-mailman')) { + symlink('/etc/mailman/virtual-mailman','/var/lib/mailman/data/virtual-mailman'); + } + if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); + if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); + + exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); + + // Fix list URL + $app->system->exec_safe('/usr/sbin/withlist -l -r fix_url ?', $data["new"]["listname"]); + + $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); + + } + + // The purpose of this plugin is to rewrite the main.cf file + function update($event_name, $data) { + global $app, $conf; + + $this->update_config(); + + if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { + $app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]); + exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); + $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); + } + + if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); + if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); + } + + function delete($event_name, $data) { + global $app, $conf; + + $this->update_config(); + + $app->system->exec_safe("nohup /usr/lib/mailman/bin/rmlist -a ? >/dev/null 2>&1 &", $data["old"]["listname"]); + + exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); + + if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); + if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); + + } + + function update_config() { + global $app, $conf; + + copy($this->mailman_config_dir.'mm_cfg.py', $this->mailman_config_dir.'mm_cfg.py~'); + + // load the server configuration options + $app->uses('getconf'); + $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); + + // load files + if(file_exists($conf["rootpath"]."/conf-custom/mm_cfg.py.master")) { + $content = file_get_contents($conf["rootpath"]."/conf-custom/mm_cfg.py.master"); + } else { + $content = file_get_contents($conf["rootpath"]."/conf/mm_cfg.py.master"); + } + $old_file = file_get_contents($this->mailman_config_dir."/mm_cfg.py"); + + $old_options = array(); + $lines = explode("\n", $old_file); + foreach ($lines as $line) + { + if (strlen($line) && substr($line, 0, 1) != '#') + { + list($key, $value) = explode("=", $line); + if ($value && $value !== '') + { + $key = rtrim($key); + $old_options[$key] = trim($value); + } + } + } + + // create virtual_domains list + $domainAll = $app->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); + $virtual_domains = ''; + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } + + $content = str_replace('{hostname}', $server_config['hostname'], $content); + $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); + $content = str_replace('{virtual_domains}', $virtual_domains, $content); + + file_put_contents($this->mailman_config_dir."/mm_cfg.py", $content); + } + +} // end class + +?> -- GitLab From 639966111216b0563f12fa48ae6101d752b3b9c8 Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 28 Dec 2023 21:37:46 +0100 Subject: [PATCH 06/29] Continue adaptations --- install/lib/installer_base.lib.php | 2 +- server/conf/sympa_list_creation.xml.master | 25 ++++++++ server/plugins-available/sympa_plugin.inc.php | 57 ++++++++++++------- 3 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 server/conf/sympa_list_creation.xml.master diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 109ce25023..48ff15c7b0 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1057,7 +1057,7 @@ class installer_base extends stdClass { chgrp('/etc/sympa/sympa_transport.db', 'postfix'); } - $config_dir = $conf['sympa']['config_dir'].'/'; + $config_dir = $conf['sympa']['config_dir'].'/sympa/'; $full_file_name = $config_dir.'sympa.conf'; //* Backup exiting file if(is_file($full_file_name)) { diff --git a/server/conf/sympa_list_creation.xml.master b/server/conf/sympa_list_creation.xml.master new file mode 100644 index 0000000000..b1bf5d486c --- /dev/null +++ b/server/conf/sympa_list_creation.xml.master @@ -0,0 +1,25 @@ + + + {hostname} + my_profile + a list example + + open + editor + private + fr + + serge.aumont@renater.fr + C.R.U. + + + olivier.salaun@renater.fr + + + my_file + + + user@domain.org + + Computing + diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 070838d08e..fce4d3d84b 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -34,7 +34,8 @@ class sympa_plugin { var $class_name = 'sympa_plugin'; - var $mailman_config_dir = '/etc/sympa/'; + var $sympa_config_dir = '/etc/sympa/'; + var $sympa_expldir_dir = '/var/lib/sympa/list_data'; //* This function is called during ispconfig installation to determine // if a symlink shall be created for this plugin. @@ -64,8 +65,6 @@ class sympa_plugin { $app->plugins->registerEvent('mail_mailinglist_update', 'sympa_plugin', 'update'); $app->plugins->registerEvent('mail_mailinglist_delete', 'sympa_plugin', 'delete'); - - } function insert($event_name, $data) { @@ -73,7 +72,8 @@ class sympa_plugin { $this->update_config(); - $pid = $app->system->exec_safe("nohup /usr/lib/mailman/bin/newlist -u ? -e ? ? ? ? >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $data["new"]["domain"], $data["new"]["listname"], $data["new"]["email"], $data["new"]["password"]); + // TODO: Generate a config File + $pid = $app->system->exec_safe("nohup /usr/bin/sympa --robot ? --input_file >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $data["new"]["domain"], $data["new"]["listname"], $data["new"]["email"], $data["new"]["password"]); // wait for /usr/lib/mailman/bin/newlist-call $running = true; do { @@ -82,16 +82,16 @@ class sympa_plugin { unset($out); } while ($running); unset($out); - if(is_file('/etc/mailman/virtual-mailman') && !is_link('/var/lib/mailman/data/virtual-mailman')) { - symlink('/etc/mailman/virtual-mailman','/var/lib/mailman/data/virtual-mailman'); - } - if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); - if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); + /* if(is_file('/etc/mailman/virtual-mailman') && !is_link('/etc/sympa/virtual.sympa')) { + symlink('/etc/mailman/virtual-mailman','/etc/sympa/virtual.sympa'); + } */ + if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); - exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); // Fix list URL - $app->system->exec_safe('/usr/sbin/withlist -l -r fix_url ?', $data["new"]["listname"]); + //$app->system->exec_safe('/usr/sbin/withlist -l -r fix_url ?', $data["new"]["listname"]); $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); @@ -104,13 +104,14 @@ class sympa_plugin { $this->update_config(); if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { + // TODO: Change password reset tool $app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]); - exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); } - if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); - if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); + if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); } function delete($event_name, $data) { @@ -118,31 +119,32 @@ class sympa_plugin { $this->update_config(); - $app->system->exec_safe("nohup /usr/lib/mailman/bin/rmlist -a ? >/dev/null 2>&1 &", $data["old"]["listname"]); + $app->system->exec_safe("nohup /usr/bin/sympa --close_list=? >/dev/null 2>&1 &", $data["old"]["listname"]); - exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); - if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); - if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); + if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); } function update_config() { global $app, $conf; - copy($this->mailman_config_dir.'mm_cfg.py', $this->mailman_config_dir.'mm_cfg.py~'); + copy($this->sympa_config_dir.'/sympa/sympa.conf', $this->sympa_config_dir.'/sympa/sympa.conf~'); // load the server configuration options $app->uses('getconf'); $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); // load files + // TODO: Change file if(file_exists($conf["rootpath"]."/conf-custom/mm_cfg.py.master")) { $content = file_get_contents($conf["rootpath"]."/conf-custom/mm_cfg.py.master"); } else { $content = file_get_contents($conf["rootpath"]."/conf/mm_cfg.py.master"); } - $old_file = file_get_contents($this->mailman_config_dir."/mm_cfg.py"); + $old_file = file_get_contents($this->sympa_config_dir."/mm_cfg.py"); $old_options = array(); $lines = explode("\n", $old_file); @@ -168,13 +170,24 @@ class sympa_plugin { $virtual_domains .= "'".$domain['domain']."'"; else $virtual_domains .= ", '".$domain['domain']."'"; + + // create the domain https://github.com/sympa-community/sympa-community.github.io/blob/master/manual/install/configure-mail-server-postfix.md#adding-new-domain + if(!is_dir($this->sympa_config_dir/$domain['domain'])) mkdir($this->sympa_config_dir/$domain['domain'], 0755); + chown($this->sympa_config_dir/$domain['domain'], 'sympa'); + chgrp($this->sympa_config_dir/$domain['domain'], 'sympa'); + if(!is_file($this->sympa_config_dir/$domain['domain'].'/robot.conf')) touch($this->sympa_config_dir/$domain['domain'].'/robot.conf'); + chown($this->sympa_config_dir/$domain['domain'].'/robot.conf', 'sympa'); + chgrp($this->sympa_config_dir/$domain['domain'].'/robot.conf', 'sympa'); + if(!is_dir($this->sympa_expldir_dir/$domain['domain'])) mkdir($this->sympa_expldir_dir/$domain['domain'], 0750); + chown($this->sympa_expldir_dir/$domain['domain'], 'sympa'); + chgrp($this->sympa_expldir_dir/$domain['domain'], 'sympa'); } $content = str_replace('{hostname}', $server_config['hostname'], $content); $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); - $content = str_replace('{virtual_domains}', $virtual_domains, $content); + #$content = str_replace('{virtual_domains}', $virtual_domains, $content); - file_put_contents($this->mailman_config_dir."/mm_cfg.py", $content); + file_put_contents($this->sympa_config_dir.'/sympa/sympa.conf', $content); } } // end class -- GitLab From 477f07ac4f7dad4adf8bad765b1941db6204a06b Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 29 Dec 2023 19:50:25 +0100 Subject: [PATCH 07/29] Reworked sympa_plugin --- server/conf/sympa_list_creation.xml.master | 22 ++----- server/plugins-available/sympa_plugin.inc.php | 58 ++++++++++++------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/server/conf/sympa_list_creation.xml.master b/server/conf/sympa_list_creation.xml.master index b1bf5d486c..80f8a5cfa6 100644 --- a/server/conf/sympa_list_creation.xml.master +++ b/server/conf/sympa_list_creation.xml.master @@ -1,25 +1,15 @@ - {hostname} - my_profile - a list example + {listname}@{domain} + private_working_group + {listname} open editor private - fr + en - serge.aumont@renater.fr - C.R.U. + {email} - - olivier.salaun@renater.fr - - - my_file - - - user@domain.org - - Computing + Other diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index fce4d3d84b..4d028dd3eb 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -70,10 +70,25 @@ class sympa_plugin { function insert($event_name, $data) { global $app, $conf; - $this->update_config(); + // Still needed? + //$this->update_config(); + + // Generate a config File + if(file_exists($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master")) { + $content = file_get_contents($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master"); + } else { + $content = file_get_contents($conf["rootpath"]."/conf/sympa_list_creation.xml.master"); + } + + $content = str_replace('{listname}', $data["new"]["listname"], $content); + $content = str_replace('{domain}', $data["new"]["domain"], $content); + $content = str_replace('{email}', $data["new"]["email"], $content); + + $filename = 'sympa_list_creation'.$data["new"]['mailinglist_id'].'.xml'; - // TODO: Generate a config File - $pid = $app->system->exec_safe("nohup /usr/bin/sympa --robot ? --input_file >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $data["new"]["domain"], $data["new"]["listname"], $data["new"]["email"], $data["new"]["password"]); + file_put_contents($filename, $content); + + $pid = $app->system->exec_safe("nohup /usr/bin/sympa --create_list --robot ? --input_file ? >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $filename); // wait for /usr/lib/mailman/bin/newlist-call $running = true; do { @@ -85,8 +100,8 @@ class sympa_plugin { /* if(is_file('/etc/mailman/virtual-mailman') && !is_link('/etc/sympa/virtual.sympa')) { symlink('/etc/mailman/virtual-mailman','/etc/sympa/virtual.sympa'); } */ - if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); + // Still needed? if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + // Still needed? if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); @@ -103,7 +118,8 @@ class sympa_plugin { $this->update_config(); - if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { + // Still needed? + /* if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { // TODO: Change password reset tool $app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]); exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); @@ -111,7 +127,7 @@ class sympa_plugin { } if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); + if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); */ } function delete($event_name, $data) { @@ -119,18 +135,18 @@ class sympa_plugin { $this->update_config(); - $app->system->exec_safe("nohup /usr/bin/sympa --close_list=? >/dev/null 2>&1 &", $data["old"]["listname"]); + $app->system->exec_safe("nohup /usr/bin/sympa --close_list=? >/dev/null 2>&1 &", $data["old"]["listname"].'@'.$data["old"]["domain"]); exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); - if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); + // Still needed? if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + // Still needed? if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); } function update_config() { global $app, $conf; - +/* copy($this->sympa_config_dir.'/sympa/sympa.conf', $this->sympa_config_dir.'/sympa/sympa.conf~'); // load the server configuration options @@ -139,14 +155,14 @@ class sympa_plugin { // load files // TODO: Change file - if(file_exists($conf["rootpath"]."/conf-custom/mm_cfg.py.master")) { - $content = file_get_contents($conf["rootpath"]."/conf-custom/mm_cfg.py.master"); + if(file_exists($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master")) { + $content = file_get_contents($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master"); } else { - $content = file_get_contents($conf["rootpath"]."/conf/mm_cfg.py.master"); + $content = file_get_contents($conf["rootpath"]."/conf/sympa_list_creation.xml.master"); } - $old_file = file_get_contents($this->sympa_config_dir."/mm_cfg.py"); + $old_file = file_get_contents($this->sympa_config_dir."/mm_cfg.py"); */ - $old_options = array(); + /* $old_options = array(); $lines = explode("\n", $old_file); foreach ($lines as $line) { @@ -181,13 +197,13 @@ class sympa_plugin { if(!is_dir($this->sympa_expldir_dir/$domain['domain'])) mkdir($this->sympa_expldir_dir/$domain['domain'], 0750); chown($this->sympa_expldir_dir/$domain['domain'], 'sympa'); chgrp($this->sympa_expldir_dir/$domain['domain'], 'sympa'); - } + } */ - $content = str_replace('{hostname}', $server_config['hostname'], $content); - $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); - #$content = str_replace('{virtual_domains}', $virtual_domains, $content); + // Still needed? $content = str_replace('{hostname}', $server_config['hostname'], $content); + // $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); + // $content = str_replace('{virtual_domains}', $virtual_domains, $content); - file_put_contents($this->sympa_config_dir.'/sympa/sympa.conf', $content); + //file_put_contents($this->sympa_config_dir.'/sympa/sympa.conf', $content); } } // end class -- GitLab From 3a0b9de7bd4f1d9966b47d9e22f04285bd552491 Mon Sep 17 00:00:00 2001 From: Jonas <22-jnsc@users.noreply.git.ispconfig.org> Date: Fri, 29 Dec 2023 21:28:23 +0000 Subject: [PATCH 08/29] Remove zip upload --- .gitlab-ci.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 41890c48d4..2ffd62604b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,11 +94,17 @@ build:package: - if [[ $RET > 1 ]] ; then exit $RET ; fi - echo "Listing tar contents for verification" - tar -tvf ISPConfig-${VER}.tar.gz - - echo "Uploading file to download server" - - curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ - - if [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(p[0-9]+)?$ ]] ; then echo "Stable release ${VER}" ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ISPConfig-3-stable.tar.gz ; echo -n "${VER}" > ispconfig3_version.txt ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ispconfig3_version.txt ftp://${DEPLOY_FTP_SERVER}/web/ ; else echo "Dev release ${VER}" ; fi - - rm ISPConfig-${VER}.tar.gz - - echo "Download url is https://download.ispconfig.org/ISPConfig-${VER}.tar.gz" + #- echo "Uploading file to download server" + #- curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ + #- if [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(p[0-9]+)?$ ]] ; then echo "Stable release ${VER}" ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ISPConfig-3-stable.tar.gz ; echo -n "${VER}" > ispconfig3_version.txt ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ispconfig3_version.txt ftp://${DEPLOY_FTP_SERVER}/web/ ; else echo "Dev release ${VER}" ; fi + #- rm ISPConfig-${VER}.tar.gz + #- echo "Download url is https://download.ispconfig.org/ISPConfig-${VER}.tar.gz" + + artifacts: + paths: + - ISPConfig-${VER}.tar.gz + expire_in: 1 week + needs: ["syntax:lint"] allow_failure: false -- GitLab From 2cd167811c6027a2991ef210e9dc03847f1b9b89 Mon Sep 17 00:00:00 2001 From: Jonas <22-jnsc@users.noreply.git.ispconfig.org> Date: Fri, 29 Dec 2023 21:48:13 +0000 Subject: [PATCH 09/29] Change ver to CI_COMMIT_REF_NAME --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ffd62604b..f31038461c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,7 +102,7 @@ build:package: artifacts: paths: - - ISPConfig-${VER}.tar.gz + - ISPConfig-${CI_COMMIT_REF_NAME}.tar.gz expire_in: 1 week -- GitLab From de6d6d32e6eacc3a68d38e76e9d006e2ffe291cc Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 30 Dec 2023 18:21:44 +0100 Subject: [PATCH 10/29] Fix installer errors --- install/lib/installer_base.lib.php | 8 ++++---- server/conf/sympa.conf.master | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 48ff15c7b0..b794c0f2cd 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1093,11 +1093,11 @@ class installer_base extends stdClass { chmod($config_dir.'/master.cf~2', 0400); } //* Configure master.cf and add a line for deliver - $content = rf($config_dir.'/master.cf'); + $content_master = rf($config_dir.'/master.cf'); $deliver_content = 'sympa unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/queue ${nexthop}'."\n"; $deliver_content .= 'sympabounce unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/bouncequeue ${nexthop}'."\n"; af($config_dir.'/master.cf', $deliver_content); - unset($content); + unset($content_master); unset($deliver_content); } @@ -1425,8 +1425,8 @@ class installer_base extends stdClass { exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); ## exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); - chmod('etc/sympa/sympa_transport', 0640); - chmod('etc/sympa/sympa_transport.db', 0640); + chmod('/etc/sympa/sympa_transport', 0640); + chmod('/etc/sympa/sympa_transport.db', 0640); chgrp('/etc/sympa/sympa_transport', 'postfix'); chgrp('/etc/sympa/sympa_transport.db', 'postfix'); diff --git a/server/conf/sympa.conf.master b/server/conf/sympa.conf.master index d19fa2f30d..f87f005d35 100644 --- a/server/conf/sympa.conf.master +++ b/server/conf/sympa.conf.master @@ -12,7 +12,7 @@ domain {hostname} ## Listmasters can be defined for each virtual host, however, the default ## listmasters will have privileges to manage all virtual hosts. ## Example: listmaster your_email_address@domain.tld -listmaster listmaster@hotel.phphost.ch +listmaster listmaster@{hostname} ###\\\\ Database related ////### -- GitLab From 1b1d124d72411d96c56bac48c3bfbe3b29d70c60 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 30 Dec 2023 20:01:19 +0100 Subject: [PATCH 11/29] Fix installer --- install/lib/installer_base.lib.php | 7 ++- install/tpl/sympa.conf.master | 97 ++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 install/tpl/sympa.conf.master diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index b794c0f2cd..a3b822f29b 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1050,7 +1050,7 @@ class installer_base extends stdClass { exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); - ## exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); + exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); chmod('etc/sympa/sympa_transport', 0640); chmod('etc/sympa/sympa_transport.db', 0640); chgrp('/etc/sympa/sympa_transport', 'postfix'); @@ -1065,9 +1065,10 @@ class installer_base extends stdClass { } // load files - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.conf.master', 'tpl/sympa.conf.master.master'); + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.conf.master', 'tpl/sympa.conf.master'); $old_file = rf($full_file_name); + // TODO: FIX parsing of old config $old_options = array(); $lines = explode("\n", $old_file); foreach ($lines as $line) @@ -1424,7 +1425,7 @@ class installer_base extends stdClass { exec('/usr/sbin/postmap hash:/etc/sympa/transport.sympa'); exec('/usr/sbin/postmap hash:/etc/sympa/virtual.sympa'); exec('/usr/lib/sympa/bin/sympa_newaliases.pl 2>/dev/null'); - ## exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); + exec('/usr/sbin/postmap hash:/etc/sympa/sympa_transport'); chmod('/etc/sympa/sympa_transport', 0640); chmod('/etc/sympa/sympa_transport.db', 0640); chgrp('/etc/sympa/sympa_transport', 'postfix'); diff --git a/install/tpl/sympa.conf.master b/install/tpl/sympa.conf.master new file mode 100644 index 0000000000..f87f005d35 --- /dev/null +++ b/install/tpl/sympa.conf.master @@ -0,0 +1,97 @@ +###\\\\ Service description ////### + +## domain +## Primary mail domain name +## Example: domain mail.example.org +domain {hostname} + +## listmaster +## Email addresses of listmasters +## Email addresses of the listmasters (users authorized to perform global +## server commands). Some error reports may also be sent to these addresses. +## Listmasters can be defined for each virtual host, however, the default +## listmasters will have privileges to manage all virtual hosts. +## Example: listmaster your_email_address@domain.tld +listmaster listmaster@{hostname} + +###\\\\ Database related ////### + +## db_type +## Type of the database +## Possible types are "MySQL", "PostgreSQL", "Oracle" and "SQLite". +db_type mysql + +## db_host +## Hostname of the database server +## With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. +## "/var/run/postgresql" for connection with Unix domain socket. +## Example: db_host localhost +db_host localhost + +## db_port +## Port of the database server +db_port 3306 + +## db_name +## Name of the database +## With SQLite, this must be the full path to database file. +## With Oracle Database, this must be SID, net service name or easy connection +## identifier (to use net service name, db_host should be set to "none" and +## HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file). +db_name sympa + +## db_user +## User for the database connection +## Example: db_user sympa +db_user sympa + +## db_passwd +## Password for the database connection +## What ever you use a password or not, you must protect the SQL server (is it +## not a public internet service ?) +## Example: db_passwd your_passwd +db_passwd ZzK3VT8AB2NU + +###\\\\ List definition ////### + +## lang +## Language of the list +## This parameter defines the language used for the list. It is used to +## initialize a user's language preference; Sympa command reports are +## extracted from the associated message catalog. +lang {default_language} + +###\\\\ Web interface parameters ////### + +## wwsympa_url +## URL prefix of web interface +## This is used to construct URLs of web interface. The protocol (either +## https:// or http://) is required. +## Example: wwsympa_url https://web.example.org/sympa +wwsympa_url http://{hostname}/wws + +## static_content_path +## Directory for static contents +static_content_path /usr/share/sympa/static_content + +## css_path +## Directory for static style sheets (CSS) +## After an upgrade, static CSS files are upgraded with the newly installed +## "css.tt2" template. Therefore, this is not a good place to store customized +## CSS files. +css_path /var/lib/sympa/css + +## css_url +## URL for style sheets (CSS) +## To use auto-generated static CSS, HTTP server have to map it with +## "css_path". +css_url /css-sympa + +## pictures_path +## Directory for subscribers pictures +pictures_path /var/lib/sympa/pictures + +## pictures_url +## URL for subscribers pictures +## HTTP server have to map it with "pictures_path" directory. +pictures_url /pictures-sympa -- GitLab From f590f1d63568709bbbe121f2013adffb04c72ca1 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 30 Dec 2023 20:33:15 +0100 Subject: [PATCH 12/29] Fix parsing of old config --- install/lib/installer_base.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index a3b822f29b..e642561716 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1068,14 +1068,13 @@ class installer_base extends stdClass { $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.conf.master', 'tpl/sympa.conf.master'); $old_file = rf($full_file_name); - // TODO: FIX parsing of old config $old_options = array(); $lines = explode("\n", $old_file); foreach ($lines as $line) { if (trim($line) != '' && substr($line, 0, 1) != '#') { - @list($key, $value) = @explode("=", $line); + @list($key, $value) = @preg_split('/\s+/', $line); if (isset($value) && $value !== '') { $key = rtrim($key); @@ -1122,9 +1121,11 @@ class installer_base extends stdClass { $virtual_domains = "' '"; $content = str_replace('{hostname}', $conf['hostname'], $content); - if(!isset($old_options['DEFAULT_SERVER_LANGUAGE']) || $old_options['DEFAULT_SERVER_LANGUAGE'] == '') $old_options['DEFAULT_SERVER_LANGUAGE'] = "'en_US'"; + if(!isset($old_options['DEFAULT_SERVER_LANGUAGE']) || $old_options['DEFAULT_SERVER_LANGUAGE'] == '') $old_options['DEFAULT_SERVER_LANGUAGE'] = 'en'; $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); - $content = str_replace('{virtual_domains}', $virtual_domains, $content); + + // TODO: Fix write in correct file + //$content = str_replace('{virtual_domains}', $virtual_domains, $content); wf($full_file_name, $content); -- GitLab From 13966a494610d5b8d96607437a126089c570221e Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 30 Dec 2023 22:38:21 +0100 Subject: [PATCH 13/29] Re add folder creation --- server/plugins-available/sympa_plugin.inc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 4d028dd3eb..202c153e29 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -70,8 +70,7 @@ class sympa_plugin { function insert($event_name, $data) { global $app, $conf; - // Still needed? - //$this->update_config(); + $this->update_config(); // Generate a config File if(file_exists($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master")) { @@ -84,7 +83,7 @@ class sympa_plugin { $content = str_replace('{domain}', $data["new"]["domain"], $content); $content = str_replace('{email}', $data["new"]["email"], $content); - $filename = 'sympa_list_creation'.$data["new"]['mailinglist_id'].'.xml'; + $filename = '/tmp/sympa_list_creation'.$data["new"]['mailinglist_id'].'.xml'; file_put_contents($filename, $content); @@ -146,8 +145,9 @@ class sympa_plugin { function update_config() { global $app, $conf; -/* - copy($this->sympa_config_dir.'/sympa/sympa.conf', $this->sympa_config_dir.'/sympa/sympa.conf~'); + + /* + //copy($this->sympa_config_dir.'/sympa/sympa.conf', $this->sympa_config_dir.'/sympa/sympa.conf~'); // load the server configuration options $app->uses('getconf'); @@ -160,7 +160,7 @@ class sympa_plugin { } else { $content = file_get_contents($conf["rootpath"]."/conf/sympa_list_creation.xml.master"); } - $old_file = file_get_contents($this->sympa_config_dir."/mm_cfg.py"); */ + $old_file = file_get_contents($this->sympa_config_dir."/mm_cfg.py"); /* $old_options = array(); $lines = explode("\n", $old_file); @@ -175,7 +175,7 @@ class sympa_plugin { $old_options[$key] = trim($value); } } - } + }*/ // create virtual_domains list $domainAll = $app->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); @@ -197,7 +197,7 @@ class sympa_plugin { if(!is_dir($this->sympa_expldir_dir/$domain['domain'])) mkdir($this->sympa_expldir_dir/$domain['domain'], 0750); chown($this->sympa_expldir_dir/$domain['domain'], 'sympa'); chgrp($this->sympa_expldir_dir/$domain['domain'], 'sympa'); - } */ + } // Still needed? $content = str_replace('{hostname}', $server_config['hostname'], $content); // $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); -- GitLab From 7ec08b5fac28ee465e5db2d6f80c1689866eb6ca Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 30 Dec 2023 22:52:49 +0100 Subject: [PATCH 14/29] Remove domain from list name --- server/conf/sympa_list_creation.xml.master | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/conf/sympa_list_creation.xml.master b/server/conf/sympa_list_creation.xml.master index 80f8a5cfa6..16e1ad30ea 100644 --- a/server/conf/sympa_list_creation.xml.master +++ b/server/conf/sympa_list_creation.xml.master @@ -1,6 +1,6 @@ - {listname}@{domain} + {listname} private_working_group {listname} -- GitLab From e2b35bfeb7f5df51769bdda5ec7703e382339e55 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 31 Dec 2023 00:02:06 +0100 Subject: [PATCH 15/29] Fix php errors --- server/plugins-available/sympa_plugin.inc.php | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 202c153e29..3f89e4fc0d 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -188,17 +188,37 @@ class sympa_plugin { $virtual_domains .= ", '".$domain['domain']."'"; // create the domain https://github.com/sympa-community/sympa-community.github.io/blob/master/manual/install/configure-mail-server-postfix.md#adding-new-domain - if(!is_dir($this->sympa_config_dir/$domain['domain'])) mkdir($this->sympa_config_dir/$domain['domain'], 0755); - chown($this->sympa_config_dir/$domain['domain'], 'sympa'); - chgrp($this->sympa_config_dir/$domain['domain'], 'sympa'); - if(!is_file($this->sympa_config_dir/$domain['domain'].'/robot.conf')) touch($this->sympa_config_dir/$domain['domain'].'/robot.conf'); - chown($this->sympa_config_dir/$domain['domain'].'/robot.conf', 'sympa'); - chgrp($this->sympa_config_dir/$domain['domain'].'/robot.conf', 'sympa'); - if(!is_dir($this->sympa_expldir_dir/$domain['domain'])) mkdir($this->sympa_expldir_dir/$domain['domain'], 0750); - chown($this->sympa_expldir_dir/$domain['domain'], 'sympa'); - chgrp($this->sympa_expldir_dir/$domain['domain'], 'sympa'); + if(!is_dir($this->sympa_config_dir.'/'.$domain['domain'])) mkdir($this->sympa_config_dir.'/'.$domain['domain'], 0755); + chown($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); + chgrp($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); + if(!is_file($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf')) touch($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf'); + chown($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); + chgrp($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); + + /* TODO : add config to robot.conf + listmaster adresse-email-admin@retzo.net + create_list listmaster + wwsympa_url http://lists.$line/sympa" > $SYSCONFDIR.'/'.$line/robot.conf + */ + /* TODO : add config to transport.sympa + echo "sympa@$line sympa:sympa@$line + listmaster@$line sympa:listmaster@$line + bounce@$line sympabounce:sympa@$line + abuse-feedback-report@$line sympabounce:sympa@$line" >> $SYSCONFDIR/transport.sympa + */ + + /* TODO : add config to virtual.sympa + echo "sympa-request@$line postmaster@retzo.net + sympa-owner@$line postmaster@retzo.net" >> $SYSCONFDIR/virtual.sympa + */ + + if(!is_dir($this->sympa_expldir_dir.'/'.$domain['domain'])) mkdir($this->sympa_expldir_dir.'/'.$domain['domain'], 0750); + chown($this->sympa_expldir_dir.'/'.$domain['domain'], 'sympa'); + chgrp($this->sympa_expldir_dir.'/'.$domain['domain'], 'sympa'); } + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); + // Still needed? $content = str_replace('{hostname}', $server_config['hostname'], $content); // $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); // $content = str_replace('{virtual_domains}', $virtual_domains, $content); -- GitLab From ec4be1ac8b4dad2d406d49f570101b221761e543 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 31 Dec 2023 17:43:02 +0100 Subject: [PATCH 16/29] Add more variables --- install/lib/installer_base.lib.php | 75 +++++++++++++++--------------- server/conf/sympa.conf.master | 16 +++---- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index e642561716..9a1d11e35d 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1057,6 +1057,25 @@ class installer_base extends stdClass { chgrp('/etc/sympa/sympa_transport.db', 'postfix'); } + $config_dir = $conf['postfix']['config_dir']; + //* Configure master.cf and add a line for deliver + if(!$this->get_postfix_service('sympa', 'unix')) { + //* backup + if(is_file($config_dir.'/master.cf')){ + copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); + } + if(is_file($config_dir.'/master.cf~2')){ + chmod($config_dir.'/master.cf~2', 0400); + } + //* Configure master.cf and add a line for deliver + $content_master = rf($config_dir.'/master.cf'); + $deliver_content = 'sympa unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/queue ${nexthop}'."\n"; + $deliver_content .= 'sympabounce unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/bouncequeue ${nexthop}'."\n"; + af($config_dir.'/master.cf', $deliver_content); + unset($content_master); + unset($deliver_content); + } + $config_dir = $conf['sympa']['config_dir'].'/sympa/'; $full_file_name = $config_dir.'sympa.conf'; //* Backup exiting file @@ -1083,46 +1102,28 @@ class installer_base extends stdClass { } } - //* Configure master.cf and add a line for deliver - if(!$this->get_postfix_service('sympa', 'unix')) { - //* backup - if(is_file($config_dir.'/master.cf')){ - copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); - } - if(is_file($config_dir.'/master.cf~2')){ - chmod($config_dir.'/master.cf~2', 0400); - } - //* Configure master.cf and add a line for deliver - $content_master = rf($config_dir.'/master.cf'); - $deliver_content = 'sympa unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/queue ${nexthop}'."\n"; - $deliver_content .= 'sympabounce unix - n n - - pipe'."\n".' flags=hqRu null_sender= user=sympa argv=/usr/lib/sympa/bin/bouncequeue ${nexthop}'."\n"; - af($config_dir.'/master.cf', $deliver_content); - unset($content_master); - unset($deliver_content); - } + $content = str_replace('{hostname}', $conf['hostname'], $content); + + if(!isset($old_options['lang']) || $old_options['lang'] == '') $old_options['lang'] = 'en'; + $content = str_replace('{lang}', $old_options['lang'], $content); + + if(!isset($old_options['listmaster']) || $old_options['listmaster'] == '') $old_options['listmaster'] = 'listmaster@'.$conf['hostname']; + $content = str_replace('{listmaster}', $old_options['listmaster'], $content); - $virtual_domains = ''; - if($status == 'update') - { - // create virtual_domains list - $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); + if(!isset($old_options['db_type']) || $old_options['db_type'] == '') $old_options['db_type'] = 'mysql'; + $content = str_replace('{db_type}', $old_options['db_type'], $content); - if(is_array($domainAll)) { - foreach($domainAll as $domain) - { - if ($domainAll[0]['domain'] == $domain['domain']) - $virtual_domains .= "'".$domain['domain']."'"; - else - $virtual_domains .= ", '".$domain['domain']."'"; - } - } - } - else - $virtual_domains = "' '"; + if(!isset($old_options['db_port']) || $old_options['db_port'] == '') $old_options['db_port'] = '3306'; + $content = str_replace('{db_port}', $old_options['db_port'], $content); - $content = str_replace('{hostname}', $conf['hostname'], $content); - if(!isset($old_options['DEFAULT_SERVER_LANGUAGE']) || $old_options['DEFAULT_SERVER_LANGUAGE'] == '') $old_options['DEFAULT_SERVER_LANGUAGE'] = 'en'; - $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); + if(!isset($old_options['db_name']) || $old_options['db_name'] == '') $old_options['db_name'] = 'sympa'; + $content = str_replace('{db_name}', $old_options['db_name'], $content); + + if(!isset($old_options['db_user']) || $old_options['db_user'] == '') $old_options['db_user'] = 'sympa'; + $content = str_replace('{db_user}', $old_options['db_user'], $content); + + if(!isset($old_options['db_passwd']) || $old_options['db_passwd'] == '') $old_options['db_passwd'] = 'your_passwd'; + $content = str_replace('{db_passwd}', $old_options['db_passwd'], $content); // TODO: Fix write in correct file //$content = str_replace('{virtual_domains}', $virtual_domains, $content); diff --git a/server/conf/sympa.conf.master b/server/conf/sympa.conf.master index f87f005d35..ac26f873d9 100644 --- a/server/conf/sympa.conf.master +++ b/server/conf/sympa.conf.master @@ -12,25 +12,25 @@ domain {hostname} ## Listmasters can be defined for each virtual host, however, the default ## listmasters will have privileges to manage all virtual hosts. ## Example: listmaster your_email_address@domain.tld -listmaster listmaster@{hostname} +listmaster {listmaster} ###\\\\ Database related ////### ## db_type ## Type of the database ## Possible types are "MySQL", "PostgreSQL", "Oracle" and "SQLite". -db_type mysql +db_type {db_type} ## db_host ## Hostname of the database server ## With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. ## "/var/run/postgresql" for connection with Unix domain socket. ## Example: db_host localhost -db_host localhost +db_host {db_host} ## db_port ## Port of the database server -db_port 3306 +db_port {db_port} ## db_name ## Name of the database @@ -38,19 +38,19 @@ db_port 3306 ## With Oracle Database, this must be SID, net service name or easy connection ## identifier (to use net service name, db_host should be set to "none" and ## HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file). -db_name sympa +db_name {db_name} ## db_user ## User for the database connection ## Example: db_user sympa -db_user sympa +db_user {db_user} ## db_passwd ## Password for the database connection ## What ever you use a password or not, you must protect the SQL server (is it ## not a public internet service ?) ## Example: db_passwd your_passwd -db_passwd ZzK3VT8AB2NU +db_passwd {db_passwd} ###\\\\ List definition ////### @@ -59,7 +59,7 @@ db_passwd ZzK3VT8AB2NU ## This parameter defines the language used for the list. It is used to ## initialize a user's language preference; Sympa command reports are ## extracted from the associated message catalog. -lang {default_language} +lang {lang} ###\\\\ Web interface parameters ////### -- GitLab From c7fbd7ce15eee411ca5ad54105258a8f2f61399b Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 31 Dec 2023 18:21:49 +0100 Subject: [PATCH 17/29] Set list creation to closed --- install/lib/installer_base.lib.php | 9 --------- server/conf/sympa.conf.master | 6 +++++- server/plugins-available/sympa_plugin.inc.php | 12 +++++------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 9a1d11e35d..9b31d1bb95 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1106,27 +1106,18 @@ class installer_base extends stdClass { if(!isset($old_options['lang']) || $old_options['lang'] == '') $old_options['lang'] = 'en'; $content = str_replace('{lang}', $old_options['lang'], $content); - if(!isset($old_options['listmaster']) || $old_options['listmaster'] == '') $old_options['listmaster'] = 'listmaster@'.$conf['hostname']; $content = str_replace('{listmaster}', $old_options['listmaster'], $content); - if(!isset($old_options['db_type']) || $old_options['db_type'] == '') $old_options['db_type'] = 'mysql'; $content = str_replace('{db_type}', $old_options['db_type'], $content); - if(!isset($old_options['db_port']) || $old_options['db_port'] == '') $old_options['db_port'] = '3306'; $content = str_replace('{db_port}', $old_options['db_port'], $content); - if(!isset($old_options['db_name']) || $old_options['db_name'] == '') $old_options['db_name'] = 'sympa'; $content = str_replace('{db_name}', $old_options['db_name'], $content); - if(!isset($old_options['db_user']) || $old_options['db_user'] == '') $old_options['db_user'] = 'sympa'; $content = str_replace('{db_user}', $old_options['db_user'], $content); - if(!isset($old_options['db_passwd']) || $old_options['db_passwd'] == '') $old_options['db_passwd'] = 'your_passwd'; $content = str_replace('{db_passwd}', $old_options['db_passwd'], $content); - - // TODO: Fix write in correct file - //$content = str_replace('{virtual_domains}', $virtual_domains, $content); wf($full_file_name, $content); diff --git a/server/conf/sympa.conf.master b/server/conf/sympa.conf.master index ac26f873d9..c19e08843b 100644 --- a/server/conf/sympa.conf.master +++ b/server/conf/sympa.conf.master @@ -68,7 +68,7 @@ lang {lang} ## This is used to construct URLs of web interface. The protocol (either ## https:// or http://) is required. ## Example: wwsympa_url https://web.example.org/sympa -wwsympa_url http://{hostname}/wws +wwsympa_url https://{hostname}/wws ## static_content_path ## Directory for static contents @@ -95,3 +95,7 @@ pictures_path /var/lib/sympa/pictures ## URL for subscribers pictures ## HTTP server have to map it with "pictures_path" directory. pictures_url /pictures-sympa + +## create_list +## Who is able to create lists +create_list closed \ No newline at end of file diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 3f89e4fc0d..35d3f866bd 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -117,16 +117,14 @@ class sympa_plugin { $this->update_config(); - // Still needed? - /* if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { - // TODO: Change password reset tool - $app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]); - exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); + if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { + //$app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]); + //exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); } - if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); */ + // if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + // if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); } function delete($event_name, $data) { -- GitLab From 8fdc0c536c35f27354b641f633b778fda91a04a4 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 31 Dec 2023 20:39:28 +0100 Subject: [PATCH 18/29] generate transport and virtual --- server/plugins-available/sympa_plugin.inc.php | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 35d3f866bd..2df3e83c1c 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -88,7 +88,6 @@ class sympa_plugin { file_put_contents($filename, $content); $pid = $app->system->exec_safe("nohup /usr/bin/sympa --create_list --robot ? --input_file ? >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $filename); - // wait for /usr/lib/mailman/bin/newlist-call $running = true; do { exec('ps -p '.intval($pid), $out); @@ -197,31 +196,53 @@ class sympa_plugin { listmaster adresse-email-admin@retzo.net create_list listmaster wwsympa_url http://lists.$line/sympa" > $SYSCONFDIR.'/'.$line/robot.conf - */ - /* TODO : add config to transport.sympa - echo "sympa@$line sympa:sympa@$line - listmaster@$line sympa:listmaster@$line - bounce@$line sympabounce:sympa@$line - abuse-feedback-report@$line sympabounce:sympa@$line" >> $SYSCONFDIR/transport.sympa - */ - /* TODO : add config to virtual.sympa - echo "sympa-request@$line postmaster@retzo.net - sympa-owner@$line postmaster@retzo.net" >> $SYSCONFDIR/virtual.sympa + if(is_dir($this->sympa_config_dir.'/'.$domain['domain'])) { + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, $this->mailman_group); + chmod($full_file_name, 0755); + } */ + //* Configure transport.sympa and add aliases + $content_transport = rf($this->sympa_config_dir.'/transport.sympa'); + if(strpos($content_transport, 'listmaster@'.$domain['domain']) === false){ + af($this->sympa_config_dir.'/transport.sympa', "listmaster@".$domain['domain']." sympa:listmaster@".$domain['domain']."\n"); + } + if(strpos($content_transport, 'sympa@'.$domain['domain']) === false){ + af($this->sympa_config_dir.'/transport.sympa', "sympa@".$domain['domain']." sympa:sympa@".$domain['domain']."\n"); + } + if(strpos($content_transport, 'bounce@'.$domain['domain']) === false){ + af($this->sympa_config_dir.'/transport.sympa', "bounce@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); + } + if(strpos($content_transport, 'abuse-feedback-report@'.$domain['domain']) === false){ + af($this->sympa_config_dir.'/transport.sympa', "abuse-feedback-report@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); + } + unset($content_transport); + + //* Configure virtual.sympa and add aliases + $content_virtual = rf($this->sympa_config_dir.'/virtual.sympa '); + if(strpos($content_virtual , 'sympa-request@'.$domain['domain']) === false){ + af($this->sympa_config_dir.'/virtual.sympa', "sympa-request@".$domain['domain']." postmaster@".$domain['domain']."\n"); + } + if(strpos($content_virtual , 'sympa-owner@'.$domain['domain']) === false){ + af($this->sympa_config_dir.'/virtual.sympa', "sympa-owner@".$domain['domain']." postmaster@".$domain['domain']."\n"); + } + unset($content_virtual); + if(!is_dir($this->sympa_expldir_dir.'/'.$domain['domain'])) mkdir($this->sympa_expldir_dir.'/'.$domain['domain'], 0750); chown($this->sympa_expldir_dir.'/'.$domain['domain'], 'sympa'); chgrp($this->sympa_expldir_dir.'/'.$domain['domain'], 'sympa'); } - exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); - - // Still needed? $content = str_replace('{hostname}', $server_config['hostname'], $content); - // $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); - // $content = str_replace('{virtual_domains}', $virtual_domains, $content); + if(is_file($this->sympa_config_dir.'/virtual.sympa')) exec('postmap '.$this->sympa_config_dir.'/virtual.sympa'); + if(is_file($this->sympa_config_dir.'/transport.sympa')) exec('postmap '.$this->sympa_config_dir.'/transport.sympa'); - //file_put_contents($this->sympa_config_dir.'/sympa/sympa.conf', $content); + exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); } } // end class -- GitLab From 1620e717064c3300a596c1694e20724c44f71d83 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 31 Dec 2023 21:06:39 +0100 Subject: [PATCH 19/29] Add needed functions --- server/plugins-available/sympa_plugin.inc.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 2df3e83c1c..de48a973a6 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -245,6 +245,67 @@ class sympa_plugin { exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); } + + function rf($file){ + global $app; + clearstatcache(); + if(!$fp = fopen($file, 'rb')){ + $app->log('WARNING: Could not open file '.$file, 2); + return false; + } else { + if(filesize($file) > 0){ + $content = fread($fp, filesize($file)); + } else { + $content = ''; + } + fclose($fp); + return $content; + } + } + + function mkdirs($strPath, $mode = '0755'){ + if(isset($strPath) && $strPath != ''){ + //* Verzeichnisse rekursiv erzeugen + if(is_dir($strPath)){ + return true; + } + $pStrPath = dirname($strPath); + if(!mkdirs($pStrPath, $mode)){ + return false; + } + $old_umask = umask(0); + $ret_val = mkdir($strPath, octdec($mode)); + umask($old_umask); + return $ret_val; + } + return false; + } + function wf($file, $content){ + global $app; + $this->mkdirs(dirname($file)); + if(!$fp = fopen($file, 'wb')){ + $app->log('WARNING: Could not open file '.$file, 2); + return false; + } else { + fwrite($fp, $content); + fclose($fp); + return true; + } + } + + function af($file, $content){ + global $app; + $this->mkdirs(dirname($file)); + if(!$fp = fopen($file, 'ab')){ + $app->log('WARNING: Could not open file '.$file, 2); + return false; + } else { + fwrite($fp, $content); + fclose($fp); + return true; + } + } + } // end class ?> -- GitLab From 46c0091a6158818ccb3ffa94161434c384478978 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 1 Jan 2024 17:02:15 +0100 Subject: [PATCH 20/29] Add alias file --- install/tpl/list_aliases.tt2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/install/tpl/list_aliases.tt2 b/install/tpl/list_aliases.tt2 index e69de29bb2..22357d9e62 100644 --- a/install/tpl/list_aliases.tt2 +++ b/install/tpl/list_aliases.tt2 @@ -0,0 +1,19 @@ +#------------------------------ [% list.name %]@[% list.domain %]: list alias created [% date %] +[% IF is_virtual_domain -%] +/^([% list.name %])-(request|editor|owner|subscribe|unsubscribe)\@[% list.domainescaped %]$/ $1+[% list.domain %]@sympa$2. +/^([% list.name %])\@[% list.domainescaped %]$/ $1+[% list.domain %]@sympalist. +[% ELSIF is_default_domain -%] +[% list.name %]: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]@[% list.domain %]" +[% list.name %]-request: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-request@[% list.domain %]" +[% list.name %]-editor: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-editor@[% list.domain %]" +#[% list.name %]-subscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-subscribe@[% list.domain %]" +[% list.name %]-unsubscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-unsubscribe@[% list.domain %]" +[% list.name %][% return_path_suffix %]: "| /usr/lib/sympa/lib/sympa/bouncequeue [% list.name %]@[% list.domain %]" +[% ELSE -%] +[% list.domain %]-[% list.name %]: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]@[% list.domain %]" +[% list.domain %]-[% list.name %]-request: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-request@[% list.domain %]" +[% list.domain %]-[% list.name %]-editor: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-editor@[% list.domain %]" +#[% list.domain %]-[% list.name %]-subscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-subscribe@[% list.domain %]" +[% list.domain %]-[% list.name %]-unsubscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-unsubscribe@[% list.domain %]" +[% list.domain %]-[% list.name %][% return_path_suffix %]: "| /usr/lib/sympa/lib/sympa/bouncequeue [% list.name %]@[% list.domain %]" +[% END -%] \ No newline at end of file -- GitLab From 343fe1133f84397725d9204318719bae93cf6148 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 1 Jan 2024 17:17:43 +0100 Subject: [PATCH 21/29] Fix af/rf/wf functions --- server/plugins-available/sympa_plugin.inc.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index de48a973a6..79ab301380 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -209,28 +209,28 @@ class sympa_plugin { */ //* Configure transport.sympa and add aliases - $content_transport = rf($this->sympa_config_dir.'/transport.sympa'); + $content_transport = $this->rf($this->sympa_config_dir.'/transport.sympa'); if(strpos($content_transport, 'listmaster@'.$domain['domain']) === false){ - af($this->sympa_config_dir.'/transport.sympa', "listmaster@".$domain['domain']." sympa:listmaster@".$domain['domain']."\n"); + $this->af($this->sympa_config_dir.'/transport.sympa', "listmaster@".$domain['domain']." sympa:listmaster@".$domain['domain']."\n"); } if(strpos($content_transport, 'sympa@'.$domain['domain']) === false){ - af($this->sympa_config_dir.'/transport.sympa', "sympa@".$domain['domain']." sympa:sympa@".$domain['domain']."\n"); + $this->af($this->sympa_config_dir.'/transport.sympa', "sympa@".$domain['domain']." sympa:sympa@".$domain['domain']."\n"); } if(strpos($content_transport, 'bounce@'.$domain['domain']) === false){ - af($this->sympa_config_dir.'/transport.sympa', "bounce@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); + $this->af($this->sympa_config_dir.'/transport.sympa', "bounce@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); } if(strpos($content_transport, 'abuse-feedback-report@'.$domain['domain']) === false){ - af($this->sympa_config_dir.'/transport.sympa', "abuse-feedback-report@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); + $this->af($this->sympa_config_dir.'/transport.sympa', "abuse-feedback-report@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); } unset($content_transport); //* Configure virtual.sympa and add aliases - $content_virtual = rf($this->sympa_config_dir.'/virtual.sympa '); + $content_virtual = $this->rf($this->sympa_config_dir.'/virtual.sympa '); if(strpos($content_virtual , 'sympa-request@'.$domain['domain']) === false){ - af($this->sympa_config_dir.'/virtual.sympa', "sympa-request@".$domain['domain']." postmaster@".$domain['domain']."\n"); + $this->af($this->sympa_config_dir.'/virtual.sympa', "sympa-request@".$domain['domain']." postmaster@".$domain['domain']."\n"); } if(strpos($content_virtual , 'sympa-owner@'.$domain['domain']) === false){ - af($this->sympa_config_dir.'/virtual.sympa', "sympa-owner@".$domain['domain']." postmaster@".$domain['domain']."\n"); + $this->af($this->sympa_config_dir.'/virtual.sympa', "sympa-owner@".$domain['domain']." postmaster@".$domain['domain']."\n"); } unset($content_virtual); @@ -245,7 +245,8 @@ class sympa_plugin { exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); } - + // TODO: + // If someone has a better idea than redefining this functions function rf($file){ global $app; clearstatcache(); -- GitLab From 3102347312cb837756d2fcb463ae6771557bc09b Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 1 Jan 2024 18:35:43 +0100 Subject: [PATCH 22/29] Configure for Postfix --- server/conf/sympa.conf.master | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/conf/sympa.conf.master b/server/conf/sympa.conf.master index c19e08843b..fc58dd10e9 100644 --- a/server/conf/sympa.conf.master +++ b/server/conf/sympa.conf.master @@ -98,4 +98,16 @@ pictures_url /pictures-sympa ## create_list ## Who is able to create lists -create_list closed \ No newline at end of file +create_list closed + +## sendmail_aliases +## Path of the file that contains all list related aliases +sendmail_aliases /etc/sympa/sympa_transport + +## aliases_program +## Program used to update alias database +aliases_program postmap + +## aliases_db_type +## Type of alias database +aliases_db_type hash \ No newline at end of file -- GitLab From a6365e47102ae4a90c62b5c4823eafaa99d3881a Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 1 Jan 2024 19:15:05 +0100 Subject: [PATCH 23/29] Add config to tpl --- install/tpl/sympa.conf.master | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/install/tpl/sympa.conf.master b/install/tpl/sympa.conf.master index f87f005d35..aa0c094830 100644 --- a/install/tpl/sympa.conf.master +++ b/install/tpl/sympa.conf.master @@ -95,3 +95,19 @@ pictures_path /var/lib/sympa/pictures ## URL for subscribers pictures ## HTTP server have to map it with "pictures_path" directory. pictures_url /pictures-sympa + +## create_list +## Who is able to create lists +create_list closed + +## sendmail_aliases +## Path of the file that contains all list related aliases +sendmail_aliases /etc/sympa/sympa_transport + +## aliases_program +## Program used to update alias database +aliases_program postmap + +## aliases_db_type +## Type of alias database +aliases_db_type hash \ No newline at end of file -- GitLab From ccffe40d3c91d9c03c0e76c0f6a5c695cdf340c8 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 1 Jan 2024 20:01:33 +0100 Subject: [PATCH 24/29] Fix sympa virtual --- server/plugins-available/sympa_plugin.inc.php | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 79ab301380..5495cb75e8 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -34,7 +34,7 @@ class sympa_plugin { var $class_name = 'sympa_plugin'; - var $sympa_config_dir = '/etc/sympa/'; + var $sympa_config_dir = '/etc/sympa'; var $sympa_expldir_dir = '/var/lib/sympa/list_data'; //* This function is called during ispconfig installation to determine @@ -188,34 +188,30 @@ class sympa_plugin { if(!is_dir($this->sympa_config_dir.'/'.$domain['domain'])) mkdir($this->sympa_config_dir.'/'.$domain['domain'], 0755); chown($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); chgrp($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); - if(!is_file($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf')) touch($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf'); - chown($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); - chgrp($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); - /* TODO : add config to robot.conf - listmaster adresse-email-admin@retzo.net - create_list listmaster - wwsympa_url http://lists.$line/sympa" > $SYSCONFDIR.'/'.$line/robot.conf - + /* if(is_dir($this->sympa_config_dir.'/'.$domain['domain'])) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.robot.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.robot.conf.master', $full_file_name); } else { - copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + copy('tpl/mailman-virtual_to_transport.sh', $this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf'); } chgrp($full_file_name, $this->mailman_group); chmod($full_file_name, 0755); - } - */ + }*/ + + if(!is_file($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf')) touch($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf'); + chown($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); + chgrp($this->sympa_config_dir.'/'.$domain['domain'].'/robot.conf', 'sympa'); //* Configure transport.sympa and add aliases $content_transport = $this->rf($this->sympa_config_dir.'/transport.sympa'); - if(strpos($content_transport, 'listmaster@'.$domain['domain']) === false){ - $this->af($this->sympa_config_dir.'/transport.sympa', "listmaster@".$domain['domain']." sympa:listmaster@".$domain['domain']."\n"); - } if(strpos($content_transport, 'sympa@'.$domain['domain']) === false){ $this->af($this->sympa_config_dir.'/transport.sympa', "sympa@".$domain['domain']." sympa:sympa@".$domain['domain']."\n"); } + if(strpos($content_transport, 'listmaster@'.$domain['domain']) === false){ + $this->af($this->sympa_config_dir.'/transport.sympa', "listmaster@".$domain['domain']." sympa:listmaster@".$domain['domain']."\n"); + } if(strpos($content_transport, 'bounce@'.$domain['domain']) === false){ $this->af($this->sympa_config_dir.'/transport.sympa', "bounce@".$domain['domain']." sympabounce:sympa@".$domain['domain']."\n"); } @@ -225,7 +221,7 @@ class sympa_plugin { unset($content_transport); //* Configure virtual.sympa and add aliases - $content_virtual = $this->rf($this->sympa_config_dir.'/virtual.sympa '); + $content_virtual = $this->rf($this->sympa_config_dir.'/virtual.sympa'); if(strpos($content_virtual , 'sympa-request@'.$domain['domain']) === false){ $this->af($this->sympa_config_dir.'/virtual.sympa', "sympa-request@".$domain['domain']." postmaster@".$domain['domain']."\n"); } -- GitLab From 6442ac0a991c156289a13d9ed5802773ecd4259e Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 2 Jan 2024 16:54:41 +0100 Subject: [PATCH 25/29] Fix template file --- install/tpl/list_aliases.tt2 | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/install/tpl/list_aliases.tt2 b/install/tpl/list_aliases.tt2 index 22357d9e62..bb60922735 100644 --- a/install/tpl/list_aliases.tt2 +++ b/install/tpl/list_aliases.tt2 @@ -1,19 +1,7 @@ -#------------------------------ [% list.name %]@[% list.domain %]: list alias created [% date %] -[% IF is_virtual_domain -%] -/^([% list.name %])-(request|editor|owner|subscribe|unsubscribe)\@[% list.domainescaped %]$/ $1+[% list.domain %]@sympa$2. -/^([% list.name %])\@[% list.domainescaped %]$/ $1+[% list.domain %]@sympalist. -[% ELSIF is_default_domain -%] -[% list.name %]: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]@[% list.domain %]" -[% list.name %]-request: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-request@[% list.domain %]" -[% list.name %]-editor: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-editor@[% list.domain %]" -#[% list.name %]-subscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-subscribe@[% list.domain %]" -[% list.name %]-unsubscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-unsubscribe@[% list.domain %]" -[% list.name %][% return_path_suffix %]: "| /usr/lib/sympa/lib/sympa/bouncequeue [% list.name %]@[% list.domain %]" -[% ELSE -%] -[% list.domain %]-[% list.name %]: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]@[% list.domain %]" -[% list.domain %]-[% list.name %]-request: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-request@[% list.domain %]" -[% list.domain %]-[% list.name %]-editor: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-editor@[% list.domain %]" -#[% list.domain %]-[% list.name %]-subscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-subscribe@[% list.domain %]" -[% list.domain %]-[% list.name %]-unsubscribe: "| /usr/lib/sympa/lib/sympa/queue [% list.name %]-unsubscribe@[% list.domain %]" -[% list.domain %]-[% list.name %][% return_path_suffix %]: "| /usr/lib/sympa/lib/sympa/bouncequeue [% list.name %]@[% list.domain %]" -[% END -%] \ No newline at end of file +#--- [% list.name %]@[% list.domain %]: list transport map created at [% date %] +[% list.name %]@[% list.domain %] sympa:[% list.name %]@[% list.domain %] +[% list.name %]-request@[% list.domain %] sympa:[% list.name %]-request@[% list.domain %] +[% list.name %]-editor@[% list.domain %] sympa:[% list.name %]-editor@[% list.domain %] +#[% list.name %]-subscribe@[% list.domain %] sympa:[% list.name %]-subscribe@[%list.domain %] +[% list.name %]-unsubscribe@[% list.domain %] sympa:[% list.name %]-unsubscribe@[% list.domain %] +[% list.name %][% return_path_suffix %]@[% list.domain %] sympabounce:[% list.name %]@[% list.domain %] \ No newline at end of file -- GitLab From a2aa158f2e87eec85a0e767ca6ce90d2a96aa320 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 2 Jan 2024 17:10:34 +0100 Subject: [PATCH 26/29] Update master file in right directory --- install/tpl/sympa.conf.master | 18 +++--- server/conf/sympa.conf.master | 113 ---------------------------------- 2 files changed, 9 insertions(+), 122 deletions(-) delete mode 100644 server/conf/sympa.conf.master diff --git a/install/tpl/sympa.conf.master b/install/tpl/sympa.conf.master index aa0c094830..fc58dd10e9 100644 --- a/install/tpl/sympa.conf.master +++ b/install/tpl/sympa.conf.master @@ -12,25 +12,25 @@ domain {hostname} ## Listmasters can be defined for each virtual host, however, the default ## listmasters will have privileges to manage all virtual hosts. ## Example: listmaster your_email_address@domain.tld -listmaster listmaster@{hostname} +listmaster {listmaster} ###\\\\ Database related ////### ## db_type ## Type of the database ## Possible types are "MySQL", "PostgreSQL", "Oracle" and "SQLite". -db_type mysql +db_type {db_type} ## db_host ## Hostname of the database server ## With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. ## "/var/run/postgresql" for connection with Unix domain socket. ## Example: db_host localhost -db_host localhost +db_host {db_host} ## db_port ## Port of the database server -db_port 3306 +db_port {db_port} ## db_name ## Name of the database @@ -38,19 +38,19 @@ db_port 3306 ## With Oracle Database, this must be SID, net service name or easy connection ## identifier (to use net service name, db_host should be set to "none" and ## HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file). -db_name sympa +db_name {db_name} ## db_user ## User for the database connection ## Example: db_user sympa -db_user sympa +db_user {db_user} ## db_passwd ## Password for the database connection ## What ever you use a password or not, you must protect the SQL server (is it ## not a public internet service ?) ## Example: db_passwd your_passwd -db_passwd ZzK3VT8AB2NU +db_passwd {db_passwd} ###\\\\ List definition ////### @@ -59,7 +59,7 @@ db_passwd ZzK3VT8AB2NU ## This parameter defines the language used for the list. It is used to ## initialize a user's language preference; Sympa command reports are ## extracted from the associated message catalog. -lang {default_language} +lang {lang} ###\\\\ Web interface parameters ////### @@ -68,7 +68,7 @@ lang {default_language} ## This is used to construct URLs of web interface. The protocol (either ## https:// or http://) is required. ## Example: wwsympa_url https://web.example.org/sympa -wwsympa_url http://{hostname}/wws +wwsympa_url https://{hostname}/wws ## static_content_path ## Directory for static contents diff --git a/server/conf/sympa.conf.master b/server/conf/sympa.conf.master deleted file mode 100644 index fc58dd10e9..0000000000 --- a/server/conf/sympa.conf.master +++ /dev/null @@ -1,113 +0,0 @@ -###\\\\ Service description ////### - -## domain -## Primary mail domain name -## Example: domain mail.example.org -domain {hostname} - -## listmaster -## Email addresses of listmasters -## Email addresses of the listmasters (users authorized to perform global -## server commands). Some error reports may also be sent to these addresses. -## Listmasters can be defined for each virtual host, however, the default -## listmasters will have privileges to manage all virtual hosts. -## Example: listmaster your_email_address@domain.tld -listmaster {listmaster} - -###\\\\ Database related ////### - -## db_type -## Type of the database -## Possible types are "MySQL", "PostgreSQL", "Oracle" and "SQLite". -db_type {db_type} - -## db_host -## Hostname of the database server -## With PostgreSQL, you can also use the path to Unix Socket Directory, e.g. -## "/var/run/postgresql" for connection with Unix domain socket. -## Example: db_host localhost -db_host {db_host} - -## db_port -## Port of the database server -db_port {db_port} - -## db_name -## Name of the database -## With SQLite, this must be the full path to database file. -## With Oracle Database, this must be SID, net service name or easy connection -## identifier (to use net service name, db_host should be set to "none" and -## HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file). -db_name {db_name} - -## db_user -## User for the database connection -## Example: db_user sympa -db_user {db_user} - -## db_passwd -## Password for the database connection -## What ever you use a password or not, you must protect the SQL server (is it -## not a public internet service ?) -## Example: db_passwd your_passwd -db_passwd {db_passwd} - -###\\\\ List definition ////### - -## lang -## Language of the list -## This parameter defines the language used for the list. It is used to -## initialize a user's language preference; Sympa command reports are -## extracted from the associated message catalog. -lang {lang} - -###\\\\ Web interface parameters ////### - -## wwsympa_url -## URL prefix of web interface -## This is used to construct URLs of web interface. The protocol (either -## https:// or http://) is required. -## Example: wwsympa_url https://web.example.org/sympa -wwsympa_url https://{hostname}/wws - -## static_content_path -## Directory for static contents -static_content_path /usr/share/sympa/static_content - -## css_path -## Directory for static style sheets (CSS) -## After an upgrade, static CSS files are upgraded with the newly installed -## "css.tt2" template. Therefore, this is not a good place to store customized -## CSS files. -css_path /var/lib/sympa/css - -## css_url -## URL for style sheets (CSS) -## To use auto-generated static CSS, HTTP server have to map it with -## "css_path". -css_url /css-sympa - -## pictures_path -## Directory for subscribers pictures -pictures_path /var/lib/sympa/pictures - -## pictures_url -## URL for subscribers pictures -## HTTP server have to map it with "pictures_path" directory. -pictures_url /pictures-sympa - -## create_list -## Who is able to create lists -create_list closed - -## sendmail_aliases -## Path of the file that contains all list related aliases -sendmail_aliases /etc/sympa/sympa_transport - -## aliases_program -## Program used to update alias database -aliases_program postmap - -## aliases_db_type -## Type of alias database -aliases_db_type hash \ No newline at end of file -- GitLab From d338f31f094e054003ba215337fcd216d2f761a5 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 2 Jan 2024 17:27:58 +0100 Subject: [PATCH 27/29] cleanup comments --- server/plugins-available/sympa_plugin.inc.php | 54 ++----------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/server/plugins-available/sympa_plugin.inc.php b/server/plugins-available/sympa_plugin.inc.php index 5495cb75e8..144ed2d00d 100644 --- a/server/plugins-available/sympa_plugin.inc.php +++ b/server/plugins-available/sympa_plugin.inc.php @@ -95,16 +95,11 @@ class sympa_plugin { unset($out); } while ($running); unset($out); - /* if(is_file('/etc/mailman/virtual-mailman') && !is_link('/etc/sympa/virtual.sympa')) { - symlink('/etc/mailman/virtual-mailman','/etc/sympa/virtual.sympa'); - } */ - // Still needed? if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - // Still needed? if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); + + if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); + if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); - - // Fix list URL - //$app->system->exec_safe('/usr/sbin/withlist -l -r fix_url ?', $data["new"]["listname"]); $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); @@ -117,13 +112,9 @@ class sympa_plugin { $this->update_config(); if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { - //$app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]); - //exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); + // Password not used in Sympa, no action needed $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); } - - // if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - // if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); } function delete($event_name, $data) { @@ -134,45 +125,10 @@ class sympa_plugin { $app->system->exec_safe("nohup /usr/bin/sympa --close_list=? >/dev/null 2>&1 &", $data["old"]["listname"].'@'.$data["old"]["domain"]); exec('nohup '.$conf['init_scripts'] . '/' . 'sympa reload >/dev/null 2>&1 &'); - - // Still needed? if(is_file('/etc/sympa/virtual.sympa')) exec('postmap /etc/sympa/virtual.sympa'); - // Still needed? if(is_file('/etc/sympa/sympa_transport')) exec('postmap /etc/sympa/sympa_transport'); - } function update_config() { global $app, $conf; - - /* - //copy($this->sympa_config_dir.'/sympa/sympa.conf', $this->sympa_config_dir.'/sympa/sympa.conf~'); - - // load the server configuration options - $app->uses('getconf'); - $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); - - // load files - // TODO: Change file - if(file_exists($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master")) { - $content = file_get_contents($conf["rootpath"]."/conf-custom/sympa_list_creation.xml.master"); - } else { - $content = file_get_contents($conf["rootpath"]."/conf/sympa_list_creation.xml.master"); - } - $old_file = file_get_contents($this->sympa_config_dir."/mm_cfg.py"); - - /* $old_options = array(); - $lines = explode("\n", $old_file); - foreach ($lines as $line) - { - if (strlen($line) && substr($line, 0, 1) != '#') - { - list($key, $value) = explode("=", $line); - if ($value && $value !== '') - { - $key = rtrim($key); - $old_options[$key] = trim($value); - } - } - }*/ // create virtual_domains list $domainAll = $app->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); @@ -189,7 +145,7 @@ class sympa_plugin { chown($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); chgrp($this->sympa_config_dir.'/'.$domain['domain'], 'sympa'); - /* + /* If we need custom variable per domain, might be good for the lang if(is_dir($this->sympa_config_dir.'/'.$domain['domain'])) { if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.robot.conf.master')) { copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/sympa.robot.conf.master', $full_file_name); -- GitLab From 861ad7a7d5055afc495cd0e0b2051b314b3f9d65 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 2 Jan 2024 18:03:54 +0100 Subject: [PATCH 28/29] add db_host option --- install/lib/installer_base.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 9b31d1bb95..c0b6a5dff4 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1110,6 +1110,8 @@ class installer_base extends stdClass { $content = str_replace('{listmaster}', $old_options['listmaster'], $content); if(!isset($old_options['db_type']) || $old_options['db_type'] == '') $old_options['db_type'] = 'mysql'; $content = str_replace('{db_type}', $old_options['db_type'], $content); + if(!isset($old_options['db_host']) || $old_options['db_host'] == '') $old_options['db_host'] = 'localhost'; + $content = str_replace('{db_host}', $old_options['db_host'], $content); if(!isset($old_options['db_port']) || $old_options['db_port'] == '') $old_options['db_port'] = '3306'; $content = str_replace('{db_port}', $old_options['db_port'], $content); if(!isset($old_options['db_name']) || $old_options['db_name'] == '') $old_options['db_name'] = 'sympa'; -- GitLab From 7ce029829c1c0650f5cc7dc92e35940a6f6e2a57 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 2 Jan 2024 18:36:26 +0100 Subject: [PATCH 29/29] Restore original gitlab-ci file --- .gitlab-ci.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f31038461c..41890c48d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,17 +94,11 @@ build:package: - if [[ $RET > 1 ]] ; then exit $RET ; fi - echo "Listing tar contents for verification" - tar -tvf ISPConfig-${VER}.tar.gz - #- echo "Uploading file to download server" - #- curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ - #- if [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(p[0-9]+)?$ ]] ; then echo "Stable release ${VER}" ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ISPConfig-3-stable.tar.gz ; echo -n "${VER}" > ispconfig3_version.txt ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ispconfig3_version.txt ftp://${DEPLOY_FTP_SERVER}/web/ ; else echo "Dev release ${VER}" ; fi - #- rm ISPConfig-${VER}.tar.gz - #- echo "Download url is https://download.ispconfig.org/ISPConfig-${VER}.tar.gz" - - artifacts: - paths: - - ISPConfig-${CI_COMMIT_REF_NAME}.tar.gz - expire_in: 1 week - + - echo "Uploading file to download server" + - curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ + - if [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(p[0-9]+)?$ ]] ; then echo "Stable release ${VER}" ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ISPConfig-${VER}.tar.gz ftp://${DEPLOY_FTP_SERVER}/web/ISPConfig-3-stable.tar.gz ; echo -n "${VER}" > ispconfig3_version.txt ; curl -u "${DEPLOY_FTP_USER}:${DEPLOY_FTP_PASSWORD}" -T ispconfig3_version.txt ftp://${DEPLOY_FTP_SERVER}/web/ ; else echo "Dev release ${VER}" ; fi + - rm ISPConfig-${VER}.tar.gz + - echo "Download url is https://download.ispconfig.org/ISPConfig-${VER}.tar.gz" needs: ["syntax:lint"] allow_failure: false -- GitLab