def _rules_config(rules):
 if (rules is None):
  rules = DEFAULT_RULES
 lines = [RULES_HEADER]
 for entry in rules:
  entry.setdefault('proto', 'tcp')
  entry.setdefault('dest_port', '-')
  entry.setdefault('source_port', '-')
  entry.setdefault('original_dest', '-')
  entry.setdefault('rate_limit', '-')
  entry.setdefault('user', '-')
  entry.setdefault('mark', '-')
  entry.setdefault('conn_limit', '-')
  entry.setdefault('time', '-')
  if isinstance(entry['dest_port'], list):
   entry['dest_port'] = ','.join(map(str, entry['dest_port']))
  if isinstance(entry['source_port'], list):
   entry['source_port'] = ','.join(map(str, entry['source_port']))
  lines.append((RULES_FORMAT % entry))
 file('/etc/shorewall/rules', contents=''.join(lines), use_sudo=True)

def _rules_config ( rules ) : if ( rules is None ) : rules = DEFAULT_RULES lines = [ RULES_HEADER ] for entry in rules : entry . setdefault ( 'proto' , 'tcp' ) entry . setdefault ( 'dest_port' , '-' ) entry . setdefault ( 'source_port' , '-' ) entry . setdefault ( 'original_dest' , '-' ) entry . setdefault ( 'rate_limit' , '-' ) entry . setdefault ( 'user' , '-' ) entry . setdefault ( 'mark' , '-' ) entry . setdefault ( 'conn_limit' , '-' ) entry . setdefault ( 'time' , '-' ) if isinstance ( entry [ 'dest_port' ] , list ) : entry [ 'dest_port' ] = ',' . join ( map ( str , entry [ 'dest_port' ] ) ) if isinstance ( entry [ 'source_port' ] , list ) : entry [ 'source_port' ] = ',' . join ( map ( str , entry [ 'source_port' ] ) ) lines . append ( ( RULES_FORMAT % entry ) ) file ( '/etc/shorewall/rules' , contents = '' . join ( lines ) , use_sudo = True )
policy configuration .