Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/ufw/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/ufw/applications.pyc


^Oc@sdZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
dZdZdZ
dZd	Zd
ZdS(s'applications.py: common classes for ufwiN(tdebugtwarn(tUFWErrorcCstjj|s-td}t|nd}i}tj|}|jd}tjd}x|D]}|d|}tjj	|sqnn|j
|rtd|qnn|jds|jd	s|jd
s|jds|jds|jd
r+td|qnnd}	ytj
|t
j}	Wn.tk
r{td|}
t|
qnnX|	|krtd|}
t|
qnn||	|krtd|}
t|
qnn||	7}tj}y|j|Wn.tk
r/td|}
t|
qnnXx|jD]}t|dkrutd|}
t|
q=nt|std|}
t|
q=ny1tjj|td|}
t|
w=Wntk
rnXt}
x|j|D]\}}t|dkr>td|}
t|
t}
Pnt|dkrtdi|d6|d6}
t|
t}
PqqW|
rq=n|j|rtd|}
t|
ni}x'|j|D]\}}|||<qW|||<q=WqnW|S(swGet profiles found in profiles database.  Returns dictionary with
       profile name as key and tuples for fields
    s!Profiles directory does not existi
iis^\.t/sSkipping '%s': hidden files	.dpkg-news	.dpkg-olds
.dpkg-dists.rpmnews.rpmsavet~s
Skipping '%s'sSkipping '%s': couldn't statsSkipping '%s': too bigs*Skipping '%s': too many files read alreadysSkipping '%s': couldn't processi@sSkipping '%s': name too longsSkipping '%s': invalid names$Skipping '%s': also in /etc/servicessSkipping '%s': field too longs4Skipping '%(value)s': value too long for '%(field)s'tvaluetfields(Duplicate profile '%s', using last foundi(i(tostpathtisdirt_RtlistdirtsorttretcompiletisfiletsearchRtendswithtstattST_SIZEt	ExceptionRtConfigParsertRawConfigParsertreadtsectionstlentvalid_profile_nametufwtutiltget_services_prototFalsetitemstTruethas_key(tprofiles_dirterr_msgtmax_sizetprofilestfilest
total_sizetpattftabs_pathtsizetwarn_msgtcdicttptskiptkeyRtpdict((s4/usr/lib/python2.7/dist-packages/ufw/applications.pytget_profiless













	

cCsF|dkrtSyt|tSWnnXtjd|rBtStS(s0Only accept a limited set of characters for nametalls ^[a-zA-Z0-9][a-zA-Z0-9 _\-\.+]*$(RtintR
tmatchR (tname((s4/usr/lib/python2.7/dist-packages/ufw/applications.pyRs
cCs[dddg}x|D]y}|j|sXtdi|d6|d6}t|q||stdi|d6|d6}t|qqW|djd}t|d	krtd
|}tSyOxH|D]@}tjj|\}}tj	j
d||}	t|	qWWn9tk
rV}
t|
td|}t|nXt
S(
s'Make sure profile has everything neededttitletdescriptiontportss/Profile '%(fn)s' missing required field '%(f)s'tfnR)s1Profile '%(fn)s' has empty required field '%(f)s't|isNo ports found in profile '%s'tACCEPTsInvalid ports in profile '%s'(R!R
RtsplitRRRRtparse_port_prototcommontUFWRuleRRR (R6tprofilet
app_fieldsR)R#R9R.tporttprototrulete((s4/usr/lib/python2.7/dist-packages/ufw/applications.pytverify_profiles0
	
	

cCs6d}d}|j|r2||r2||}n|S(s#Retrieve the title from the profiletR7(R!(RAtsR((s4/usr/lib/python2.7/dist-packages/ufw/applications.pyt	get_titles

cCs6d}d}|j|r2||r2||}n|S(s)Retrieve the description from the profileRHR8(R!(RARIR((s4/usr/lib/python2.7/dist-packages/ufw/applications.pytget_descriptions

cCs?g}d}|j|r;||r;||jd}n|S(s'Retrieve a list of ports from a profileR9R;(R!R=(RAR9R((s4/usr/lib/python2.7/dist-packages/ufw/applications.pyt	get_portss
(t__doc__RRR
Rtufw.utilRRRt
ufw.commonRR2RRGRJRKRL(((s4/usr/lib/python2.7/dist-packages/ufw/applications.pyt<module>s	o		#