def __init__(self):
        server_front_ip = config.host(net.get_hostname()).get_front_ip()
        server_back_ip = config.host(net.get_hostname()).get_back_ip()

        server_network_front = net.get_network_cidr(server_front_ip, config.general.get_front_netmask())

        server_network_back = net.get_network_cidr(server_back_ip, config.general.get_back_netmask())
Exemple #2
0
    def __init__(self):

        netmasks = {}

        #Add localhost IP/netmask
        local_ip = "127.0.0.1"
        self.server_ips.append(local_ip)
        netmasks[local_ip] = "255.0.0.0"

        #Add IPs for front/back net if they exist.
        front_ip = config.host(net.get_hostname()).get_front_ip()
        if front_ip:
            self.server_ips.append(front_ip)
            netmasks[front_ip] = config.general.get_front_netmask()
        back_ip = config.host(net.get_hostname()).get_back_ip()
        if config.general.is_back_enabled() and back_ip:
            self.server_ips.append(back_ip)
            netmasks[back_ip] = config.general.get_back_netmask()

        if len(self.server_ips) < 2:
            app.print_error(
                "Didn't find any valid IP addresses from front or back net. Exiting"
            )
            sys.exit(1)

        for ip in self.server_ips:
            self.server_networks.append(net.get_network_cidr(ip, netmasks[ip]))

        self.virtual_alias_domains = config.general.get_option(
            "mailrelay.virtual_alias_domains", "")

        for alias_row in config.general.get_option("mailrelay.virtual_aliases",
                                                   "").split(";"):
            if len(alias_row.strip()) == 0:
                #Don't process empty rows
                break
            split_row = alias_row.split(" ", 1)
            if len(split_row) != 2:
                app.print_error(
                    "Expected mailrelay.virtual_alias to be two words separated by space, several entries "
                    "separated by semicolon. Found \"%s\"" % alias_row)
                sys.exit(1)
            self.virtual_aliases[split_row[0]] = split_row[1]
Exemple #3
0
    def __init__(self):

        netmasks = {}

        # Add localhost IP/netmask
        local_ip = "127.0.0.1"
        self.server_ips.append(local_ip)
        netmasks[local_ip] = "255.0.0.0"

        # Add IPs for front/back net if they exist.
        front_ip = config.host(net.get_hostname()).get_front_ip()
        if front_ip:
            self.server_ips.append(front_ip)
            netmasks[front_ip] = config.general.get_front_netmask()
        back_ip = config.host(net.get_hostname()).get_back_ip()
        if config.general.is_back_enabled() and back_ip:
            self.server_ips.append(back_ip)
            netmasks[back_ip] = config.general.get_back_netmask()

        if len(self.server_ips) < 2:
            app.print_error("Didn't find any valid IP addresses from front or back net. Exiting")
            sys.exit(1)

        for ip in self.server_ips:
            self.server_networks.append(net.get_network_cidr(ip, netmasks[ip]))

        self.virtual_alias_domains = config.general.get_option("mailrelay.virtual_alias_domains", "")

        for alias_row in config.general.get_option("mailrelay.virtual_aliases", "").split(";"):
            if len(alias_row.strip()) == 0:
                # Don't process empty rows
                break
            split_row = alias_row.split(" ", 1)
            if len(split_row) != 2:
                app.print_error(
                    "Expected mailrelay.virtual_alias to be two words separated by space, several entries "
                    'separated by semicolon. Found "%s"' % alias_row
                )
                sys.exit(1)
            self.virtual_aliases[split_row[0]] = split_row[1]
Exemple #4
0
 def get_front_subnet(self):
     '''The back subnet (ie. 10.100.10.0/24)'''
     return net.get_network_cidr(self.get_front_network(),
                                 self.get_front_netmask())
Exemple #5
0
 def get_front_subnet(self):
     '''The back subnet (ie. 10.100.10.0/24)'''
     return net.get_network_cidr(
         self.get_front_network(),
         self.get_front_netmask()
     )
Exemple #6
0
import iptables
import net
import scopen
import version

# The version of this module, used to prevent the same script version to be
# executed more then once on the same host.
SCRIPT_VERSION = 1

# Get network settings from install.cfg
mail_server_hostname = config.general.get_mail_relay_server()

server_front_ip = config.host(mail_server_hostname).get_front_ip()
server_back_ip = config.host(mail_server_hostname).get_back_ip()

server_front_network = net.get_network_cidr(server_front_ip,
                                            config.general.get_front_netmask())
server_back_network = net.get_network_cidr(server_back_ip,
                                           config.general.get_back_netmask())


def build_commands(commands):
    commands.add(
        "install-postfix-server",
        install_mail_server,
        help="Install postfix/mail-relay server on the current server.")
    commands.add(
        "install-postfix-client",
        install_mail_client,
        help="Install postfix/mail-relay client on the current server.")
    commands.add(
        "uninstall-postfix-server",
Exemple #7
0
import iptables
import net
import scopen
import version

# The version of this module, used to prevent the same script version to be
# executed more then once on the same host.
SCRIPT_VERSION = 1

# Get network settings from install.cfg
mail_server_hostname = config.general.get_mail_relay_server()

server_front_ip = config.host(mail_server_hostname).get_front_ip()
server_back_ip = config.host(mail_server_hostname).get_back_ip()

server_front_network = net.get_network_cidr(server_front_ip,
  config.general.get_front_netmask())
server_back_network = net.get_network_cidr(server_back_ip ,
  config.general.get_back_netmask())


def build_commands(commands):
  commands.add("install-postfix-server", install_mail_server, help="Install postfix/mail-relay server on the current server.")
  commands.add("install-postfix-client", install_mail_client, help="Install postfix/mail-relay client on the current server.")
  commands.add("uninstall-postfix-server", uninstall_mail_relay, help="Uninstall postfix/mail-relay client on the current server.")
  commands.add("uninstall-postfix-client", uninstall_mail_relay, help="Uninstall postfix/mail-relay client on the current server.")
  commands.add("send-test-email", send_test_mail, help="Send a test email to the sysop address")


def install_mail_server(args):
  '''
  Installs a postfix-based mail relay MTA that listens on the DMZ, and relays
Exemple #8
0
 def get_back_subnet(self):
     """The back subnet (ie. 10.100.10.0/24)"""
     return net.get_network_cidr(self.get_back_network(), self.get_back_netmask())