Current time: 05-21-2024, 01:23 PM Hello There, Guest! (LoginRegister)


Post Reply 
Mail relay to customer server
Author Message
ispcomm Offline
Junior Member
*

Posts: 93
Joined: Apr 2008
Reputation: 3
Post: #19
RE: Mail relay to customer server
I can confirm that the failures in the dmn-mngr are due to some extra beautifying on my own code which is not in trunk (yet). I'll push it there via a ticket, but in the mean time here's a patch agains trunk that works so you can give back some feedback (dmn-mngr only)
Code:
--- ispcp-dmn-mngr    (/mirror/ispcp/trunk/engine)    (revision 1339)
+++ ispcp-dmn-mngr    (/local/ispcp/trunk/engine)    (local)
@@ -2059,6 +2080,7 @@
    }

    my $dmn_name        = @$dmn_data[1];
+    my $dmn_relay             = @$dmn_data[22];
    my $conf_dir        = $main::cfg{'CONF_DIR'};
    my $cmd_postmap     = $main::cfg{'CMD_POSTMAP'};
    my $tpl_dir         = "$conf_dir/postfix/parts";
@@ -2068,6 +2090,9 @@
    my $working_cfg     = "$working_dir/domains";
    my $timestamp       = time;
    my $backup_cfg      = "$backup_dir/domains.$timestamp";
+    my $transport_cfg         = $main::cfg{'MTA_TRANSPORT_HASH'};
+    my $transport_working_cfg = "$working_dir/transport";
+    my $transport_backup_cfg  = "$backup_dir/transport.$timestamp";
    my ($sys, $working) = (undef, undef);

    #
@@ -2084,8 +2109,8 @@
    #
    $working =~ s/^$dmn_name\t\t\t[^\n]+\n//gim;

-    # Add domain entry only if mail accounts are activated
-    if (@$dmn_data[8] >= 0) {
+    # Add domain entry only if mail accounts are activated and domain relay is off (i.e. deliver mail locally)
+    if (@$dmn_data[8] >= 0 && $dmn_relay eq "_no_" ) {
        $working .= "$dmn_name\t\t\tvdmn_entry\n";
    }

@@ -2108,6 +2133,48 @@
    $rs = sys_command("$cmd_postmap $sys_cfg");
    return $rs if ($rs != 0);

+    #
+    # Transport Table handling (for domain mx relay handling)
+    #
+    push_el(\@main::el, 'dmn_add_mta_cfg_data()', 'Transport Table...');
+    
+    ($rs, $sys) = get_file($transport_cfg);
+    return $rs if ($rs != 0);
+    
+    ($rs, $working) = get_file($transport_working_cfg);
+    return $rs if ($rs != 0);
+    
+    #
+    # Adding to the transport table in case mxrelay <> '_no_'
+    #
+    $working =~ s/^$dmn_name[\s]+[^\n]+\n//gim;
+    
+    if ( $dmn_relay ne "_no_" ) {
+        $working .= "$dmn_name\t\t\tsmtp:[$dmn_relay]\n";
+    }
+
+    #
+    # Let's do some backup first;
+    #
+    $rs = store_file($transport_backup_cfg, $sys, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644);
+    return $rs if ($rs != 0);
+    
+    #
+    # Let's write configs;
+    #
+    
+    $rs = store_file($transport_working_cfg, $working, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644);
+    return $rs if ($rs != 0);
+    
+    $rs = store_file($transport_cfg, $working, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644);
+    return $rs if ($rs != 0);
+    
+    $rs = sys_command("$cmd_postmap $transport_cfg");
+    return $rs if ($rs != 0);
+    
+    #
+    # Finishing off.
+    #
    push_el(\@main::el, 'dmn_add_mta_cfg_data()', 'Ending...');
    return 0;
}
@@ -2135,6 +2202,9 @@
    my $working_cfg     = "$working_dir/domains";
    my $timestamp       = time;
    my $backup_cfg      = "$backup_dir/domains.$timestamp";
+    my $transport_cfg         = $main::cfg{'MTA_TRANSPORT_HASH'};
+    my $transport_working_cfg = "$working_dir/transport";
+    my $transport_backup_cfg  = "$backup_dir/transport.$timestamp";
    my ($sys, $working) = (undef, undef);

    #
@@ -2169,6 +2239,38 @@
    $rs = sys_command("$cmd_postmap $sys_cfg");
    return $rs if ($rs != 0);

+    #
+    # Transport Table handling (for domain mx relay handling)
+    #
+    push_el(\@main::el, 'dmn_del_mta_cfg_data()', 'Transport Table...');
+    
+    ($rs, $sys) = get_file($transport_cfg);
+    return $rs if ($rs != 0);
+    
+    ($rs, $working) = get_file($transport_working_cfg);
+    return $rs if ($rs != 0);
+    
+    $working =~ s/^$dmn_name[\s]+[^\n]+\n//gim;
+
+    #
+    # Let's do some backup first;
+    #
+    $rs = store_file($transport_backup_cfg, $sys, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644);
+    return $rs if ($rs != 0);
+    
+    #
+    # Let's write configs;
+    #
+    
+    $rs = store_file($transport_working_cfg, $working, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644);
+    return $rs if ($rs != 0);
+    
+    $rs = store_file($transport_cfg, $working, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644);
+    return $rs if ($rs != 0);
+    
+    $rs = sys_command("$cmd_postmap $transport_cfg");
+    return $rs if ($rs != 0);
+
    push_el(\@main::el, 'dmn_del_mta_cfg_data()', 'Ending...');
    return 0;
}
@@ -3556,7 +3661,7 @@
        t1.domain_created_id, t1.domain_created, t1.domain_last_modified, t1.domain_mailacc_limit, t1.domain_ftpacc_limit,
        t1.domain_traffic_limit, t1.domain_sqld_limit, t1.domain_sqlu_limit, t1.domain_status, t1.domain_alias_limit,
        t1.domain_subd_limit, t1.domain_ip_id, t1.domain_disk_limit, t1.domain_disk_usage, t1.domain_php,
-        t1.domain_cgi, t2.ip_number FROM domain AS t1, server_ips AS t2 WHERE t1.domain_ip_id = t2.ip_id
+        t1.domain_cgi, t2.ip_number, t1.domain_mxrelay FROM domain AS t1, server_ips AS t2 WHERE t1.domain_ip_id = t2.ip_id
        AND t1.domain_id = $main::dmn_task_id";

    ($rs, $rows) = doSQL($sql);
ADDED: For some reason attachments didn't work so I had to quote the whole patch. sorry.

ispcomm.
(This post was last modified: 06-10-2008 11:04 PM by ispcomm.)
06-10-2008 06:28 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Mail relay to customer server - ispcomm - 05-19-2008, 04:38 PM
RE: Mail relay to customer server - Cube - 05-20-2008, 08:34 AM
RE: Mail relay to customer server - simple - 05-21-2008, 12:51 AM
RE: Mail relay to customer server - rbtux - 05-20-2008, 07:07 PM
RE: Mail relay to customer server - ispcomm - 06-10-2008 06:28 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)