+
    	:iē  c                   sZ   ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RIt^ RI	t	^ RI
t
^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt Rt ^ RI t / t!]PD                  R8  d   R]!R&   ] PF                  ! ]3RR/]!BRR/B t$]$P@                  t%^t,^t-^t.^t/^t0^t1^t2Rt3Rt4Rt5Rt6Rt7Rt8Rt9Rt:Rt;R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.]=R0&   R1]=R2&   R3]=R4&   / t>]%! R54      ]>R6&   ]%! R74      ]>R8&   ]%! R94      ]>R:&   ]%! R;4      ]>R<&   ]%! R=4      ]>R>&   ]%! R?4      ]>R@&   ]%! RA4      ]>RB&   ]%! RC4      ]>RD&   / t?R6]?RE&   R8]?RF&   R:]?RG&   R<]?RH&   R>]?RI&   R@]?RJ&   RB]?RK&   RD]?RL&   Rs@RsARsBRsCRsD. sERsFRsGRsHRsIRsJRsKRsLRsMRsNRsORsPRsQRsRRsSRsTRsURsVRsWRsXRM tYRRN ltZRO t[RP t\RQ t]RR t^RRS lt_RT t`RRU ltaRV tbRW tcRX tdRY teRZ tfR[ tgR\ th. 3R] lti. 3R^ ltjR_ tk]P                  ! 4       3R` ltm]P                  ! 4       3Ra ltn]P                  ! 4       3Rb lto]P                  ! 4       3Rc ltpRd tqRe trRf tsRg ttRh tuRi tvRj twRk txRl tyRm tzRn t{Ro t|Rp t}Rq t~Rr tRs tRt tRu tRv tRw tRx tRy tRz tR{ tR| tR} tR~ tR tR t]3R ltR tR tR tR tR tR tR tR tRR ltRR ltR tR tR tR tR#     ^ RI&t&]']&PP                  R&    EL_  ]) d    ^ RI*t*]+]*PP                  R&     EL}i ; i; i)    N)	BoolQuery)PortconQuery)SELinuxPolicy)ObjClassQuery)RBACRuleQuery)	RoleQuery)TERuleQuery)TypeAttributeQuery)	TypeQuery)	UserQueryzselinux-pythonTunicodeZ	localedirz/usr/share/localeZfallback_allowZ
auditallowZ
neverallowZ	dontauditsourcetargetpermlistclassZ
transitionZ
role_allowZetc_tz/etcZtmp_tz/tmpZunit_file_tz/usr/lib/systemd/systemz/lib/systemd/systemz/etc/systemd/systemZvar_cache_tz
/var/cacheZ	var_lib_tz/var/libZlog_tz/var/logZ	var_run_tz/var/runz/runZ
var_lock_tz	/run/lockz/var/run/lockZvar_spool_tz
/var/spoolZ	content_tz/var/wwwz	all filesazregular filefZ	directorydzcharacter deviceZczblock devicebzsocket fileZszsymbolic linklz
named pipep z--z-dz-cz-bz-sz-lz-pc                 sz    V P                  R ^4      ^,          p \        V4      V 3#   \         d    ^ T 3u # i ; i)z/policy.)Zrsplitint
ValueError)Zpolicy_pathZ	extension   & 6/usr/lib/python3.14/site-packages/sepolicy/__init__.pypolicy_sortkeyr      sF    "":q1!4I9~{** +~s   ( ::c                 s     V \         P                  ! 4       ,           p\        P                  ! R V,          4      pVP                  \        R7       VR,          #     M; i\        \        R4      4      h)z%s.*ZkeyzNo SELinux Policy installed)selinuxZselinux_binary_policy_pathglobsortr   r   r   )Zrootpathpolicies   &  r   get_installed_policyr&      s_    g88::99Vd]+.)|
Q45
66s   AA Ac                s    \         P                   ! \        P                  ! 4       : V : R24      pV'       g   R# VP                  \        R7       VR,          # )z?Get the path to the policy file located in the given store namez/policy/policy.*Nr   r   )r!   r    Zselinux_pathr"   r   )storer$   r   r   get_store_policyr(      sA    yy!..0%9 :HMMnM%B<    c                 s    R s R sR sR sR sR sR sR sR s \        V 4      s
R #    \        \        R4      T ,          4      h; i)NzFailed to read %s policy file)all_domainsall_attributesbools	all_typesrole_allowsZusersroles
file_types
port_typesr   _polr   r   policy_file   &r   policyr6      s_     KNEIKEEJJK[)K:;kIJJs   ! >c                 sF    \        V 4      pV'       g   R # \        V4       R # N)r(   r6   )r'   r4   r   r   load_store_policyr8      s    "5)K
;r)   c                  s0    \        4       p \        V 4       R # r7   )r&   r6   r3       r   init_policyr:      s    &(K
;r)   c                 s   \         '       g   \        4        V \        8X  dv   \        \         4      pWn        \        VP                  4       4      pV'       d7   \        V4      ^8  d'   RVn        Wn        \        VP                  4       4      pR V 4       # V \        8X  d5   \        \         4      pV'       d   Wn        R VP                  4        4       # V \        8X  d5   \        \         4      pV'       d   Wn        R VP                  4        4       # V \        8X  d   \        \         4      pV'       dh   VP                  R4       Uu. uF  p\!        V4      NK  	  pp\        V4      ^8X  d   WRn        M'\        V4      ^8X  d   V^ ,          V^ ,          3Vn        \         P$                  '       d   R VP                  4        4       # R VP                  4        4       # V \&        8X  db   \)        \         4      pV'       d   Wn        \         P$                  '       d   R VP                  4        4       # R	 VP                  4        4       # V \*        8X  d5   \-        \         4      pV'       d   Wn        R
 VP                  4        4       # V \.        8X  d5   \1        \         4      pV'       d   Wn        R VP                  4        4       # \3        R4      hu upi )   Nc              3   s  "   T Fu  pR \        \        \        VP                  4       4      4      R\        V4      R\	        VP
                  4      R\        \        \        VP                  4       4      4      /x  Kw  	  R# 5i)aliasesnameZ
permissive
attributesN)listmapstrr<   boolZispermissiver>   Z.0xr   r   	<genexpr>info.<locals>.<genexpr>   sb      
 a	 tCQYY[12CF$q~~.$s378	

 s   A=A?c              3   s   "   T F`  pR \        V4      R\        \        \         VP                  4       4      4      R\        \        \         VP	                  4       4      4      /x  Kb  	  R# 5i)r=   r/   typesN)rA   r?   r@   expandrG   rC   r   r   rE   rF      sT        a CFT#c188:./T#c1779-.
 s   A(A*c              3   s   "   T F9  pR \        V4      R\        \        \         VP                  4       4      4      /x  K;  	  R# 5i)r=   rG   N)rA   r?   r@   rH   rC   r   r   rE   rF      s=        a CFT#c188:./
 s   AA-c              3   s$  "   T F  pR VP                   P                  R\        VP                  4      R\        VP                  P
                  4      R\        VP                  P                  4      RVP                   P                  /x  K  	  R# 5i)highprotocolrangetypelowN)portsrJ   rA   rK   contextZrange_type_rN   rC   r   r   rE   rF      sj      $ #! C

OQYY--.AIIOO,qww{{ #s   BBc           	   3   s   "   T Fg  pR VP                   P                  R\        VP                  4      R\        VP                  P
                  4      RVP                   P                  /x  Ki  	  R# 5i)rJ   rK   rM   rN   N)rO   rJ   rA   rK   rP   rQ   rN   rC   r   r   rE   rF     sV       
 a	 AGGLLAJJC		(177;;	

 s   A/A1c              3   s   "   T F_  pR \        VP                  4      R\        V4      R\        \        \         VP                  4      4      R\        VP
                  4      /x  Ka  	  R# 5i)rL   r=   r/   ZlevelN)rA   Z	mls_ranger?   r@   r/   Z	mls_levelrC   r   r   rE   rF     sW      $
 #!	 Q[[)Ac#qww/0Q[[)	
 #s   A'A)c           
   3   s   "   T F5  pR \        V4      R\        \        \         VP                  4      4      /x  K7  	  R# 5i)r=   r/   N)rA   r?   r@   r/   rC   r   r   rE   rF     s;        a CFT#c177+,
 s   =?c              3   sT   "   T F  pR \        V4      RVP                  /x  K   	  R# 5i)r=   stateN)rA   rR   rC   r   r   rE   rF     s/        a CFQWW
 s   &(c              3   sf   "   T F'  pR \        V4      R\        VP                  4      /x  K)  	  R# 5i)r=   r   N)rA   r?   permsrC   r   r   rE   rF   )  s3        a CFQWW
 s   /1zInvalid type)r2   r:   TYPEr	   r=   r?   resultslenZaliasROLEr   	ATTRIBUTEr   PORTr   splitr   rO   mlsUSERr
   BOOLEANr   TCLASSr   r   )setyper=   qrU   irO      &&    r   inforc      sP   4~dOqyy{#CL1$AFG199;'G
  	 
4dOF  99;	  	  
9	t$F  99;  	 
 
4%)ZZ_5_SV_E55zQUq 8U1X.888$ yy{$ $ 
 99;  	  
4dOF888$
 yy{$ $  99;  	 
 
7	dOF  99;  	 
 
6	$F  99;  	  ((w 6s   
Kc           
      s   R \        V P                  4      R\        V P                  4      R\        V P                  4      R\        V P                  4      /p / pV P
                  P                   F  pVP                  V\        V4      &   K  	  V P
                  P                  ! R/ VB V P                  8H  pWAR&    \        \        \         V P                  4      4      VR&    \        V P                  4      VR&    V P
                  P                   Uu. uF  p\        V4      VP                  3NK  	  upVR&    \        V P
                  4      VR	&    V P                  VR
&   V#   \         d    Rp Li ; i  \         d     Li ; i  \         d     Li ; iu upi   \         d     Lri ; i  \         d     Lji ; i  \         d     T# i ; i)rM   r   r   r   Tenabledr   	transtypebooleansconditionalfilename )rA   ruletyper   r   tclassrg   rf   rR   ZevaluateZconditional_blockAttributeErrorr?   r@   rS   defaultrh   )Zruler   Z	boolstatebooleanrd   r   s   &     r   _setools_rule_to_dictro   2  s   DMM"#dkk"#dkk"T[[!		A		''00G&-mmIc'l# 1 ""++8i8D<R<RR
 iLSdjj12*T\\*+484D4D4M4MN4Mq#a&!''*4MN*t//0-* H?    
   O 
  
  Hs   A E& =&E9 $F
 =F   F5F  <F1 G &E65E69FF
FFF   F.-F.1F?>F?GGc           	      s   \         '       g   \        4        V'       g   / p\        \        \        \
        \        \        \        .4      pV  F*  pW29  g   K  \        R RP                  V4      ,          4      h	  Rp\        V9   d   \        V\        ,          4      pRp\        V9   d   \        V\        ,          4      pRp\        V9   d&   \        V\        ,          4      P                  R4      p. p. p\        V 9   d   VP!                  \        4       \
        V 9   d   VP!                  \
        4       \        V 9   d   VP!                  \        4       \        V 9   d   VP!                  \        4       \#        V4      ^ 8  da   \%        \         VVVVR7      p	\&        V9   d   V\&        ,          V	n        YyP+                  4        U
u. uF  p
\-        V
4      NK  	  up
,          p\        V 9   de   . ROp\%        \         VVVVR7      p	\&        V9   d   V\&        ,          V	n        YyP+                  4        U
u. uF  p
\-        V
4      NK  	  up
,          p\        V 9   dj   R.p\/        \         VVVVR7      p	V	P+                  4        F>  pVP!                  R\        VP0                  4      R\        VP2                  4      /4       K@  	  V# u up
i u up
i )	zType has to be in %s NZ,)rj   r   r   rk   r   r   r   )type_transitionZtype_changeZtype_member)r2   r:   setALLOW
AUDITALLOW
NEVERALLOW	DONTAUDIT
TRANSITION
ROLE_ALLOWr   joinSOURCErA   TARGETCLASSrZ   appendrV   r   PERMSrS   rU   ro   r   r   r   )rG   ZseinfoZvalid_typesr_   r   r   rk   ZtoretZtertypesr`   rD   ZrtypesZratypesrs   &&            r   searchr   d  s8   4uj*iZXYK$3chh{6KKLL  FVF^$FVF^$FVE]#))#.EH~U
#U
#E	"
8}q!)%%%	' F?UmAGIIK@Kq'*K@@UB!'%%%	' F?UmAGIIK@Kq'*K@@U)$#*!'!'!'	) ALL(CM"CM3 4  L7 A As   	K8Kc           	      s.  a aaaa	 / p. pS .o	S.o S	\        \        V 3R  l\        4       4      4      ^ ,          R,          ,          o	 S\        \        T3R l\        4       4      4      ^ ,          R,          ,          o\        R \        TTT	3R l\	        4       4      4      p T FJ  pTP                  RTR,          RTR,          TR,          3/4       YE9  g   K7  TP                  T4       / pKL  	  T#     L; i    L; i  \         d    Tu # i ; i)c                    < V R ,          S8H  # r=   ri   )rD   src   &r   <lambda>"get_conditionals.<locals>.<lambda>  s    !F)s*:r)   r>   c                 r   r   ri   )rD   destr   r   r   r     s    1V9+<r)   c                     V # r7   ri   )Zyr5   r   r   r     s    1r)   c                 s   < V R ,          S9   ;'       dG    V R,          S9   ;'       d3    \        S4      P                  V \        ,          4      ;'       d    RV 9   # )r   r   rg   )rr   Zissubsetr~   )rD   	dest_listpermsrc_lists   &r   r   r     s^    (x' # #(y(# #D	""1U8,# # "#r)   r   rg   rd   )r?   filterget_all_types_infor@   get_all_allow_rulesZupdater}   KeyError)
r   r   rk   r   ZtdictZtlistZallowsra   r   r   s
   ff&f    @@r   get_conditionalsr     s   EEuHID :<N<PQRSTUVbccT&!<>P>RSTUVWXdee	 f &#
 $%' (FALL(AhK=AQSTU^S_@`ab!U#	  L-  s/   6C6 6C= $4D D 6C:=DDDc           
      s    R pV  F  pVR,          ^,          '       g   K  Rp M	  \        R4      VRP                  \        \        R V 4      4      4      3,          # )Frg   Tz-- Allowed %s [ %s ]z || c                 sP    R V R,          ^ ,          V R,          ^,          3,          # )z%s=%drg   ri   rD   r5   r   r   Z.get_conditionals_format_text.<locals>.<lambda>  s8    wZ[\iZjklZmopq~o  AB  pC  ZD  PDr)   )r   ry   rr   r@   )Zcondrd   rD   r%   r   get_conditionals_format_textr     ss    G]AG  #$S  FD  FJ  BK  >L  2M  (N  N  Nr)   c                 sP    \        \        \        V 4      4      ^ ,          R,          # )r    rG   )r?   rc   rX   )Z	attributer5   r   get_types_from_attributer     s    Y	*+A.w77r)   c                 s@   . p/ p\        4        F6  pVP                  \        V 4      4      '       g   K%  VP                  V4       K8  	  \	        4       pV F/  p WC,          R ,          \
        WC,          R,          ,          3W#&   K1  	  V#   \         d	    . Y#&    KG  i ; iregexftype)get_all_file_types
startswithgen_short_namer}   
get_fcdictfile_type_strr   )r_   Zflistmpathsr   fcdicts   &    r   get_file_typesr     s    EF!<<v.//LLO " \F	7+]69W;M-NOFI 
 M  	FI	s   +B

BBc                s    V '       g   V #  \        \        \        V 4      4      R,          #   \        \        3 d    T u # i ; i)zReturn the real name of a type

* If 'name' refers to a type alias, return the corresponding type name.
* Otherwise return the original name (even if the type does not exist).
r=   )Znextrc   rT   ZRuntimeErrorZStopIterationr   r5   r   get_real_type_namer     sA     Dt$%f---( s   , AAc           	      s   \        4       p. p/ p\        \        .R V RRR.RR/4      pVe   \        V4      ^ 8X  d   V# \	        4       pRR.pV F  pVR,          V9   d   K  R	V9   d   VR	,          '       g   K+  VR,          P                  R
4      '       dK   VR,          V9  d   KY  VR,          V9  d+   VR,          V 8w  d   VP                  VR,          4       K  K  K  \        VR,          4       F  pW9  g   K  VP                  V4       K  	  K  	  V F/  p	 WY,          R,          \        WY,          R,          ,          3W9&   K1  	  V#   \         d	    . Y9&    KG  i ; i)r   r   openwriter   fileZ	proc_typeZsysctl_typer   rd   _tr   r   )
r   r   rs   rV   r   endswithr}   r   r   r   )
r_   r0   Z
all_writesr   r   r   r>   ra   tr   s
   &         r   get_writable_filesr     sY   #%JJFug&*vw>OQXZ`abH3x=A-\F}-JX;*$>Y<<X;%%{*,{*,X;&(%%ak2 ) - .ak:&%%a( ; " 	7+]69W;M-NOFI 
 M  	FI	s   +EE! E!c                 s  a \         P                  P                  V 4      '       d   V .#  \        P                  ! R V ,          4      pT pTP                  R4      '       d   TRR R,           p\         P                  P                  T4      o SR,          R8w  d
   SR,          o \        P                  ! R T ,          4      p\        T3R l\         P                  ! S4      4       Uu. uF  q1P                  T4      '       g   K  TNK  	  up#    \        RT 4       . u # ; i  \         d    \        R4        Li ; iu upi    . u # ; i)	z%s$zbad reg:z(/.*)?N/ztry failed got an IndexErrorc                 s   < SV ,           # r7   ri   )rD   r#   r   r   r   Zfind_file.<locals>.<lambda>5  s	    r)   ir   )osr#   ZexistsreZcompileprintr   Zdirname
IndexErrorr@   ZlistdirZmatch)ZregZpatr   rD   r#   s   &   @r   	find_filer     s   	ww~~cujj#& 	Azz(crFSL77??1D.8s?CKDjj#&12::d3CDUDa		RSDUU#j#	  .,-.
 V	sB   D D# %AE (D?D?E D #D<;D<?E E
c                 s    \        V 4      pVP                  4        FK  pVP                  R 4      '       g   K  W19  g   K$  W#,           F  p\        V4       F	  pVu u u # 	  K  	  KM  	  R# )_exec_tN)get_entrypointskeysr   r   )domainexclude_listZexecutable_filesexer#   r   rb   r   find_all_filesr   :  s\    &v.$$&<<	""s'>(--"4AH ) . '
 r)   c                 s    \        4       p V P                  R 4      '       d3   W9  d-   W ,          R,           F  p\        V4       F  pVu u # 	  K  	  R#   \         d     R# i ; i)r   r   N)r   r   r   r   )r   r   r   r#   r   s   &&   r   find_entrypoint_pathr   D  se    \F<<	""s'>G,,"4AH ) -
   s   AA A A&%A&c                 s    \        VR 4      ;_uu_ 4       pV FS  pVP                  4       pV'       g   K  V^ ,          P                  R4      '       d   K=  RV^,          RV/W^ ,          &   KU  	  RRR4       V #   + '       g   i     T # ; i  \         d,   pTP                  \        P
                  8w  d   h  Rp?T # Rp?ii ; i)r   #ZequivmodifyN)r   rZ   r   OSErrorerrnoENOENT)Zedictfc_pathr   fder   s   &&&   r   read_file_equivr   P  s    '32GGI1QqT__S11#*AaD(F"CEA$K    L   L  77ell" #Ls?   B A:A:A:0B :B	B B C B??Cc                 sh    \         '       d   \         # / s \        \         V R ,           RR7      s \         # )z.subsTr   )file_equiv_modifiedr   r   r5   r   get_file_equiv_modifiedr   ]  s0    "")*=w?PY]^r)   c                 sz    \         '       d   \         # \        V 4      s \        \         V R ,           RR7      s \         # )z
.subs_distFr   )
file_equivr   r   r   r5   r   get_file_equivr   f  s0    z(1J W|-CERJr)   c                 s@   \         '       d   \         # . s  \        V R ,           R4      ;_uu_ 4       pVP                  4       pRRR4       X Fk  pTP                  4       p\        T4      ^ 8X  d   K%   \        T4      ^8  d   \        T^,          ,          pMRp\         P                  T^ ,          T34       Km  	  \         #   + '       g   i     L; i  \         d-   pTP                  \        P
                  8w  d   h . u Rp?# Rp?ii ; i  \         d     K  i ; i).localr   Nr   )local_filesr   	readlinesr   r   r   rZ   rV   trans_file_type_strr}   r   )r   r   fcr   ra   recr   s   &      r   get_local_file_pathsr   o  s    {K'H$c**bB + ggis8q=	3x!|+CF3A/  ' +* 77ell"	  		sM   C CC 2ADC	C C D!D DDDDc                 sR   \         '       d   \         # \        V R 4      pVP                  4       pVP                  4        \        V R,           R 4      pW!P                  4       ,          pVP                  4        / s  \        V R,           R 4      ;_uu_ 4       pW!P                  4       ,          pRRR4       T F  pTP                  4       p \        T4      ^8  d   \        T^,          ,          pMRpTR,          P                  R4      ^,          pT\         9   d-   \         T,          R,          P                  T^ ,          4       K  RT^ ,          .RT/\         T&   K  	  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&   \         #   + '       g   i     EL/; i  \         d,   pTP
                  \
        P                  8w  d   h  Rp?ELcRp?ii ; i    EKo  ; i)r   z	.homedirsr   Nr   :r   r   zall log filesZlogfilezall user tmp filesZuser_tmp_typezall user home filesZuser_home_typezall virtual image filesZvirt_image_typezBall files on file systems which do not support extended attributesZ	noxattrfsz)all sandbox content in tmpfs file systemsZsandbox_tmpfs_typez&all user content in tmpfs file systemsZuser_tmpfs_typezall files on the system	file_typezAuse this label for random content that will be shared using sambaZsamba_share_tr   )r   r   r   closer   r   r   rZ   rV   r   r}   )r   r   r   r   ra   r   r   r      &       r   r   r     s   v	gs	B	BHHJ	g#S	)B,,.BHHJF'H$c**b,,. B + ggi	3x!|+CF3Bc"1%AF{q	'"))#a&1$s1vh?q	   !?"34F9&)=(>?F? '*?)@AF!(+D*E FF"%i$jkF;$+.Y-Z#[F !(+S*T UF"%>$?@F;&)l(mnF?M? +** 77ell" #"	sI   ;G' G-G' A;H H G$	G' $G' 'H2 HH H&c                 s     \        \        .R R/4       Uu. uF  qR,          V 8X  g   K  VNK  	  up# u upi   \        \        3 d     R# i ; i)r   processre   Nr   rw   	TypeErrorrl   r_   rD   r   r   get_transitions_intor     sU    !:,)0DEbEa;[aIaEbbb~&    9 449 9 AAc                 s^     \        \        .R V RR/4      #   \        \        3 d     R# i ; ir   r   r   Nr   )r_   r5   r   get_transitionsr     s9    zlXvw	$JKK~& s    ,,c                 s     \        \        .R V /4       Uu. uF  qR,          R8w  g   K  VNK  	  up# u upi   \        \        3 d     R# i ; ir   r   r   r   r   get_file_transitionsr     sU    !:,60BC_CazU^G^C___~& r   c                 s    . p\        \        .R V /4      pV F6  pRV9   g   K   VR,           F  pW9   g   K  VP                  V4       K  	  K8  	  V#     KA  ; i)r   rf   )r   rs   r}   )r_   rn   Zboollistr   r   r   rb   r   get_boolean_rulesr     sb    Hug&12H?:A| * '  Os   AAAc                  s    \        R 4      # )Z
entry_type)r   ri   r)   r   get_all_entrypointsr     s    #L11r)   c                 s    \        \        \        .V R .R.R7      pVP                  4        Uu. uF*  q"P                  V 8X  g   K  \        VP                  4      NK,  	  up# u upi )r   
entrypoint)rj   r   rk   rS   )r   r2   rs   rU   r   rA   r   )r_   r`   rD   r%   r   get_entrypoint_typesr     sS    D#W!"8'.		*A
 $%99;E;a((f2DMCM;EEEs   A!A!c                 s  a \         P                  ! V 4      ^,          P                  R4      ^,          o \        \	        V3R l\        \        .RRRR/4      4      4      pV^ ,          R,          #   \        \        \        3 d     R# i ; i)	r;   r   c                 r   )r   ri   )rD   r   r   r   r   Z$get_init_transtype.<locals>.<lambda>  s    AhK:,Er)   r   init_tr   r   re   N)
r    Z
getfileconrZ   r?   r   r   rw   r   rl   r   )r#   entrypointsr   s   & @r   get_init_transtyper     s    ##D)!,2237:J6"Evzl]egoqx  {D  ]E  HF  G  H1~k**~z2 s   ;A2 2BBc                 s    \        \        R .RR.R7      p. pVP                  4        F2  p VP                  V 8X  d   VP	                  VP
                  4       K2  K4  	  V#   \         d     KF  i ; irq   r   r   )rj   r   rk   )r   r2   rU   rm   r}   r   rl   )re   r`   r   ra      &   r   get_init_entrypointr     sw    D/0#%;	(A KYY[	yyI%""188, &    		s   ,A  A/.A/c                  sF   \        \        R .RR.R7      p / pV P                  4        Fc  p \        VP                  4      pW19   d-   W,          P                  \        VP                  4      4       KK  \        VP                  4      .W&   Ke  	  V#   \         d     Kw  i ; ir   )r   r2   rU   rA   rm   r}   r   rl   )r`   r   ra   re          r   get_init_entrypoints_strr     s    D/0#%;	(A KYY[	AIII'&--c!((m<*-ahh-&    		s   AB3BB B c                 s     \        R  \        \        .RRRV RR/4      4      p\        V4      ^ ,          #   \        \
        3 d     R# i ; i)c                     V R ,          # )re   ri   r   r5   r   r   Z,get_init_entrypoint_target.<locals>.<lambda>  s    AkNr)   r   r   r   r   r   N)r@   r   rw   r?   r   r   )r   r   r   r   get_init_entrypoint_targetr     sg    2FJ<(T\^fhrt{  ~G  JH  5I  JK ##z" s   36 A
Ac                 s    \        4       p/ p\        V 4       F/  p W,          R ,          \        W,          R,          ,          3W#&   K1  	  V#   \         d	    . Y#&    KG  i ; ir   )r   r   r   r   )r_   r   r   r   r   r   r   r      s`    \FF!&)	7+]69W;M-NOFI *
 M  	FI	s   +AA A c                  s   \        \        4      ^ 8  d   \        # \        4        \        P                  ! 4       p  \        V 4      p\        P                  ! 4       pVP                  V4       \        VP                  P                  4       4      sVP                  4        \        P!                  4        \        #    \        P                  P                  RT ,          4       \        P                  ! ^4        LZ; i)r    z#could not open interface info [%s]
)rV   methodsgen_interfacesdefaultsinterface_infor   
interfacesZInterfaceSetZ	from_filer?   r   r   sysZstderrr   Zexitr"   )Zfnr   Zifs      r   get_methodsr   +  s    
7|a		 	 	"B	"X%%'bs~~**,-


 LLNN

?"DEs   A$B9 9>C9c                  sr    \         f&   \        \        4       U u. uF  q R,          NK  	  up s \         # u up i )Nr=   )r-   rc   rT   r   r9   r   get_all_typesr   @  s/    (,T
3
1vYY
3	 4s   4c                  sN    \         f   \        \        \        4      4      s \         # r7   )all_types_infor?   rc   rT   ri   r)   r   r   r   F  s    d4j)r)   c                  s~    \         f1   \        \        \        \        R4      4      ^ ,          R,          4      s \         # )NZ
userdomainrG   )
user_typesr?   rc   rX   ri   r)   r   get_user_typesr   L  s.    $tI|<=a@IJ
r)   c                  sj   \         '       d   \         # / s \        \        \        .R 7      p V P	                  4        Fp  p\        VP                  4      p\        VP                  4      pVR8X  g   VR8X  d   K=  V\         9   d   \         V,          P                  V4       Kf  V.\         V&   Kr  	  \         # ))rj   Zsystem_r)	r.   r   r2   rs   rU   rA   r   r   r}   )r`   r   r   Ztgtr   r   get_all_role_allowsr   S  s    {KdeW-AYY[!((m!((m*z 1+##C( #uK  r)   c                  sT   ^ RI p . p\        \        4       4      pV F  pV P                  ! RR,          V4      p\	        V4      ^ 8  g   K/  \	        V P                  ! RR,          V^ ,          4      4      ^ 8X  g   K`  V^ ,          V9  g   Kp  VP                  V^ ,          4       K  	  V# )r    Nz(.*)%sz_exec_t$z_initrc$)r   sortedr   findallrV   r}   )r   r*   rG   ra   ms        r   get_all_entrypoint_domainsr   g  s    K=?#EJJx*,a0q6A:2::h3QqT:;q@QqTQ\E\""1Q4(	 
 r)   c                  s    ^ RI Hp  \        P
                  ! 4       p\        P                  ! 4       p \        P                  ! V4      P                  \        P                  ! V4      P                  8:  d   R#  \        P                  ! 4       ^ 8w  d   \        \        R4      4      h\        V ! R4      ^,          4       R#   \         d
    ^ RIHp   Li ; i  \         d     Lli ; i)r    )getstatusoutputNzEYou must regenerate interface info by running /usr/bin/sepolgen-ifgenz/usr/bin/sepolgen-ifgen)Zcommandsr   ImportError
subprocessr   r   headersr   ZstatZst_mtimer   Zgetuidr   r   r   )r   Zifiler   r   r   r   r   s  s    /, ##%E G777$$(?(?? @
 
yy{abcdd	/3
4Q
78  /./  s#   C AC CCC&%C&c                  s   \         '       d   \         \        3# / s/ s \        \        4       EF  p V R ,          V R,          8X  d   \	        V R ,          4      pM)\	        V R ,          4      : R\	        V R,          4      : 2pV R,          V R,          3\         9   d.   \         V R,          V R,          3,          P                  V4       MV.\         V R,          V R,          3&   RV 9   d4   V R,          V R,          3\        V R ,          V R,          V R,          3&   K  V R,          \        V R ,          V R,          V R,          3&   EK  	  \         \        3# )rN   rJ   rI   rM   rK   rL   )portrecsportrecsbynumrc   rY   rA   r}   )ra   Zport     r   gen_port_dictr     s    x-((MH$ZU8qy qx=D!!E(mS6^<DfIq}%1ai:/077=486Hai:/0a<CDV9aPWjBYM1U8QvY*>?CDV9M1U8QvY*>?   m$$r)   c                  s    \         '       g1   \        \        \        \        R 4      4      ^ ,          R,          4      s \         # )r   rG   )r*   r?   rc   rX   ri   r)   r   get_all_domainsr     s-    ;4Y 9:1=gFGr)   c                  s    \         '       d   \         # \        '       g   \        4        \        \        4      p V P	                  4        Uu. uF   p\        V4      R 8w  g   K  \        V4      NK"  	  ups \         # u upi )Zobject_r)r/   r2   r:   r   rU   rA   r`   rD   r   r   get_all_rolesr    sW    u 4$AYY[A[CFj,@VSV[AEL Bs   
A9!A9c                  s    \         '       gf   \        \        \        4      4      s \        P
                  '       d8   \          F-  p R P                  V R,          P                  R4      4      V R&   K/  	  \         # )r   rL   rp   )selinux_user_listr?   rc   r\   r2   r[   ry   rZ   r   r9   r   get_selinux_usersr    sQ     d,888&WWQwZ%5%5c%:;'
 'r)   c                  s   \         '       d   \         # \        \        P                  ! 4       R 4      p V P	                  4       pV P                  4        . s VP                  R4       F  pVP                  4       p\        V4      ^ 8X  g   VP                  R4      '       d   K<  VP                  R4      p\         P                  RV^ ,          RV^,          RRP                  VR,          4      /4       K  	  \         # )r   
r   r   r=   Zseuserr[   :   NN)login_mappingsr   r    Zselinux_usersconf_pathreadr   rZ   striprV   r   r}   ry   )r   bufr   rD   r   r   get_login_mappingsr
    s    ~	g,,.	4B
'')CHHJNYYt_GGIq6Q;!,,s++GGCLvqtXqtUCHHQrUOTU  r)   c                  s>    \        \        R  \        4       4      4      # )c                 r   r   ri   r   r5   r   r   Zget_all_users.<locals>.<lambda>  s    &	r)   )r   r@   r  ri   r)   r   get_all_usersr    s    #)+<+>?@@r)   c                      \         '       d   \         # \        \        \        \        R 4      4      ^ ,          R,          4      s \         # )r   rG   )r0   r?   r   rc   rX   ri   r)   r   r   r     3    zfT)[9:1=gFGJr)   c                  r  )Z	port_typerG   )r1   r?   r   rc   rX   ri   r)   r   get_all_port_typesr    r  r)   c                  sV    \         '       g   \        \        \        4      4      s \         # r7   )r,   r?   rc   r]   ri   r)   r   get_all_boolsr    s    5T']#Lr)   c                 s\    R P                  V R\        V4      )  P                  R4      4      # )rp   Nr   )ry   rV   rZ   )r   Ztrims   &&r   prettyprintr    s(    88AkD	zN((-..r)   c                 r   r7   ri   )r   r5   r   markupr    s    Hr)   c                 sL   R V! V 4      ,          pV P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R	4      '       d   VR
\        V R4      ,          ,           # V P                  R4      '       d   VR
\        V R4      ,          ,           # V P                  R4      '       g   V P                  R4      '       d
   VR,           # V P                  R4      '       d
   VR,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VRV R\        R4      )  ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R4      '       d   VR\        V R4      ,          ,           # V P                  R 4      '       d   VR\        V R 4      ,          ,           # V P                  R!4      '       d   VR"\        V R!4      ,          ,           # V P                  R#4      '       d   VR$\        V R#4      ,          ,           # V P                  R%4      '       d   VR&\        V R%4      ,          ,           # V P                  R'4      '       d   VR(\        V R'4      ,          ,           # V P                  R)4      '       d   VR*\        V R)4      ,          ,           # V P                  R+4      '       d   VR$\        V R+4      ,          ,           # V P                  R,4      '       d   VR-\        V R,4      ,          ,           # V P                  R.4      '       d   VR/\        V R.4      ,          ,           # V P                  R04      '       d   VR1\        V R04      ,          ,           # V P                  R24      '       d   VR3\        V R24      ,          ,           # V P                  R44      '       d   VR1\        V R44      ,          ,           # V P                  R54      '       d   VR1\        V R54      ,          ,           # V P                  R64      '       d   VR1\        V R64      ,          ,           # V P                  R54      '       d   VR7\        V R54      ,          ,           # V P                  R84      '       d   VR9\        V R84      ,          ,           # V P                  R:4      '       d   VR;\        V R:4      ,          ,           # V P                  R<4      '       d   VR=\        V R<4      ,          ,           # V P                  R>4      '       d   VR?\        V R>4      ,          ,           # V P                  R@4      '       d
   VRA,           # V P                  RB4      '       d   VRC\        V RB4      ,          ,           # VRD\        V RE4      ,          ,           # )Fz+Set files with the %s type, if you want to Z
_var_run_tz8store the %s files under the /run or /var/run directory.Z_pid_tz,store the %s files under the /run directory.Z
_var_lib_tz0store the %s files under the /var/lib directory.Z_var_tz,store the %s files under the /var directory.Z_var_spool_tz2store the %s files under the /var/spool directory.Z_spool_tZ_cache_tZ_var_cache_tz/store the files under the /var/cache directory.Z	_keytab_tz)treat the files as kerberos keytab files.Z_lock_tzEtreat the files as %s lock data, stored under the /var/lock directoryZ_log_tzKtreat the data as %s log data, usually stored under the /var/log directory.Z	_config_tzRtreat the files as %s configuration data, usually stored under the /etc directory.Z_conf_tr   z,transition an executable to the %s_t domain.NZ_cgi_content_tz"treat the files as %s cgi content.Z_rw_content_tz)treat the files as %s read/write content.Z_rw_tZ_write_tZ_db_tz'treat the files as %s database content.Z_ra_content_tz*treat the files as %s read/append content.Z_cert_tz'treat the files as %s certificate data.Z_key_tztreat the files as %s key data.Z	_secret_tz"treat the files as %s secret data.Z_ra_tZ_ro_tz(treat the files as %s read/only content.Z
_modules_tztreat the files as %s modules.Z
_content_tztreat the files as %s content.Z_state_tz!treat the files as %s state data.Z_files_tZ_file_tZ_data_tztreat the data as %s content.Z_tmp_tz1store %s temporary files in the /tmp directories.Z_etc_tz'store %s files in the /etc directories.Z_home_tz+store %s files in the users home directory.Z_tmpfs_tz&store %s files on a tmpfs file system.Z_unit_file_tz#treat files as a systemd unit file.Z_htaccess_tz#treat the file as a %s access file.ztreat the files as %s data.r   )r   r  rV   )r   r  Ztxt   && r   get_descriptionr    s   
7&)
CCzz,OR]^_amRnnnnzz(CkRSU]F^^^^zz,G+VWYeJffffzz(CkRSUaFbbbbzz.!!IKXY[eLffffzz*IKXY[eLffffzz*N!;!;FFFzz+@@@zz)\_jklnw_xxxxzz(bepqrt|e}}}}zz+ilwxy  |G  mH  H  H  	Hzz)ilwxy  |E  mF  F  F  	Fzz)CaHX#i.FYYYYzz"##9KK[<\\\\zz/""@;qRaCbbbbzz'@;qRYCZZZZzz*@;qR\C]]]]zz'>QPWAXXXXzz/""AKPQSbDcccczz)>QPYAZZZZzz(6Q9QQQQzz+9K;<WWWWzz'AKPQSZD[[[[zz'?+aQXBYYYYzz,5A|8TTTTzz,5A|8TTTTzz*8;q*;UUUUzz*5Az8RRRRzz)5Ay8QQQQzz)5Ay8QQQQzz)4{1i7PPPPzz(H;WXZbKcccczz(>QPXAYYYYzz)B[QRT]E^^^^zz*=Az@ZZZZzz.!!:::zz-  :[M=ZZZZ.Q1EEEEr)   c            
      s~    \         '       g-   \        \        \        R  \	        \
        4      4      4      4      s \         # )c                 r   r   ri   r   r5   r   r   Z$get_all_attributes.<locals>.<lambda>S  s    1V9r)   )r+   r?   r   r@   rc   rX   ri   r)   r   get_all_attributesr  P  s(    >fS)<d9o%NOPr)   c                 s@    V F  pW \         ,          9  g   K   R # 	  R# )FT)r~   )ZdictrS   r   r  r   _dict_has_permsr  W  s    E{"  r)   c                 s    \        4       pV P                  R 4      '       d   \        V 4      p V RR pMT pVR ,           V9  d   \        RV,          4      hVR,          R8X  d   VRR R,           pW#3# VR,           pW#3# )r   Nzdomain %s_t does not existr   r   ir   )r   r   r   r   )r_   r*   
domainname
short_namer   r   r   r   ^  s    !#Kt#F+CR[

D+5
BCC"~_s*
 ##  #%
##r)   c                  sF    \         '       g   \        \        .4      s \         # r7   )all_allow_rulesr   rs   ri   r)   r   r   r   n  s    ? %/r)   c                  s    \         '       gG   \        \        R R\        \        .R7      p V P                  4        Uu. uF  p\        V4      NK  	  ups \         # u upi )z.*T)rn   Zboolean_regexrj   )all_bool_rulesr   r2   rs   rv   rU   ro   r   r   r   get_all_bool_rulesr  t  sK    >d$*/);=<=IIKHKq/2KH Is   Ac                  sX    \         '       g   \        \        \        .4      4      s \         # r7   )all_transitionsr?   r   rw   ri   r)   r   get_all_transitionsr  |  s    ?vzl34r)   c                 s  a  . p. p\        S 4      w  r4\        R  \        V 3R l\        4       4      4       EF  pV F  p\	        V\
        4      '       g   K   \        P                  ! V^ ,          4      pV^ ,          P                  V4      '       g   V^ ,          P                  V4      '       dF   V^ ,          V3V9  d4   V^ ,          V'       * 3V9  d   VP                  V^ ,          V34       K  K  K  V^ ,          V3V9  g   K  V^ ,          V'       * 3V9  g   K  VP                  V^ ,          V34       K  	  EK
  	  W!3#   \         d    T^,          p Li ; i)c                 r   )rf   ri   r   r5   r   r   get_bools.<locals>.<lambda>  s    1Z=r)   c                 s6   < R V 9   ;'       d    V R,          S8H  # )rf   r   ri   )rD   r_   r   r   r   r    s    :?;d;dqQY{^dOd;dr)   )r   r@   r   r  Z
isinstanceZtupler    Zsecurity_get_boolean_activer   r   r}   )r_   r,   Zdomainboolsr  r  ra   r   rd   s   f       r   	get_boolsr    s2   EK+F3J(&1dfxfz*{|Aa''!==adC tz**adooj.I.IaD'?+51Q4W:MU`:`&&!g7 ;a5 aD'?%/QqTw;4Gu4TLL!A$1  }   A$s   EEEc                  s^    \         '       g   \        P                  ! 4       ^,          s \         # )r;   )rf   r    Zsecurity_get_boolean_namesri   r)   r   get_all_booleansr    s    8557:Or)   c                 s     \         P                  ! V 4      pVP                  4       pVP                  4        V#   \         d0    \        T 4      pTP                  4       pTP                  4         T# i ; ir7   )gzipr   r  r   IOError)r#   r   r	  r%   r   
policy_xmlr"    sb    YYt_ggi


 J	  $Zggi

J	s   6: 6A43A4c                 s   \         '       d   \         # ^ RIp/ s  VP                  P                  P	                  \        V 4      4      pVP                  R4       EF  pVP                  R4       EFH  pVP                  R4       F  pVP                  R4      P                  R4      P                  P                  R4      p\        P                  ! RRV4      pVP                  R	4      VP                  R
4      V3\         VP                  R	4      &   K  	  VP                  R4       F  pVP                  R4      P                  R4      P                  P                  R4      p\        P                  ! RRV4      pVP                  R	4      VP                  R
4      V3\         VP                  R	4      &   K  	  EKK  	  VP                  R4       F~  pVP                  R4      P                  R4      P                  P                  R4      p\        P                  ! RRV4      pRVP                  R
4      V3\         VP                  R	4      &   K  	  EK  	  VP                  R4       F~  pVP                  R4      P                  R4      P                  P                  R4      p\        P                  ! RRV4      pRVP                  R
4      V3\         VP                  R	4      &   K  	  \         #   \         d	     \         # i ; i)r    NZlayerZmoduleZtunabledescr   r  rp   r=   ZdftvalrB   Zglobal)booleans_dictZxml.etree.ElementTreeZetreeZElementTreeZ
fromstringr"  r   ZfindZtextr  r   ZsubZgetr!  )r#   ZxmlZtreer   r   r   r#  ra   r   r   gen_bool_dictr%    sU   } Myy$$//
40@Ag&AYYx(9-A66&>..s388>>tDD66$T2D45EE&M155?TX3YM!%%-0 . 6*A66&>..s388>>tDD66$T2D45EE&M155?TX3YM!%%-0 + ) \\&)vvf~**3/44::4@vvdC.08!%%/4/PaeeFm, * ' i(A66&>&&s+0066t<D66$T*D,4aeeHot+LM!%%-( )   s   KK, ,K?>K?c                 sh    \        4       pW9   d   \        W,          ^ ,          4      # \        R4      # )r    Zunknown)r%  r   )rn   r$  r   r   boolean_categoryr&    s,    !OM'*++|r)   c                 s    \        4       pW9   d   \        W,          ^,          4      # V P                  R4      p\        R4      P                  V^ ,          RP	                  VR,          4      R7      # )r  r   zAllow {subject} to {rest}rp   :r;   NN)ZsubjectZrest)r%  r   rZ   Zformatry   )rn   r$  r#  r%   r   boolean_descr'    s`    !OM'*++}}S!,-44T!W388TXY[T\K]4^^r)   c                  s    ^ RI p Rp ^ RIpVP                  RR7      pV#   \        \        \
        \        T P                  3 d    Rp T# i ; i)r    Nr   T)ZprettyZMisc)r   distror=   ZModuleNotFoundErrorr   r!  ZUnicodeErrorZCalledProcessError)r   Zsystem_releaser(  r   r   get_os_versionr)    sW    N D1   '<A^A^_   s     (AAc                  sR    R s R sR sR sR sR sR sR sR sR s	R s	R s
R sR sR sR sR sR sR sR # r7   )r+   r*   r-   rf   r$  r,   r   r0   r   r   r   r   r1   r.   r/   r   r  r  ri   r)   r   reinitr*    sd    ( NKIHMEFJKGGHMJKEJNr)   )i   )r   r7   )z#/usr/share/selinux/devel/policy.xml)r   r    r!   Zsepolgen.defaultsr   Zsepolgen.interfacesr   r   r   r   r   Zsetools.boolqueryr   Zsetools.portconqueryr   Zsetools.policyrepr   Zsetools.objclassqueryr   Zsetools.rbacrulequeryr   Zsetools.rolequeryr   Zsetools.terulequeryr   Zsetools.typeattrqueryr   Zsetools.typequeryr	   Zsetools.userqueryr
   ZPROGNAMEZgettextZkwargsZversion_infoZtranslationr   r   ZbuiltinsrA   Z__dict__r   Z__builtin__r   rT   rW   rX   rY   r\   r]   r^   rs   rt   ru   rv   rz   r{   r~   r|   rw   rx   ZDEFAULT_DIRSr   r   r2   r   r   r   r   r   r-   r   r   r.   r   r   r*   r/   r  r  r0   r1   r,   r+   rf   r$  r  r  r  r   r&   r(   r6   r8   r:   rc   ro   r   r   r   r   r   r   r   r   r   r   r   Zselinux_file_context_pathr   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  r  r"  r%  r&  r'  r)  r*  ri   r)   r   <module>r+     s  
    $ ( 
 	 	  ' - + / / ' + 4 ' ',F
$ yH 	#1	#	# "	#A 	
		A 		
	


			

 V V *7& '&3" #&3" #*\ &Z "Z &Z "V ([  ,_ *\ &Z {^c ~&c {^c )*c ~&c }%c 'c |_c   B  D  D  D  D  D  D  D    
	
	
 

7K4j)Z/dHVBN8!H6 )+  ,. 	
 %,$E$E$G  #<<>  ")!B!B!D 8 88: +\2F$*(	9$%4$A/ % ZFz$  *	>_	&C&,,!$# ,$+S!,s+   (AK/ /L*2LL'"L*&L''L*