ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/usr/lib64/python2.7/site-packages/seobject/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/usr/lib64/python2.7/site-packages/seobject/__init__.pyc

�
4��]c@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlTdZddl
Z
ddl
mZmZmZe�ddlmZddlZejed�eje�yejededd	�WnMek
r?ejedd	�n*ek
rhddlZeejd
<nXeaddlZiZe ed<e ed<e ed
<e!ed<e!ed<e!ed<e"ed<e"ed<e"ed<e#ed<e#ed<e#ed<e$ed<e$ed<e$ed<e%ed<e%ed<e%ed<e&ed<e&ed<e&ed<e'ed <e'ed!<e'ed"<id
d6dd6dd6dd6dd6dd6dd6d d"6Z(i	d#d6d#d
6d$d6d%d6d&d6d'd6d(d6d)d 6dd6Z)y6ddl*Z*e*j+e*j,��d*fd+��YZ-Wn&e.k
rRZ/d*fd,��YZ-nXd-fd.��YZ0d/�Z1d0d1�Z2d0d2�Z3d3fd4��YZ4d5e4fd6��YZ5d7e4fd8��YZ6d9e4fd:��YZ7d;e4fd<��YZ8d=e4fd>��YZ9d?e4fd@��YZ:dAe4fdB��YZ;dCe4fdD��YZ<dEe4fdF��YZ=dGe4fdH��YZ>dIe4fdJ��YZ?dKe4fdL��YZ@dS(Mi����N(t*tpolicycoreutils(tboolean_desctboolean_categoryt
gen_bool_dict(tIPs/usr/share/localetunicodetcodesetsutf-8t_ts	all filestasregular files--tfs-dt	directorytds-cscharacter devicetcs-bsblock devicetbs-stsockettss-ltls
symbolic linktps-ps
named pipetanytblocktchartdirtfiletsymlinktpipetloggercBs_eZd�Zdddddddd�Zdddddddd�Zd�Zd�ZRS(cCs%tj�|_g|_g|_dS(N(tauditt
audit_opentaudit_fdtlog_listtlog_change_list(tself((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt__init__os	R	c	
Cs�d}	||kr)||	d7}d}	n||krL||	d7}d}	n||kro||	d7}d}	n|jj|jtjtjdt|�|d||||||dddg�dS(Nt-tsenamet,troletrangeiR	(RtappendRRtAUDIT_ROLE_ASSIGNtsystargvtstr(
R!tmsgtnameR$tseroletseranget	oldsenamet	oldserolet
oldserangetsep((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytlogts			c		CsT|jj|jtjtjdt|�|d||||||dddg�dS(NiR	(RR(RRtAUDIT_ROLE_REMOVER*R+R,(	R!R-R.R$R/R0R1R2R3((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt
log_remove�scCs5|jj|jtjt|�ddddg�dS(NtsemanageR	(R R(RRtAUDIT_USER_MAC_CONFIG_CHANGER,(R!R-((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt
log_change�scCsfx%|jD]}tj||g�q
Wx%|jD]}tj||g�q2Wg|_g|_dS(N(RRtaudit_log_semanage_messageR taudit_log_user_comm_message(R!tsuccessR((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytcommit�s	(t__name__t
__module__R"R5R7R:R>(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRns
		cBs_eZd�Zdddddddd�Zdddddddd�Zd�Zd�ZRS(cCs
g|_dS(N(R(R!((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"�sR	c	
Cs�d||f}	|dkr-|	d|7}	n|dkrJ|	d|7}	n|dkrg|	d|7}	n|dkr�|	d|7}	n|dkr�|dkr�|	d|7}	n|dkr�|dkr�|	d|7}	n|jj|	�dS(	Ns %s name=%sR	s sename=s oldsename=s role=s
 old_role=s
 MLSRange=s old_MLSRange=(tNoneRR((
R!R-R.R$R/R0R1R2R3tmessage((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR5�sc			Cs&|j||||||||�dS(N(R5(	R!R-R.R$R/R0R1R2R3((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR7�scCs|jjd|�dS(Ns %s(RR((R!R-((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR:�scCsJ|dkrd}nd}x(|jD]}tjtj||�q%WdS(NisSuccessful: sFailed: (RtsyslogtLOG_INFO(R!R=RBR((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR>�s
	(R?R@R"R5R7R:R>(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s
		t
nullloggercBsVeZdddddddd�Zdddddddd�Zd�Zd�ZRS(R	c		CsdS(N((	R!R-R.R$R/R0R1R2R3((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR5�sc		CsdS(N((	R!R-R.R$R/R0R1R2R3((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR7�scCsdS(N((R!R-((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR:�scCsdS(N((R!R=((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR>�s(R?R@R5R7R:R>(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRE�s	cCsfd}d}|d|d}|d|d}|d|dd|d}tjd	|d
|�S(Nss[0-9]*sc[0-9]*s(\.s)?s(\,s)*s(-s(:t^t$(tretsearch(trawtsensitivitytcategoryt	cat_ranget
categoriestreg((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytvalidate_level�sicCs�d}|dkr%d||f}n|}tj|�\}}|dkrP|S|ri|t|�}n|dkry|S|SdS(Nsa:b:c:is%s%siR	(tselinuxtselinux_raw_to_trans_contexttlen(RJtprependtfillertcontexttrcttrans((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt	translate�scCs�d}|dkr%d||f}n|}tj|�\}}|dkrP|S|ri|t|�}n|dkry|S|SdS(Nsa:b:c:is%s%siR	(RQtselinux_trans_to_raw_contextRS(RXRTRURVRWRJ((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytuntranslate�stsemanageRecordscBskeZeZd	Zd	Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd�ZRS(
cCsdt|_|j|�|_tj�\}}|dksE||krTt�|_nt�|_dS(NR	(	tFalsetnoreloadt
get_handletshRQtselinux_getpolicytypeRtmylogRE(R!tstoreRWt
localstore((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"�s	cCs|st|_ndS(N(tTrueR^(R!tload((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt
set_reload�scCsFtjrtjSt�}|s4ttd���ntjrf|dkrft||t�|t_nt	|�s�t
|�ttd���nt|�}|tkr�t
|�ttd���nt
|�}|dkr�t
|�ttd���nt|�atdkr6t
|�ttd���n|t_tjS(Ns Could not create semanage handleR	s:SELinux policy is not managed or store cannot be accessed.sCannot read policy store.is'Could not establish semanage connections!Could not test MLS enabled status(R\thandletsemanage_handle_createt
ValueErrorRttransactiontsemanage_select_storetSEMANAGE_CON_DIRECTRctsemanage_is_managedtsemanage_handle_destroytsemanage_access_checktSEMANAGE_CAN_READtsemanage_connecttsemanage_mls_enabledtis_mls_enabled(R!RcRhRW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR_�s2		



	cCsttd���dS(NsNot yet implemented(RjR(R!((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt	deleteall"scCs5tjrttd���n|j�tt_dS(Ns(Semanage transaction already in progress(R\RkRjRtbeginRe(R!((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytstart%s	
cCsAtjr
dSt|j�}|dkr=ttd���ndS(Nis$Could not start semanage transaction(R\Rktsemanage_begin_transactionR`RjR(R!RW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRv+s
	cCsttd���dS(NsNot yet implemented(RjR(R!((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt
customized2scCs}tjr
dS|jr)t|jd�nt|j�}|dkri|jjd�tt	d���n|jjd�dS(Nis%Could not commit semanage transactioni(
R\RkR^tsemanage_set_reloadR`tsemanage_commitRbR>RjR(R!RW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR>5s		cCs5tjsttd���ntt_|j�dS(Ns$Semanage transaction not in progress(R\RkRjRR]R>(R!((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytfinishAs		N(R?R@R]RkRARhRcR"RgR_RuRwRvRyR>R|(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR\�s			$					t
moduleRecordscBs_eZd�Zd�Zd�Zeed�Zd�Zd�Z	d�Z
d�Zd�ZRS(	cCstj||�dS(N(R\R"(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"JscCs�g}t|j�\}}}|dkr?ttd���nx t|�D]}t||�}t|j|�\}}|dkr�ttd���nt|j|�\}}|dkr�ttd���nt|j|�\}}	|dkrttd���nt	|j|�\}}
|dkrEttd���n|j
|||	|
f�qLW|jdd�d	t�|jdd
��|S(NisCould not list SELinux modulessCould not get module namesCould not get module enabledsCould not get module prioritysCould not get module lang_exttkeycSs|dS(Ni((tt((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt<lambda>istreversecSs|dS(Ni((R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�js(
tsemanage_module_list_allR`RjRR'tsemanage_module_list_nthtsemanage_module_info_get_namet semanage_module_info_get_enabledt!semanage_module_info_get_priorityt!semanage_module_info_get_lang_extR(tsortRe(R!RRWtmlisttnumbertitmodR.tenabledtprioritytlang_ext((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytget_allMs,cCsd|j�}t|�dkr"dSgg|D]}|ddkr,|^q,D]}d|d^qLS(Niis-d %s(R�RS(R!tALLRtx((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRymscCs�|j�}t|�dkr"dS|rOdtd�td�td�fGHnx`|D]X}|ddkr{td�}n|r�qVnd}d	|d|d
|d|fGHqVWdS(Nis
%-25s %-9s %s
sModule NametPrioritytLanguageitDisabledR	s%-25s %-9s %-5s %sii(R�RSR(R!theadingt	locallistR�Rtdisabled((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytlistss'
cCs�|sttd���ntjj|�sFttd�|��nt|j|�}|dkr}ttd�|��nt|j|�}|dkr�|j�ndS(NsYou did not define module name.sModule does not exists %s is3Invalid priority %d (needs to be between 1 and 999)(	RjRtostpathtexiststsemanage_set_default_priorityR`tsemanage_module_install_fileR>(R!tmoduleR�RW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytadd�scCs|sttd���nx�|j�D]�}t|j�\}}|dkrdttd���nt|j||�}|dkr�ttd���nt|j||�}|dkr(|r�ttd�|��q�ttd�|��q(q(W|j�dS(NsYou did not define module name.isCould not create module keysCould not set module key namesCould not enable module %ssCould not disable module %s(RjRtsplittsemanage_module_key_createR`tsemanage_module_key_set_nametsemanage_module_set_enabledR>(R!R�tenabletmRWR~((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytset_enabled�scCsZtjj|�s+ttd�|��nt|j|�}|dkrV|j�ndS(NsModule does not exists %s i(R�R�R�RjRR�R`R>(R!RRW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytmodify�s
cCs�|sttd���nt|j|�}|dkrRttd�|��nxW|j�D]I}t|j|�}|dkr_|dkr_ttd�|��q_q_W|j�dS(NsYou did not define module name.is3Invalid priority %d (needs to be between 1 and 999)i����s*Could not remove module %s (remove failed)(RjRR�R`R�tsemanage_module_removeR>(R!R�R�RWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytdelete�scCskgg|j�D]}|ddkr|^qD]}|d^q0}x|D]}|j|t�qMWdS(Nii(R�R�Re(R!RR�RR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�sF
(
R?R@R"R�RyReR]R�R�R�R�R�Ru(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR}Hs		 						tdontauditClasscBseZd�Zd�ZRS(cCstj||�dS(N(R\R"(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"�scCsQ|dkr!ttd���n|j�t|j|dk�}|j�dS(Ntontoffs'dontaudit requires either 'on' or 'off'(R�R�(RjRRvtsemanage_set_disable_dontauditR`R>(R!t	dontauditRW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyttoggle�s

(R?R@R"R�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s	tpermissiveRecordscBsDeZd�Zd�Zeed�Zd�Zd�Zd�Z	RS(cCstj||�dS(N(R\R"(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"�scCs�g}t|j�\}}}|dkr?ttd���nxat|�D]S}t||�}t|�}|rL|jd�rL|j|j	d�d�qLqLW|S(NisCould not list SELinux modulestpermissive_i(
tsemanage_module_listR`RjRR'R�tsemanage_module_get_namet
startswithR(R�(R!RRWR�R�R�R�R.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s!cCs�ggtjtj�D]}|dr|^qD]}|d^q0}t|�dkr\dS|j�}|r�dtd�GHnx|D]}|GHq�W|r�dS|r�dtd�GHnx"|D]}||kr�|GHq�q�WdS(Nt
permissiveR.is
%-25s
sCustomized Permissive TypessBuiltin Permissive Types(tsepolicytinfotTYPERSR�R(R!R�R�R�tyR�RyR((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��sF
	
cCs�ddl}|tj�kr7ttd�|��nyddlj}Wn#tk
rottd���nXd|}d|}t|j	|t
|�|d�}|dkr�|j�n|dkr�ttd�|��ndS(	Ni����s%s is not a domain types�The sepolgen python module is required to setup permissive domains.
In some distributions it is included in the policycoreutils-devel patckage.
# yum install policycoreutils-devel
Or similar for your distro.s
permissive_%ss(typepermissive %s)tcilis?Could not set permissive domain %s (module installation failed)(tglobR�tget_all_domainsRjRtsepolgen.moduleR�tImportErrortsemanage_module_installR`RSR>(R!tsetypeR�R�R.tmodtxtRW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s


!
cCs`xO|j�D]A}t|jd|�}|dkr
ttd�|��q
q
W|j�dS(Ns
permissive_%sis5Could not remove permissive domain %s (remove failed)(R�R�R`RjRR>(R!R.tnRW((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s
cCs;|j�}t|�dkr7|jdj|��ndS(Nit (R�RSR�tjoin(R!R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRus(
R?R@R"R�ReR]R�R�R�Ru(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s		
		tloginRecordscBs�eZdd�Zd�Zd�Zdd
d�Zdd
d�Zd�Zd�Z	d�Z
d	�Zed
�Z
d�Zeed�ZRS(R	cCs8tj||�d|_d|_d|_d|_dS(N(R\R"RAR1R3R$R0(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"s
			c
Cs�tj|�\}|_|_|dkr3d}nt�}|j|j�d\}}|j|�\}\}}	tdkr�|r�t|�}q�|}nt|j	|�\}}
|dkr�t
td�|��nt|j	|
�\}}|dkrt
td�|��n|r:t
|
�|j|||�S|ddkr�ytj|d�Wq�t
td�|d��q�Xn1ytj|�Wnt
td	�|��nXt|j	�\}}|dkr�t
td
�|��nt|j	||�}|dkr+t
td�|��n|rnt|j	||�}|dkrnt
td�|��qnnt|j	||�}|dkr�t
td
�|��nt|j	|
|�}|dkr�t
td�|��nt
|
�t|�dS(NR	tuser_uiisCould not create a key for %ss2Could not check if login mapping for %s is definedt%sLinux Group %s does not existsLinux User %s does not exists%Could not create login mapping for %ssCould not set name for %ssCould not set MLS range for %ss!Could not set SELinux user for %ss"Could not add login mapping for %s(RQtgetseuserbynameR1R3tseluserRecordstgetRtR[tsemanage_seuser_key_createR`RjRtsemanage_seuser_existstsemanage_seuser_key_freet_loginRecords__modifytgrptgetgrnamtpwdtgetpwnamtsemanage_seuser_createtsemanage_seuser_set_nametsemanage_seuser_set_mlsrangetsemanage_seuser_set_senametsemanage_seuser_modify_localtsemanage_seuser_free(
R!R.R$R0trectuserrecRWR2tRANGER/tkR�tu((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt__add s\			
!
cCsKy+|j�|j|||�|j�Wntk
rF}|�nXdS(N(Rvt_loginRecords__addR>Rj(R!R.R$R0terror((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�]s
c
CsWtj|�\}|_|_|dkrF|rFttd���nt�}|j|j�\}\}}|dkr�|j|�\}\}}	n|}	|r�||_n	||_t	|j
|�\}}
|dkr�ttd�|��nt|j
|
�\}}|dkr2ttd�|��n|sQttd�|��nt|j
|
�\}}|dkr�ttd�|��nt
|�|_t|�|_|r�t|j
|t|��n|dkr�t|j
||�||_n|j|_t|j
|
|�}|dkr?ttd�|��nt|
�t|�dS(	NR	sRequires seuser or serangeisCould not create a key for %ss2Could not check if login mapping for %s is defineds#Login mapping for %s is not definedsCould not query seuser for %ss%Could not modify login mapping for %s(RQR�R1R3RjRR�R�R0R�R`R�tsemanage_seuser_querytsemanage_seuser_get_mlsrangetsemanage_seuser_get_senameR�R[R�R$R�R�R�(
R!R.R$R0R�R�R�RWR2R/R�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt__modifyesF		
cCsKy+|j�|j|||�|j�Wntk
rF}|�nXdS(N(RvR�R>Rj(R!R.R$R0R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
c
Cs�tj|�\}|_|_t�}|j|j�\}\}}t|j|�\}}|dkr�tt	d�|��nt
|j|�\}}|dkr�tt	d�|��n|s�tt	d�|��nt|j|�\}}|dkrtt	d�|��n|s:tt	d�|��nt|j|�}|dkrqtt	d�|��nt
|�tjd�\}|_|_|j|j�\}\}}	dS(NisCould not create a key for %ss2Could not check if login mapping for %s is defineds#Login mapping for %s is not defineds<Login mapping for %s is defined in policy, cannot be deleteds%Could not delete login mapping for %st__default__(RQR�R1R3R�R�R�R`RjRR�tsemanage_seuser_exists_localtsemanage_seuser_del_localR�R$R0(
R!R.R�R�R�RWR2R�R�R/((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt__delete�s,	
cCsEy%|j�|j|�|j�Wntk
r@}|�nXdS(N(Rvt_loginRecords__deleteR>Rj(R!R.R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s

cCs�t|j�\}}|dkr6ttd���ny<|j�x!|D]}|jt|��qJW|j�Wntk
r�}|�nXdS(NisCould not list login mappings(tsemanage_seuser_list_localR`RjRRvR�tsemanage_seuser_get_nameR>(R!RWtulistR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s

cCs�i}tj�d|_x�tj|j�D]�\}}}||jkr,x�|D]v}y\t|d|�}|j�j�jd�}|j	�|d|d|df||<WqQt
k
r�qQXqQWq,q,W|S(Ns/loginst/t:iii(RQtselinux_policy_roottlogins_pathR�twalktopentreadtrstripR�tcloset
IndexError(R!tddictR�tdirstfilesR.tfdR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytget_all_logins�s"

#
cCs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx<|jD]1}t|�}t|�t|�df||<qjW|S(NisCould not list login mappingsR(	R�R`R�tsemanage_seuser_listRjRR�R�R�(R!R�R�RWR�R.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s#cCs�g}|jt�}t|j��}|j�xh|D]`}||dry|jd||d||d|f�q8|jd||d|f�q8W|S(Nis-a -s %s -r '%s' %sis-a -s %s %s(R�ReR�tkeysR�R((R!RR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRy�s

-#c	Cs�|j|�}|j�}t|j��}t|j��}t|�dkrgt|�dkrgdS|j�|j�tdkr_|r�dtd�td�td�td�fGHnx?|D]7}||}d||dt|d�|d	fGHq�Wt|�rd
|j	GHnx�|D]7}||}d||dt|d�|d	fGHq!WnL|r�dtd�td�fGHnx%|D]}d|||dfGHq�WdS(
Niis
%-20s %-20s %-20s %s
s
Login NamesSELinux Users
MLS/MCS RangetServices%-20s %-20s %-20s %sis
Local customization in %ss

%-25s %-25s
s%-25s %-25s(
R�R�R�R�RSR�RtRRYR�(	R!R�R�R�tldicttlkeysR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s.$

0

+

.
N(R?R@R"R�R�RAR�R�R�R�RuR�R]R�RyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s	=	2				
		R�cBs�eZdd�Zd�Zd�Zd�Zgdd
dd�Zgdd
dd�Zd�Z	d�Z
d	�Zed
�Z
d�Zeed�ZRS(R	cCstj||�dS(N(R\R"(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"scCs�t|j|�\}}|dkr=ttd�|��nt|j|�\}}|dkrzttd�|��nt|j|�\}}|dkr�ttd�|��nt|�}t|j|�}t|�t	|�||fS(NisCould not create a key for %ss-Could not check if SELinux user %s is definedsCould not query user for %s(
tsemanage_user_key_createR`RjRtsemanage_user_existstsemanage_user_querytsemanage_user_get_mlsrangetsemanage_user_get_rolestsemanage_user_key_freetsemanage_user_free(R!R.RWR�R�R�R0R/((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s

cCsktdkrK|r!t|�}nd}|dkr<d}qKt|�}nt|�dkrvttd�|��nt|j|�\}}|dkr�ttd�|��nt|j|�\}}|dkr�ttd�|��n|rt|�|j	|||||�St
|j�\}}	|dkrSttd�|��nt|j|	|�}|dkr�ttd	�|��nxV|D]N}
t|j|	|
�}|dkr�ttd
�i|
d6|d6��q�q�Wtdkrit
|j|	|�}|dkr,ttd
�|��nt|j|	|�}|dkrittd�|��qint|j|	|�}|dkr�ttd�i|
d6|d6��nt|j|	�\}}|dkr�ttd�|��nt|j||	�}|dkr(ttd�|��nt|�t|	�|jjdd|ddj|�d|�dS(Nits0R	s%You must add at least one role for %sisCould not create a key for %ss-Could not check if SELinux user %s is defineds$Could not create SELinux user for %ssCould not set name for %ss(Could not add role %(ROLE)s for %(NAME)stROLEtNAMEsCould not set MLS range for %ssCould not set MLS level for %ss,Could not add prefix %(PREFIX)s for %(ROLE)stPREFIXsCould not extract key for %ssCould not add SELinux user %stseuserR$R/R%R0(RtR[RSRjRRR`RRt_seluserRecords__modifytsemanage_user_createtsemanage_user_set_nametsemanage_user_add_roletsemanage_user_set_mlsrangetsemanage_user_set_mlsleveltsemanage_user_set_prefixtsemanage_user_key_extracttsemanage_user_modify_localRRbR5R�(R!R.trolestselevelR0tprefixRWR�R�R�trR~((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�,s^	

+'

cCsay1|j�|j|||||�|j�Wn)tk
r\}|jjd�|�nXdS(Ni(Rvt_seluserRecords__addR>RjRb(R!R.RRR0RR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�js
cCs+d}d}dj|�}|dkr�t|�dkr�|r�|dkr�tdkrmttd���q�ttd���nt|j|�\}	}
|	dkr�ttd�|��nt|j|
�\}	}|	dkr�ttd�|��n|sttd	�|��nt|j|
�\}	}|	dkrXttd
�|��nt	|�}t
|j|�\}	}
|	dkr�dj|
�}n|r�t|j|t|��n|dkr�t
|j|t|��n|dkrt|j||�nt|�dkr{x*|
D]"}||krt||�qqWx3|D](}||
krLt|j||�qLqLWnt|j|
|�}	|	dkr�ttd�|��nt|
�t|�dj|j��}dj|j��}|jjd
d|d|d|d|d|d|�dS(NR	R�iis&Requires prefix, roles, level or rangesRequires prefix or rolessCould not create a key for %ss-Could not check if SELinux user %s is definedsSELinux user %s is not definedsCould not query user for %ss Could not modify SELinux user %sR%R
R$R1R/R0R2R3(R�RSRtRjRRR`RRRRRR[RRtsemanage_user_del_roleRRRRR�RbR5(R!R.RRR0RR2R3tnewrolesRWR�R�R�trlistRR&((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�ssV1



cCsay1|j�|j|||||�|j�Wn)tk
r\}|jjd�|�nXdS(Ni(RvRR>RjRb(R!R.RRR0RR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
c	Cs�t|j|�\}}|dkr=ttd�|��nt|j|�\}}|dkrzttd�|��n|s�ttd�|��nt|j|�\}}|dkr�ttd�|��n|s�ttd�|��nt|j|�\}}|dkr2ttd�|��nt|�}t|j|�\}}dj	|�}t
|j|�}|dkr�ttd�|��nt|�t|�|j
jd	d
|d|d|�dS(
NisCould not create a key for %ss-Could not check if SELinux user %s is definedsSELinux user %s is not defineds7SELinux user %s is defined in policy, cannot be deletedsCould not query user for %sR%s Could not delete SELinux user %sR
R1R3R2(RR`RjRRtsemanage_user_exists_localRRRR�tsemanage_user_del_localRRRbR7(	R!R.RWR�R�R�R3RR2((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s2

cCsUy%|j�|j|�|j�Wn)tk
rP}|jjd�|�nXdS(Ni(Rvt_seluserRecords__deleteR>RjRb(R!R.R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s

cCs�t|j�\}}|dkr6ttd���nyW|j�x<|D]4}y|jt|��WqJtk
r}qJqJXqJW|j�Wn)tk
r�}|j	jd�|�nXdS(NisCould not list login mappings(
tsemanage_user_list_localR`RjRRvR!tsemanage_user_get_nametOSErrorR>Rb(R!RWR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s


cCs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}t|�}t|j|�\}}|dkr�ttd�|��ndj|�}t	|�t
|�t|�|f|t|�<qjW|S(NisCould not list SELinux userss Could not list roles for user %sR�(R"R`R�tsemanage_user_listRjRR#RR�tsemanage_user_get_prefixtsemanage_user_get_mlslevelR(R!R�R�RWR�R.RR((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s2cCs�g}|jt�}t|j��}|j�x�|D]y}||dsZ||dr�|jd||d||d||d|f�q8|jd||d|f�q8W|S(Niis-a -L %s -r %s -R '%s' %sis
-a -R '%s' %s(R�ReR�R�R�R((R!RR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRys

8#cCs[|j|�}t|j��}t|�dkr7dS|j�tdkr|r�ddtd�td�td�fGHdtd�td	�td
�td�td�fGHnx�|D]J}d
|||dt||d�t||d�||dfGHq�WnL|r/dtd�td�fGHnx%|D]}d|||dfGHq6WdS(Niis
%-15s %-10s %-10s %-30sR	tLabelingsMLS/s%-15s %-10s %-10s %-30s %s
sSELinux UsertPrefixs	MCS Levels	MCS Ranges
SELinux Roless%-15s %-10s %-10s %-30s %siis	%-15s %s
s%-15s %s(R�R�R�RSR�RtRRY(R!R�R�R�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s
'9
K
N(R?R@R"R�RR�RARR�R!R�RuR]R�RyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s		>		9		!	
		tportRecordscBs�eZgZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zed
�Z
ed�Zd�Zeed
�ZRS(R	cCsLtj||�y$tjtjd�dd|_Wntk
rGnXdS(Nt	port_typeittypes(R\R"R�R�t	ATTRIBUTEtvalid_typestRuntimeError(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"'s
$
c	Cs7|dkrt}n'|dkr*t}nttd���|dkr]ttd���n|jd�}t|�dkr�t|d�}}n t|d�}t|d�}|d	kr�ttd
���nt|j|||�\}}|dkr'ttd�i|d6|d
6��n||||fS(NttcptudpsProtocol udp or tcp is requiredR	sPort is requiredR#iii��sInvalid Ports1Could not create a key for %(PROTOTYPE)s/%(PORT)st	PROTOTYPEtPORT(	tSEMANAGE_PROTO_TCPtSEMANAGE_PROTO_UDPRjRR�RStinttsemanage_port_key_createR`(	R!tporttprototproto_dtportsthightlowRWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt__genkey.s$		'c
Cs�tdkr*|r!t|�}q*d}n|dkrKttd���ntj|�|jkr|ttd�|��n|j||�\}}}}tj	r�t
|j|�\}	}
nt|j|�\}	}
|	dkr	ttd�i|d6|d	6��n|
r6ttd
�i|d6|d	6��nt
|j�\}	}|	dkr~ttd�i|d6|d	6��nt||�t|||�t|j�\}	}|	dkr�ttd�i|d6|d	6��nt|j|d
�}	|	dkr+ttd�i|d6|d	6��nt|j|d�}	|	dkrsttd�i|d6|d	6��nt|j||�}	|	dkr�ttd�i|d6|d	6��n|rt|j||�}	|	dkrttd�i|d6|d	6��qnt|j||�}	|	dkrTttd�i|d6|d	6��nt|j||�}	|	dkr�ttd�i|d6|d	6��nt|�t|�t|�|jjd|tj|�d
d||f�dS(NiR	R	sType is requireds'Type %s is invalid, must be a port typeis8Could not check if port %(PROTOCOL)s/%(PORT)s is definedtPROTOCOLR3s*Port %(PROTOCOL)s/%(PORT)s already defineds/Could not create port for %(PROTOCOL)s/%(PORT)ss2Could not create context for %(PROTOCOL)s/%(PORT)stsystem_us<Could not set user in port context for %(PROTOCOL)s/%(PORT)stobject_rs<Could not set role in port context for %(PROTOCOL)s/%(PORT)ss<Could not set type in port context for %(PROTOCOL)s/%(PORT)ssBCould not set mls fields in port context for %(PROTOCOL)s/%(PORT)ss4Could not set port context for %(PROTOCOL)s/%(PORT)ss(Could not add port %(PROTOCOL)s/%(PORT)ss8resrc=port op=add lport=%s proto=%s tcontext=%s:%s:%s:%s(RtR[RjRR�tget_real_type_nameR.t_portRecords__genkeyR\Rktsemanage_port_exists_localR`tsemanage_port_existstsemanage_port_createtsemanage_port_set_prototsemanage_port_set_rangetsemanage_context_createtsemanage_context_set_usertsemanage_context_set_roletsemanage_context_set_typetsemanage_context_set_mlstsemanage_port_set_contsemanage_port_modify_localtsemanage_context_freetsemanage_port_key_freetsemanage_port_freeRbR:Rtgetprotobyname(
R!R8R9R0ttypeR�R:R=R<RWR�Rtcon((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�Hs^		'''
''''*''


cCs.|j�|j||||�|j�dS(N(Rvt_portRecords__addR>(R!R8R9R0RT((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
c

CsF|rI|dkrItdkr4ttd���qIttd���n|r�tj|�|jkr�ttd�|��n|j||�\}}}}t|j|�\}	}
|	dkr�ttd�i|d6|d	6��n|
sttd
�i|d6|d	6��nt	|j|�\}	}|	dkrattd�i|d6|d	6��nt
|�}|r�t|j|t|��nd}|dkr�t
|j||�nt|j||�}	|	dkr�ttd
�i|d6|d	6��nt|�t|�|jjd|tj|�dd||f�dS(NR	isRequires setype or serangesRequires setypes1Type %s is invalid, must be a file or device typeis9Could not check if port @%(PROTOCOL)s/%(PORT)s is definedR?R3s*Port @%(PROTOCOL)s/%(PORT)s is not defineds*Could not query port %(PROTOCOL)s/%(PORT)sR	s+Could not modify port %(PROTOCOL)s/%(PORT)ss;resrc=port op=modify lport=%s proto=%s tcontext=%s:%s:%s:%sR@RA(RtRjRR�RBR.RCRER`tsemanage_port_querytsemanage_port_get_conRMR[RLRORQRRRbR:RRS(
R!R8R9R0R�R�R:R=R<RWR�RRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s6''''

cCs.|j�|j||||�|j�dS(N(Rvt_portRecords__modifyR>(R!R8R9R0R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs[t|j�\}}|dkr6ttd���n|j�x
|D]}t|�}t|�}t|�}t|�}d||f}|j	||�\}	}
}}|dkr�ttd�|��nt
|j|	�}|dkrttd�|��nt|	�||kr&|}n|jj
d|tj|�f�qGW|j�dS(NisCould not list the portss%s-%ssCould not create a key for %ssCould not delete the port %ss&resrc=port op=delete lport=%s proto=%s(tsemanage_port_list_localR`RjRRvtsemanage_port_get_prototsemanage_port_get_proto_strtsemanage_port_get_lowtsemanage_port_get_highRCtsemanage_port_del_localRQRbR:RRSR>(R!RWtplistR8R9t	proto_strR=R<tport_strR�R:((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s*


	'c	Cs�|j||�\}}}}t|j|�\}}|dkrittd�i|d6|d6��n|s�ttd�i|d6|d6��nt|j|�\}}|dkr�ttd�i|d6|d6��n|sttd�i|d6|d6��nt|j|�}|dkrSttd�i|d6|d6��nt|�|jj	d|t
j|�f�dS(	Nis8Could not check if port %(PROTOCOL)s/%(PORT)s is definedR?R3s)Port %(PROTOCOL)s/%(PORT)s is not definedsBPort %(PROTOCOL)s/%(PORT)s is defined in policy, cannot be deleteds+Could not delete port %(PROTOCOL)s/%(PORT)ss&resrc=port op=delete lport=%s proto=%s(RCRER`RjRRDR_RQRbR:RRS(	R!R8R9R�R:R=R<RWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s '''''
cCs(|j�|j||�|j�dS(N(Rvt_portRecords__deleteR>(R!R8R9((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx~|jD]s}t|�}t|�}t|�}t	|�}t
|�}	t|�}
t|�}||f||
||	f<qjW|S(NisCould not list ports(
RZR`R`tsemanage_port_listRjRRXtsemanage_context_get_typetsemanage_context_get_mlsR[R\R]R^(R!R�R�RWR8RUtctypetlevelR9RaR=R<((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s cCs<i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}t|�}t|�}t|�}t	|�}t
|�}	t|�}
||ft|j
��kr�g|||f<n|	|
kr|||fjd|	�qj|||fjd|	|
f�qjW|S(NisCould not list portss%ds%d-%d(RZR`R`RdRjRRXReR[R\R]R^R�R�R((R!R�R�RWR8RURgR9RaR=R<((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytget_all_by_types&%cCs�g}|jt�}t|j��}|j�x�|D]�}|d|dkr\|dnd|d|df}||dr�|jd||d||d|d|f�q8|jd||d|d|f�q8W|S(Niis%s-%ss-a -t %s -r '%s' -p %s %sis-a -t %s -p %s %s(R�ReR�R�R�R((R!RR�R�R�R8((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRys

64*cCs�|j|�}t|j��}t|�dkr7dS|j�|rndtd�td�td�fGHnxZ|D]R}d|}|d||d7}x$||dD]}|d	|7}q�W|GHquWdS(
Nis%-30s %-8s %s
sSELinux Port TypetProtosPort Numbers%-30s %-8s s%sis, %s(RiR�R�RSR�R(R!R�R�R�R�R�R�R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�,s
'

(R?R@R.R"RCRVR�RYR�RuRcR�R]R�RiRyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR*$s		@		(					t
ibpkeyRecordscBs�eZgZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
d�Zd
d�Z
d
�Zdd
d�ZRS(R	cCsRtj||�y4td�tjtjd�ddD��|_WnnXdS(Ncss|]}t|�VqdS(N(R,(t.0R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pys	<genexpr>Bstibpkey_typeiR,(R\R"tsetR�R�R-R.(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"?s
4cCs�|dkr!ttd���n|jd�}t|�dkr\t|dd�}}n&t|dd�}t|dd�}|dkr�ttd���nt|j|||�\}}|dkr�ttd�||f��n||||fS(	NR	sSubnet Prefix is requiredR#iii��sInvalid Pkeys Could not create a key for %s/%s(RjRR�RSR6tsemanage_ibpkey_key_createR`(R!tpkeyt
subnet_prefixtpkeysR<R=RWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR>FscCshtdkr0|dkr!d}q0t|�}n|dkrQttd���ntj|�|jkr�ttd�|��n|j||�\}}}}t|j	|�\}}	|dkr�ttd�||f��n|	rttd�||f��nt
|j	�\}}
|dkrHttd	�||f��nt|j	|
|�t|
||�t
|j	�\}}|dkr�ttd
�||f��nt|j	|d�}|dkr�ttd�||f��nt|j	|d
�}|dkr+ttd�||f��nt|j	||�}|dkrkttd�||f��ntdkr�|dkr�t|j	||�}|dkr�ttd�||f��q�nt|j	|
|�}|dkrttd�||f��nt|j	||
�}|dkrFttd�||f��nt|�t|�t|
�dS(NiR	R	sType is requireds)Type %s is invalid, must be a ibpkey typeis*Could not check if ibpkey %s/%s is definedsibpkey %s/%s already defineds!Could not create ibpkey for %s/%ss"Could not create context for %s/%sR@s.Could not set user in ibpkey context for %s/%sRAs.Could not set role in ibpkey context for %s/%ss.Could not set type in ibpkey context for %s/%ss4Could not set mls fields in ibpkey context for %s/%ss&Could not set ibpkey context for %s/%ssCould not add ibpkey %s/%s(RtR[RjRR�RBR.t_ibpkeyRecords__genkeytsemanage_ibpkey_existsR`tsemanage_ibpkey_createt!semanage_ibpkey_set_subnet_prefixtsemanage_ibpkey_set_rangeRIRJRKRLRMtsemanage_ibpkey_set_contsemanage_ibpkey_modify_localRPtsemanage_ibpkey_key_freetsemanage_ibpkey_free(R!RpRqR0RTR�R=R<RWR�RRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�YsX	"

cCs.|j�|j||||�|j�dS(N(Rvt_ibpkeyRecords__addR>(R!RpRqR0RT((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs|dkrN|dkrNtdkr9ttd���qNttd���n|r�tj|�|jkr�ttd�|��n|j||�\}}}}t|j|�\}}	|dkr�ttd�||f��n|	sttd�||f��nt	|j|�\}}
|dkrNttd	�||f��nt
|
�}tdkr�|dkr�t|j|t|��n|dkr�t
|j||�nt|j||
�}|dkr�ttd
�||f��nt|�t|
�dS(NR	isRequires setype or serangesRequires setypes)Type %s is invalid, must be a ibpkey typeis*Could not check if ibpkey %s/%s is definedsibpkey %s/%s is not definedsCould not query ibpkey %s/%ssCould not modify ibpkey %s/%s(RtRjRR�RBR.RsRtR`tsemanage_ibpkey_querytsemanage_ibpkey_get_conRMR[RLRyRzR{(R!RpRqR0R�R�R=R<RWR�RRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s2
cCs.|j�|j||||�|j�dS(N(Rvt_ibpkeyRecords__modifyR>(R!RpRqR0R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
c	Cs#t|j�\}}|dkr6ttd���n|j�x�|D]�}t|j|�\}}t|�}t|�}d||f}|j||�\}}}}|dkr�ttd�|��nt	|j|�}|dkrttd�|��nt
|�qGW|j�dS(NisCould not list the ibpkeyss%s-%ssCould not create a key for %ssCould not delete the ibpkey %s(tsemanage_ibpkey_list_localR`RjRRvt!semanage_ibpkey_get_subnet_prefixtsemanage_ibpkey_get_lowtsemanage_ibpkey_get_highRstsemanage_ibpkey_del_localRzR>(	R!RWR`tibpkeyRqR=R<tpkey_strR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s"

cCs9|j||�\}}}}t|j|�\}}|dkrattd�||f��n|s�ttd�||f��nt|j|�\}}|dkr�ttd�||f��n|s�ttd�||f��nt|j|�}|dkr+ttd�||f��nt|�dS(Nis*Could not check if ibpkey %s/%s is definedsibpkey %s/%s is not defineds4ibpkey %s/%s is defined in policy, cannot be deletedsCould not delete ibpkey %s/%s(RsRtR`RjRtsemanage_ibpkey_exists_localR�Rz(R!RpRqR�R=R<RWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��scCs(|j�|j||�|j�dS(N(Rvt_ibpkeyRecords__deleteR>(R!RpRq((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
icCs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}t|�}t|�}|dkr�qjnt|�}t	|j|�\}}t
|�}	t|�}
||f||	|
|f<qjW|S(NisCould not list ibpkeystreserved_ibpkey_t(R�R`R`tsemanage_ibpkey_listRjRR~ReRfR�R�R�(R!R�R�RWR�RURgRhRqR=R<((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s"c
Cs6i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}t|�}t|�}t|j|�\}}t	|�}t
|�}	||f|j�kr�g|||f<n||	kr
|||fjd|�qj|||fjd||	f�qjW|S(NisCould not list ibpkeyss0x%xs	0x%x-0x%x(
R�R`R`R�RjRR~ReR�R�R�R�R((
R!R�R�RWR�RURgRqR=R<((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRis$%cCs�g}|jt�}|j�}|j�x�|D]�}|d|dkrV|dnd|d|df}||dr�|jd||d||d|d|f�q2|jd||d|d|f�q2W|S(Niis%s-%ss-a -t %s -r '%s' -x %s %sis-a -t %s -x %s %s(R�ReR�R�R((R!RR�R�R�R8((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRys

64*icCs�|j|�}|j�}t|�dkr1dS|j�|rhdtd�td�td�fGHnxZ|D]R}d|}|d||d7}x$||dD]}|d	|7}q�W|GHqoWdS(
Nis%-30s %-18s %s
sSELinux IB Pkey Typet
Subnet_PrefixsPkey Numbers%-30s %-18s s%sis, %s(RiR�RSR�R(R!R�R�R�R�R�R�R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�,s
'

(R?R@R.R"RsR|R�RR�RuR�R�R�RiRyR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRk<s		<		$					
tibendportRecordscBs�eZgZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
d�Zd
d�Z
d
�Zdd
d�ZRS(R	cCsRtj||�y4td�tjtjd�ddD��|_WnnXdS(Ncss|]}t|�VqdS(N(R,(RlR((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pys	<genexpr>Bstibendport_typeiR,(R\R"RnR�R�R-R.(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"?s
4cCs�|dkr!ttd���nt|�}|dksE|dkrZttd���nt|j||�\}}|dkr�ttd�||f��n|||fS(NR	sIB device name is requiredi�isInvalid Port Numberis*Could not create a key for ibendport %s/%s(RjRR6tsemanage_ibendport_key_createR`(R!t	ibendportt
ibdev_nameR8RWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR>FscCsbtdkr0|dkr!d}q0t|�}n|dkrQttd���ntj|�|jkr�ttd�|��n|j||�\}}}t|j	|�\}}|dkr�ttd�||f��n|rttd�||f��nt
|j	�\}}	|dkrEttd	�||f��nt|j	|	|�t|	|�t
|j	�\}}
|dkr�ttd
�||f��nt|j	|
d�}|dkr�ttd�||f��nt|j	|
d
�}|dkr%ttd�||f��nt|j	|
|�}|dkrettd�||f��ntdkr�|dkr�t|j	|
|�}|dkr�ttd�||f��q�nt|j	|	|
�}|dkrttd�||f��nt|j	||	�}|dkr@ttd�||f��nt|
�t|�t|	�dS(NiR	R	sType is requireds-Type %s is invalid, must be an ibendport typeis-Could not check if ibendport %s/%s is definedsibendport %s/%s already defineds$Could not create ibendport for %s/%ss"Could not create context for %s/%sR@s1Could not set user in ibendport context for %s/%sRAs1Could not set role in ibendport context for %s/%ss1Could not set type in ibendport context for %s/%ss7Could not set mls fields in ibendport context for %s/%ss)Could not set ibendport context for %s/%ssCould not add ibendport %s/%s(RtR[RjRR�RBR.t_ibendportRecords__genkeytsemanage_ibendport_existsR`tsemanage_ibendport_createt!semanage_ibendport_set_ibdev_nametsemanage_ibendport_set_portRIRJRKRLRMtsemanage_ibendport_set_contsemanage_ibendport_modify_localRPtsemanage_ibendport_key_freetsemanage_ibendport_free(R!R�R�R0RTR�R8RWR�RRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�TsX	
"

cCs.|j�|j||||�|j�dS(N(Rvt_ibendportRecords__addR>(R!R�R�R0RT((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs|dkrN|dkrNtdkr9ttd���qNttd���n|r�tj|�|jkr�ttd�|��n|j||�\}}}t|j|�\}}|dkr�ttd�||f��n|sttd�||f��nt	|j|�\}}	|dkrKttd	�||f��nt
|	�}
tdkr�|dkr�t|j|
t|��n|dkr�t
|j|
|�nt|j||	�}|dkr�ttd
�||f��nt|�t|	�dS(NR	isRequires setype or serangesRequires setypes-Type %s is invalid, must be an ibendport typeis-Could not check if ibendport %s/%s is definedsibendport %s/%s is not definedsCould not query ibendport %s/%ss Could not modify ibendport %s/%s(RtRjRR�RBR.R�R�R`tsemanage_ibendport_querytsemanage_ibendport_get_conRMR[RLR�R�R�(R!R�R�R0R�R�R8RWR�RRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s2
cCs.|j�|j||||�|j�dS(N(Rvt_ibendportRecords__modifyR>(R!R�R�R0R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCst|j�\}}|dkr6ttd���n|j�x�|D]�}t|j|�\}}t|�}|jt|�|�\}}}|dkr�ttd�t	|f��nt
|j|�}|dkr�ttd�||f��nt|�qGW|j�dS(NisCould not list the ibendportss Could not create a key for %s/%ds$Could not delete the ibendport %s/%d(
tsemanage_ibendport_list_localR`RjRRvt!semanage_ibendport_get_ibdev_nametsemanage_ibendport_get_portR�R,t	ibdevnametsemanage_ibendport_del_localR�R>(R!RWR`R�R�R8R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s

!cCs6|j||�\}}}t|j|�\}}|dkr^ttd�||f��n|s�ttd�||f��nt|j|�\}}|dkr�ttd�||f��n|s�ttd�||f��nt|j|�}|dkr(ttd�||f��nt|�dS(Nis-Could not check if ibendport %s/%s is definedsibendport %s/%s is not defineds7ibendport %s/%s is defined in policy, cannot be deleteds Could not delete ibendport %s/%s(R�R�R`RjRtsemanage_ibendport_exists_localR�R�(R!R�R�R�R8RWR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��scCs(|j�|j||�|j�dS(N(Rvt_ibendportRecords__deleteR>(R!R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
ic
Cs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]v}t|�}t|�}|dkr�qjnt|�}t	|j|�\}}t
|�}	||f||	|f<qjW|S(NisCould not list ibendportstreserved_ibendport_t(R�R`R`tsemanage_ibendport_listRjRR�ReRfR�R�(
R!R�R�RWR�RURgRhR�R8((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s c	Cs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}t|�}t|�}t|j|�\}}t	|�}||f|j
�kr�g|||f<n|||fjd|�qjW|S(NisCould not list ibendportss0x%x(R�R`R`R�RjRR�ReR�R�R�R((	R!R�R�RWR�RURgR�R8((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRi�scCs�g}|jt�}|j�}|j�x~|D]v}||dr~|jd||d||d|d|df�q2|jd||d|d|df�q2W|S(Nis-a -t %s -r '%s' -z %s %sis-a -t %s -z %s %s(R�ReR�R�R((R!RR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRys

8.icCs�|j|�}|j�}t|�dkr1dS|j�|rhdtd�td�td�fGHnxZ|D]R}d|}|d||d7}x$||dD]}|d	|7}q�W|GHqoWdS(
Nis%-30s %-18s %s
sSELinux IB End Port TypesIB Device NamesPort Numbers%-30s %-18s s%sis, %s(RiR�RSR�R(R!R�R�R�R�R�R�R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s
'

(R?R@R.R"R�R�R�R�R�RuR�R�R�RiRyR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�<s		;		$					tnodeRecordscBs�eZgZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zed
�Z
d�Zeed�ZRS(
R	cCs[tj||�ddg|_y$tjtjd�dd|_Wntk
rVnXdS(Ntipv4tipv6t	node_typeiR,(R\R"tprotocolR�R�R-R.R/(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"1s$
cCs�|}|}d}|dkr3ttd���nt|�dksU|ddkr�t||�}|jd�}t|j��}|dkr�|j�dkr�d}nd|j�}ny|jj	|�}Wnttd	���nX|||fS(
NR	sNode Address is requirediR�s0.0.0.0is::sipv%dsUnknown or missing protocol(
RjRRSRt	strNormalR,tnetmasktversionR�tindex(R!taddrtmaskR�tnewaddrtnewmasktnewprotocolR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytvalidate9s""	c	Cs�|j|||�\}}}tdkrH|r?t|�}qHd}n|dkrittd���ntj|�|jkr�ttd�|��nt|j	|||�\}}|dkr�ttd�|��n|dkrttd�|��nt
|j	|�\}}|rJt|�|j|||j
|||�St|j	�\}}	|dkr�ttd	�|��nt|	|�t|j	|	||�}t|j	�\}}
|dkr�ttd
�|��nt|j	|	||�}|dkr ttd�|��nt|j	|
d�}|dkrZttd
�|��nt|j	|
d�}|dkr�ttd�|��nt|j	|
|�}|dkr�ttd�|��n|rt|j	|
|�}|dkrttd�|��qnt|j	|	|
�}|dkrKttd�|��nt|j	||	�}|dkr�ttd�|��nt|
�t|�t|	�|jjd||tj|j
|�dd||f�dS(NiR	R	sSELinux node type is requireds'Type %s is invalid, must be a node typeisCould not create key for %ss%Could not check if addr %s is definedsCould not create addr for %ssCould not create context for %ssCould not set mask for %sR@s)Could not set user in addr context for %sRAs)Could not set role in addr context for %ss)Could not set type in addr context for %ss/Could not set mls fields in addr context for %ss!Could not set addr context for %ssCould not add addr %ssCresrc=node op=add laddr=%s netmask=%s proto=%s tcontext=%s:%s:%s:%s(R�RtR[RjRR�RBR.tsemanage_node_key_createR`tsemanage_node_existstsemanage_node_key_freet_nodeRecords__modifyR�tsemanage_node_createtsemanage_node_set_prototsemanage_node_set_addrRItsemanage_node_set_maskRJRKRLRMtsemanage_node_set_contsemanage_node_modify_localRPtsemanage_node_freeRbR:RRS(R!R�R�R9R0RgRWR�R�tnodeRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�Rsh	
 



cCs1|j�|j|||||�|j�dS(N(Rvt_nodeRecords__addR>(R!R�R�R9R0Rg((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs4|j|||�\}}}|rF|dkrFttd���n|r}tj|�|jkr}ttd�|��nt|j|||�\}}|dkr�ttd�|��nt|j|�\}}|dkr�ttd�|��n|sttd�|��nt	|j|�\}}	|dkrYttd�|��nt
|	�}
|r�t|j|
t|��n|dkr�t
|j|
|�nt|j||	�}|dkr�ttd	�|��nt|�t|	�|jjd
||tj|j|�dd||f�dS(
NR	sRequires setype or seranges'Type %s is invalid, must be a node typeisCould not create key for %ss%Could not check if addr %s is definedsAddr %s is not definedsCould not query addr %ssCould not modify addr %ssFresrc=node op=modify laddr=%s netmask=%s proto=%s tcontext=%s:%s:%s:%sR@RA(R�RjRR�RBR.R�R`R�tsemanage_node_querytsemanage_node_get_conRMR[RLR�R�R�RbR:RRSR�(R!R�R�R9R0R�RWR�R�R�RU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s6

cCs1|j�|j|||||�|j�dS(N(RvR�R>(R!R�R�R9R0R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs�|j|||�\}}}t|j|||�\}}|dkrattd�|��nt|j|�\}}|dkr�ttd�|��n|s�ttd�|��nt|j|�\}}|dkr�ttd�|��n|sttd�|��nt|j|�}|dkrPttd�|��nt|�|j	j
d||tj|j
|�f�dS(NisCould not create key for %ss%Could not check if addr %s is definedsAddr %s is not defineds/Addr %s is defined in policy, cannot be deletedsCould not delete addr %ss1resrc=node op=delete laddr=%s netmask=%s proto=%s(R�R�R`RjRR�tsemanage_node_exists_localtsemanage_node_del_localR�RbR:RRSR�(R!R�R�R9RWR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s&
cCs+|j�|j|||�|j�dS(N(Rvt_nodeRecords__deleteR>(R!R�R�R9((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCs�t|j�\}}|dkr6ttd���n|j�xN|D]F}|jt|j|�dt|j|�d|jt	|��qGW|j
�dS(Nis!Could not deleteall node mappingsi(tsemanage_node_list_localR`RjRRvR�tsemanage_node_get_addrtsemanage_node_get_maskR�tsemanage_node_get_protoR>(R!RWtnlistR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s

Dc	Cs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}t|�}t|j|�}t|j|�}|j	t
|�}t|�t|�t
|�t|�f||d|d|f<qjW|S(NisCould not list addrsi(R�R`tilisttsemanage_node_listRjRR�R�R�R�R�tsemanage_context_get_usertsemanage_context_get_roleReRf(	R!R�R�RWR�RUR�R�R9((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��sCc	Cs�g}|jt�}t|j��}|j�x�|D]�}||dr�|jd|d|d||d||d|df�q8|jd|d|d||d|df�q8W|S(Nis-a -M %s -p %s -t %s -r '%s' %siiis-a -M %s -p %s -t %s %s(R�ReR�R�R�R((R!RR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRys

?5cCs?|j|�}t|j��}t|�dkr7dS|j�|rSddGHntr�x�|D]�}d}x"|D]}|dt|�}qsWd	|d|d
|d||d||d
||dt||dt�fGHq`WnPxM|D]E}d
|d|d
|d||d||d
||dfGHq�WdS(Nis%-18s %-18s %-5s %-5s
s
IP AddresstNetmasktProtocoltContextR	s	s%-18s %-18s %-5s %s:%s:%s:%s iiis%-18s %-18s %-5s %s:%s:%s (s
IP AddressR�R�R�(	R�R�R�RSR�RtR,RYR](R!R�R�R�R�R�tvaltfields((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s


Z
(R?R@R.R"R�R�R�R�R�R�R�RuR]R�RyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�.s		G		&				
	tinterfaceRecordscBsweZdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
d	�Zd
�Ze
e
d�ZRS(R	cCstj||�dS(N(R\R"(R!Rc((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"'sc	CsUtdkr*|r!t|�}q*d}n|dkrKttd���nt|j|�\}}|dkr�ttd�|��nt|j|�\}}|dkr�ttd�|��n|r�t|�|j|||�St	|j�\}}|dkr"ttd�|��nt
|j||�}t|j�\}}|dkrqttd	�|��nt|j|d
�}|dkr�ttd�|��nt
|j|d�}|dkr�ttd
�|��nt|j||�}|dkrttd�|��n|rbt|j||�}|dkrbttd�|��qbnt|j||�}|dkr�ttd�|��nt|j||�}|dkr�ttd�|��nt|j||�}|dkrttd�|��nt|�t|�t|�|jjd|d
d||f�dS(NiR	R	sSELinux Type is requiredisCould not create key for %ss*Could not check if interface %s is defineds!Could not create interface for %ssCould not create context for %sR@s.Could not set user in interface context for %sRAs.Could not set role in interface context for %ss.Could not set type in interface context for %ss4Could not set mls fields in interface context for %ss&Could not set interface context for %ss$Could not set message context for %ssCould not add interface %ss4resrc=interface op=add netif=%s tcontext=%s:%s:%s:%s(RtR[RjRtsemanage_iface_key_createR`tsemanage_iface_existstsemanage_iface_key_freet_interfaceRecords__modifytsemanage_iface_createtsemanage_iface_set_nameRIRJRKRLRMtsemanage_iface_set_ifcontsemanage_iface_set_msgcontsemanage_iface_modify_localRPtsemanage_iface_freeRbR:(	R!t	interfaceR0RgRWR�R�tifaceRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�*s`	



cCs+|j�|j|||�|j�dS(N(Rvt_interfaceRecords__addR>(R!R�R0Rg((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�ks
c	Cs�|r(|dkr(ttd���nt|j|�\}}|dkrettd�|��nt|j|�\}}|dkr�ttd�|��n|s�ttd�|��nt|j|�\}}|dkr�ttd�|��nt|�}|r,t|j|t|��n|dkrNt	|j||�nt
|j||�}|dkr�ttd�|��nt|�t|�|j
jd	|d
d||f�dS(NR	sRequires setype or serangeisCould not create key for %ss*Could not check if interface %s is definedsInterface %s is not definedsCould not query interface %ssCould not modify interface %ss7resrc=interface op=modify netif=%s tcontext=%s:%s:%s:%sR@RA(RjRR�R`R�tsemanage_iface_querytsemanage_iface_get_ifconRMR[RLR�R�R�RbR:(	R!R�R0R�RWR�R�R�RU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�ps0

cCs+|j�|j|||�|j�dS(N(RvR�R>(R!R�R0R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s
cCsNt|j|�\}}|dkr=ttd�|��nt|j|�\}}|dkrzttd�|��n|s�ttd�|��nt|j|�\}}|dkr�ttd�|��n|s�ttd�|��nt|j|�}|dkr,ttd�|��nt|�|jj	d|�dS(NisCould not create key for %ss*Could not check if interface %s is definedsInterface %s is not defineds4Interface %s is defined in policy, cannot be deletedsCould not delete interface %ss"resrc=interface op=delete netif=%s(
R�R`RjRR�tsemanage_iface_exists_localtsemanage_iface_del_localR�RbR:(R!R�RWR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s$
cCs%|j�|j|�|j�dS(N(Rvt_interfaceRecords__deleteR>(R!R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s

cCsrt|j�\}}|dkr6ttd���n|j�x!|D]}|jt|��qGW|j�dS(Nis(Could not delete all interface  mappings(tsemanage_iface_list_localR`RjRRvR�tsemanage_iface_get_nameR>(R!RWR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�s

cCs�i}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nxQ|jD]F}t|�}t|�t|�t	|�t
|�f|t|�<qjW|S(NisCould not list interfaces(R�R`R�tsemanage_iface_listRjRR�R�R�ReRfR�(R!R�R�RWR�RU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s8cCs�g}|jt�}t|j��}|j�xh|D]`}||dry|jd||d||d|f�q8|jd||d|f�q8W|S(Nis-a -t %s -r '%s' %sis-a -t %s %s(R�ReR�R�R�R((R!RR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRy�s

-#c	Cs|j|�}t|j��}t|�dkr7dS|j�|redtd�td�fGHntr�x�|D]G}d|||d||d||dt||dt�fGHqrWn>x;|D]3}d	|||d||d||dfGHq�WdS(
Nis	%-30s %s
sSELinux InterfaceR�s%-30s %s:%s:%s:%s iiis%-30s %s:%s:%s (	R�R�R�RSR�RRtRYR](R!R�R�R�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s

H
(R?R@R"R�R�R�R�R�R�RuR]R�RyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�&s	A		"				
	tfcontextRecordscBs�eZgZdd�Zd�Zd�Zd�Zdd�Zd�Zdddd�Z
dddd	�Zd
�Zd�Z
d�Zd
�Zd�Zed�Zd�Zeed�ZRS(R	cCs�tj||�yJtjtjd�dd|_|jtjtjd�dd7_Wntk
rmnXi|_i|_t	|_
y�ttj
�d�}xl|j�D]^}|j�}t|�dkr�q�n|jd�r�q�n|j�\}}||j|<q�W|j�Wntk
r.nXy�ttj�d�}xl|j�D]^}|j�}t|�dkr~qTn|jd�r�qTn|j�\}}||j|<qTW|j�Wntk
r�nXdS(Nt	file_typeiR,tdevice_nodeRt#(R\R"R�R�R-R.R/tequivt
equiv_distR]t	equal_indR�RQtselinux_file_context_subs_patht	readlineststripRSR�R�R�tIOErrort#selinux_file_context_subs_dist_path(R!RcR�R�ttargett
substitute((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"�sF *
			

cCs�|jr�tj�}d|}t|d�}x;t|jj��D]$}|jd||j|f�qDW|j�y$t	j
|t	j|�tj�WnnXt	j
||�t|_ntj|�dS(Ns%s.tmptws%s %s
(R�RQR�R�R�R�R�twriteR�R�tchmodtstattST_MODEtrenameR]R\R>(R!t	subs_filettmpfileR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR>	s	
"
$c	Cs�|j�|dkr?|ddkr?ttd�|��n|dkrt|ddkrtttd�|��n|t|jj��kr�ttd�|��n|j|�xp|j|jfD]\}xS|D]K}|j|d�r�ttd�i|d6|d6||d	6��q�q�Wq�W|j	j
d
tjd|d�tjd
|d�f�||j|<t
|_|j�dS(NR�i����s=Target %s is not valid. Target is not allowed to end with '/'sESubstitute %s is not valid. Substitute is not allowed to end with '/'s'Equivalence class for %s already existssJFile spec %(TARGET)s conflicts with equivalency rule '%(SOURCE)s %(DEST)s'tTARGETtSOURCEtDESTs!resrc=fcontext op=add-equal %s %stsglobittglob(RvRjRR�R�R�R�R�R�RbR:Rtaudit_encode_nv_stringReR�R>(R!R�R�tfdictR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt	add_equal#	s 


:8
	cCs�|j�|t|jj��kr>ttd�|��n||j|<t|_|jj	dt
jd|d�t
jd|d�f�|j�dS(Ns(Equivalence class for %s does not existss$resrc=fcontext op=modify-equal %s %sRiR(
RvR�R�R�RjRReR�RbR:RRR>(R!R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytmodify_equal:	s

	8R@cCst|j�\}}|dkr:ttd�|��n|dkrOd}nt|j||�}|dkr�ttd�|��nt|j|d�}|dkr�ttd�|��ntdkrt|j|d	�}|dkrttd
�|��qn|S(NisCould not create context for %sR	R@s)Could not set user in file context for %sRAs)Could not set role in file context for %siR	s/Could not set mls fields in file context for %s(RIR`RjRRJRKRtRM(R!R�R
RWRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt	createconC	s 	cCs�|dks!|jd�dkr6ttd���n|jd�dkr`ttd���nx�|j|jfD]|}xs|D]k}|j|d�r�tj||||�}ttd	�i|d
6|d6||d6|d
6��q�q�WqsWdS(NR	s
isInvalid file specificationR�i����s)File specification can not include spacesR�sjFile spec %(TARGET)s conflicts with equivalency rule '%(SOURCE)s %(DEST)s'; Try adding '%(DEST1)s' insteadRRRtDEST1(tfindRjRR�R�R�RHtsub(R!R�RR�R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�Y	s!
c	Cs�|j|�|dkr"d}ntdkrLt|�}|sLd}qLn|dkrmttd���n|dkr�tj|�|jkr�ttd�|��nt|j	|t
|�\}}|dkr�ttd	�|��nt|j	|�\}}|dkr+ttd
�|��n|sqt|j	|�\}}|dkrqttd
�|��qqn|r�t
|�|j|||||�St|j	�\}}	|dkr�ttd�|��nt|j	|	|�}|dkr�|j||�}
t|j	|
|�}|dkrAttd�|��n|r�t|j	|
|�}|dkr�ttd
�|��q�nt|j	|	|
�}|dkr�ttd�|��q�nt|	t
|�t|j	||	�}|dkrttd�|��n|dkr%t|
�nt
|�t|	�|sHd}n|jjdtjd|d�t||d||f�dS(NR	R@iR	sSELinux Type is requireds<<none>>s1Type %s is invalid, must be a file or device typeisCould not create key for %ss1Could not check if file context for %s is defineds$Could not create file context for %ss)Could not set type in file context for %ss/Could not set mls fields in file context for %ss!Could not set file context for %ss!Could not add file context for %ss6resrc=fcontext op=add %s ftype=%s tcontext=%s:%s:%s:%sRRA(R�RtR[RjRR�RBR.tsemanage_fcontext_key_createR`t
file_typestsemanage_fcontext_existstsemanage_fcontext_exists_localtsemanage_fcontext_key_freet_fcontextRecords__modifytsemanage_fcontext_createtsemanage_fcontext_set_exprRRLRMtsemanage_fcontext_set_contsemanage_fcontext_set_typetsemanage_fcontext_modify_localRPtsemanage_fcontext_freeRbR:RRtftype_to_audit(R!R�RTtftypeR0R
RWR�R�tfcontextRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�e	sf
	$



	cCs1|j�|j|||||�|j�dS(N(Rvt_fcontextRecords__addR>(R!R�RTRR0R
((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��	s
cCsa|r3|dkr3|dkr3ttd���n|dkrptj|�|jkrpttd�|��n|j|�t|j|t|�\}}|dkr�ttd�|��nt	|j|�\}}|dkr�ttd�|��n|s>t
|j|�\}}|s>ttd�|��q>nyt|j|�\}}	WnWtk
r�yt
|j|�\}}	Wq�tk
r�ttd	�|��q�XnX|dkr�t|	�}
|
dkr�|j|�}
n|rt|j|
t|��n|dkr.t|j|
|�n|dkrPt|j|
|�nt|j|	|
�}|dkr�ttd
�|��q�n:t|j|	d�}|dkr�ttd
�|��nt|j||	�}|dkrttd�|��nt|�t|	�|s$d}n|jjd
tjd|d�t||d||f�dS(NR	s"Requires setype, serange or seusers<<none>>s1Type %s is invalid, must be a file or device typeisCould not create a key for %ss1Could not check if file context for %s is defineds"File context for %s is not defineds#Could not query file context for %ss!Could not set file context for %ss$Could not modify file context for %sR@s9resrc=fcontext op=modify %s ftype=%s tcontext=%s:%s:%s:%sRRA(R	s<<none>>(RjRR�RBR.R�RR`RRRtsemanage_fcontext_query_localR$tsemanage_fcontext_querytsemanage_fcontext_get_conRARRMR[RJRLRRRRRbR:RRR(R!R�R�RR0R
RWR�R�RRU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��	s\$




	cCs1|j�|j|||||�|j�dS(N(RvRR>(R!R�R�RR0R
((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��	s
cCsKt|j�\}}|dkr6ttd���n|j�x�|D]�}t|�}t|�}t|�}t|j|t	|�\}}|dkr�ttd�|��nt
|j|�}|dkr�ttd�|��nt|�|jj
dtjd|d�tt|f�qGWi|_t|_|j�dS(Nis Could not list the file contextssCould not create a key for %ss$Could not delete the file context %ss$resrc=fcontext op=delete %s ftype=%sR(tsemanage_fcontext_list_localR`RjRRvtsemanage_fcontext_get_exprtsemanage_fcontext_get_typetsemanage_fcontext_get_type_strRRtsemanage_fcontext_del_localRRbR:RRRtfile_type_str_to_optionR�ReR�R>(R!RWtflistRR�Rt	ftype_strR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�	s&


5		cCs�|t|jj��kr[|jj|�t|_|jjdtj	d|d��dSt
|j|t|�\}}|dkr�t
td�|��nt|j|�\}}|dkr�t
td�|��n|sWt|j|�\}}|dkrt
td�|��n|r>t
td�|��qWt
td�|��nt|j|�}|dkr�t
td�|��nt|�|jjd	tj	d|d�t|f�dS(
Ns!resrc=fcontext op=delete-equal %sRisCould not create a key for %ss1Could not check if file context for %s is defineds;File context for %s is defined in policy, cannot be deleteds"File context for %s is not defineds$Could not delete file context for %ss$resrc=fcontext op=delete %s ftype=%s(R�R�R�tpopReR�RbR:RRRR`RRjRRRR&RR(R!R�RRWR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�
s.	#
cCs(|j�|j||�|j�dS(N(Rvt_fcontextRecords__deleteR>(R!R�R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�/
s
cCs�|r!t|j�\}|_n�t|j�\}|_|dkrZttd���nt|j�\}}|dkr�ttd���nt|j�\}}|dkr�ttd���n|j|7_|j|7_ddlm}|�}x�|jD]�}t	|�}t
|�}	t|	�}
t|�}|rzt
|�t|�t|�t|�f|||
f<q||||
f<qW|S(NisCould not list file contextss1Could not list file contexts for home directoriess"Could not list local file contextsi����(tOrderedDict(R"R`R(tsemanage_fcontext_listRjRtsemanage_fcontext_list_homedirstcollectionsR,R#R$R%R!R�R�ReRf(R!R�RWt
fchomedirstfclocalR,R�RtexprRR)RU((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�4
s0	7cCsg}|jt�}t|j��}x�|D]�}||r.||dr�|jdt|d||d||d|df�q�|jdt|d||d|df�q.q.Wt|j�r
x>t|jj��D]$}|jd|j||f�q�Wn|S(Nis-a -f %s -t %s -r '%s' '%s'iiis-a -f %s -t %s '%s's-a -e %s %s(R�ReR�R�R(R'RSR�(R!Rt	fcon_dictR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRyT
s

<5%c
Cs�|j|�}t|j��}t|�dkr%|r`dtd�td�td�fGHnx�|D]�}||rtr�d|d|d||d||d||dt||d	t�fGHqd
|d|d||d||d||dfGHqgd|d|dfGHqgWnt|j�r�|s�|rNtd�GHnx6t|jj��D]}d
||j|fGHqdWq�nt|j	�r�|r�td�GHnx6t|j	j��D]}d
||j	|fGHq�WndS(Nis%-50s %-18s %s
sSELinux fcontextRTR�s%-50s %-18s %s:%s:%s:%s iiis%-50s %-18s %s:%s:%s s%-50s %-18s <<None>>s,
SELinux Distribution fcontext Equivalence 
s%s = %ss%
SELinux Local fcontext Equivalence 
(
R�R�R�RSRRtRYR]R�R�(R!R�R�R3R�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�d
s,'

O; N(R?R@R.R"R>R	R
RR�RARR�RR�RuR+R�R]R�RyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��s"&					G	>			!	 	tbooleanRecordscBs�eZdd�Zd�Zded�Zd�Zd�Zd�Z	ed�Z
d�Zd	�Zd
�Z
eeed�ZRS(
R	cCs�tj||�i|_d|jd<d|jd<d|jd<d|jd<d|jd<d|jd<y+tj�\}|_tj�\}}Wng|_d}nX|jdks�|j|kr�t	|_
n	t|_
dS(	NitTRUEitFALSEtONtOFFt1t0(R\R"tdictRQtsecurity_get_boolean_namestcurrent_booleansRaRARcRetmodify_localR](R!RcRWtptype((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR"�
s"	





	
cCs�tj|�}t|j|�\}}|dkrLttd�|��nt|j|�\}}|dkr�ttd�|��n|s�ttd�|��nt|j|�\}}|dkr�ttd�|��n|j�|j	krt
||j	|j��n.ttd�djt|j	j
�����|jr�||jkr�t|j||�}|dkr�ttd�|��q�nt|j||�}|dkr�ttd	�|��nt|�t|�dS(
NisCould not create a key for %ss(Could not check if boolean %s is definedsBoolean %s is not definedsCould not query file context %ss0You must specify one of the following values: %ss, s(Could not set active value of boolean %ssCould not modify boolean %s(RQtselinux_boolean_subtsemanage_bool_key_createR`RjRtsemanage_bool_existstsemanage_bool_querytupperR;tsemanage_bool_set_valueR�R�R�R>R=tsemanage_bool_set_activetsemanage_bool_modify_localtsemanage_bool_key_freetsemanage_bool_free(R!R.tvalueRWR�R�R((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt__mod�
s0.
cCs�|j�|r�t|�}x�|j�jd�D]�}|j�}t|�dkr\q2ny|jd�\}}Wn5tk
r�ttdi|d6|d6���nX|j|j�|j��q2W|j	�n|j||�|j
�dS(Ns
it=s)Bad format %(BOOLNAME)s: Record %(VALUE)stBOOLNAMEtVALUE(RvR�R�R�R�RSRjRt_booleanRecords__modR�R>(R!R.RJtuse_fileR�RtboolnameR�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��
s

( 
cCsItj|�}t|j|�\}}|dkrLttd�|��nt|j|�\}}|dkr�ttd�|��n|s�ttd�|��nt|j|�\}}|dkr�ttd�|��n|sttd�|��nt|j|�}|dkr;ttd�|��nt	|�dS(NisCould not create a key for %ss(Could not check if boolean %s is definedsBoolean %s is not defineds2Boolean %s is defined in policy, cannot be deletedsCould not delete boolean %s(
RQR@RAR`RjRRBtsemanage_bool_exists_localtsemanage_bool_del_localRH(R!R.RWR�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��
s$cCs%|j�|j|�|j�dS(N(Rvt_booleanRecords__deleteR>(R!R.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��
s

cCs~t|j�\}|_|dkr9ttd���n|j�x*|jD]}t|�}|j|�qMW|j�dS(NisCould not list booleans(	tsemanage_bool_list_localR`tblistRjRRvtsemanage_bool_get_nameRTR>(R!RWtbooleanR.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRu�
s
cCsi}|r't|j�\}|_nt|j�\}|_|dkr`ttd���nx�|jD]�}g}t|�}|jt|��|j	r�||j
kr�|jtj|��|jtj
|��n"|j|d�|j|d�|||<qjW|S(NisCould not list booleans(RUR`RVtsemanage_bool_listRjRRWR(tsemanage_bool_get_valueR>R=RQtsecurity_get_boolean_pendingtsecurity_get_boolean_active(R!R�R�RWRXRJR.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR��
s"cCstj|�}t|�S(N(RQR@R(R!R.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytget_descscCstj|�}t|�S(N(RQR@R(R!R.((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pytget_categoryscCsrg}|jt�}t|j��}|j�x:|D]2}||r8|jd||d|f�q8q8W|S(Ns	-m -%s %si(R�ReR�R�R�R((R!RR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyRys


&cCs=td�td�f}|rx|j|�}t|j��}x2|D]*}||rFd|||dfGHqFqFWdS|j|�}t|j��}t|�dkr�dS|r�dtd�td�td	�td
�fGHnxQ|D]I}||r�d||||d|||d|j|�fGHq�q�WdS(NR�R�s%s=%siis%-30s %s  %s %s
sSELinux booleantStatetDefaulttDescriptions%-30s (%-5s,%5s)  %s(RR�R�R�RSR](R!R�R�RPton_offR�R�R�((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR�s"

0

N(R?R@R"RORAR]R�RTR�RuR�R]R^RyReR�(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyR4�
s				
			
(AR�R�tstringRQttempfileR�RHR*R�tshutilRR8tPROGNAMER�RRRtIPyRtgettexttbindtextdomaint
textdomaintinstallRet	TypeErrorR�tbuiltinsR,t__dict__RtRCRtSEMANAGE_FCONTEXT_ALLtSEMANAGE_FCONTEXT_REGtSEMANAGE_FCONTEXT_DIRtSEMANAGE_FCONTEXT_CHARtSEMANAGE_FCONTEXT_BLOCKtSEMANAGE_FCONTEXT_SOCKtSEMANAGE_FCONTEXT_LINKtSEMANAGE_FCONTEXT_PIPER'RRtaudit_closeRRR$R�RERPRYR[R\R}R�R�R�R�R*RkR�R�R�R�R4(((s7/usr/lib64/python2.7/site-packages/seobject/__init__.pyt<module>s�
































""
	^{
H��
�������

Zerion Mini Shell 1.0