+
    	:iȸ c                   s   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI5 Rt	^ RI
t
^ RIHt ^ RIHt ^ RIt ^ RIt/ t]P$                  RM8  d   R]R&   ]P&                  ! ]	3RR	/]BR
R/B t]P                   t^ RIt/ t]]R&   ]]R&   ]]R&   ]]R&   ]]R&   ]]R&   ] ]R&   ] ]R&   ] ]R&   ]!]R&   ]!]R&   ]!]R&   ]"]R&   ]"]R&   ]"]R&   ]#]R&   ]#]R&   ]#]R&   ]$]R&   ]$]R&   ]$]R &   ]%]R!&   ]%]R"&   ]%]R#&   RRRRRRRRRRRRR RR#R!/t&RR$RR$RR%RR&RR'RR(RR)R!R*RR/	t' ^ RI(t(](PR                  ! ](PT                  ! 4       4        ! R+ R,4      t+ ! R. R/4      t-R0 t.RNR1 lt/RNR2 lt0 ! R3 R44      t1 ! R5 R6]14      t2 ! R7 R8]14      t3 ! R9 R:]14      t4 ! R; R<]14      t5 ! R= R>]14      t6 ! R? R@]14      t7 ! RA RB]14      t8 ! RC RD]14      t9 ! RE RF]14      t: ! RG RH]14      t; ! RI RJ]14      t< ! RK RL]14      t=R#     ^ RIt]]P0                  R&    EL  ] d    ^ RIt]]P0                  R&     ELi ; i; i  ],]3 d     ! R- R,4      t+ Li ; i)O    N)*zselinux-python)SELinuxPolicy)	TypeQueryTunicodeZ	localedirz/usr/share/localeZfallback_ z	all filesZazregular filez--Zfz-dZ	directoryZdz-czcharacter deviceZcz-bzblock devicebz-ssocketZsz-llzsymbolic linkpz-pz
named pipeZanyZblockZcharZdirfileZsymlinkZpipec                   sF   a  ] tR t^lt o R tRR ltRR ltR tR tRt	V t
R# )	loggerc                sV    \         P                  ! 4       V n        . V n        . V n        R # N)audit
audit_openaudit_fdlog_listlog_change_listself   &-/usr/lib/python3.14/site-packages/seobject.py__init__logger.__init__n   s!    !,,.DMDM#%D     c	                sN   R p	W68w  d   WR,           ,          pRp	WG8w  d   WR,           ,          pRp	WX8w  d   WR,           ,          pRp	V P                   P                  V P                  \        P                  \
        P                  ^ ,          \        V4      V^ W4WVWxRRR.4       R# )-sename,roleranger   N)r   appendr   r   ZAUDIT_ROLE_ASSIGNsysargvstr)
r   msgnamer   seroleserange	oldsename	oldserole
oldserangeZsep
   &&&&&&&&& r   log
logger.logs   s    C"X~%"V|#$W}$MM  $--1H1H#((ST+WZ[^W_aeghjp  {B  OX  fh  jl  np  "q  rr   c	                s    V P                   P                  V P                  \        P                  \
        P                  ^ ,          \        V4      V^ W4WVWxRRR.4       R# )r    r   N)r   r   r   r   ZAUDIT_ROLE_REMOVEr    r!   r"   	r   r#   r$   r   r%   r&   r'   r(   r)   	   &&&&&&&&&r   
log_removelogger.log_remove   si    MM  $--1H1H#((ST+WZ[^W_aeghjp  {B  OX  fh  jl  np  "q  rr   c           	     s    V P                   P                  V P                  \        P                  \        V4      R RRR.4       R# )semanager   N)r   r   r   r   ZAUDIT_USER_MAC_CONFIG_CHANGEr"   r   r#      &&r   
log_changelogger.log_change   s:      ''8Z8Z\_`c\dfprtvxz|(}~r   c                s    V P                    F  p\        P                  ! W!.,           !   K   	  V P                   F  p\        P                  ! W!.,           !   K   	  . V n         . V n        R # r   )r   r   Zaudit_log_semanage_messager   Zaudit_log_user_comm_message)r   successr	      && r   commitlogger.commit   sU    ]]001y=B #))11A	MC * DM#%D r   )r   r   r   Nr   r   r   r   r   r   r   __name__
__module____qualname____firstlineno__r   r+   r/   r4   r8   __static_attributes____classdictcell__Z__classdict__   @r   r   r   l   s&     	&
	r	r		& 	&r   r   c                   sF   a  ] tR t^t o R tRR ltRR ltR tR tRt	V t
R# )	r   c                s    . V n         R # r   r   r   r   r   r   r      s	    DMr   c	                st   R V: RV: 2p	VR8w  d   V	RV,           ,          p	VR8w  d   V	RV,           ,          p	VR8w  d   V	RV,           ,          p	VR8w  d   V	RV,           ,          p	VR8w  d   Ve   V	RV,           ,          p	VR8w  d   Ve   V	R	V,           ,          p	V P                   P                  V	4       R# )
 z name=r   z sename=z oldsename=z role=z
 old_role=Nz
 MLSRange=z old_MLSRange=r   r   )
r   r#   r$   r   r%   r&   r'   r(   r)   messager*   r   r+   r,      s    '*D1G|:..B=944|8f,,B<)33"}!4<'11RJ$:+j88MM  )r   c	           
     s.    V P                  WW4WVWx4       R # r   )r+   r-   r.   r   r/   r0      s    HHSIZr   c                sJ    V P                   P                  R V,          4       R# )z %sNrF   r2   r3   r   r4   r5      s    MM  -r   c                s    V^8X  d   RpMRpV P                    F.  p\        P                  ! \        P                  W#,           4       K0  	  R# )   zSuccessful: zFailed: N)r   syslogZLOG_INFO)r   r6   rG   r	      &&  r   r8   r9      s5    !|($]]foow{; #r   rD   Nr:   r;   rB   rC   r   r   r      s$     		* 	[	.	< 	<r   c                   s@   a  ] tR t^t o RR ltRR ltR tR tRtV t	R# )
nullloggerc	                    R # r    r-   r.   r   r+   Znulllogger.log       r   c	                rL   r   rM   r-   r.   r   r/   Znulllogger.log_remove   rN   r   c                rL   r   rM   r2   r3   r   r4   Znulllogger.log_change   rN   r   c                rL   r   rM   )r   r6   r3   r   r8   Znulllogger.commit   rN   r   rM   Nr:   )
r<   r=   r>   r?   r+   r/   r4   r8   r@   rA   rB   rC   r   rK   rK      s      r   rK   c                 s   R pRpVR,           V,           R,           pVR,           V,           R,           pVR,           V,           R,           R,           V,           R,           p\         P                  ! RV,           R	,           V 4      # )
zs[0-9]*zc[0-9]*z(\.z)?z(\,z)*z(-z(:Z^Z$)reZsearch)rawZsensitivityZcategoryZ	cat_rangeZ
categoriesZregs   &     r   validate_levelrQ      sp    KH6!H,t3IV#i/$6J

{
*T
1D
8:
E
LC99S3Y_c**r   c                     R pV^8X  d
   V: V : 2pMT p\         P                  ! V4      w  rEV^ 8w  d   V # V'       d   V\        V4      R pVR8X  d   V # V# za:b:c:Nr   )selinuxZselinux_raw_to_trans_contextlen)rP   prependfillercontextrctrans   &&    r   	translater\      s_    F!|"C(66w?KR	Qw
c&kl#{
r   c                 rR   rS   )rT   Zselinux_trans_to_raw_contextrU   )rZ   rV   rW   rX   rY   rP   r[   r   untranslater]      s_    F!|"E*44W=IR	Qw#f+,
by
r   c                   sj   a  ] tR t^t o RtRtRtRtRR ltR t	R t
R tR tR tR	 tR
 tR tRtV tR# )semanageRecordsFNc                sl   V'       d$   \        V\        4      '       d   Wn        MWn        \	        VR R4      V n        V P                  '       g   \	        VRR4      V n        V P                  V P                  4      V n        \        P                  ! 4       w  r#V P                  R8X  g   V P                  V8X  d   \        4       V n        R# \        P                  ! V P                  4       \        P                  ! \        P                  ! 4       : V P                  : 24       \!        4       V n        R# )noreloadFstorer   N)
isinstancer"   r`   argsZgetattrr_   
get_handleshrT   selinux_getpolicytyper   mylogsepolicyZload_store_policyZselinux_set_policy_rootZselinux_pathrK   )r   rb   rY   Z
localstorerJ   r   r   ZsemanageRecords.__init__   s    $$$!
 	j%8zzz w3DJ//$**- 668::tzzZ7DJ&&tzz2++g6J6J6Ldjj,YZ#DJr   c                s    V'       * V n         R # r   )r_   )r   Zloadr3   r   
set_reloadZsemanageRecords.set_reload  s     r   c                s   \         P                  '       d   \         P                  # \        4       pV'       g   \        \	        R 4      4      h\         P
                  '       g#   VR8w  d   \        W!\        4       V\         n        \        V4      '       g    \        V4       \        \	        R4      4      h\        V4      pV\        8  d    \        V4       \        \	        R4      4      h\        V4      pV^ 8  d    \        V4       \        \	        R4      4      h\        V4      s\        ^ 8  d    \        V4       \        \	        R4      4      hV\         n        \         P                  # )z Could not create semanage handler   z:SELinux policy is not managed or store cannot be accessed.zCannot read policy store.z'Could not establish semanage connectionz!Could not test MLS enabled status)r^   handleZsemanage_handle_create
ValueErrorr   transactionZsemanage_select_storeZSEMANAGE_CON_DIRECTr`   Zsemanage_is_managedZsemanage_handle_destroyZsemanage_access_checkZSEMANAGE_CAN_READZsemanage_connectZsemanage_mls_enabledis_mls_enabled)r   r`   ri   rY   rJ   r   rc   ZsemanageRecords.get_handle  s    !!!")))')QABCC***u{!&1DE$)O!"6**#F+Q[\]]"6*!!#F+Q:;<<f%6#F+QHIJJ-f5A#F+QBCDD!'%%%r   c                *    \        \        R 4      4      hzNot yet implementedrj   r   r   r   r   	deleteallZsemanageRecords.deleteall3      0122r   c                s    \         P                  '       d   \        \        R 4      4      hV P	                  4        R\         n        R# )z(Semanage transaction already in progressTN)r^   rk   rj   r   beginr   r   r   startZsemanageRecords.start6  s0    &&&QIJKK

&*#r   c                s    \         P                  '       d   R # \        V P                  4      pV^ 8  d   \	        \        R4      4      hR # )Nz$Could not start semanage transaction)r^   rk   Zsemanage_begin_transactionrd   rj   r   r   rY      & r   rr   ZsemanageRecords.begin<  s<    &&&'06QEFGG r   c                rm   rn   ro   r   r   r   
customizedZsemanageRecords.customizedC  rq   r   c                sR   \         P                  '       d   R # V P                  '       d   \        V P                  ^ 4       \        V P                  4      pV^ 8  d0   V P                  P                  ^ 4       \        \        R4      4      hV P                  P                  ^4       R # )Nz%Could not commit semanage transaction)
r^   rk   r_   Zsemanage_set_reloadrd   Zsemanage_commitrf   r8   rj   r   rt   ru   r   r8   ZsemanageRecords.commitF  sr    &&&===+TWW%6JJa QFGHH

!r   c                s    \         P                  '       g   \        \        R 4      4      hR\         n        V P	                  4        R# )z$Semanage transaction not in progressFN)r^   rk   rj   r   r8   r   r   r   finishZsemanageRecords.finishR  s0    ***QEFGG&+#r   )rb   rf   r_   rd   r`   r   )r<   r=   r>   r?   rk   ri   r`   rb   r   rh   rc   rp   rs   rr   rv   r8   rw   r@   rA   rB   rC   r   r^   r^      sM     KFED&,!"&H3+H3
 r   r^   c                   sX   a  ] tR tRt o RR ltR tR tRR ltR tR t	R	 t
R
 tRtV tR# )moduleRecordsiY  Nc                0    \         P                  W4       R # r   r^   r   r   rb   r3   r   r   ZmoduleRecords.__init__[        ,r   c                s   . p\        V P                  4      w  r#pV^ 8  d   \        \        R4      4      h\	        V4       F  p\        W54      p\        V P                  V4      w  r'V^ 8  d   \        \        R4      4      h\        V P                  V4      w  r(V^ 8  d   \        \        R4      4      h\        V P                  V4      w  r)V^ 8  d   \        \        R4      4      h\        V P                  V4      w  r*V^ 8  d   \        \        R4      4      hVP                  WxW34       K  	  VP                  R RR7       VP                  R	 R
7       V# )r    Could not list SELinux moduleszCould not get module namezCould not get module enabledzCould not get module priorityzCould not get module lang_extc                 s    V ^,          # i   rM   tr   r   <lambda>'moduleRecords.get_all.<locals>.<lambda>z      QqTr   T)keyZreversec                 s    V ^ ,          # r    rM   r   r   r   r   r   {  r   r   )r   )Zsemanage_module_list_allrd   rj   r   r   semanage_module_list_nthZsemanage_module_info_get_nameZ semanage_module_info_get_enabledZ!semanage_module_info_get_priorityZ!semanage_module_info_get_lang_extr   Zsort)r   r	   rY   mlistnumberimodr$   ZenabledpriorityZlang_ext   &          r   get_allZmoduleRecords.get_all^  s(   6tww?F6Q?@AAvA*54C4TWWcBHBAv #>!?@@:477CHKBAv #A!BCC<TWWcJLBAv #B!CDD<TWWcJLBAv #B!CDDHHdX89' , 	
>40	>"r   c                s    V P                  4       p\        V4      ^ 8X  d   . # V Uu. uF  q"^,          ^ 8X  g   K  VNK  	  up Uu. uF  pRV^ ,          ,          NK  	  up# u upi u upi )r    z-d %s)r   rU   )r   allr   x   &   r   rv   ZmoduleRecords.customized~  s]    llns8q=I47(ECqQ419C(EF(E1!A$(EFF(EFs   A"A"A'c           
     s   V P                  4       p\        V4      ^ 8X  d   R# V'       d6   \        R\        R4      :R R\        R4      :R R\        R4      : R24       V F[  pV^,          ^ 8X  d   \        R	4      pMV'       d   K'  R
p\        V^ ,          :R RV^,          :R RV^,          :R RV: 24       K]  	  R# )r    N
zModule Name25rE   ZPriorityZ9ZLanguageZDisabledr   5)r   rU   printr   )r   heading	locallistr   r   Zdisabled   &&&   r   listZmoduleRecords.list  s    llns8q==)91Z=!J-XYAtqyZ=!A$$!addHEF r   c                sT   \         P                  P                  V4      '       g   \        \	        R 4      V,          4      h\        V P                  V4      pV^ 8  d   \        \	        R4      V,          4      h\        V P                  V4      pV^ 8  d   V P                  4        R# R# )zModule does not exist: %s 3Invalid priority %d (needs to be between 1 and 999)N)	ospathexistsrj   r   semanage_set_default_priorityrd   Zsemanage_module_install_filer8   )r   r   r   rY   s   &&& r   addZmoduleRecords.add  s~    ww~~d##Q;<tCDD*477H=6QTUX``aa)$''487KKM r   c                s   VP                  4        F  p\        V P                  4      w  rEV^ 8  d   \        \	        R4      4      h\        V P                  WS4      pV^ 8  d   \        \	        R4      4      h\        V P                  WR4      pV^ 8  g   K  V'       d   \        \	        R4      V,          4      h\        \	        R4      V,          4      h	  V P                  4        R# )r    zCould not create module keyzCould not set module key namezCould not enable module %szCould not disable module %sN)splitZsemanage_module_key_createrd   rj   r   Zsemanage_module_key_set_nameZsemanage_module_set_enabledr8   )r   moduleZenablemrY   r   r   r   set_enabledZmoduleRecords.set_enabled  s    A09GBAv #@!ABB-dggs>BAv #B!CDD,TWWcBBAv$Q'C%Dq%HII$Q'D%E%IJJ   	r   c                sF   \        V P                  V4      pV^ 8  d   \        \        R4      V,          4      hVP	                  4        FD  p\        V P                  V4      pV^ 8  g   K"  VR8w  g   K+  \        \        R4      V,          4      h	  V P                  4        R# )r    r   z*Could not remove module %s (remove failed)Ni)r   rd   rj   r   r   semanage_module_remover8   )r   r   r   rY   r      &&&  r   deleteZmoduleRecords.delete  s    *477H=6QTUX``aaA'3BAv"( #O!PST!TUU  
 	r   c                s    V P                  4        Uu. uF  q^,          ^ 8X  g   K  VNK  	  up Uu. uF  q"^ ,          NK  	  ppV F  pV P                  VR4       K  	  R# u upi u upi )rH   TN)r   r   )r   r   r   r	   r      &    r   rp   ZmoduleRecords.deleteall  s^    '+||~C~!1AA~CDCaqTTCDAQ%  DDs   A"A"A'rM   r   rH   r    )r<   r=   r>   r?   r   r   rv   r   r   r   r   rp   r@   rA   rB   rC   r   rx   rx   Y  s5     -@GG 
$
& &r   rx   c                   s0   a  ] tR tRt o RR ltR tRtV tR# )dontauditClassi  Nc                ry   r   rz   r{   r3   r   r   ZdontauditClass.__init__  r|   r   c                s    VR9  d   \        \        R4      4      hV P                  4        \        V P                  VR8H  4       V P                  4        R# )onoffz'dontaudit requires either 'on' or 'off'N)r   r   )rj   r   rr   Zsemanage_set_disable_dontauditrd   r8   )r   Z	dontauditr3   r   toggleZdontauditClass.toggle  s@    M)QHIJJ

&tww	U0BCr   rM   r   )r<   r=   r>   r?   r   r   r@   rA   rB   rC   r   r   r     s     - r   r   c                   sR   a  ] tR tRt o RR ltR tR tRR ltR tR t	R	 t
R
tV tR# )permissiveRecordsi  Nc                ry   r   rz   r{   r3   r   r   ZpermissiveRecords.__init__  r|   r   c                sT   . p\        V P                  4      w  r#pV^ 8  d   \        \        R4      4      h\	        V4       Fc  p\        W54      p\        V4      pV'       g   K#  VP                  R4      '       g   K<  VP                  VP                  R4      ^,          4       Ke  	  V# )r    r}   Zpermissive_)
Zsemanage_module_listrd   rj   r   r   r   Zsemanage_module_get_name
startswithr   r   )r   r	   rY   r   r   r   r   r$      &       r   r   ZpermissiveRecords.get_all  s    2477;F6Q?@AAvA*54C+C0Dt66M2156	 
 r   c                sl    \        V P                  4       4       Uu. uF  pR V,          NK  	  up# u upi )z-a %s)sortedr   )r   r   ru   r   rv   ZpermissiveRecords.customized  s-    %+DLLN%;<%;!%;<<<s   1c                s    \         P                  ! \         P                  4       Uu. uF  q3R ,          '       g   K  VNK  	  up Uu. uF  qDR,          NK  	  pp\        V4      ^ 8X  d   R# V'       d   \	        R\        R4      ,          4       V P                  4       pV F  pWv9  g   K  \	        V4       K  	  \        V4      ^ 8X  d   R# V'       d   \	        R\        R4      ,          4       V F  p\	        V4       K  	  R# u upi u upi )Z
permissiver$   Nz
%-25s
zBuiltin Permissive TypeszCustomized Permissive Types)rg   infoZTYPErU   r   r   r   )r   r   r   r   Zyr   rv   r      &&&     r   r   ZpermissiveRecords.list  s    .6mmHMM.J"^.JP\oo11.J"^_"^Qyy"^_s8q=+#=!>?@\\^
A"a  z?a+#@!ABCA!H ! #__s   DDDc                s    R V,          pRV,          p\        V P                  V\        V4      VR4      pV^ 8  d   V P                  4        V^ 8  d   \	        \        R4      V,          4      hR# )permissive_%sz(typepermissive %s)Zcilz?Could not set permissive domain %s (module installation failed)N)Zsemanage_module_installrd   rU   r8   rj   r   )r   typer$   ZmodtxtrY      &&   r   r   ZpermissiveRecords.add  sc    %&-$TWWfc&k4O7KKM6Q`adhhii r   c                s    VP                  4        FB  p\        V P                  R V,          4      pV^ 8  g   K)  \        \	        R4      V,          4      h	  V P                  4        R# )r   z5Could not remove permissive domain %s (remove failed)N)r   r   rd   rj   r   r8   )r   r$   ZnrY   rJ   r   r   ZpermissiveRecords.delete  sP    A'11DEBAv #Z![^b!bcc 
 	r   c                s    V P                  4       p\        V4      ^ 8  d%   RP                  V4      pV P                  V4       R# R# )r    rE   N)r   rU   joinr   )r   r	   r   s   &  r   rp   ZpermissiveRecords.deleteall  s6    LLNq6A:((1+CKK r   rM   r   r   )r<   r=   r>   r?   r   r   rv   r   r   r   rp   r@   rA   rB   rC   r   r   r     s.     -=(	j r   r   c                   s   a  ] tR tRt o RR ltR tR tR tRR ltRR lt	R	 t
R
 tR tR tRR ltR tRR ltRtV tR# )loginRecordsi  Nc                sh    \         P                  W4       R V n        R V n        R V n        R V n        R # r   )r^   r   r'   r)   r   r&   r{   r3   r   r   ZloginRecords.__init__  s,      ,r   c                s@   \         P                  ! V4      w  q@n        V n        VR 8X  d   Rp\	        V P
                  4      pVP                  V P                  4      w  pw  rxVP                  V4      w  pw  ry\        ^8X  d   VR 8w  d   \        V4      pMTp\        V P                  V4      w  rzV^ 8  d   \        \        R4      V,          4      hV^ ,          R8X  d     \        P                  ! VR,          4       M \        P                   ! V4       \#        V P                  4      w  r{V^ 8  d   \        \        R4      V,          4      h\%        V P                  W4      pV^ 8  d   \        \        R4      V,          4      h\        ^8X  d@   VR 8w  d9   \'        V P                  W4      pV^ 8  d   \        \        R	4      V,          4      h\)        V P                  W4      pV^ 8  d   \        \        R
4      V,          4      h\+        V P                  W4      pV^ 8  d   \        \        R4      V,          4      h\-        V
4       \/        V4       R#    \        \        R4      TR,          ,          4      h; i   \        \        R4      T,          4      h; i)r   Zuser_uCould not create a key for %sZ%rH   NNzLinux Group %s does not existzLinux User %s does not existz%Could not create login mapping for %sCould not set name for %sCould not set MLS range for %sz!Could not set SELinux user for %sz"Could not add login mapping for %sN)rT   getseuserbynamer'   r)   seluserRecordsrb   getrl   r]   semanage_seuser_key_createrd   rj   r   grpZgetgrnampwdZgetpwnamZsemanage_seuser_createZsemanage_seuser_set_namesemanage_seuser_set_mlsrangesemanage_seuser_set_senamesemanage_seuser_modify_localsemanage_seuser_key_freesemanage_seuser_free)r   r$   r   r&   recuserrecr   rY   r(   r%   kus   &&&&        r   __addZloginRecords.__add  s#   /6/F/Ft/L,^T_R<F +!(T^^!<%kk&1|Q"}%g.,TWWd;6Q>?$FGG7c>PT"X&KT" )16QFG$NOO%dggq76Q:;dBCCagm-dggqBBAv #C!Dt!KLL';6QBCdJKK)$''186QCDtKLL #Q=P #B!Cd2h!NOOK #A!BT!IJJs   !I  J  $I= Jc                s     V P                  4        V P                  V4      '       d/   \        \        R 4      V,          4       V P	                  WV4       MV P                  WV4       V P                  4        R#   \         d   pThRp?ii ; i)z:Login mapping for %s is already defined, modifying insteadN)rr   _loginRecords__existsr   r   _loginRecords__modify_loginRecords__addr8   rj   r   r$   r   r&   error   &&&& r   r   ZloginRecords.addS  sm    
	JJL}}T""aTUX\\]dG4

41KKM 	K	s   &A; AA; ;BBBc                   \        V P                  V4      w  r#V^ 8  d   \        \        R4      V,          4      h\	        V P                  V4      w  r$V^ 8  d   \        \        R4      V,          4      h\        V4       V# )r    r   2Could not check if login mapping for %s is defined)r   rd   rj   r   semanage_seuser_existsr   r   r$   rY   r   r   r   r   __existsZloginRecords.__existsa  sn    ,TWWd;6Q>?$FGG-dggq96QSTW[[\\ #r   c                s   \         P                  ! V4      w  q@n        V n        VR 8X  d   VR 8X  d   \	        \        R4      4      h\        V P                  4      pVP                  V P                  4      w  pw  rxVR 8w  d   VP                  V4      w  pw  ryMTp	VR 8w  d   W0n	        MW`n	        \        V P                  V4      w  rzV^ 8  d   \	        \        R4      V,          4      h\        V P                  V
4      w  r{V^ 8  d   \	        \        R4      V,          4      hV'       g   \	        \        R4      V,          4      h\        V P                  V
4      w  r|V^ 8  d   \	        \        R4      V,          4      h\        V4      V n        \        V4      V n        \         ^8X  d(   VR 8w  d!   \#        V P                  V\%        V4      4       VR 8w  d   \'        V P                  W4       W n        MV P                  V n        \+        V P                  W4      pV^ 8  d   \	        \        R4      V,          4      h\-        V
4       \/        V4       R# )r   zRequires seuser or seranger   r   #Login mapping for %s is not definedzCould not query seuser for %sz%Could not modify login mapping for %sN)rT   r   r'   r)   rj   r   r   rb   r   r&   r   rd   r   Zsemanage_seuser_querysemanage_seuser_get_mlsrangesemanage_seuser_get_senamerl   r   r]   r   r   r   r   r   )r   r$   r   r&   r   r   r   rY   r(   r%   r   r   r   s   &&&&         r   __modifyZloginRecords.__modifym  s   /6/F/Ft/L,^T_R<GrMQ;<== +!(T^^!<R<")++f"5E<BFb="L L,TWWd;6Q>?$FGG-dggq96QSTW[[\\QDELMM'36Q>?$FGG6q93A6agm(![5IJR<&tww: K..DK)$''186QFG$NOO #Qr   c                s     V P                  4        V P                  WV4       V P                  4        R #   \         d   pThR p?ii ; ir   )rr   r   r8   rj   r   r   r   modifyZloginRecords.modify  s<    	JJLMM$0KKM 	K	s   26 AAAc                s   \         P                  ! V4      w  q n        V n        \	        V P
                  4      pVP                  V P                  4      w  pw  rV\        V P                  V4      w  rWV^ 8  d   \        \        R4      V,          4      h\        V P                  V4      w  rXV^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      w  rXV^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      pV^ 8  d   \        \        R4      V,          4      h\        V4       \         P                  ! R4      w  q n        V n        VP                  V P                  4      w  pw  rYR# )r    r   r   r   z<Login mapping for %s is defined in policy, cannot be deletedz%Could not delete login mapping for %sZ__default__N)rT   r   r'   r)   r   rb   r   r   rd   rj   r   r   Zsemanage_seuser_exists_localZsemanage_seuser_del_localr   r   r&   )
r   r$   r   r   r   rY   r(   r   r   r%   
   &&        r   __deleteZloginRecords.__delete  sm   /6/F/Ft/L,^T_ +!(T^^!<,TWWd;6Q>?$FGG-dggq96QSTW[[\\QDELMM3DGGQ?6QSTW[[\\Q]^aeeff&tww26QFG$NOO #)0)@)@)O&[$,%kk$++6|Fr   c                s     V P                  4        V P                  V4       V P                  4        R #   \         d   pThR p?ii ; ir   )rr   _loginRecords__deleter8   rj   r   r$   r   r7   r   r   ZloginRecords.delete  s:    	JJLMM$KKM 	K	s   15 A AAc                s   \        V P                  4      w  rV^ 8  d   \        \        R4      4      h V P	                  4        V F  pV P                  \        V4      4       K  	  V P                  4        R#   \         d   pThRp?ii ; ir    Could not list login mappingsN)semanage_seuser_list_localrd   rj   r   rr   r   semanage_seuser_get_namer8   r   rY   ulistr   r   r   r   rp   ZloginRecords.deleteall  sr    096Q>?@@	JJL6q9: KKM 	K	s   AA9 9BBBc                s   / p\         P                  ! 4       R ,           V n        \        P                  ! V P                  4       F  w  r#pW P                  8X  g   K  V Fv  p \        VR,           V,           4      pVP                  4       P                  4       P                  R4      pVP                  4        V^,          V^,          V^ ,          3W&   Kx  	  K  	  V#   \         d     K  i ; i)z/logins/:)rT   Zselinux_policy_rootlogins_pathr   ZwalkopenreadZrstripr   closeZ
IndexError)r   ddictr   ZdirsZfilesr$   fdr   r   r   get_all_loginsZloginRecords.get_all_logins  s    "6689D!#)9)9!:D'''!D!$*t"34 ggi..066s;
'*1vs1vs1v&> " ";  & s   "A2CC-,C-c                s0   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   F'  p\        V4      p\        V4      \        V4      R3W%&   K)  	  V# )r    r   r   )	r   rd   r   Zsemanage_seuser_listrj   r   r   r   r   )r   r   r   rY   r   r$   r[   r   r   ZloginRecords.get_all  s    9$''BR3DGG<R6Q>?@@A+A.D5a8:VWX:Y[^_EK  r   c           	     sT   . pV P                  R 4      p\        VP                  4       4       Fw  pW#,          ^,          '       d:   VP                  RW#,          ^ ,          : RW#,          ^,          : RV: 24       KQ  VP                  RW#,          ^ ,          : RV: 24       Ky  	  V# )Tz-a -s  -r '' rE   r   r   keysr   r   r	   r   r   r   r   rv   ZloginRecords.customized  x    T"

%Ax{{%(1++ux{{ANO%(1++q9:	 &
 r   c                s   V P                  V4      pV P                  4       p\        VP                  4       4      p\        VP                  4       4      p\	        V4      ^ 8X  d   \	        V4      ^ 8X  d   R# \
        ^8X  Ed   V'       dD   \        R\        R4      :R R\        R4      :R R\        R4      :R R\        R4      : R2	4       V FF  pW7,          p\        V:R RV^ ,          :R R\        V^,          4      :R RV^,          : 24       KH  	  \	        V4      '       d   \        R	V P                  ,          4       V FF  pWG,          p\        V:R RV^ ,          :R R\        V^,          4      :R RV^,          : 24       KH  	  R# V'       d)   \        R\        R4      :R
 R\        R4      :R
 R24       V F$  p\        V:R
 RW7,          ^ ,          :R
 24       K&  	  R# )r    Nr   z
Login NameZ20rE   SELinux UserzMLS/MCS RangeZServicez
Local customization in %sr   )
r   r   r   r   rU   rl   r   r   r\   r   )	r   r   r   r   ZldictZlkeysr   r   r   	   &&&      r   r   ZloginRecords.list  sJ   Y'##%uzz|$ejjl#t9>c%jAoQAlOQ~EVXYZiXjlmnwlxyzH1Q441Q4!A$OP  5zz3d6F6FFGH1Q441Q4!A$OP  1\?An<MNOq%(1++67 r   )r   r'   r)   r   r&   r   r   )r   r   r   r   )r<   r=   r>   r?   r   r   r   r   r   r   r   r   rp   r   r   rv   r   r@   rA   rB   rC   r   r   r     sM     4 l
0 d7<8 8r   r   c                   s   a  ] tR tRt o RR ltR tR tR tR t. RRR3R	 lt	. RRR3R
 lt
R tR tR tRR ltR tRR ltRtV tR# )r   i  Nc                ry   r   rz   r{   r3   r   r   ZseluserRecords.__init__  r|   r   c                s   \        V P                  V4      w  r#V^ 8  d   \        \        R4      V,          4      h\	        V P                  V4      w  r$V^ 8  d   \        \        R4      V,          4      h\        V P                  V4      w  r%V^ 8  d   \        \        R4      V,          4      h\        V4      p\        V P                  V4      p\        V4       \        V4       Wg3# )r    r   -Could not check if SELinux user %s is definedCould not query user for %s)
semanage_user_key_createrd   rj   r   semanage_user_existssemanage_user_querysemanage_user_get_mlsrangesemanage_user_get_rolessemanage_user_key_freesemanage_user_free)r   r$   rY   r   r   r   r&   r%      &&      r   r   ZseluserRecords.get"  s    *477D96Q>?$FGG+DGGQ76QNORVVWW%dggq16Q<=DEE,Q/(!4q!1r   c                s   \         ^8X  d+   VR8X  d   RpM\        V4      pVR8X  d   RpM\        V4      p\        V4      ^8  d   \        \	        R4      V,          4      h\        V P                  V4      w  rgV^ 8  d   \        \	        R4      V,          4      h\        V P                  4      w  rhV^ 8  d   \        \	        R4      V,          4      h\        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      hV FD  p	\        V P                  W4      pV^ 8  g   K"  \        \	        R4      P                  WR7      4      h	  \         ^8X  dq   \        V P                  W4      pV^ 8  d   \        \	        R	4      V,          4      h\        V P                  W4      pV^ 8  d   \        \	        R
4      V,          4      h\        V P                  W4      pV^ 8  d&   \        \	        R4      P                  X	VR7      4      h\        V P                  V4      w  rjV^ 8  d   \        \	        R4      V,          4      h\        V P                  Wx4      pV^ 8  d   \        \	        R4      V,          4      h\!        V4       \#        V4       V P$                  P'                  RVRP)                  V4      VR7       R# )rH   r   s0z%You must add at least one role for %sr   z$Could not create SELinux user for %sr   z$Could not add role {role} for {name})r   r$   r   zCould not set MLS level for %sz(Could not add prefix {prefix} for {role})r   prefixzCould not extract key for %szCould not add SELinux user %sseuserr   )r   r%   r&   N)rl   r]   rU   rj   r   r   rd   Zsemanage_user_createZsemanage_user_set_namesemanage_user_add_roleformatsemanage_user_set_mlsrangesemanage_user_set_mlslevelsemanage_user_set_prefixZsemanage_user_key_extractsemanage_user_modify_localr   r   rf   r+   r   )r   r$   rolesselevelr&   r  rY   r   r   rr      &&&&&&     r   r   ZseluserRecords.__add2  sK   Q"}%g."}%g.u:>QFG$NOO*477D96Q>?$FGG&tww/6QEFMNN#DGGQ56Q:;dBCCA'6BAv #I!J!Q!QWX!Q!dee 
 Q+DGGQ@BAv #C!Dt!KLL+DGGQ@BAv #C!Dt!KLL%dggq96QIJQQWXagQhii-dggq9	6Q=>EFF'66Q>?$FGGq!1

xSXXe_gVr   c                sZ    V P                  4        V P                  V4      '       d0   \        \        R 4      V,          4       V P	                  WW4V4       MV P                  WW4V4       V P                  4        R#   \         d#   pT P                  P                  ^ 4       ThRp?ii ; i)z5SELinux user %s is already defined, modifying insteadN)	rr   _seluserRecords__existsr   r   _seluserRecords__modify_seluserRecords__addr8   rj   rf   r   r$   r	  r
  r&   r  r      &&&&&& r   r   ZseluserRecords.addi  s    
	JJL}}T""aOPSWWXd7VD

4&AKKM 	JJa K	s   &A= AA= =B*B%%B*c                r   )r    r   r   )r   rd   rj   r   r   r   r   r   r   r   ZseluserRecords.__existsv  sn    *477D96Q>?$FGG+DGGQ76QNORVVWWq!r   r   c           
     s   R pR pRP                  V4      pVR 8X  dR   \        V4      ^ 8X  dB   VR 8X  d;   VR 8X  d4   \        ^8X  d   \        \	        R4      4      h\        \	        R4      4      h\        V P                  V4      w  rV	^ 8  d   \        \	        R4      V,          4      h\        V P                  V
4      w  rV	^ 8  d   \        \	        R4      V,          4      hV'       g   \        \	        R4      V,          4      h\        V P                  V
4      w  rV	^ 8  d   \        \	        R4      V,          4      h\        V4      p\        V P                  V4      w  rV	^ 8  d   RP                  V4      p\        ^8X  d(   VR 8w  d!   \        V P                  V\        V4      4       \        ^8X  d(   VR 8w  d!   \        V P                  V\        V4      4       VR 8w  d   \        V P                  W4       \        V4      ^ 8w  dD   V F  pW9  g   K  \        W4       K  	  V F!  pW9  g   K  \!        V P                  W4       K#  	  \#        V P                  W4      p	V	^ 8  d   \        \	        R4      V,          4      h\%        V
4       \'        V4       R	P                  VP)                  4       4      pR	P                  VP)                  4       4      pV P*                  P-                  R
WWWgR7       R# )r   rE   z&Requires prefix, roles, level or rangezRequires prefix or rolesr   r   SELinux user %s is not definedr   z Could not modify SELinux user %sr   r  )r   r'   r%   r&   r(   r)   N)r   rU   rl   rj   r   r   rd   r   r   r   r   r  r]   r  r  Zsemanage_user_del_roler  r  r   r   r   rf   r+   )r   r$   r	  r
  r&   r  r(   r)   ZnewrolesrY   r   r   r   rlistr  r   s   &&&&&&          r   r   ZseluserRecords.__modify  sX   	
88E?R<CJ!O2'R-" #K!LMM #=!>??*477D96Q>?$FGG+DGGQ76QNORVVWWQ?@4GHH%dggq16Q<=DEE/2
-dggq97Iagm&tww;w3GHagm&tww;w3GHR<$TWWa8u:?>*10  >*477A9  (66QABTIJJq!1xx()HHY__./	

xTfo  	Hr   c                s     V P                  4        V P                  WW4V4       V P                  4        R#   \         d#   pT P                  P                  ^ 4       ThRp?ii ; ir    N)rr   r  r8   rj   rf   r  r  r   r   ZseluserRecords.modify  sP    	JJLMM$w@KKM 	JJa K	s   37 A$AA$c                s   \        V P                  V4      w  r#V^ 8  d   \        \        R4      V,          4      h\	        V P                  V4      w  r$V^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      w  r$V^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      w  r%V^ 8  d   \        \        R4      V,          4      h\        V4      p\        V P                  V4      w  r'RP                  V4      p\        V P                  V4      pV^ 8  d   \        \        R4      V,          4      h\        V4       \        V4       V P                  P                  RWVR	7       R
# )r    r   r   r  z7SELinux user %s is defined in policy, cannot be deletedr   r   z Could not delete SELinux user %sr  )r'   r)   r(   N)r   rd   rj   r   r   Zsemanage_user_exists_localr   r   r   r   Zsemanage_user_del_localr   r   rf   r/   )	r   r$   rY   r   r   r   r)   r  r(   	   &&       r   r   ZseluserRecords.__delete  ss   *477D96Q>?$FGG+DGGQ76QNORVVWWQ?@4GHH1$''1=6QNORVVWWQXY\``aa%dggq16Q<=DEE/2
-dggq9HHUO	$TWWa06QABTIJJq!1

h$Ybcr   c                s     V P                  4        V P                  V4       V P                  4        R#   \         d#   pT P                  P                  ^ 4       ThRp?ii ; ir  )rr   _seluserRecords__deleter8   rj   rf   r   r7   r   r   ZseluserRecords.delete  sL    	JJLMM$KKM 	JJa K	s   15 A" AA"c                sR   \        V P                  4      w  rV^ 8  d   \        \        R4      4      h V P	                  4        V F  pV P                  \        V4      4       K  	  V P                  4        R#   \         d#   pT P                  P                  ^ 4       ThRp?ii ; ir   )	semanage_user_list_localrd   rj   r   rr   r  semanage_user_get_namer8   rf   r   r   r   rp   ZseluserRecords.deleteall  s    .tww76Q>?@@	JJL4Q78 KKM 	JJa K	s   AA9 9B&B!!B&c                s   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   F  p\        V4      p\        V P                  V4      w  r6V^ 8  d   \	        \        R4      V,          4      hRP                  V4      p\        V4      \        V4      \        V4      V3V\        V4      &   K  	  V# )r    zCould not list SELinux usersz Could not list roles for user %srE   )r  rd   r   Zsemanage_user_listrj   r   r  r   r   Zsemanage_user_get_prefixZsemanage_user_get_mlslevelr   )r   r   r   rY   r   r$   r  r	  r   r   r   ZseluserRecords.get_all  s    7@R1$'':R6Q=>??A)!,D1$''1=KRAv #E!F!MNNHHUOE0H0KMghiMj  mG  HI  mJ  LQ  0RE(+,  r   c                s   . pV P                  R 4      p\        VP                  4       4       F  pW#,          ^,          '       g   W#,          ^,          '       dK   VP                  RW#,          ^,          : RW#,          ^,          : RW#,          ^,          : RV: 24       Kw  VP                  RW#,          ^,          : RV: 24       K  	  V# )Tz-a -L z -r z -R 'r   z-a -R 'r   r   r   r   rv   ZseluserRecords.customized  s    T"

%Ax{{ehqkkUXa[[RWRZ[\R]R]_`abEHQKK;<	 &
 r   c                sN   V P                  V4      p\        V4      ^ 8X  d   R# \        VP                  4       4      p\        ^8X  Ed   V'       d   \        RR:R R\        R4      :R R\        R4      :R R\        R4      :R	 24       \        \        R
4      :R R\        R4      :R R\        R4      :R R\        R4      :R	 R\        R4      : R2
4       V Fk  p\        V:R RW5,          ^ ,          :R R\        W5,          ^,          4      :R R\        W5,          ^,          4      :R	 RW5,          ^,          : 2	4       Km  	  R# V'       d'   \        \        R
4      :R R\        R4      : R24       V F#  p\        V:R RW5,          ^,          : 24       K%  	  R# )r    Nr   r   Z15rE   ZLabelingZ10zMLS/30r   ZPrefixz	MCS Levelz	MCS RangezSELinux Roles)r   rU   r   r   rl   r   r   r\   r   r   r   r   r   r   r   r   r   ZseluserRecords.list  s-   Y'u:?ejjl#QR:&	STU[S\]^.8I1X;XYZeXfhijuhvxy  {J  yK  L  Ma!iPUPXYZP[F\^ghmhpqrhs^tv{v~  @A  wB  C  D  a&7?9KLMAux{34 r   )r   r   r   r   )r<   r=   r>   r?   r   r   r  r   r  r  r   r  r   rp   r   rv   r   r@   rA   rB   rC   r   r   r     sg     - 5Wn
 $&r2b 6Hp "$RB dB(5 5r   r   c                      a  ] tR tRt o . tRR ltR tR tR tR t	R t
R	 tR
 tR tR tRR ltRR ltR tRR ltRtV tR# )portRecordsi-  Nc                s    \         P                  W4        \        \        \        P                  ! \        P
                  R 4      4      ^ ,          R,          4      V n        R#   \         d     R# i ; i)Z	port_typetypesN)r^   r   r   rg   r   	ATTRIBUTEvalid_typesRuntimeErrorr{   r3   r   r   ZportRecords.__init__1  sV      ,	#Dx7I7I;)W$XYZ$[\c$deD 		s   A
A# #A21A2c                s|   R \         R\        R\        R\        /pW#P	                  4       9   d
   W2,          pM\        \        R4      4      hVR8X  d   \        \        R4      4      h\        V\        4      '       d   VP                  R^4      pMV3p\        V4      ^8X  d   \        V^ ,          4      ;rgM$\        V^ ,          4      p\        V^,          4      pVR8  d   \        \        R	4      4      h\        V P                  WvV4      w  rV^ 8  d%   \        \        R
4      P                  W!R7      4      hWWv3# )ZtcpZudpZsctpZdccpz0Protocol has to be one of udp, tcp, dccp or sctpr   zPort is requiredr     zInvalid Portz)Could not create a key for {proto}/{port}protoport)ZSEMANAGE_PROTO_TCPZSEMANAGE_PROTO_UDPZSEMANAGE_PROTO_SCTPZSEMANAGE_PROTO_DCCPr   rj   r   ra   r"   r   rU   intZsemanage_port_key_createrd   r  )
r   r$  r#  Z	protocolsproto_dZportshighlowrY   r   s
   &&&       r   __genkeyZportRecords.__genkey8  s   ..002	
 NN$$&GQQRSS2:Q1233dC  JJsA&EGEu:?U1X&D3eAh-CuQx=D%<Q~.//*477CwG6QJKRRY^RjkkC&&r   c                s`   \         ^8X  d   VR8X  d   RpM\        V4      pVR8X  d   \        \        R4      4      h\        P
                  ! V4      pW@P                  9  d   \        \        R4      V,          4      hV P                  W4      w  rVrx\        V P                  4      w  rV	^ 8  d%   \        \        R4      P                  W!R7      4      h\        W4       \        WV4       \        V P                  4      w  rV	^ 8  d%   \        \        R4      P                  W!R7      4      h\        V P                  VR4      p	V	^ 8  d%   \        \        R	4      P                  W!R7      4      h\        V P                  VR
4      p	V	^ 8  d%   \        \        R4      P                  W!R7      4      h\!        V P                  W4      p	V	^ 8  d%   \        \        R4      P                  W!R7      4      h\         ^8X  dI   VR8w  dB   \#        V P                  W4      p	V	^ 8  d%   \        \        R4      P                  W!R7      4      h\%        V P                  W4      p	V	^ 8  d%   \        \        R4      P                  W!R7      4      h\'        V P                  WZ4      p	V	^ 8  d%   \        \        R4      P                  W!R7      4      h\)        V4       \+        V4       \-        V
4       V P.                  P1                  RV: R\2        P4                  ! V4      : RR: RR
: RV: RV: 24       R# )rH   r   r   Type is required'Type %s is invalid, must be a port typez(Could not create port for {proto}/{port}r"  z+Could not create context for {proto}/{port}system_uz5Could not set user in port context for {proto}/{port}object_rz5Could not set role in port context for {proto}/{port}z5Could not set type in port context for {proto}/{port}z;Could not set mls fields in port context for {proto}/{port}z-Could not set port context for {proto}/{port}z!Could not add port {proto}/{port}zresrc=port op=add lport= proto=
 tcontext=r   N)rl   r]   rj   r   rg   get_real_type_namer  _portRecords__genkeyZsemanage_port_createrd   r  Zsemanage_port_set_protoZsemanage_port_set_rangesemanage_context_createsemanage_context_set_usersemanage_context_set_rolesemanage_context_set_typesemanage_context_set_mlsZsemanage_port_set_consemanage_port_modify_localsemanage_context_freesemanage_port_key_freesemanage_port_freerf   r4   r   getprotobyname)r   r$  r#  r&   r   r   r&  r(  r'  rY   r
   con   &&&&&       r   r   ZportRecords.__addX  s   Q"}%g.2:Q1233**40'''QHIDPQQ"&--"<S&tww/6QIJQQX]Qijj+-+DGG4	6QLMTT[`Tlmm&twwZ@6QVW^^ej^vww&twwZ@6QVW^^ej^vww&tww:6QVW^^ej^vwwagm)$''3@BAv #`!a!h!hot!h  "A  B  B"477A36QNOVV]bVnoo'66QBCJJQVJbccc"q!1

\`bhbwbwx}b~  AK  MW  Y]  _f  g  	hr   c                   V P                  4        V P                  W4      '       d8   \        \        R 4      P	                  W!R7      4       V P                  WW44       MV P                  WW44       V P                  4        R# )z6Port {proto}/{port} already defined, modifying insteadr"  N)rr   _portRecords__existsr   r   r  _portRecords__modify_portRecords__addr8   )r   r$  r#  r&   r      &&&&&r   r   ZportRecords.add  s\    

==%%!LMTT[`TlmMM$w5JJtG2r   c                s    V P                  W4      w  r4rV\        V P                  V4      w  rxV^ 8  d%   \        \	        R4      P                  W!R7      4      h\        V4       V# )r    1Could not check if port {proto}/{port} is definedr"  )r1  semanage_port_existsrd   rj   r   r  r9  	r   r$  r#  r   r&  r(  r'  rY   r   r   r   r   ZportRecords.__exists  s[    "&--"<S+DGGQ76QRSZZafZrssq!r   c                s   VR 8X  d;   VR 8X  d4   \         ^8X  d   \        \        R4      4      h\        \        R4      4      h\        P                  ! V4      pV'       d,   W@P
                  9  d   \        \        R4      V,          4      hV P                  W4      w  rVrx\        V P                  V4      w  rV	^ 8  d%   \        \        R4      P                  W!R7      4      hV
'       g%   \        \        R4      P                  W!R7      4      h\        V P                  V4      w  rV	^ 8  d%   \        \        R4      P                  W!R7      4      h\        V4      p\         ^8X  d+   VR 8X  d   RpM \        V P                  V\        V4      4       VR 8w  d   \        V P                  W4       \        V P                  W[4      p	V	^ 8  d%   \        \        R	4      P                  W!R7      4      h\!        V4       \#        V4       V P$                  P'                  R
V: R\(        P*                  ! V4      : RR: RR: RV: RV: 24       R# )r   Requires setype or serangeRequires setyper+  rC  r"  "Port {proto}/{port} is not definedz#Could not query port {proto}/{port}r   z$Could not modify port {proto}/{port}zresrc=port op=modify lport=r.  r/  r,  r   r-  N)rl   rj   r   rg   r0  r  r1  rD  rd   r  Zsemanage_port_querysemanage_port_get_conr6  r]   r5  r7  r9  r:  rf   r4   r   r;  )r   r$  r#  r&   setyper   r&  r(  r'  rY   r   r
   r<  s   &&&&&        r   r   ZportRecords.__modify  s   b=Vr\" #?!@AA #4!566,,V4f$4$44QHIFRSS"&--"<S+DGGQ76QRSZZafZrssQCDKKRWKcdd%dggq16QDELLSXLdee#A&Q"}(#{77KLR<%dggs;'66QEFMMTYMeffq!1

_cekezez  |A  fB  DN  PZ  \b  dk  l  	mr   c                j    V P                  4        V P                  WW44       V P                  4        R # r   )rr   r@  r8   )r   r$  r#  r&   rJ  rB  r   r   ZportRecords.modify  s"    

d73r   c           	     s   \        V P                  4      w  rV^ 8  d   \        \        R4      4      hV P	                  4        V F  p\        V4      p\        V4      p\        V4      p\        V4      pV: RV: 2pV P                  W4      w  rrgV^ 8  d   \        \        R4      V,          4      h\        V P                  V	4      pV^ 8  d   \        \        R4      V,          4      h\        V	4       Wg8X  d   TpV P                  P                  RV: R\        P                  ! V4      : 24       K  	  V P!                  4        R# )r    zCould not list the portsr   r   zCould not delete the port %sresrc=port op=delete lport=r.  N)semanage_port_list_localrd   rj   r   rr   semanage_port_get_protosemanage_port_get_proto_strsemanage_port_get_lowsemanage_port_get_highr1  semanage_port_del_localr9  rf   r4   r   r;  r8   )r   rY   plistr$  r#  	proto_strr(  r'  Zport_strr   r&  r   r   rp   ZportRecords.deleteall  s   .tww76Q9:;;

D+D1E3E:I'-C)$/D"%t,H&*mmH&H#QAv #B!Ch!NOO(!4BAv #A!BX!MNN"1%{JJ!!hX^XmXmnwXx"yz' * 	r   c                s   V P                  W4      w  r4rV\        V P                  V4      w  rxV^ 8  d%   \        \	        R4      P                  W!R7      4      hV'       g%   \        \	        R4      P                  W!R7      4      h\        V P                  V4      w  rxV^ 8  d%   \        \	        R4      P                  W!R7      4      hV'       g%   \        \	        R4      P                  W!R7      4      h\        V P                  V4      pV^ 8  d%   \        \	        R4      P                  W!R7      4      h\        V4       V P                  P                  RV: R\        P                  ! V4      : 24       R# )	r    rC  r"  rH  z;Port {proto}/{port} is defined in policy, cannot be deletedz$Could not delete port {proto}/{port}rL  r.  N)r1  rD  rd   rj   r   r  Zsemanage_port_exists_localrR  r9  rf   r4   r   r;  rE  r   r   r   ZportRecords.__delete  s0   "&--"<S+DGGQ76QRSZZafZrssQCDKKRWKcdd1$''1=6QRSZZafZrssQ\]ddkpd|}}$TWWa06QEFMMTYMeffq!

$PVPePefkPlmnr   c                h    V P                  4        V P                  W4       V P                  4        R # r   )rr   _portRecords__deleter8   )r   r$  r#     &&&r   r   ZportRecords.delete  s     

d"r   c                s   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   FW  p\        V4      p\        V4      p\        V4      p\        V4      p\        V4      p	\        V4      p
\        V4      pWg3W*W3&   KY  	  V# )r    Could not list ports)rM  rd   rS  semanage_port_listrj   r   rI  semanage_context_get_typesemanage_context_get_mlsrN  rO  rP  rQ  )r   r   r   rY   r$  r<  ctypelevelr#  rT  r(  r'  s   &&          r   r   ZportRecords.get_all  s    7@R1$'':R6Q5677JJD'-C-c2E,S1E+D1E3E:I'-C)$/D-2NE()  r   c                s6   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   F  p\        V4      p\        V4      p\        V4      p\        V4      p\        V4      p	\        V4      p
Wh3VP                  4       9  d   . W&V3&   W8X  d#   W&V3,          P                  RV	,          4       K  W&V3,          P                  RW3,          4       K  	  V# )r    rX  z%dz%d-%d)rM  rd   rS  rY  rj   r   rI  rZ  rN  rO  rP  rQ  r   r   )r   r   r   rY   r$  r<  r\  r#  rT  r(  r'     &&         r   get_all_by_typeZportRecords.get_all_by_type!  s    7@R1$'':R6Q5677JJD'-C-c2E+D1E3E:I'-C)$/D!5,.i(){i()00<i()00C;1FG  r   c                   . pV P                  R 4      p\        VP                  4       4       F  pV^ ,          V^,          8X  d
   V^ ,          MV^ ,          : RV^,          : 2pW#,          ^,          '       dE   VP                  RW#,          ^ ,          : RW#,          ^,          : RV^,          : RV: 24       K  VP                  RW#,          ^ ,          : RV^,          : RV: 24       K  	  V# )Tr   -a -t r   z' -p rE    -p r   r   r	   r   r   r$  r   r   rv   ZportRecords.customized9  s    T"

%AQ41Q4<1Q4!ad-CDx{{UXa[[RSTURVRVX\]^QqTT4HI & r   c           	     s   V P                  V4      p\        V4      ^ 8X  d   R# \        VP                  4       4      pV'       d5   \	        \        R4      :R R\        R4      :R R\        R4      : R24       V FZ  pR	V,          pVR
W5,          ^ ,          ,          ,          pW5,          R,           F  pVRV,          ,          pK  	  \	        V4       K\  	  R# )r    NzSELinux Port Typer  rE   ZProtoZ8Port Numberr   z%-30s %-8s %sr   , %s)r_  rU   r   r   r   r   r   r   r   r   r   r   r   r
   r   r   r   ZportRecords.listD  s    $$Y/u:?ejjl#q)<'=qz1]K[\]A!#C4%(1+%%CXb\\vz! "#J r   rS  r  r   r   r   )r<   r=   r>   r?   r  r   r1  rA  r   r?  r@  r   rp   rV  r   r   r_  rv   r   r@   rA   rB   rC   r   r  r  -  s[     K'@8ht(mT
<o,
(0	 r   r  c                   r  )ibpkeyRecordsiS  Nc                    \         P                  W4        \        \        \        P
                  ! V P                  4      4      R .R7      p\        R VP                  4        4       4      V n	        R#     R# ; i)Zibpkey_typeZattrsc              3   8   "   T F  p\        V4      x  K  	  R # 5ir   r"   Z.0r   ru   r   	<genexpr>Z)ibpkeyRecords.__init__.<locals>.<genexpr>[  s     %Bkc!ffk   N)
r^   r   r   r   rg   get_store_policyr`   r   resultsr  r   rb   Zqr7   r   r   ZibpkeyRecords.__init__W  s\      ,	-(A(A$**(MNWdVefA%%Baiik%BBD	   AA3 3A8c                s   VR 8X  d   \        \        R4      4      hVP                  R4      p\        V4      ^8X  d   \	        V^ ,          ^ 4      ;rEM&\	        V^ ,          ^ 4      p\	        V^,          ^ 4      pVR8  d   \        \        R4      4      h\        V P                  W%V4      w  rgV^ 8  d%   \        \        R4      P                  W!R7      4      hWrWT3# )r   zSubnet Prefix is requiredr   r!  zInvalid Pkeyz1Could not create a key for {subnet_prefix}/{pkey}subnet_prefixpkey)rj   r   r   rU   r%  Zsemanage_ibpkey_key_createrd   r  )r   rw  rv  Zpkeysr'  r(  rY   r   r   r   r)  ZibpkeyRecords.__genkey_  s    BQ:;<<

3u:?U1Xq))D3eAh"CuQx#D%<Q~.//,TWWm$O6QRSZZivZ  C  D  D#,,r   c                s   \         ^8X  d   VR8X  d   RpM\        V4      pVR8X  d   \        \        R4      4      h\        P
                  ! V4      pW@P                  9  d   \        \        R4      V,          4      hV P                  W4      w  rRrg\        V P                  4      w  rV^ 8  d%   \        \        R4      P                  W!R7      4      h\        V P                  W4       \        WV4       \        V P                  4      w  rV^ 8  d%   \        \        R4      P                  W!R7      4      h\        V P                  V
R4      pV^ 8  d%   \        \        R	4      P                  W!R7      4      h\        V P                  V
R
4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\!        V P                  W4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\         ^8X  dI   VR8w  dB   \#        V P                  W4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\%        V P                  W4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\'        V P                  WY4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\)        V
4       \+        V4       \-        V	4       R# )rH   r   r   r*  )Type %s is invalid, must be a ibpkey typez2Could not create ibpkey for {subnet_prefix}/{pkey}ru  z3Could not create context for {subnet_prefix}/{pkey}r,  z?Could not set user in ibpkey context for {subnet_prefix}/{pkey}r-  z?Could not set role in ibpkey context for {subnet_prefix}/{pkey}z?Could not set type in ibpkey context for {subnet_prefix}/{pkey}zECould not set mls fields in ibpkey context for {subnet_prefix}/{pkey}z7Could not set ibpkey context for {subnet_prefix}/{pkey}z+Could not add ibpkey {subnet_prefix}/{pkey}N)rl   r]   rj   r   rg   r0  r  _ibpkeyRecords__genkeyZsemanage_ibpkey_createrd   r  Z!semanage_ibpkey_set_subnet_prefixZsemanage_ibpkey_set_ranger2  r3  r4  r5  r6  Zsemanage_ibpkey_set_consemanage_ibpkey_modify_localr8  semanage_ibpkey_key_freesemanage_ibpkey_free)r   rw  rv  r&   r   r   r(  r'  rY   r
   r<     &&&&&      r   r   ZibpkeyRecords.__addr  s   Q"}%g.2:Q1233**40'''QJKdRSS(,d(J%3(16QST[[jw[  D  E  E)$''1D!!$/+DGG4	6QTU\\kx\  E  F  F&twwZ@6Q`ahh  xEh  Q  R  R&twwZ@6Q`ahh  xEh  Q  R  R&tww:6Q`ahh  xEh  Q  R  Ragm)$''3@BAv #j!k!r!r  BO!r  "[  \  \$TWWa56QXY``o|`  I  J  J)$''186QLMTTcpT|}}c" #Qr   c                r>  )z@ibpkey {subnet_prefix}/{pkey} already defined, modifying insteadru  N)rr   _ibpkeyRecords__existsr   r   r  _ibpkeyRecords__modify_ibpkeyRecords__addr8   )r   rw  rv  r&   r   rB  r   r   ZibpkeyRecords.add  sb    

==--!VW^^mz^  G  HMM$w=JJtG:r   c                s    V P                  W4      w  r2rE\        V P                  V4      w  rgV^ 8  d%   \        \	        R4      P                  W!R7      4      h\        V4       V# )r    ;Could not check if ibpkey {subnet_prefix}/{pkey} is definedru  )ry  semanage_ibpkey_existsrd   rj   r   Zformnatr{  r   rw  rv  r   r(  r'  rY   r   r   r   r   ZibpkeyRecords.__exists  sh    (,d(J%3-dggq96Q\]ee  uBe  N  O  O #r   c                s   VR 8X  d;   VR 8X  d4   \         ^8X  d   \        \        R4      4      h\        \        R4      4      h\        P                  ! V4      pV'       d,   W@P
                  9  d   \        \        R4      V,          4      hV P                  W4      w  rRrg\        V P                  V4      w  rV^ 8  d%   \        \        R4      P                  W!R7      4      hV	'       g%   \        \        R4      P                  W!R7      4      h\        V P                  V4      w  rV^ 8  d%   \        \        R4      P                  W!R7      4      h\        V
4      p\         ^8X  d(   VR 8w  d!   \        V P                  V\        V4      4       VR 8w  d   \        V P                  W4       \        V P                  WZ4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\!        V4       \#        V
4       R	# )
r   rF  rG  rx  r  ru  ,ibpkey {subnet_prefix}/{pkey} is not definedz-Could not query ibpkey {subnet_prefix}/{pkey}z.Could not modify ibpkey {subnet_prefix}/{pkey}N)rl   rj   r   rg   r0  r  ry  r  rd   r  Zsemanage_ibpkey_querysemanage_ibpkey_get_conr6  r]   r5  rz  r{  r|  )r   rw  rv  r&   rJ  r   r(  r'  rY   r   r
   r<  r=  r   r   ZibpkeyRecords.__modify  s   b=Vr\" #?!@AA #4!566,,V4f$4$44QJKfTUU(,d(J%3-dggq96Q\]dd  tAd  M  N  NQMNUUdqU}~~'36QNOVVerV~%a(agm$TWWc;w3GHR<%dggs;)$''186QOPWWfsW  A  A #Qr   c                rK  r   )rr   r  r8   )r   rw  rv  r&   rJ  rB  r   r   ZibpkeyRecords.modify  s"    

d7;r   c                s   \        V P                  4      w  rV^ 8  d   \        \        R4      4      hV P	                  4        V F  p\        V P                  V4      w  r\        V4      p\        V4      pV: RV: 2pV P                  Wt4      w  rrVV^ 8  d   \        \        R4      V,          4      h\        V P                  V4      pV^ 8  d   \        \        R4      V,          4      h\        V4       K  	  V P                  4        R# )r    zCould not list the ibpkeysr   r   zCould not delete the ibpkey %sN)semanage_ibpkey_list_localrd   rj   r   rr   !semanage_ibpkey_get_subnet_prefixsemanage_ibpkey_get_lowsemanage_ibpkey_get_highry  semanage_ibpkey_del_localr{  r8   )	r   rY   rS  ibpkeyrv  r(  r'  Zpkey_strr   s	   &        r   rp   ZibpkeyRecords.deleteall  s    096Q;<==

F"CDGGV"TR)&1C+F3D"%t,H,0MM(,R)QsAv #B!Ch!NOO*477A6BAv #C!Dx!OPP$Q'  	r   c                s   V P                  W4      w  r2rE\        V P                  V4      w  rgV^ 8  d%   \        \	        R4      P                  W!R7      4      hV'       g%   \        \	        R4      P                  W!R7      4      h\        V P                  V4      w  rgV^ 8  d%   \        \	        R4      P                  W!R7      4      hV'       g%   \        \	        R4      P                  W!R7      4      h\        V P                  V4      pV^ 8  d%   \        \	        R4      P                  W!R7      4      h\        V4       R# )r    r  ru  r  zEibpkey {subnet_prefix}/{pkey} is defined in policy, cannot be deletedz.Could not delete ibpkey {subnet_prefix}/{pkey}N)	ry  r  rd   rj   r   r  Zsemanage_ibpkey_exists_localr  r{  r  r   r   r   ZibpkeyRecords.__delete  s9   (,d(J%3-dggq96Q\]dd  tAd  M  N  NQMNUUdqU}~~3DGGQ?6Q\]dd  tAd  M  N  NQfgnn  ~Kn  W  X  X&tww26QOPWWfsW  A  A #r   c                rU  r   )rr   _ibpkeyRecords__deleter8   )r   rw  rv  rW  r   r   ZibpkeyRecords.delete  s     

d*r   c                s   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   Fb  p\        V4      p\        V4      pVR8X  d   K"  \        V4      p\        V P                  V4      w  r8\        V4      p	\        V4      p
Wg3W)W3&   Kd  	  V# )r    Could not list ibpkeysZreserved_ibpkey_t)r  rd   rS  semanage_ibpkey_listrj   r   r  rZ  r[  r  r  r  )r   r   r   rY   r  r<  r\  r]  rv  r(  r'  r^  r   r   ZibpkeyRecords.get_all  s    9$''BR3DGG<R6Q7899jjF)&1C-c2E++,S1E"CDGGV"TR)&1C+F3D16E,- ! r   c                s:   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   F  p\        V4      p\        V4      p\        V P                  V4      w  r7\        V4      p\        V4      p	Wg3VP                  4       9  d   . W&V3&   W8X  d#   W&V3,          P                  RV,          4       K  W&V3,          P                  RW3,          4       K  	  V# )r    r  0x%xz	0x%x-0x%x)r  rd   rS  r  rj   r   r  rZ  r  r  r  r   r   )
r   r   r   rY   r  r<  r\  rv  r(  r'  r   r   r_  ZibpkeyRecords.get_all_by_type-  s    9$''BR3DGG<R6Q7899jjF)&1C-c2E"CDGGV"TR)&1C+F3D%UZZ\902m,-{m,-44Vc\Bm,-44[C;5NO ! r   c                r`  )Tr   ra  r   z' -x rE   z -x r   rc  r   r   rv   ZibpkeyRecords.customizedD  s    T"

%AQ41Q4<1Q4!ad-CDx{{UXa[[RSTURVRVX\]^QqTT4HI & r   c           	        V P                  V4      pVP                  4       p\        V4      ^ 8X  d   R# V'       d5   \        \	        R4      :R R\	        R4      :R R\	        R4      : R24       \        V4       FZ  pR	V,          pVR
W5,          ^ ,          ,          ,          pW5,          R,           F  pVRV,          ,          pK  	  \        V4       K\  	  R# )r    NzSELinux IB Pkey Typer  rE   ZSubnet_Prefix18zPkey Numberr   %-30s %-18s re  r   rf  r_  r   rU   r   r   r   rg  r   r   r   ZibpkeyRecords.listP  s    $$Y/zz|t9>*@(A1_CUWXYfWghiA 1$C4%(1+%%CXb\\vz! "#J r   rh  r   r   r   )r<   r=   r>   r?   r  r   ry  r  r   r~  r  r   rp   r  r   r   r_  rv   r   r@   rA   rB   rC   r   ri  ri  S  sW     K-&6 p$ L
.$(
*.
 r   ri  c                   r  )ibendportRecordsi_  Nc                rj  )Zibendport_typerk  c              3   rl  r   rm  rn  ru   r   ro  Z,ibendportRecords.__init__.<locals>.<genexpr>g  s     "?;a3q66;rp  N)
r^   r   r   r   rg   rq  r`   Zsetrr  r  rs  r7   r   r   ZibendportRecords.__init__c  s\      ,	-(A(A$**(MNWgVhiA""?199;"??D	rt  c                s    VR 8X  d   \        \        R4      4      h\        V4      pV^8  g   V^8  d   \        \        R4      4      h\        V P                  W#4      w  rEV^ 8  d%   \        \        R4      P                  W!R7      4      hWRV3# )r   zIB device name is requiredzInvalid Port Numberz=Could not create a key for ibendport {ibdev_name}/{ibendport}
ibdev_name	ibendport)rj   r   r%  Zsemanage_ibendport_key_createrd   r  )r   r  r  r$  rY   r   r   r   r)  ZibendportRecords.__genkeyk  s    Q;<==9~#:Q4566/J6Q^_ffr|f  S  T  Tt$$r   c                s   \         ^8X  d   VR8X  d   RpM\        V4      pVR8X  d   \        \        R4      4      h\        P
                  ! V4      pW@P                  9  d   \        \        R4      V,          4      hV P                  W4      w  rQp\        V P                  4      w  rxV^ 8  d%   \        \        R4      P                  W&R7      4      h\        V P                  W4       \        W4       \        V P                  4      w  ryV^ 8  d%   \        \        R4      P                  W&R7      4      h\        V P                  V	R4      pV^ 8  d%   \        \        R	4      P                  W&R7      4      h\        V P                  V	R
4      pV^ 8  d%   \        \        R4      P                  W&R7      4      h\!        V P                  W4      pV^ 8  d%   \        \        R4      P                  W&R7      4      h\         ^8X  dI   VR8w  dB   \#        V P                  W4      pV^ 8  d%   \        \        R4      P                  W&R7      4      h\%        V P                  W4      pV^ 8  d%   \        \        R4      P                  W&R7      4      h\'        V P                  WX4      pV^ 8  d%   \        \        R4      P                  W&R7      4      h\)        V	4       \+        V4       \-        V4       R# )rH   r   r   r*  -Type %s is invalid, must be an ibendport typez2Could not create ibendport for {ibdev_name}/{port}r  r$  z/Could not create context for {ibendport}/{port}r,  z?Could not set user in ibendport context for {ibdev_name}/{port}r-  z?Could not set role in ibendport context for {ibdev_name}/{port}z?Could not set type in ibendport context for {ibdev_name}/{port}zECould not set mls fields in ibendport context for {ibdev_name}/{port}z7Could not set ibendport context for {ibdev_name}/{port}z+Could not add ibendport {ibdev_name}/{port}N)rl   r]   rj   r   rg   r0  r  _ibendportRecords__genkeyZsemanage_ibendport_createrd   r  Z!semanage_ibendport_set_ibdev_nameZsemanage_ibendport_set_portr2  r3  r4  r5  r6  Zsemanage_ibendport_set_consemanage_ibendport_modify_localr8  semanage_ibendport_key_freesemanage_ibendport_free)
r   r  r  r&   r   r   r$  rY   r
   r<  s
   &&&&&     r   r   ZibendportRecords.__addy  s   Q"}%g.2:Q1233**40'''QNORVVWW#}}YCt+DGG46QST[[gq[}~~)$''1A#A,+DGG4	6QPQXXdnXz{{&twwZ@6Q`ahht~h  K  L  L&twwZ@6Q`ahht~h  K  L  L&tww:6Q`ahht~h  K  L  Lagm)$''3@BAv #j!k!r!r  I!r  "U  V  V'86QXY``lv`  C  D  D,TWWa;6QLMTT`jTvwwc"#A&"r   c                s   V P                  4        V P                  W4      '       d=   \        \        R 4      P	                  V\
        R7      4       V P                  WW44       MV P                  WW44       V P                  4        R# )z@ibendport {ibdev_name}/{port} already defined, modifying insteadr  N)	rr   _ibendportRecords__existsr   r   r  r$  _ibendportRecords__modify_ibendportRecords__addr8   )r   r  r  r&   r   rB  r   r   ZibendportRecords.add  se    

==//!VW^^jt{^  A  BMM)?JJyg<r   c                s    V P                  W4      w  r1p\        V P                  V4      w  rVV^ 8  d%   \        \	        R4      P                  W$R7      4      h\        V4       V# )r    z;Could not check if ibendport {ibdev_name}/{port} is definedr  )r  semanage_ibendport_existsrd   rj   r   r  r  r   r  r  r   r$  rY   r      &&&    r   r   ZibendportRecords.__exists  sd    #}}YCt0!<6Q\]ddpzd  G  H  H#A&r   c                s   VR 8X  d;   VR 8X  d4   \         ^8X  d   \        \        R4      4      h\        \        R4      4      h\        P                  ! V4      pV'       d,   W@P
                  9  d   \        \        R4      V,          4      hV P                  W4      w  rRp\        V P                  V4      w  rxV^ 8  d%   \        \        R4      P                  W!R7      4      hV'       g%   \        \        R4      P                  W!R7      4      h\        V P                  V4      w  ryV^ 8  d%   \        \        R4      P                  W!R7      4      h\        V	4      p
\         ^8X  d(   VR 8w  d!   \        V P                  V
\        V4      4       VR 8w  d   \        V P                  W4       \        V P                  WY4      pV^ 8  d%   \        \        R4      P                  W!R7      4      h\!        V4       \#        V	4       R	# )
r   rF  rG  r  @Could not check if ibendport {ibdev_name}/{ibendport} is definedr  1ibendport {ibdev_name}/{ibendport} is not definedz2Could not query ibendport {ibdev_name}/{ibendport}z3Could not modify ibendport {ibdev_name}/{ibendport}N)rl   rj   r   rg   r0  r  r  r  rd   r  Zsemanage_ibendport_querysemanage_ibendport_get_conr6  r]   r5  r  r  r  )r   r  r  r&   rJ  r   r$  rY   r   r
   r<  r}  r   r   ZibendportRecords.__modify  s   b=Vr\" #?!@AA #4!566,,V4f$4$44QNORXXYY $i D0!<6Qabiiui  V  W  WQRSZZfpZ  G  H  H*477A66QST[[gq[  H  I  I(+agm$TWWc;w3GHR<%dggs;,TWWa;6QTU\\hr\  I  J  J#A&"r   c                rK  r   )rr   r  r8   )r   r  r  r&   rJ  rB  r   r   ZibendportRecords.modify  s"    

iW=r   c                s,   \        V P                  4      w  rV^ 8  d   \        \        R4      4      hV P	                  4        V F  p\        V P                  V4      w  r\        V4      pV P                  \        V4      V4      w  rdpV^ 8  d%   \        \        R4      P                  WER7      4      h\        V P                  V4      pV^ 8  d%   \        \        R4      P                  WER7      4      h\        V4       K  	  V P                  4        R# )r    zCould not list the ibendportsz.Could not create a key for {ibdev_name}/{port}r  z2Could not delete the ibendport {ibdev_name}/{port}N)semanage_ibendport_list_localrd   rj   r   rr   !semanage_ibendport_get_ibdev_namesemanage_ibendport_get_portr  r"   r  semanage_ibendport_del_localr  r8   )r   rY   rS  r  r  r$  r   s   &      r   rp   ZibendportRecords.deleteall  s    3DGG<6Q>?@@

I@)TR.y9D$(MM#d)Z$H!QDAv #S!T![![gq![!}~~-dggq9BAv #W!X!_!_ku!_  "B  C  C'*  	r   c                s   V P                  W4      w  r2p\        V P                  V4      w  rVV^ 8  d%   \        \	        R4      P                  W!R7      4      hV'       g%   \        \	        R4      P                  W!R7      4      h\        V P                  V4      w  rVV^ 8  d%   \        \	        R4      P                  W!R7      4      hV'       g%   \        \	        R4      P                  W!R7      4      h\        V P                  V4      pV^ 8  d%   \        \	        R4      P                  W!R7      4      h\        V4       R# )r    r  r  r  zJibendport {ibdev_name}/{ibendport} is defined in policy, cannot be deletedz3Could not delete ibendport {ibdev_name}/{ibendport}N)	r  r  rd   rj   r   r  Zsemanage_ibendport_exists_localr  r  r  r  r   r   ZibendportRecords.__delete  s=    $i D0!<6Qabiiui  V  W  WQRSZZfpZ  G  H  H6twwB6Qabiiui  V  W  WQklss  @Js  `  a  a)$''156QTU\\hr\  I  J  J#A&r   c                rU  r   )rr   _ibendportRecords__deleter8   )r   r  r  rW  r   r   ZibendportRecords.delete  s     

i,r   c                s   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   FW  p\        V4      p\        V4      pVR8X  d   K"  \        V4      p\        V P                  V4      w  r8\        V4      p	Wg3W)V3&   KY  	  V# )r    Could not list ibendportsZreserved_ibendport_t)r  rd   rS  semanage_ibendport_listrj   r   r  rZ  r[  r  r  )
r   r   r   rY   r  r<  r\  r]  r  r$  r   r   r   ZibendportRecords.get_all  s    <TWWER6tww?R6Q:;<<I,Y7C-c2E..,S1E@)TR.y9D).E$% $ r   c                s   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   Fx  p\        V4      p\        V4      p\        V P                  V4      w  r7\        V4      pWg3VP                  4       9  d   . W&V3&   W&V3,          P                  RV,          4       Kz  	  V# )r    r  r  )r  rd   rS  r  rj   r   r  rZ  r  r  r   r   )	r   r   r   rY   r  r<  r\  r  r$  r  r   r_  Z ibendportRecords.get_all_by_type0  s    <TWWER6tww?R6Q:;<<I,Y7C-c2E@)TR.y9D"%**,6-/j)**%&--ftm< $ r   c                s   . pV P                  R 4      p\        VP                  4       4       F  pW#,          ^,          '       dL   VP                  RW#,          ^ ,          : RW#,          ^,          : RV^,          : RV^ ,          : 24       Kc  VP                  RW#,          ^ ,          : RV^,          : RV^ ,          : 24       K  	  V# )Tra  r   z' -z rE   z -z r   r   r   r   rv   ZibendportRecords.customizedC  s    T"

%Ax{{UXa[[RSTURVRVXYZ[X\]^QqTT1Q4HI	 &
 r   c           	     r  )r    NzSELinux IB End Port Typer  rE   zIB Device Namer  rd  r   r  re  r   rf  r  rg  r   r   r   ZibendportRecords.listN  s    $$Y/zz|t9>*D(EqIYGZ\]^k\lmnA 1$C4%(1+%%CXb\\vz! "#J r   rh  r   r   r   )r<   r=   r>   r?   r  r   r  r  r   r  r  r   rp   r  r   r   r_  rv   r   r@   rA   rB   rC   r   r  r  _  sW     K%5#n$#L
*'(
(&	 r   r  c                   s~   a  ] tR tRt o . tRR ltR tR tR tR t	R t
R	 tR
 tR tR tRR ltR tRR ltRtV tR# )nodeRecordsi]  Nc                s    \         P                  W4       R R.V n         \        \        \        P
                  ! \        P                  R4      4      ^ ,          R,          4      V n        R#   \         d     R# i ; i)ipv4Zipv6Z	node_typer  N)	r^   r   protocolr   rg   r   r  r  r   r{   r3   r   r   ZnodeRecords.__init__a  sb      ,(	#Dx7I7I;)W$XYZ$[\c$deD 		s   A
A, ,A;:A;c                s6   TpTpR pVR 8X  d   \        \        R4      4      h\        V4      ^ 8X  g   V^ ,          R8X  dZ   \        P                  ! W,           4      p\        VP                  4      p\        VP                  4      pRVP                  ,          p V P                  P                  V4      p \        P                  ! T4      pYEYh3#    \        \        R4      4      h; i   TR8X  d   \        P                  p L8\        \        R4      4      h; i)r   zNode Address is requiredr   zipv%dzUnknown or missing protocolr  )rj   r   rU   	ipaddressZ
ip_networkr"   Znetwork_addressZnetmaskZversionr  Zindexr   r;  ZIPPROTO_IPIP)	r   addrmaskr  ZnewaddrZnewmaskZnewprotocolr   Zaudit_protocol	   &&&&     r   validateZnodeRecords.validatei  s    2:Q9:;; t9>T!W^$$T[1A!++,G!))nG*H	?----h7K
	C#228<N <<	?Q<=>>	C
 F"!'!4!4 #@!ABBs   C 6C) C&)DDc                s   V P                  WV4      w  rr6\        ^8X  d   VR8X  d   RpM\        V4      pVR8X  d   \        \	        R4      4      h\
        P                  ! V4      pWPP                  9  d   \        \	        R4      V,          4      h\        V P                  WV4      w  rxV^ 8  d   \        \	        R4      V,          4      h\        V P                  4      w  ryV^ 8  d   \        \	        R4      V,          4      h\        W4       \        V P                  WV4      p\        V P                  4      w  rzV^ 8  d   \        \	        R4      V,          4      h\        V P                  WV4      pV^ 8  d   \        \	        R4      V,          4      h\        V P                  V
R	4      pV^ 8  d   \        \	        R
4      V,          4      h\!        V P                  V
R4      pV^ 8  d   \        \	        R4      V,          4      h\#        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      h\        ^8X  d@   VR8w  d9   \%        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      h\'        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      h\)        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      h\+        V
4       \-        V4       \/        V	4       V P0                  P3                  RV: RV: RV: RR	: RR: RV: RV: 24       R# )rH   r   r   zSELinux node type is required'Type %s is invalid, must be a node typeCould not create key for %szCould not create addr for %sCould not create context for %szCould not set mask for %sr,  z)Could not set user in addr context for %sr-  z)Could not set role in addr context for %sz)Could not set type in addr context for %sz/Could not set mls fields in addr context for %sz!Could not set addr context for %szCould not add addr %szresrc=node op=add laddr=	 netmask=r.  r/  r   N)r  rl   r]   rj   r   rg   r0  r  semanage_node_key_createrd   Zsemanage_node_createZsemanage_node_set_protoZsemanage_node_set_addrr2  Zsemanage_node_set_maskr3  r4  r5  r6  Zsemanage_node_set_consemanage_node_modify_localr8  semanage_node_key_freesemanage_node_freerf   r4   )r   r  r  r#  r&   r\  audit_protorY   r   noder<  r  r   r   ZnodeRecords.__add  s   )-t5)I&EQ"}%g.B;Q>?@@++E2(((QHIEQRR*477DF6Q<=DEE)$''2
6Q=>EFF,#DGGT$?+DGG4	6Q@ADHII#DGGT$?6Q:;dBCC&twwZ@6QJKdRSS&twwZ@6QJKdRSS&tww;6QJKdRSSagm)$''3@BAv #T!UX\!\]]"477D66QBCdJKK'96Q67$>??c"q!4 

gkmqs~  AK  MW  Y^  `g  h  	ir   c                s    V P                  4        V P                  WV4      '       d0   \        \        R 4      V,          4       V P	                  WW4V4       MV P                  WW4V4       V P                  4        R# )z*Addr %s already defined, modifying insteadN)rr   _nodeRecords__existsr   r   _nodeRecords__modify_nodeRecords__addr8   )r   r  r  r#  r&   r\     &&&&&&r   r   ZnodeRecords.add  sX    

==U++!@ADHIMM$ee<JJt559r   c                s0   V P                  WV4      w  rr4\        V P                  WV4      w  rVV^ 8  d   \        \	        R4      V,          4      h\        V P                  V4      w  rWV^ 8  d   \        \	        R4      V,          4      h\        V4       V# )r    r  %Could not check if addr %s is defined)r  r  rd   rj   r   semanage_node_existsr  r   r  r  r#  r  rY   r   r      &&&&    r   r   ZnodeRecords.__exists  s    )-t5)I&E*477DF6Q<=DEE+DGGQ76QFG$NOOq!r   c                sh   V P                  WV4      w  rr6VR 8X  d   VR 8X  d   \        \        R4      4      h\        P                  ! V4      pV'       d,   WPP
                  9  d   \        \        R4      V,          4      h\        V P                  WV4      w  rxV^ 8  d   \        \        R4      V,          4      h\        V P                  V4      w  ryV^ 8  d   \        \        R4      V,          4      hV	'       g   \        \        R4      V,          4      h\        V P                  V4      w  rzV^ 8  d   \        \        R4      V,          4      h\        V
4      p\        ^8X  d(   VR 8w  d!   \        V P                  V\        V4      4       VR 8w  d   \        V P                  W4       \        V P                  W4      pV^ 8  d   \        \        R4      V,          4      h\!        V4       \#        V
4       V P$                  P'                  RV: R	V: R
V: RR: RR: RV: RV: 24       R# )r   rF  r  r  r  Addr %s is not definedzCould not query addr %szCould not modify addr %szresrc=node op=modify laddr=r  r.  r/  r,  r   r-  N)r  rj   r   rg   r0  r  r  rd   r  Zsemanage_node_querysemanage_node_get_conrl   r6  r]   r5  r  r  r  rf   r4   )r   r  r  r#  r&   rJ  r  rY   r   r   r  r<  s   &&&&&&      r   r   ZnodeRecords.__modify  s   )-t5)I&Eb=Vr\Q;<==,,V4f$4$44QHIFRSS*477DF6Q<=DEE+DGGQ76QFG$NOOQ784?@@(!4
6Q89D@AA#D)agm$TWWc;w3GHR<%dggs;'96Q9:TABBq!4 

jnpt  wB  DN  PZ  \b  dk  l  	mr   c                l    V P                  4        V P                  WW4V4       V P                  4        R # r   )rr   r  r8   )r   r  r  r#  r&   rJ  r  r   r   ZnodeRecords.modify  s$    

d%&9r   c                s   V P                  WV4      w  rr4\        V P                  WV4      w  rVV^ 8  d   \        \	        R4      V,          4      h\        V P                  V4      w  rWV^ 8  d   \        \	        R4      V,          4      hV'       g   \        \	        R4      V,          4      h\        V P                  V4      w  rWV^ 8  d   \        \	        R4      V,          4      hV'       g   \        \	        R4      V,          4      h\        V P                  V4      pV^ 8  d   \        \	        R4      V,          4      h\        V4       V P                  P                  RV: RV: RV: 24       R	# )
r    r  r  r  z/Addr %s is defined in policy, cannot be deletedzCould not delete addr %szresrc=node op=delete laddr=r  r.  N)r  r  rd   rj   r   r  Zsemanage_node_exists_localZsemanage_node_del_localr  rf   r4   r  r  r   r   ZnodeRecords.__delete  s*   )-t5)I&E*477DF6Q<=DEE+DGGQ76QFG$NOOQ784?@@1$''1=6QFG$NOOQPQTXXYY$TWWa06Q9:TABBq!

UY[_almnr   c                j    V P                  4        V P                  WV4       V P                  4        R # r   )rr   _nodeRecords__deleter8   )r   r  r  r#     &&&&r   r   ZnodeRecords.delete,  s"    

d%(r   c           	     s   \        V P                  4      w  rV^ 8  d   \        \        R4      4      hV P	                  4        V Ff  pV P                  \        V P                  V4      ^,          \        V P                  V4      ^,          V P                  \        V4      ,          4       Kh  	  V P                  4        R# )r    z!Could not deleteall node mappingsN)semanage_node_list_localrd   rj   r   rr   r  semanage_node_get_addrsemanage_node_get_maskr  semanage_node_get_protor8   )r   rY   Znlistr  r   r   rp   ZnodeRecords.deleteall1  s    .tww76QBCDD

DMM0$?BDZ[_[b[bdhDijkDlnrn{n{  }T  UY  }Z  o[  \ r   c                s   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   F  p\        V4      p\        V P                  V4      p\        V P                  V4      pV P                  \        V4      ,          p\        V4      \        V4      \        V4      \        V4      3W&^,          V^,          V3&   K  	  V# )r    zCould not list addrs)r  rd   ilistZsemanage_node_listrj   r   r  r  r  r  r  semanage_context_get_usersemanage_context_get_rolerZ  r[  )	r   r   r   rY   r  r<  r  r  r#  r  r   r   ZnodeRecords.get_all;  s    7@R1$'':R6Q5677JJD'-C)$''48D)$''48DMM"9$"?@E0I#0NPijmPn  qJ  KN  qO  Qi  jm  Qn  0oE7DGU+,  r   c                s   . pV P                  R 4      p\        VP                  4       4       F  pW#,          ^,          '       dW   VP                  RV^,          : RV^,          : RW#,          ^,          : RW#,          ^,          : RV^ ,          : 2
4       Kn  VP                  RV^,          : RV^,          : RW#,          ^,          : RV^ ,          : 24       K  	  V# )Tz-a -M rb   -t r   r   rE   r   r   r   r   rv   ZnodeRecords.customizedM  s    T"

%Ax{{addAaDD%(ST++W\W_`aWbWbdefgdhijaddAaDD%(1++qQRtTU	 &
 r   c                s   V P                  V4      p\        V4      ^ 8X  d   R# \        VP                  4       4      pV'       d    \	        R:R RR:R RR:R RR:R R	24       \
        '       d   V F  pR
pV F  pVR,           \        V4      ,           pK  	  \	        V^ ,          :R RV^,          :R RV^,          :R RW5,          ^ ,          : RW5,          ^,          : RW5,          ^,          : R\        W5,          ^,          R4      : R24       K  	  R# V Fe  p\	        V^ ,          :R RV^,          :R RV^,          :R RW5,          ^ ,          : RW5,          ^,          : RW5,          ^,          : R24       Kg  	  R# )r    Nz
IP Addressr  rE   ZNetmaskZProtocolr   Contextr   r   Z	r   F)r   rU   r   r   r   rl   r"   r\   )r   r   r   r   r   r   valZfieldsr   r   r   ZnodeRecords.listW  sF   Y'u:?ejjl#|Y
T]^_>F*s6{2C  1qttQqTT58TU;;X]X`abXcXcejemnoepepr{  }B  }E  FG  }H  JO  sP  Q  R	  addAaDD!A$$QRUZU]^_U`U`bgbjklbmbmno r   )r  r  r  r   r   r   )r<   r=   r>   r?   r  r   r  r  r   r  r  r   r  r   rp   r   rv   r   r@   rA   rB   rC   r   r  r  ]  sY     K =D@iD&mP
o6
$p pr   r  c                   st   a  ] tR tRt o RR ltR tR tR tR tR t	R	 t
R
 tR tRR ltR tRR ltRtV tR# )interfaceRecordsij  Nc                ry   r   rz   r{   r3   r   r   ZinterfaceRecords.__init__l  r|   r   c                s   \         ^8X  d   VR8X  d   RpM\        V4      pVR8X  d   \        \        R4      4      h\	        V P
                  V4      w  rEV^ 8  d   \        \        R4      V,          4      h\        V P
                  4      w  rFV^ 8  d   \        \        R4      V,          4      h\        V P
                  Wa4      p\        V P
                  4      w  rGV^ 8  d   \        \        R4      V,          4      h\        V P
                  VR4      pV^ 8  d   \        \        R4      V,          4      h\        V P
                  VR	4      pV^ 8  d   \        \        R
4      V,          4      h\        V P
                  Ws4      pV^ 8  d   \        \        R4      V,          4      h\         ^8X  d@   VR8w  d9   \        V P
                  Wr4      pV^ 8  d   \        \        R4      V,          4      h\        V P
                  Wg4      pV^ 8  d   \        \        R4      V,          4      h\        V P
                  Wg4      pV^ 8  d   \        \        R4      V,          4      h\        V P
                  WV4      pV^ 8  d   \        \        R4      V,          4      h\!        V4       \#        V4       \%        V4       V P&                  P)                  RV: RR: RR	: RV: RV: 2
4       R# )rH   r   r   SELinux Type is requiredr  z!Could not create interface for %sr  r,  z.Could not set user in interface context for %sr-  z.Could not set role in interface context for %sz.Could not set type in interface context for %sz4Could not set mls fields in interface context for %sz&Could not set interface context for %sz$Could not set message context for %szCould not add interface %szresrc=interface op=add netif=r/  r   N)rl   r]   rj   r   semanage_iface_key_createrd   Zsemanage_iface_createZsemanage_iface_set_namer2  r3  r4  r5  r6  Zsemanage_iface_set_ifconZsemanage_iface_set_msgconsemanage_iface_modify_localr8  semanage_iface_key_freesemanage_iface_freerf   r4   )r   	interfacer&   r\  rY   r   ifacer<  r  r   r   ZinterfaceRecords.__addo  sj   Q"}%g.B;Q9:;;+DGGY?6Q<=	IJJ+DGG46QBCiOPP$TWWe?+DGG4	6Q@AIMNN&twwZ@6QOPS\\]]&twwZ@6QOPS\\]]&tww;6QOPS\\]]agm)$''3@BAv #Y!Z]f!fgg%dggu:6QGH9TUU&tww;6QEFRSS(!;6Q;<yHIIc""E"

Xacmoy  |A  CJ  K  	Lr   c                s    V P                  4        V P                  V4      '       d/   \        \        R 4      V,          4       V P	                  WV4       MV P                  WV4       V P                  4        R# )z/Interface %s already defined, modifying insteadN)rr   _interfaceRecords__existsr   r   _interfaceRecords__modify_interfaceRecords__addr8   )r   r  r&   r\  r  r   r   ZinterfaceRecords.add  sR    

==##!EFRSMM)e4JJy51r   c                r   )r    r  *Could not check if interface %s is defined)r  rd   rj   r   semanage_iface_existsr  r   r  rY   r   r   r   r   r   ZinterfaceRecords.__exists  sm    +DGGY?6Q<=	IJJ,TWWa86QKLyXYY"r   c                s   VR 8X  d   VR 8X  d   \        \        R4      4      h\        V P                  V4      w  rEV^ 8  d   \        \        R4      V,          4      h\	        V P                  V4      w  rFV^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      w  rGV^ 8  d   \        \        R4      V,          4      h\        V4      p\        ^8X  d(   VR 8w  d!   \        V P                  V\        V4      4       VR 8w  d   \        V P                  W4       \        V P                  WW4      pV^ 8  d   \        \        R4      V,          4      h\        V4       \        V4       V P                  P                  RV: RR	: R
R: R
V: R
V: 2
4       R# )r   rF  r  r  Interface %s is not definedzCould not query interface %szCould not modify interface %sz resrc=interface op=modify netif=r/  r,  r   r-  N)rj   r   r  rd   r  Zsemanage_iface_querysemanage_iface_get_ifconrl   r6  r]   r5  r  r  r  rf   r4   )	r   r  r&   rJ  rY   r   r   r  r<  r  r   r   ZinterfaceRecords.__modify  su   b=Vr\Q;<==+DGGY?6Q<=	IJJ,TWWa86QKLyXYYQ<=	IJJ*477A66Q=>JKK&u-agm$TWWc;w3GHR<%dggs;(!;6Q>?)KLL"E"

[dfpr|  E  GN  O  	Pr   c                r  r   )rr   r  r8   )r   r  r&   rJ  r  r   r   ZinterfaceRecords.modify  s"    

i&1r   c                s   \        V P                  V4      w  r#V^ 8  d   \        \        R4      V,          4      h\	        V P                  V4      w  r$V^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      w  r$V^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h\        V P                  V4      pV^ 8  d   \        \        R4      V,          4      h\        V4       V P                  P                  RV,          4       R# )r    r  r  r  z4Interface %s is defined in policy, cannot be deletedzCould not delete interface %sz"resrc=interface op=delete netif=%sN)
r  rd   rj   r   r  Zsemanage_iface_exists_localZsemanage_iface_del_localr  rf   r4   r  r   r   r   ZinterfaceRecords.__delete  s   +DGGY?6Q<=	IJJ,TWWa86QKLyXYYQ<=	IJJ2477A>6QKLyXYYQUVYbbcc%dggq16Q>?)KLL"

BYNOr   c                sh    V P                  4        V P                  V4       V P                  4        R # r   )rr   _interfaceRecords__deleter8   )r   r  r3   r   r   ZinterfaceRecords.delete  s     

i r   c                s    \        V P                  4      w  rV^ 8  d   \        \        R4      4      hV P	                  4        V F  pV P                  \        V4      4       K  	  V P                  4        R# )r    z(Could not delete all interface  mappingsN)semanage_iface_list_localrd   rj   r   rr   r  semanage_iface_get_namer8   )r   rY   r   r   r   r   rp   ZinterfaceRecords.deleteall	  sX    /86QIJKK

AMM1!45 r   c                sj   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   FD  p\        V4      p\        V4      \        V4      \        V4      \        V4      3V\        V4      &   KF  	  V# )r    zCould not list interfaces)r  rd   r  Zsemanage_iface_listrj   r   r  r  r  rZ  r[  r  )r   r   r   rY   r  r<  r[   r   r   ZinterfaceRecords.get_all	  s    8AR2477;R6Q:;<<I*95C9RSV9WYrsvYw  zS  TW  zX  Zr  sv  Zw  9xE))45 $ r   c           	     sT   . pV P                  R 4      p\        VP                  4       4       Fw  pW#,          ^,          '       d:   VP                  RW#,          ^,          : RW#,          ^,          : RV: 24       KQ  VP                  RW#,          ^,          : RV: 24       Ky  	  V# )Tra  r   r   rE   r   r   r   r   rv   ZinterfaceRecords.customized	  r   r   c                s\   V P                  V4      p\        V4      ^ 8X  d   R# \        VP                  4       4      pV'       d'   \	        \        R4      :R R\        R4      : R24       \        '       dj   V Fa  p\	        V:R RW5,          ^ ,          : RW5,          ^,          : RW5,          ^,          : R\        W5,          ^,          R4      : R2
4       Kc  	  R# V FF  p\	        V:R RW5,          ^ ,          : RW5,          ^,          : RW5,          ^,          : R24       KH  	  R# )	r    NzSELinux Interfacer  rE   r  r   r   F)r   rU   r   r   r   r   rl   r\   r  r   r   r   ZinterfaceRecords.list&	  s    Y'u:?ejjl#!$7"8!I,GH>a!ehqkk58TU;;XabgbjklbmotXuvw  1ehqkk58A;;QRTU r   )r  r   r   r   )r<   r=   r>   r?   r   r  r   r  r  r   r  r   rp   r   rv   r   r@   rA   rB   rC   r   r  r  j  sM     -8Lt
 PD
P2
V Vr   r  c                   s   a  ] tR tRt o . tRR ltR tR tR tRR lt	R t
RR	 ltRR
 ltR tR tR tR tR tR tRR ltR tRR ltRtV tR# )fcontextRecordsi6	  Nc           
     s   \         P                  W4        \        \        \        P                  ! \        P
                  R 4      4      ^ ,          R,          4      V n        V ;P                  \        \        \        P                  ! \        P
                  R4      4      ^ ,          R,          4      ,          un        / V n        / V n	        RV n
         \        \        P                  ! 4       R4      pVP                  4        F^  pVP                  4       p\!        V4      ^ 8X  d   K%  VP#                  R4      '       d   K>  VP%                  4       w  rEWPP                  V&   K`  	  VP'                  4         \        \        P*                  ! 4       R4      pVP                  4        F^  pVP                  4       p\!        V4      ^ 8X  d   K%  VP#                  R4      '       d   K>  VP%                  4       w  rEWPP                  V&   K`  	  VP'                  4        R#   \         d     ELii ; i  \(         d     Li ; i  \(         d     R# i ; i)Z	file_typer  Zdevice_nodeFr  Z#N)r^   r   r   rg   r   r  r  r   equiv
equiv_dist	equal_indr   rT   selinux_file_context_subs_pathZ	readlinesstriprU   r   r   r   ZIOErrorZ#selinux_file_context_subs_dist_path)r   rb   r   r   target
substituter[   r   r   ZfcontextRecords.__init__:	  s     ,	#Dx7I7I;)W$XYZ$[\c$deDT(--8J8JM*Z%[\]%^_f%g hh 
	g<<>DB\\^GGIq6Q;<<$$%&WWY"%/

6" $ HHJ	gAACSIB\\^GGIq6Q;<<$$%&WWY"*4' $ HHJ;  		"  		  		sD   B&H A*H* >6H* 5A*H;  6H; H'&H'*H87H8;I
	I
c                s(   V P                   '       d   \        P                  ! 4       pR V,          p\        VR4      pV P                  P                  4        F-  pVP                  V: RV P                  V,          : R24       K/  	  VP                  4         \        P                  ! V\        P                  ! V4      \        P                  ,          4       \        P                  ! Y!4       RT n         \        P                  V 4       R#     L8; i)z%s.tmpZwrE   r   FN)r  rT   r  r   r  r   Zwriter   r   ZchmodstatZST_MODEZrenamer^   r8   )r   Z	subs_fileZtmpfiler   r  r   r   r8   ZfcontextRecords.commit`	  s    >>>>>@I*Ggs#B**//+fdjj.@.@AB ,HHJ"'')"4T\\"BC IIg)"DNt$	s   A D Dc           
     s    V P                  4        VR 8w  d*   VR,          R 8X  d   \        \        R4      V,          4      hVR 8w  d*   VR,          R 8X  d   \        \        R4      V,          4      hWP                  P	                  4       9   d   \        \        R4      V,          4       W P                  V&   RV n        V P                  P                  R\        P                  ! RV^ 4      : R\        P                  ! RV^ 4      : 24       V P                  4        R	# V P                  V4       V P                  V P                  3 FM  pV FD  pVP                  VR ,           4      '       g   K#  \        \        R
4      WW4,          3,          4      h	  KO  	  V P                  P                  R\        P                  ! RV^ 4      : R\        P                  ! RV^ 4      : 24       W P                  V&   RV n        V P                  4        R	# )r   z=Target %s is not valid. Target is not allowed to end with '/'zESubstitute %s is not valid. Substitute is not allowed to end with '/'z:Equivalence class for %s already exists, modifying insteadTresrc=fcontext op=modify-equal sglobrE   tglobNz4File spec %s conflicts with equivalency rule '%s %s'zresrc=fcontext op=add-equal )rr   rj   r   r  r   r   r  rf   r4   r   audit_encode_nv_stringr8   r  r  r   )r   r  r  fdictr   r   r   	add_equalZfcontextRecords.add_equalp	  s   

S=VBZ3.Q^_bhhiiB3!6QfgjttuuZZ__&&!PQTZZ[!+JJv!DNJJ!!ELhLhiprxz{L|  D  [  [  \c  eo  qr  s  #t  uKKMfjj$//2E<<--$Q']%^bhmrmuav%vww  3
 	

UEaEabikqstEuw|  xT  xT  U\  ^h  jk  xl  m  	n'

6r   c           
     s   V P                  4        WP                  P                  4       9  d   \        \	        R 4      V,          4      hW P                  V&   RV n        V P                  P                  R\        P                  ! RV^ 4      : R\        P                  ! RV^ 4      : 24       V P                  4        R# )z'Equivalence class for %s does not existTr  r  rE   r  N)rr   r  r   rj   r   r  rf   r4   r   r  r8   )r   r  r  rW  r   modify_equalZfcontextRecords.modify_equal	  s    

**QHIFRSS'

6

HdHdelntvwHxz  {W  {W  X_  ak  mn  {o  p  	qr   c                s   \        V P                  4      w  r4V^ 8  d   \        \        R4      V,          4      hVR8X  d   Rp\	        V P                  WB4      pV^ 8  d   \        \        R4      V,          4      h\        V P                  VR4      pV^ 8  d   \        \        R4      V,          4      h\        ^8X  d:   \        V P                  VR4      pV^ 8  d   \        \        R4      V,          4      hV# )	r    r  r   r,  z)Could not set user in file context for %sr-  z)Could not set role in file context for %sr   /Could not set mls fields in file context for %s)r2  rd   rj   r   r3  r4  rl   r6  )r   r  r  rY   r<  r   r   	createconZfcontextRecords.createcon	  s    +DGG4	6Q@AFJKKR<F&tww<6QJKfTUU&twwZ@6QJKfTUUQ)$''3=BAv #T!UX^!^__
r   c           	     s   VR 8X  g   VP                  R4      ^ 8  d   \        \        R4      4      hVP                  R4      R8w  d   \        \        R4      4      hV P                  V P                  3 Fl  pV Fc  pVP                  VR,           4      '       g   K#  \        P                  ! W2V,          V4      p\        \        R4      WW#,          V3,          4      h	  Kn  	  R# )	r   r   zInvalid file specificationrE   z)File specification can not include spacesr   zMFile spec %s conflicts with equivalency rule '%s %s'; Try adding '%s' insteadNr  )Zfindrj   r   r  r  r   rO   Zsub)r   r  r  r   r   r   r   r  ZfcontextRecords.validate	  s    R<6;;t,1Q;<==;;sr!QJKLLjj$//2E$$QW--q(F3A$Q'v%w  |B  GL  GO  QR  {S  &S  T  T  3r   c                s   V P                  V4       \        ^8X  d   \        V4      pVR8X  d   \        \	        R4      4      hVR8w  dB   \
        P                  ! V4      pW P                  9  d   \        \	        R4      V,          4      h\        V P                  V\        V,          4      w  rgV^ 8  d   \        \	        R4      V,          4      h\        V P                  4      w  rhV^ 8  d   \        \	        R4      V,          4      h\        V P                  W4      pVR8w  d   V P                  W4      p	\        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      h\        ^8X  d@   VR8w  d9   \        V P                  W4      pV^ 8  d   \        \	        R4      V,          4      h\!        V P                  W4      pV^ 8  d   \        \	        R	4      V,          4      h\#        V\        V,          4       \%        V P                  Wx4      pV^ 8  d   \        \	        R
4      V,          4      hVR8w  d   \'        X	4       \)        V4       \+        V4       V'       g   RpV P,                  P/                  R\0        P2                  ! RV^ 4      : R\4        V,          : RV: RR: RV: RV: 24       R# )rH   r   r  <<none>>1Type %s is invalid, must be a file or device typer  z$Could not create file context for %sz)Could not set type in file context for %sr  !Could not set file context for %sz!Could not add file context for %sr,  zresrc=fcontext op=add r   ftype=r/  r   r-  N)r  rl   r]   rj   r   rg   r0  r  semanage_fcontext_key_createrd   
file_typesZsemanage_fcontext_createZsemanage_fcontext_set_exprr  r5  r6  semanage_fcontext_set_conZsemanage_fcontext_set_typesemanage_fcontext_modify_localr8  semanage_fcontext_key_freesemanage_fcontext_freerf   r4   r   r  ftype_to_audit)
r   r  r   ftyper&   r  rY   r   fcontextr<  s
   &&&&&&    r   r   ZfcontextRecords.__add	  si   fQ!'*G2:Q9:;;:..t4D+++ #V!WZ^!^__.tww
5@QR6Q<=FGG1$'':6QEFOPP'B:..0C*477C>BAv #N!ORX!XYY!#'R--dggsD6$Q'X%Y\b%bcc*477HBBAv #F!G&!PQQ"8Z->?+DGGQA6QBCfLMM:!#&"1%x(F

Z_ZvZvw~  AG  IJ  [K  M[  \a  Mb  Mb  dj  lv  x|  ~E  F  	Gr   c                s    V P                  4        V P                  W4      '       d0   \        \        R 4      V,          4       V P	                  WW4V4       MV P                  WW4V4       V P                  4        R# )z6File context for %s already defined, modifying insteadN)rr   _fcontextRecords__existsr   r   _fcontextRecords__modify_fcontextRecords__addr8   )r   r  r   r	  r&   r  r  r   r   ZfcontextRecords.add	  sW    

==''!LMPVVWMM&?JJvUV<r   c                s   \        V P                  V\        V,          4      w  r4V^ 8  d   \        \	        R4      V,          4      h\        V P                  V4      w  r5V^ 8  d   \        \	        R4      V,          4      hV'       g;   \        V P                  V4      w  r5V^ 8  d   \        \	        R4      V,          4      h\        V4       V# )r    r  1Could not check if file context for %s is defined)r  rd   r  rj   r   semanage_fcontext_existssemanage_fcontext_exists_localr  r   r  r	  rY   r   r   r   r   r   ZfcontextRecords.__exists	  s    .tww
5@QR6Q<=FGG/;6QRSV\\]]9$''1ELRAv #V!WZ`!`aa"1%r   c                sD   VR 8X  d#   VR 8X  d   VR 8X  d   \        \        R4      4      hVR9  dB   \        P                  ! V4      pW P                  9  d   \        \        R4      V,          4      hV P                  V4       \        V P                  V\        V,          4      w  rgV^ 8  d   \        \        R4      V,          4      h\        V P                  V4      w  rhV^ 8  d   \        \        R4      V,          4      hV'       d    \        V P                  V4      w  riMv\        V P                  V4      w  rhV^ 8  d   \        \        R4      V,          4      hV'       g   \        \        R4      V,          4      h \        V P                  V4      w  riVR8w  d   \        V	4      p
V
f   V P                  V4      p
\         ^8X  d(   VR 8w  d!   \#        V P                  V
\%        V4      4       VR 8w  d   \'        V P                  W4       VR 8w  d   \)        V P                  W4       \+        V P                  W4      pV^ 8  d   \        \        R	4      V,          4      hM9\+        V P                  V	R4      pV^ 8  d   \        \        R	4      V,          4      h\-        V P                  Wy4      pV^ 8  d   \        \        R
4      V,          4      h\/        V4       \1        V	4       V'       g   RpV P2                  P5                  R\6        P8                  ! RV^ 4      : R\:        V,          : RV: RR: RV: RV: 24       R#   \         d    \        \        R4      T,          4      hi ; i  \         d    \        \        R4      T,          4      hi ; i)r   z"Requires setype, serange or seuserr  r  r   r  z#Could not query file context for %s"File context for %s is not definedNr   z$Could not modify file context for %sr,  zresrc=fcontext op=modify r  r  r/  r   r-  )r   r  )rj   r   rg   r0  r  r  r  rd   r  r  Zsemanage_fcontext_queryOSErrorr  Zsemanage_fcontext_query_localsemanage_fcontext_get_conr  rl   r6  r]   r3  r5  r  r  r  r  rf   r4   r   r  r  )r   r  rJ  r	  r&   r  rY   r   r   r
  r<  r  r   r   ZfcontextRecords.__modify	
  s8   b=Vr\flQCDEE**008F--- #V!WZ`!`aaf.tww
5@QR6Q>?&HII/;6QRSV\\]]T!8!!DX :$''1ELRAv #V!WZ`!`aa #G!H6!QRRT!>tww!J Z+H5C{nnV,!#'R-(#{77KL|)$''3?|)$''3?*477HBBAv #F!G&!PQQ  +477HdCBAv #F!G&!PQQ+DGGQA6QEFOPP"1%x(F

]b]y]y  {B  DJ  LM  ^N  P^  _d  Pe  Pe  gm  oy  {A  CJ  K  	L[  T #H!IF!RSST  T #H!IF!RSSTs   M M8 'M58'Nc                r  r   )rr   r  r8   )r   r  rJ  r	  r&   r  r  r   r   ZfcontextRecords.modifyL
  s$    

fef=r   c           	     s   \        V P                  4      w  rV^ 8  d   \        \        R4      4      hV P	                  4        V F  p\        V4      p\        V4      p\        V4      p\        V P                  V\        V,          4      w  rV^ 8  d   \        \        R4      V,          4      h\        V P                  V4      pV^ 8  d   \        \        R4      V,          4      h\        V4       V P                  P                  R\        P                  ! RV^ 4      : R\         \"        V,          ,          : 24       K  	  / V n        RV n        V P)                  4        R# )	r    z Could not list the file contextsr   z$Could not delete the file context %sresrc=fcontext op=delete r  r  TN)semanage_fcontext_list_localrd   rj   r   rr   semanage_fcontext_get_exprsemanage_fcontext_get_typesemanage_fcontext_get_type_strr  r  semanage_fcontext_del_localr  rf   r4   r   r  r  file_type_str_to_optionr  r  r8   )r   rY   flistr
  r  r	  	ftype_strr   r   r   rp   ZfcontextRecords.deleteallQ
  s/   2477;6QABCC

H/9F.x8E6u=I2477FJyDYZGRAv #B!Cf!LMM,TWWa8BAv #I!JV!STT&q)JJ!!ELhLhiprxz{L|  M  Ne  fo  Np  q  #r  s  
r   c                s   WP                   P                  4       9   d]   V P                   P                  V4       R V n        V P                  P                  R\        P                  ! RV^ 4      ,          4       R# \        V P                  V\        V,          4      w  r4V^ 8  d   \        \        R4      V,          4      h\        V P                  V4      w  r5V^ 8  d   \        \        R4      V,          4      hV'       gy   \        V P                  V4      w  r5V^ 8  d   \        \        R4      V,          4      hV'       d   \        \        R4      V,          4      h\        \        R4      V,          4      h\        V P                  V4      pV^ 8  d   \        \        R4      V,          4      h\!        V4       V P                  P                  R	\        P                  ! RV^ 4      : R
\"        V,          : 24       R# )Tz!resrc=fcontext op=delete-equal %sr  Nr   r  z;File context for %s is defined in policy, cannot be deletedr  z$Could not delete file context for %sr  r  )r  r   Zpopr  rf   r4   r   r  r  rd   r  rj   r   r  r  r  r  r  r  r   r   r   ZfcontextRecords.__deletek
  s   ZZ__&&JJNN6"!DNJJ!!"EIeIefmouwxIy"z{.tww
5@QR6Q>?&HII5dggqA6QRSV\\]]3DGGQ?LRAv #V!WZ`!`aa #`!adj!jkk #G!H6!QRR(!46QEFOPP"1%

HdHdelntvwHx  {I  JO  {P  Q  	Rr   c                rU  r   )rr   _fcontextRecords__deleter8   )r   r  r	  rW  r   r   ZfcontextRecords.delete
  s     

f$r   c                s   V'       d   \        V P                  4      w  q n        M\        V P                  4      w  q n        V^ 8  d   \	        \        R4      4      h\        V P                  4      w  r#V^ 8  d   \	        \        R4      4      h\        V P                  4      w  r$V^ 8  d   \	        \        R4      4      hV ;P                  V,          un        V ;P                  V,          un        / pV P                   Fl  p\        V4      p\        V4      p\        V4      p	\        V4      p
V
'       d1   \        V
4      \        V
4      \        V
4      \        V
4      3WWV	3&   Kg  WWy3&   Kn  	  V# )r    zCould not list file contextsz1Could not list file contexts for home directoriesz"Could not list local file contexts)r  rd   r  Zsemanage_fcontext_listrj   r   Zsemanage_fcontext_list_homedirsr  r  r  r  r  r  rZ  r[  )r   r   rY   Z
fchomedirsZfclocalr   r
  Zexprr	  r  r<  r^  r   r   ZfcontextRecords.get_all
  sK   ;DGGDR5dgg>RAv #A!BCC>twwGRAv #V!WXX8AMRAv #G!HIIJJ*$JJJ'!J

H-h7D.x8E6u=I+H5C,Ec,JLefiLj  mF  GJ  mK  Me  fi  Mj  ,kY'(+.t'( # r   c                s   . pV P                  R 4      pVP                  4        F  pW#,          '       g   K  W#,          ^,          '       dX   VP                  R\        V^,          ,          : RW#,          ^,          : RW#,          ^,          : RV^ ,          : R2	4       K  VP                  R\        V^,          ,          : RW#,          ^,          : RV^ ,          : R24       K  	  \	        V P
                  4      '       dL   V P
                  P                  4        F-  pVP                  RV P
                  V,          : RV: 24       K/  	  V# )	Tz-a -f r  r   z' 'Z'z 'z-a -e rE   )r   r   r   r  rU   r  )r   r	   	fcon_dictr   r  r   r   rv   ZfcontextRecords.customized
  s   LL&	!A||<??HH>UVWXYVZ>[>[]f]ijk]l]lnwnz{|n}n}  @A  BC  @D  @D  E  FHH6MaPQd6S6SU^UabcUdUdfghifjfjkl " tzz??**//+$**V*<*<fEF ,r   c                sL   V P                  V4      p\        V4      ^ 8w  Ed   V'       d5   \        \        R4      :R R\        R4      :R R\        R4      : R24       V'       d   VP	                  4       pM\        VP	                  4       4      pV EF  pW5,          '       d   \        '       dt   \        V^ ,          :R RV^,          :R RW5,          ^ ,          : RW5,          ^,          : RW5,          ^,          : R\        W5,          ^,          R	4      : R24       K  \        V^ ,          :R RV^,          :R RW5,          ^ ,          : RW5,          ^,          : RW5,          ^,          : R2
4       K  \        V^ ,          :R RV^,          :R R
24       EK  	  \        V P                  4      '       di   V'       ga   V'       d   \        \        R4      4       V P                  P	                  4        F&  p\        V: RV P                  V,          : 24       K(  	  \        V P                  4      '       dc   V'       d   \        \        R4      4       V P                  P	                  4        F&  p\        V: RV P                  V,          : 24       K(  	  R# R# )r    zSELinux fcontextZ50rE   r   r  r  r   r   Fz	 <<None>>z,
SELinux Distribution fcontext Equivalence 
z = z%
SELinux Local fcontext Equivalence 
N)
r   rU   r   r   r   r   rl   r\   r  r  )r   r   r   r  Zfkeysr   r  r  r   r   ZfcontextRecords.list
  s   LL+	y>QA.@,A1V9aPYl[\!(y~~/0<<%~AaDD!A$$	UVYbYefgYhYhjsjvwxjyjy  |E  FO  FR  ST  FU  W\  |]  ^  _1qttY\RS__V_VbcdVeVegpgstugvgvwxAaDD!A$$?@  t!LMN"oo224Fvtv/FGH 5tzz??aABC**//+64::f+=>? ,	 r   )r  r  r  r  r  r   )r,  )r   r   r,  r   r   )r<   r=   r>   r?   r  r   r8   r  r  r  r  r  r   r  r  r   rp   r  r   r   rv   r   r@   rA   rB   rC   r   r  r  6	  sp     K$L% :	,	T4Gl"ALF
4RB
@@ @r   r  c                   sx   a  ] tR tRt o RR ltR tRR ltR tR tR t	R	 t
RR
 ltR tR tR tRR ltRtV tR# )booleanRecordsi
  Nc                s   \         P                  W4       / V n        ^V P                  R&   ^ V P                  R&   ^V P                  R&   ^ V P                  R&   ^V P                  R&   ^ V P                  R&    \        P                  ! 4       w  q n        \        P                  ! 4       w  r#T P                  R8X  g   T P                  T8X  d
   R	T n        R# R
T n        R#    . T n        Rp LA; i)rH   ZTRUEZFALSEZONZOFFZ1Z0Nr   TF)	r^   r   dictrT   Zsecurity_get_boolean_namescurrent_booleansre   r`   modify_local)r   rb   rY   ZptyperJ   r   r   ZbooleanRecords.__init__
  s      ,			&		'		$		%		#		#	(/(J(J(L%B%557IB
 ::tzzU2 $D %D	$&D!Es   83C C,c                s<   \         P                  ! V4      p\        V P                  V4      w  r4V^ 8  d   \	        \        R4      V,          4      h\        V P                  V4      w  r5V^ 8  d   \	        \        R4      V,          4      hV'       g   \	        \        R4      V,          4      h\        V P                  V4      w  r6V^ 8  d   \	        \        R4      V,          4      hVP                  4       V P                  9   d,   \        W`P                  VP                  4       ,          4       MB\	        \        R4      RP                  V P                  P                  4       4      ,          4      hV P                  '       dI   WP                  9   d9   \        V P                  WF4      pV^ 8  d   \	        \        R4      V,          4      h\!        V P                  WF4      pV^ 8  d   \	        \        R4      V,          4      h\#        V4       \%        V4       R	# )
r    r   (Could not check if boolean %s is definedBoolean %s is not definedzCould not query file context %sz0You must specify one of the following values: %sz, (Could not set active value of boolean %szCould not modify boolean %sN)rT   selinux_boolean_subsemanage_bool_key_createrd   rj   r   semanage_bool_existssemanage_bool_queryZupperr!  semanage_bool_set_valuer   r   r#  r"  semanage_bool_set_activeZsemanage_bool_modify_localsemanage_bool_key_freesemanage_bool_free)r   r$   valuerY   r   r   r   r  r   Z__modZbooleanRecords.__mod
  s   **40*477D96Q>?$FGG+DGGQ76QIJTQRRQ:;dBCC%dggq16Q@ADHII;;=DII%#Ayy'?@QQRUYU^U^_c_h_h_m_m_oUppqq)>)>!>)$''18BAv #M!NQU!UVV'66Q<=DEEq!1r   c           	     s*   V P                  4        V'       d   \        V4      pVP                  4       P                  R 4       Fg  pVP	                  4       p\        V4      ^ 8X  d   K%   VP                  R4      w  rgT P                  TP	                  4       TP	                  4       4       Ki  	  VP                  4        MV P                  W4       V P                  4        R#   \         d&    \        \        R4      P                  YR7      4      hi ; i)r   =z&Bad format {filename}: Record {record})ZfilenameZrecordN)rr   r   r   r   r  rU   rj   r   r  _booleanRecords__modr   r8   )r   r$   r/  use_filer   r   Zboolnamer  r  r   r   ZbooleanRecords.modify  s    

dBWWY__T*GGIq6Q;r$%GGCLMH 

8>>+SYY[9 + HHJJJt# " r$Q'O%P%W%Wae%W%pqqrs   )C""0Dc                s   \         P                  ! V4      p\        V P                  V4      w  r#V^ 8  d   \	        \        R4      V,          4      h\        V P                  V4      w  r$V^ 8  d   \	        \        R4      V,          4      hV'       g   \	        \        R4      V,          4      h\        V P                  V4      w  r$V^ 8  d   \	        \        R4      V,          4      hV'       g   \	        \        R4      V,          4      h\        V P                  V4      pV^ 8  d   \	        \        R4      V,          4      h\        V4       R# )r    r   r$  r%  z2Boolean %s is defined in policy, cannot be deletedzCould not delete boolean %sN)
rT   r'  r(  rd   rj   r   r)  Zsemanage_bool_exists_localZsemanage_bool_del_localr-  r   r   r   r   ZbooleanRecords.__delete,  s   **40*477D96Q>?$FGG+DGGQ76QIJTQRRQ:;dBCC1$''1=6QIJTQRRQSTW[[\\$TWWa06Q<=DEEq!r   c                s    V P                  4        V P                  V4       V P                  4        V P                  4        V P                  V4       V P                  4        R # r   )rr   _booleanRecords__deleter8   _booleanRecords__reset_valuer   r$   r3   r   r   ZbooleanRecords.deleteD  sB    

d
 	

4 r   c                s   . p\        V P                  4      w  q n        V^ 8  d   \        \	        R4      4      hV P                  4        V P                   F0  p\        V4      pVP                  V4       V P                  V4       K2  	  V P                  4        V P                  4        V F  pV P                  V4       K  	  V P                  4        R# )r    Could not list booleansN)semanage_bool_list_localrd   blistrj   r   rr   semanage_bool_get_namer   r3  r8   r4  )r   ZdeletedrY   booleanr$   r   r   rp   ZbooleanRecords.deleteallP  s    3DGG<Z6Q89::

zzG)'2DNN4 MM$ "
 	
 	

Gw'  	r   c                s   \         P                  ! V4      p\        V P                  V4      w  r#V^ 8  d   \	        \        R4      V,          4      h\        V P                  V4      w  r$V^ 8  d   \	        \        R4      V,          4      h\        V\        V4      4       \        V P                  W44      pV^ 8  d   \	        \        R4      V,          4      h\        V4       \        V4       R# )r    r   zCould not query boolean %sr&  N)rT   r'  r(  rd   rj   r   r*  r+  semanage_bool_get_valuer,  r-  r.  )r   r$   rY   r   r   r   r   Z__reset_valueZbooleanRecords.__reset_valuem  s    **40*477D96Q>?$FGG%dggq16Q;<tCDD#:1#=>%dggq46QIJTQRRq!1r   c                sx   / pV'       d   \        V P                  4      w  q0n        M\        V P                  4      w  q0n        V^ 8  d   \	        \        R4      4      hV P                   F  p. p\        V4      pVP                  \        V4      4       V P                  '       d\   W`P                  9   dL   VP                  \        P                  ! V4      4       VP                  \        P                  ! V4      4       M0VP                  V^ ,          4       VP                  V^ ,          4       WRV&   K  	  V# )r    r6  )r7  rd   r8  Zsemanage_bool_listrj   r   r9  r   r;  r#  r"  rT   Zsecurity_get_boolean_pendingZsecurity_get_boolean_active)r   r   r   rY   r:  r/  r$   s   &&     r   r   ZbooleanRecords.get_all  s    7@R1$'':R6Q89::zzGE)'2DLL09:   T-B-B%BWAA$GHW@@FGU1X&U1X&$K " r   c                Z    \         P                  ! V4      p\        P                  ! V4      # r   )rT   r'  rg   Zboolean_descr5  r3   r   get_descZbooleanRecords.get_desc  s#    **40$$T**r   c                r<  r   )rT   r'  rg   Zboolean_categoryr5  r3   r   get_categoryZbooleanRecords.get_category  s#    **40((..r   c                s    . pV P                  R 4      p\        VP                  4       4       F9  pW#,          '       g   K  VP                  RW#,          ^,          : RV: 24       K;  	  V# )Tz-m -rE   r   r   r   r   rv   ZbooleanRecords.customized  sQ    T"

%AxxQ78 & r   c                s   \        R 4      \        R4      3pV'       dc   V P                  V4      p\        VP                  4       4       F2  pWV,          '       g   K  \	        V: RWV,          ^,          : 24       K4  	  R# V P                  V4      p\        V4      ^ 8X  d   R# V'       dA   \	        \        R4      :R R\        R4      : R\        R	4      : R\        R
4      : R24       \        VP                  4       4       Fg  pWV,          '       g   K  \	        V:R RWEV,          ^,          ,          :R RWEV,          ^ ,          ,          :R RV P                  V4      : 24       Ki  	  R# )r   r   r0  NzSELinux booleanr  rE   ZStatez  ZDefaultZDescriptionr   z (r   r   z>5z)  )r   r   r   r   r   rU   r=  )r   r   r   r2  Zon_offr   r   s   &&&&   r   r   ZbooleanRecords.list  s    E(AdG$LL+EEJJL)88Q45 * Y'u:?+<)=qz1Y<YZ[hYijk

%Axx6(1+3F3FUVxXY{H[H[]a]j]jkl]mno &r   )r8  r"  r!  r#  r   )NFr   )TFF)r<   r=   r>   r?   r   r1  r   r3  r   rp   r4  r   r=  r>  rv   r   r@   rA   rB   rC   r   r   r   
  sH     &,>("0
:(.+/p pr   r   r~   )rH   )>r   r   rT   r   rO   r    r  r   r1   ZPROGNAMErg   Zsetools.policyrepr   Zsetools.typequeryr   r  ZgettextZkwargsZversion_infoZtranslationr   r   Zbuiltinsr"   Z__dict__ZImportErrorZ__builtin__r   rI   r  ZSEMANAGE_FCONTEXT_ALLZSEMANAGE_FCONTEXT_REGZSEMANAGE_FCONTEXT_DIRZSEMANAGE_FCONTEXT_CHARZSEMANAGE_FCONTEXT_BLOCKZSEMANAGE_FCONTEXT_SOCKZSEMANAGE_FCONTEXT_LINKZSEMANAGE_FCONTEXT_PIPEr  r  r   Zaudit_closer   r   r  rK   rQ   r\   r]   r^   rx   r   r   r   r   r  ri  r  r  r  r  r   rM   r   r   <module>r?     sR  .  
  	 	 
     + ' ,F
$ yH 	#1	#	# "	#A 	
		A 
&
2/
; '
32
> (
4 '
3(
4 /
; '
3)
4 !7
 (
3*
4 4
> )
3)
4 -
8 (
3)
4 (
34
? (
3)
4 1
< &)3&-s)3#S*C'.  ewvuvyvx!K<	e&&()#& #&R +"$f fRh&O h&V
_ 
@ @FF8? F8RM5_ M5`d/ dL	JO JX| ||Jp/ JpZIV IVXh@o h@VWp_ WpcU,,!$# ,$+S!,x 	 "<!< !<"<s<   AG9 #/H7 9H4<HH1,H40H11H47II