@@ -264,6 +264,14 @@ function configure_postfix() {
264264 $ command = "chmod 755 /var/run/courier/authdaemon/ " ;
265265 caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ ,"EXECUTED: " .$ command ,"Failed to execute the command " .$ command );
266266
267+ // Changing maildrop lines in posfix master.cf
268+ 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~ ' );
269+ if (is_file ($ conf ["dist_postfix_config_dir " ].'/master.cf~ ' )) exec ('chmod 400 ' .$ conf ["dist_postfix_config_dir " ].'/master.cf~ ' );
270+ $ configfile = $ conf ["dist_postfix_config_dir " ].'/master.cf ' ;
271+ $ content = rf ($ configfile );
272+ $ 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 );
273+ wf ($ configfile ,$ content );
274+
267275 // Writing the Maildrop mailfilter file
268276 $ configfile = 'mailfilter ' ;
269277 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 .'~ ' );
@@ -289,47 +297,7 @@ function configure_postfix() {
289297 function configure_saslauthd () {
290298 global $ conf ;
291299
292- /*
293-
294- TODO: The example below is for Ubuntu 6.10
295-
296- mkdir -p /var/spool/postfix/var/run/saslauthd
297-
298- Edit /etc/default/saslauthd. Remove the # in front of START=yes and add the line PARAMS="-m /var/spool/postfix/var/run/saslauthd -r".
299-
300- vi /etc/default/saslauthd
301-
302- The file should then look like this:
303-
304- # This needs to be uncommented before saslauthd will be run automatically
305- START=yes
306-
307- # You must specify the authentication mechanisms you wish to use.
308- # This defaults to "pam" for PAM support, but may also include
309- # "shadow" or "sasldb", like this:
310- # MECHANISMS="pam shadow"
311-
312- MECHANISMS="pam"
313- PARAMS="-m /var/spool/postfix/var/run/saslauthd -r"
314-
315- We must also edit /etc/init.d/saslauthd and change the location of saslauthd's PID file.
316-
317- vi /etc/init.d/saslauthd
318-
319- Change the value of PIDFILE to /var/spool/postfix/var/run/${NAME}/saslauthd.pid:
320-
321- PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"
322-
323-
324- Then restart Postfix and Saslauthd:
325-
326- /etc/init.d/postfix restart
327- postfix check
328- /etc/init.d/saslauthd restart
329-
330-
331- */
332-
300+
333301 $ configfile = 'sasl_smtpd.conf ' ;
334302 if (is_file ($ conf ["dist_postfix_config_dir " ].'/sasl/smtpd.conf ' )) copy ($ conf ["dist_postfix_config_dir " ].'/sasl/smtpd.conf ' ,$ conf ["dist_postfix_config_dir " ].'/sasl/smtpd.conf~ ' );
335303 if (is_file ($ conf ["dist_postfix_config_dir " ].'/sasl/smtpd.conf~ ' )) exec ('chmod 400 ' .$ conf ["dist_postfix_config_dir " ].'/sasl/smtpd.conf~ ' );
@@ -343,6 +311,26 @@ function configure_saslauthd() {
343311 // TODO: Chmod and chown on the config file
344312
345313
314+
315+ // Create the spool directory
316+ exec ("mkdir -p /var/spool/postfix/var/run/saslauthd " );
317+
318+ // Edit the file /etc/default/saslauthd
319+ $ configfile = '/etc/default/saslauthd ' ;
320+ if (is_file ($ configfile )) copy ($ configfile ,$ configfile .'~ ' );
321+ if (is_file ($ configfile .'~ ' )) exec ('chmod 400 ' .$ configfile .'/~ ' );
322+ $ content = rf ($ configfile );
323+ $ content = str_replace ('START=no ' ,'START=yes ' ,$ content );
324+ $ content = str_replace ('OPTIONS="-c" ' ,'OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r" ' ,$ content );
325+ wf ($ configfile ,$ content );
326+
327+ // Edit the file /etc/default/saslauthd
328+ $ configfile = '/etc/init.d/saslauthd ' ;
329+ $ content = rf ($ configfile );
330+ $ content = str_replace ('PIDFILE=$RUN_DIR/saslauthd.pid ' ,'PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid" ' ,$ content );
331+ wf ($ configfile ,$ content );
332+
333+
346334 }
347335
348336 function configure_pam () {
@@ -379,6 +367,16 @@ function configure_courier() {
379367
380368 exec ('chmod 660 ' .$ conf ["dist_courier_config_dir " ].'/ ' .$ configfile );
381369 exec ('chown daemon:daemon ' .$ conf ["dist_courier_config_dir " ].'/ ' .$ configfile );
370+
371+ //authdaemonrc
372+ $ configfile = $ conf ["dist_courier_config_dir " ].'/authdaemonrc ' ;
373+ if (is_file ($ configfile )) copy ($ configfile ,$ configfile .'~ ' );
374+ if (is_file ($ configfile .'~ ' )) exec ('chmod 400 ' .$ configfile .'/~ ' );
375+ $ content = rf ($ configfile );
376+ $ content = str_replace ('authmodulelist="authpam" ' ,'authmodulelist="authmysql" ' ,$ content );
377+ wf ($ configfile ,$ content );
378+
379+
382380 }
383381
384382 function configure_amavis () {
@@ -539,7 +537,7 @@ function install_crontab() {
539537 unlink ('crontab.txt ' );
540538
541539 // Getmail crontab
542- exec ("crontab -u root -l > crontab.txt " );
540+ exec ("crontab -u getmail -l > crontab.txt " );
543541 $ existing_cron_jobs = file ('crontab.txt ' );
544542
545543 $ cron_jobs = array ('*/5 * * * * ' .$ conf ["dist_getmail_program " ].' -g ' .$ conf ["dist_getmail_config_dir " ].' -r ' .$ conf ["dist_getmail_config_dir " ].'/*.conf &> /dev/null ' );
@@ -549,7 +547,7 @@ function install_crontab() {
549547 }
550548 }
551549 file_put_contents ('crontab.txt ' ,$ existing_cron_jobs );
552- exec ("crontab -u root crontab.txt &> /dev/null " );
550+ exec ("crontab -u getmail crontab.txt &> /dev/null " );
553551 unlink ('crontab.txt ' );
554552
555553 }
0 commit comments