From: Leandro Lucarella Date: Mon, 22 Oct 2007 16:11:43 +0000 (-0300) Subject: Merge commit 'nico-baryon/master' X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/71a35239852c629c02006219427db45b75bc24da?hp=0dcb923d42a7489756eddd83a13a3059d8a24b2a Merge commit 'nico-baryon/master' Conflicts: pymin/services/ppp/__init__.py pymin/services/vrrp/__init__.py --- diff --git a/pymin/services/firewall/templates/iptables.sh b/pymin/services/firewall/templates/iptables.sh index bb67d9a..80f4a32 100644 --- a/pymin/services/firewall/templates/iptables.sh +++ b/pymin/services/firewall/templates/iptables.sh @@ -15,6 +15,10 @@ def optional(switch, value): /usr/sbin/iptables -t filter -F +/usr/sbin/iptables -t filter -P INPUT ACCEPT +/usr/sbin/iptables -t filter -P OUTPUT ACCEPT +/usr/sbin/iptables -t filter -P FORWARD ACCEPT + % for (index, rule) in enumerate(rules): /usr/sbin/iptables -t filter \ -I ${rule.chain|s} ${index+1|s} \ diff --git a/pymin/services/ppp/__init__.py b/pymin/services/ppp/__init__.py index 91070e7..c251e50 100644 --- a/pymin/services/ppp/__init__.py +++ b/pymin/services/ppp/__init__.py @@ -1,6 +1,8 @@ # vim: set encoding=utf-8 et sw=4 sts=4 : +import os from os import path +from signal import SIGTERM from pymin.seqtools import Sequence from pymin.dispatcher import Handler, handler, HandlerError @@ -104,7 +106,7 @@ class PppHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler): for name in names: if name in self.conns: if not self.conns[name]._running: - call(('pon', name)) + call(('pppd', 'call', name)) self.conns[name]._running = True self._dump_attr('conns') else: @@ -119,6 +121,12 @@ class PppHandler(Restorable, ConfigWriter, ReloadHandler, TransactionalHandler): if name in self.conns: if self.conns[name]._running: call(('poff', name)) + if path.exists('/var/run/ppp-' + name + '.pid'): + pid = file('/var/run/ppp-' + name + '.pid').readline() + try: + os.kill(int(pid.strip()), SIGTERM) + except OSError: + pass # XXX report error? self.conns[name]._running = False self._dump_attr('conns') else: @@ -185,3 +193,4 @@ if __name__ == '__main__': p.commit() print p.conn.list() print p.conn.show() + diff --git a/pymin/services/ppp/templates/nameX b/pymin/services/ppp/templates/nameX index 10524ff..ee70cf1 100644 --- a/pymin/services/ppp/templates/nameX +++ b/pymin/services/ppp/templates/nameX @@ -1,7 +1,16 @@ +updetach % if conn.type != 'TUNNEL': name ${conn.username} file /etc/ppp/options.${conn.name} ipparam ${conn.name} +# pppoe has a lower mtu/mru +mtu 1492 +mru 1492 +# switch off all compressions (this is a must) +nopcomp +# this is recommended +novjccomp +noccp % else: pty "pptp ${conn.server} --nolaunchpppd" name ${conn.username} diff --git a/pymin/services/ppp/templates/options.X b/pymin/services/ppp/templates/options.X index ffaf43f..6ac5714 100644 --- a/pymin/services/ppp/templates/options.X +++ b/pymin/services/ppp/templates/options.X @@ -1,3 +1,4 @@ +linkname ${conn.name} % if conn.type == 'PPP': lock ${conn.device} % elif conn.type == 'OE': diff --git a/pymin/services/vrrp/__init__.py b/pymin/services/vrrp/__init__.py index c8563a6..403cd36 100644 --- a/pymin/services/vrrp/__init__.py +++ b/pymin/services/vrrp/__init__.py @@ -13,8 +13,6 @@ from pymin.services.util import Restorable, TransactionalHandler, \ __ALL__ = ('VrrpHandler',) -pid_filename = 'vrrp.pid' - class VrrpHandler(Restorable, ParametersHandler, ReloadHandler, RestartHandler, ServiceHandler, TransactionalHandler): @@ -40,6 +38,7 @@ class VrrpHandler(Restorable, ParametersHandler, ReloadHandler, RestartHandler, def _service_stop(self): try: + pid_filename = 'vrrpd_%(dev)s_%(id)s.pid' % self.params pid = file(path.join(self._pid_dir, pid_filename )).read().strip() os.kill(int(pid), SIGTERM) except (IOError, OSError): @@ -55,4 +54,5 @@ class VrrpHandler(Restorable, ParametersHandler, ReloadHandler, RestartHandler, if __name__ == '__main__': v = VrrpHandler() v.set('prio','10') - v.commit() \ No newline at end of file + v.commit() +