Current Path : /usr/lib/python2.7/dist-packages/ufw/ |
Current File : //usr/lib/python2.7/dist-packages/ufw/applications.pyc |
^Oc @ s d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m Z d Z d Z d Z d Z d Z d Z d S( s' applications.py: common classes for ufwiN( t debugt warn( t UFWErrorc C s t j j | s- t d } t | n d } i } t j | } | j d } t j d } x| D]} | d | } t j j | s qn n | j | r t d | qn n | j d s| j d s| j d s| j d s| j d s| j d r+t d | qn n d } y t j | t j } Wn. t k r{t d | } t | qn n X| | k rt d | } t | qn n | | | k rt d | } t | qn n | | 7} t j } y | j | Wn. t k r/t d | } t | qn n Xx| j D]} t | d k rut d | } t | q=n t | st d | } t | q=n y1 t j j | t d | } t | w=Wn t k rn Xt } x | j | D] \ } } t | d k r>t d | } t | t } Pn t | d k rt d i | d 6| d 6} t | t } PqqW| rq=n | j | rt d | } t | n i } x' | j | D] \ } } | | | <qW| | | <q=Wqn W| S( sw Get profiles found in profiles database. Returns dictionary with profile name as key and tuples for fields s! Profiles directory does not existi i i s ^\.t /s Skipping '%s': hidden files .dpkg-news .dpkg-olds .dpkg-dists .rpmnews .rpmsavet ~s Skipping '%s's Skipping '%s': couldn't stats Skipping '%s': too bigs* Skipping '%s': too many files read alreadys Skipping '%s': couldn't processi@ s Skipping '%s': name too longs Skipping '%s': invalid names$ Skipping '%s': also in /etc/servicess Skipping '%s': field too longs4 Skipping '%(value)s': value too long for '%(field)s't valuet fields( Duplicate profile '%s', using last foundi ( i ( t ost patht isdirt _R t listdirt sortt ret compilet isfilet searchR t endswitht statt ST_SIZEt ExceptionR t ConfigParsert RawConfigParsert readt sectionst lent valid_profile_namet ufwt utilt get_services_protot Falset itemst Truet has_key( t profiles_dirt err_msgt max_sizet profilest filest total_sizet patt ft abs_patht sizet warn_msgt cdictt pt skipt keyR t pdict( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyt get_profiles s c C sF | d k r t Sy t | t SWn n Xt j d | rB t St S( s0 Only accept a limited set of characters for namet alls ^[a-zA-Z0-9][a-zA-Z0-9 _\-\.+]*$( R t intR t matchR ( t name( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyR s c C s[ d d d g } x | D]y } | j | sX t d i | d 6| d 6} t | q | | s t d i | d 6| d 6} t | q q W| d j d } t | d k r t d | } t SyO xH | D]@ } t j j | \ } } t j j d | | } t | q WWn9 t k rV} t | t d | } t | n Xt S( s' Make sure profile has everything neededt titlet descriptiont portss/ Profile '%(fn)s' missing required field '%(f)s't fnR) s1 Profile '%(fn)s' has empty required field '%(f)s't |i s No ports found in profile '%s't ACCEPTs Invalid ports in profile '%s'( R! R R t splitR R R R t parse_port_protot commont UFWRuleR R R ( R6 t profilet app_fieldsR) R# R9 R. t portt protot rulet e( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyt verify_profile s0 c C s6 d } d } | j | r2 | | r2 | | } n | S( s# Retrieve the title from the profilet R7 ( R! ( RA t sR ( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyt get_title s c C s6 d } d } | j | r2 | | r2 | | } n | S( s) Retrieve the description from the profileRH R8 ( R! ( RA RI R ( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyt get_description s c C s? g } d } | j | r; | | r; | | j d } n | S( s' Retrieve a list of ports from a profileR9 R; ( R! R= ( RA R9 R ( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyt get_ports s ( t __doc__R R R R t ufw.utilR R R t ufw.commonR R2 R RG RJ RK RL ( ( ( s4 /usr/lib/python2.7/dist-packages/ufw/applications.pyt <module> s o #