@@ -165,7 +165,6 @@ public function configure_database()
165165
166166 private function process_postfix_config ($ configfile )
167167 {
168- //$configfile = 'mysql-virtual_domains.cf';
169168 $ config_dir = $ this ->conf ['dist ' ]['postfix ' ]['config_dir ' ].'/ ' ;
170169 $ full_file_name = $ config_dir .$ configfile ;
171170 //* Backup exiting file
@@ -215,8 +214,8 @@ public function configure_postfix($options = '')
215214 $ this ->process_postfix_config ('mysql-virtual_client.cf ' );
216215
217216 //* Changing mode and group of the new created config files.
218- caselog ("chmod o= " .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] ."/mysql-virtual_*.cf* &> /dev/null " , __FILE__ , __LINE__ ,"chmod on mysql-virtual_*.cf* " ,"chmod on mysql-virtual_*.cf* failed " );
219- caselog ("chgrp " .$ conf ["dist " ]["postfix " ]["groupname " ]." " .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] ."/mysql-virtual_*.cf* &> /dev/null " , __FILE__ , __LINE__ ,"chgrp on mysql-virtual_*.cf* " ,"chgrp on mysql-virtual_*.cf* failed " );
217+ caselog ("chmod o= " .$ config_dir ."/mysql-virtual_*.cf* &> /dev/null " , __FILE__ , __LINE__ ,"chmod on mysql-virtual_*.cf* " ,"chmod on mysql-virtual_*.cf* failed " );
218+ caselog ("chgrp " .$ conf ["dist " ]["postfix " ]["group " ]." " .$ config_dir ."/mysql-virtual_*.cf* &> /dev/null " , __FILE__ , __LINE__ ,"chgrp on mysql-virtual_*.cf* " ,"chgrp on mysql-virtual_*.cf* failed " );
220219
221220 // Creating virtual mail user and group
222221 $ command = "groupadd -g " .$ conf ["dist " ]["postfix " ]["vmail_groupid " ]." " .$ conf ["dist " ]["postfix " ]["vmail_groupname " ];
@@ -230,51 +229,51 @@ public function configure_postfix($options = '')
230229 'mydestination = ' .$ conf ["hostname " ].', localhost, localhost.localdomain ' ,
231230 'mynetworks = 127.0.0.0/8 ' ,
232231 'virtual_alias_domains = ' ,
233- 'virtual_alias_maps = proxy:mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_forwardings.cf, mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_email2email.cf ' ,
234- 'virtual_mailbox_domains = proxy:mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_domains.cf ' ,
232+ 'virtual_alias_maps = proxy:mysql: ' .$ config_dir .'/mysql-virtual_forwardings.cf, mysql: ' .$ config_dir .'/mysql-virtual_email2email.cf ' ,
233+ 'virtual_mailbox_domains = proxy:mysql: ' .$ config_dir .'/mysql-virtual_domains.cf ' ,
235234 'virtual_mailbox_maps = proxy:mysql: ' .$ conf ["dist " ]["postfix " ]["config_dir " ].'/mysql-virtual_mailboxes.cf ' ,
236235 'virtual_mailbox_base = ' .$ conf ["dist " ]["postfix " ]["vmail_mailbox_base " ],
237236 'virtual_uid_maps = static: ' .$ conf ["dist " ]["postfix " ]["vmail_userid " ],
238237 'virtual_gid_maps = static: ' .$ conf ["dist " ]["postfix " ]["vmail_groupid " ],
239238 'smtpd_sasl_auth_enable = yes ' ,
240239 'broken_sasl_auth_clients = yes ' ,
241- 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_recipient.cf, reject_unauth_destination ' ,
240+ 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql: ' .$ config_dir .'/mysql-virtual_recipient.cf, reject_unauth_destination ' ,
242241 'smtpd_use_tls = yes ' ,
243- 'smtpd_tls_cert_file = ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/smtpd.cert ' ,
244- 'smtpd_tls_key_file = ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/smtpd.key ' ,
245- 'transport_maps = proxy:mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_transports.cf ' ,
242+ 'smtpd_tls_cert_file = ' .$ config_dir .'/smtpd.cert ' ,
243+ 'smtpd_tls_key_file = ' .$ config_dir .'/smtpd.key ' ,
244+ 'transport_maps = proxy:mysql: ' .$ config_dir .'/mysql-virtual_transports.cf ' ,
246245 'virtual_create_maildirsize = yes ' ,
247246 'virtual_mailbox_extended = yes ' ,
248- 'virtual_mailbox_limit_maps = proxy:mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_mailbox_limit_maps.cf ' ,
247+ 'virtual_mailbox_limit_maps = proxy:mysql: ' .$ config_dir .'/mysql-virtual_mailbox_limit_maps.cf ' ,
249248 'virtual_mailbox_limit_override = yes ' ,
250249 'virtual_maildir_limit_message = "The user you are trying to reach is over quota." ' ,
251250 'virtual_overquota_bounce = yes ' ,
252251 'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps ' ,
253- 'smtpd_sender_restrictions = check_sender_access mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_sender.cf ' ,
254- 'smtpd_client_restrictions = check_client_access mysql: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mysql-virtual_client.cf ' ,
252+ 'smtpd_sender_restrictions = check_sender_access mysql: ' .$ config_dir .'/mysql-virtual_sender.cf ' ,
253+ 'smtpd_client_restrictions = check_client_access mysql: ' .$ config_dir .'/mysql-virtual_client.cf ' ,
255254 'maildrop_destination_concurrency_limit = 1 ' ,
256255 'maildrop_destination_recipient_limit = 1 ' ,
257256 'virtual_transport = maildrop ' ,
258- 'header_checks = regexp: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/header_checks ' ,
259- 'mime_header_checks = regexp: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mime_header_checks ' ,
260- 'nested_header_checks = regexp: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/nested_header_checks ' ,
261- 'body_checks = regexp: ' .$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/body_checks '
257+ 'header_checks = regexp: ' .$ config_dir .'/header_checks ' ,
258+ 'mime_header_checks = regexp: ' .$ config_dir .'/mime_header_checks ' ,
259+ 'nested_header_checks = regexp: ' .$ config_dir .'/nested_header_checks ' ,
260+ 'body_checks = regexp: ' .$ config_dir .'/body_checks '
262261 );
263262
264- // Create the header ynd body check files
265- touch ($ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/header_checks ' );
266- touch ($ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/mime_header_checks ' );
267- touch ($ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/nested_header_checks ' );
268- touch ($ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/body_checks ' );
263+ //* Create the header and body check files
264+ touch ($ config_dir .'/header_checks ' );
265+ touch ($ config_dir .'/mime_header_checks ' );
266+ touch ($ config_dir .'/nested_header_checks ' );
267+ touch ($ config_dir .'/body_checks ' );
269268
270269
271- // Make a backup copy of the main.cf file
272- copy ($ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/main.cf ' ,$ conf [ " dist " ][ " postfix " ][ " config_dir " ] .'/main.cf~ ' );
270+ //* Make a backup copy of the main.cf file
271+ copy ($ config_dir .'/main.cf ' , $ config_dir .'/main.cf~ ' );
273272
274- // Executing the postconf commands
273+ //* Executing the postconf commands
275274 foreach ($ postconf_commands as $ cmd ) {
276275 $ command = "postconf -e ' $ cmd' " ;
277- caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ ," EXECUTED: " .$ command ," Failed to execute the command " .$ command );
276+ caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ , ' EXECUTED: ' .$ command , ' Failed to execute the command ' .$ command );
278277 }
279278
280279 // TODO: Change the master.cf file
@@ -285,31 +284,37 @@ public function configure_postfix($options = '')
285284
286285 */
287286 if (!stristr ($ options ,'dont-create-certs ' )) {
288- // Create the SSL certificate
289- $ command = "cd " .$ conf ["dist " ]["postfix " ]["config_dir " ]."; openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509 " ;
287+ //* Create the SSL certificate
288+ $ command = 'cd ' .$ config_dir .'; '
289+ .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout '
290+ .'smtpd.key -keyform PEM -days 365 -x509 ' ;
290291 exec ($ command );
291292
292- $ command = " chmod o= " . $ conf [ " dist " ][ " postfix " ][ " config_dir " ]. " /smtpd.key " ;
293- caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ ," EXECUTED: " .$ command ," Failed to execute the command " .$ command );
293+ $ command = ' chmod o= ' . $ config_dir. ' /smtpd.key ' ;
294+ caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , ' EXECUTED: ' .$ command , ' Failed to execute the command ' .$ command );
294295 }
295296
296297 /*
297298 We have to change the permissions of the courier authdaemon directory
298299 to make it accessible for maildrop.
299300 */
300301
301- $ command = " chmod 755 /var/run/courier/authdaemon/ " ;
302- caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ ," EXECUTED: " .$ command ," Failed to execute the command " .$ command );
302+ $ command = ' chmod 755 /var/run/courier/authdaemon/ ' ;
303+ caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , ' EXECUTED: ' .$ command , ' Failed to execute the command ' .$ command );
303304
304- // Changing maildrop lines in posfix master.cf
305- if (is_file ($ conf ["dist " ]["postfix " ]["config_dir " ].'/master.cf ' )) copy ($ conf ["dist " ]["postfix " ]["config_dir " ].'/master.cf ' ,$ conf ["dist " ]["postfix " ]["config_dir " ].'/master.cf~ ' );
306- if (is_file ($ conf ["dist " ]["postfix " ]["config_dir " ].'/master.cf~ ' )) exec ('chmod 400 ' .$ conf ["dist " ]["postfix " ]["config_dir " ].'/master.cf~ ' );
307- $ configfile = $ conf ["dist " ]["postfix " ]["config_dir " ].'/master.cf ' ;
305+ //* Changing maildrop lines in posfix master.cf
306+ if (is_file ($ config_dir .'/master.cf ' )){
307+ copy ($ config_dir .'/master.cf ' , $ config_dir .'/master.cf~ ' );
308+ }
309+ if (is_file ($ config_dir .'/master.cf~ ' )){
310+ exec ('chmod 400 ' .$ config_dir .'/master.cf~ ' );
311+ }
312+ $ configfile = $ config_dir .'/master.cf ' ;
308313 $ content = rf ($ configfile );
309- $ content = str_replace (' flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} ' ,' flags=R user= ' .$ conf ["dist " ]["postfix " ]["vmail_username " ].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender} ' ,$ content );
314+ $ content = str_replace (' flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} ' , ' flags=R user= ' .$ conf ["dist " ]["postfix " ]["vmail_username " ].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender} ' , $ content );
310315 wf ($ configfile ,$ content );
311316
312- // Writing the Maildrop mailfilter file
317+ //* Writing the Maildrop mailfilter file
313318 $ configfile = 'mailfilter ' ;
314319 if (is_file ($ conf ["dist " ]["postfix " ]["vmail_mailbox_base " ].'/. ' .$ configfile )) copy ($ conf ["dist " ]["postfix " ]["vmail_mailbox_base " ].'/. ' .$ configfile ,$ conf ["dist " ]["postfix " ]["vmail_mailbox_base " ].'/. ' .$ configfile .'~ ' );
315320 $ content = rf ("tpl/ " .$ configfile .".master " );
@@ -328,7 +333,6 @@ public function configure_postfix($options = '')
328333 caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ ,"EXECUTED: " .$ command ,"Failed to execute the command " .$ command );
329334
330335
331-
332336 }
333337
334338 function configure_saslauthd () {
0 commit comments