@@ -54,6 +54,14 @@ public function configure_postfix($options = '')
5454 $ cf = $ conf ['postfix ' ];
5555 $ config_dir = $ cf ['config_dir ' ];
5656
57+ exec ('postconf mail_version ' , $ ret );
58+ $ postfix_version =str_replace ('mail_version = ' , '' , $ ret [0 ]);
59+ unset($ ret );
60+ exec ('openssl version ' , $ ret );
61+ $ openssl_version =$ ret [0 ];
62+ unset($ ret );
63+ $ use_pfs =@(version_compare ($ openssl_version , 'OpenSSL 0.9 ' , '>= ' ) && version_compare ($ postfix_version , '2.6 ' , '>= ' ))?true :false ;
64+
5765 if (!is_dir ($ config_dir )){
5866 $ this ->error ("The postfix configuration directory ' $ config_dir' does not exist. " );
5967 }
@@ -116,6 +124,19 @@ public function configure_postfix($options = '')
116124 '{reject_slm} ' => $ reject_sender_login_mismatch ,
117125 );
118126
127+ //* If PFS is possible, configure it
128+ if ($ use_pfs && !file_exists ($ config_dir .'/dh_512.pem ' )) exec ('openssl gendh -out ' .$ config_dir .'/dh_512.pem -2 512 ' );
129+ if ($ use_pfs && !file_exists ($ config_dir .'/dh_2048.pem ' )) exec ('openssl gendh -out ' .$ config_dir .'/dh_2048.pem -2 2048 ' );
130+ if ($ use_pfs && file_exists ($ config_dir .'/dh_512.pem ' ) && file_exists ($ config_dir .'/dh_2048.pem ' )) {
131+ $ postconf_placeholders = array_merge ($ postconf_placeholders , array (
132+ '{smtpd_tls_dh512_param_file} ' => $ config_dir .'/dh_512.pem ' ,
133+ '{smtpd_tls_dh1024_param_file} ' => $ config_dir .'/dh_2048.pem ' ));
134+ } else {
135+ $ postconf_placeholders = array_merge ($ postconf_placeholders , array (
136+ '{smtpd_tls_dh512_param_file} ' => '' ,
137+ '{smtpd_tls_dh1024_param_file} ' => '' ));
138+ }
139+
119140 $ postconf_tpl = rfsel ($ conf ['ispconfig_install_dir ' ].'/server/conf-custom/install/gentoo_postfix.conf.master ' , 'tpl/gentoo_postfix.conf.master ' );
120141 $ postconf_tpl = strtr ($ postconf_tpl , $ postconf_placeholders );
121142 $ postconf_commands = array_filter (explode ("\n" , $ postconf_tpl )); // read and remove empty lines
0 commit comments