|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
out = __salt__['ufw.add_rule'](rule) |
|
|
out = __salt__['ufw.add_rule'](rule) |
|
|
except (CommandExecutionError, CommandNotFoundError) as e: |
|
|
except (CommandExecutionError, CommandNotFoundError) as e: |
|
|
|
|
|
if method.startswith('insert 1 deny') and "Invalid position '1'" in e.message: |
|
|
|
|
|
# This is probably the first rule to be added, so try again without "insert 1" |
|
|
|
|
|
return _add_rule('deny', name, app, interface, protocol, from_addr, from_port, to_addr, to_port, comment) |
|
|
return _error(name, e.message) |
|
|
return _error(name, e.message) |
|
|
|
|
|
|
|
|
adds = False |
|
|
adds = False |
|
|
|
|
|
|
|
|
if __opts__['test']: |
|
|
if __opts__['test']: |
|
|
return _test(name, "{0} would have been configured".format(name)) |
|
|
return _test(name, "{0} would have been configured".format(name)) |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
if method.startswith('insert 1 deny') and "Invalid position '1'" in line: |
|
|
|
|
|
# This is probably the first rule to be added, so try again without "insert 1" |
|
|
|
|
|
return _add_rule('deny', name, app, interface, protocol, from_addr, from_port, to_addr, to_port, comment) |
|
|
return _error(name, line) |
|
|
return _error(name, line) |
|
|
|
|
|
|
|
|
if adds: |
|
|
if adds: |
|
|
|
|
|
|
|
|
def deny(name, app=None, interface=None, protocol=None, |
|
|
def deny(name, app=None, interface=None, protocol=None, |
|
|
from_addr=None, from_port=None, to_addr=None, to_port=None, comment=None): |
|
|
from_addr=None, from_port=None, to_addr=None, to_port=None, comment=None): |
|
|
|
|
|
|
|
|
return _add_rule('deny', name, app, interface, protocol, from_addr, from_port, to_addr, to_port, comment) |
|
|
|
|
|
|
|
|
return _add_rule('insert 1 deny', name, app, interface, protocol, from_addr, from_port, to_addr, to_port, comment) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def limit(name, app=None, interface=None, protocol=None, |
|
|
def limit(name, app=None, interface=None, protocol=None, |