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 }g,n&aM>hj89So1Mxx]Qe? FbPB28eJZ^sjFYk~4WUj1fx[܏H8k*1tMҐ%bo Zl];MS򐋋0eBk2L2owS@z MgʔKNJ7=<,̏Udpg\fI9ZEE7PW$Z6 (0{k f/@\7q'_Yg$QII 1fj\jX dxi0}a$XWIIaԢpHI"HM6"doJoUvsB4 )ZlEc˝r=ݢ$/:yX4owQʖ# axӦ7?$W:+Gm)80Bj&"r_p*rᣤF>>e'q|H~20^pSx=Ŗ_( wdê0oBG]$-#|YzWrF<V?m^и/J:5.7c'~AL^['uz (CeI}MK!x.|u>\Օ>sbTKB(OGs{h+gAtW&ߧ?6<1 yE2q|5?*_FӒڻw S :̽b%h,r*A&0;@2j+rteΠEXIFExifII*V^(ifHH02100100XMP a z f;@sdZddlZddlZddlmZz ddlTWn Yn0ddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dZ dZd ZGd d d ZdefddZddZGdddZddZdS)z> classes and algorithms for the generation of SELinux policy. N)*) refpolicy) objectmodel)access) interfaces)matching)utilc@seZdZdZdddZd ddZd!dd Zefd d Zd d Z ddZ ddZ d"ddZ ddZ ddZddZddZddZdS)#PolicyGeneratoraGenerate a reference policy module from access vectors. PolicyGenerator generates a new reference policy module or updates an existing module based on requested access in the form of access vectors. It generates allow rules and optionally module require statements, reference policy interfaces, and extended permission access vector rules. By default only allow rules are generated. The methods .set_gen_refpol, .set_gen_requires and .set_gen_xperms turns on interface generation, requires generation, and xperms rules generation respectively. PolicyGenerator can also optionally add comments explaining why a particular access was allowed based on the audit messages that generated the access. The access vectors passed in must have the .audit_msgs field set correctly and .explain set to SHORT|LONG_EXPLANATION to enable this feature. The module created by PolicyGenerator can be passed to output.ModuleWriter to output a text representation. NcCs>d|_t|_d|_|r||_n t|_d|_d|_d|_ dS)zInitialize a PolicyGenerator with an optional existing module. If the module parameter is not None then access will be added to the passed in module. Otherwise a new reference policy module will be created. NF) ifgenNO_EXPLANATIONexplain gen_requiresmodulerZModule dontauditxpermsdomains)selfrr6/usr/lib/python3.9/site-packages/sepolgen/policygen.py__init__Es zPolicyGenerator.__init__cCs*|rt|||_d|_nd|_|dS)a?Set whether reference policy interfaces are generated. To turn on interface generation pass in an interface set to use for interface generation. To turn off interface generation pass in None. If interface generation is enabled requires generation will also be enabled. TN)InterfaceGeneratorr r"_PolicyGenerator__set_module_style)rZif_set perm_mapsrrrset_gen_refpolYs  zPolicyGenerator.set_gen_refpolTcCs ||_dS)a&Set whether module requires are generated. Passing in true will turn on requires generation and False will disable generation. If requires generation is disabled interface generation will also be disabled and can only be re-enabled via .set_gen_refpol. N)r)rstatusrrrset_gen_requiresksz PolicyGenerator.set_gen_requirescCs ||_dS)z)Set whether access is explained. N)r)rrrrrset_gen_explainuszPolicyGenerator.set_gen_explaincCs ||_dSN)r)rrrrrset_gen_dontauditzsz!PolicyGenerator.set_gen_dontauditcCs ||_dS)zSSet whether extended permission access vector rules are generated. N)r)rrrrrset_gen_xperms}szPolicyGenerator.set_gen_xpermscCs*|jr d}nd}|jD] }||_qdS)NTF)r rmodule_declarationsr)rrmodrrrZ__set_module_styles z"PolicyGenerator.__set_module_style1.0cCsXd}|jD]}|}q|s4t}|jjd|||_||_|jrNd|_nd|_dS)z?Set the name of the module and optionally the version. NrTF) rr"rZModuleDeclarationchildreninsertnameversionr )rr'r(mr#rrrset_module_nameszPolicyGenerator.set_module_namecCs|jrt|j|jSr)rr)rrrr get_modules zPolicyGenerator.get_modulec Csnt|}|jr|j|_d|_|jr>ttt ||jd|_|j t j krl|jd7_|j rl|jd7_|j t jkr|jd7_|j t jkrt|jdkr|jddd d |jD7_n|jd |jd d 7_|j t jkrL|jd 7_|jd7_|jd|jd 7_|jddD]}|jd|7_q2z|j t jkrLd|jvrLd|jvsd|jvrL|jsttddd d|_g}dd tt gt|jt|jt|jiDD]}||jvr||qt|dkr|jd|j|jd|f7_n0t|dkrL|jd|j|jd|f7_Wn Yn0|jj |dS)z Add access vector rule. ) verbosityz0 #!!!! This avc is allowed in the current policyzN #!!!! This av rule may have been overridden by an extended permission av rulez: #!!!! This avc has a dontaudit rule in the current policyrzH #!!!! This avc can be allowed using one of the these booleans: # %sz, cSsg|] }|dqS)rr.0xrrr z1PolicyGenerator.__add_av_rule..z5 #!!!! This avc can be allowed using the boolean '%s'rz #!!!! This avc is a constraint violation. You would need to modify the attributes of either the source or target types to allow this access.z #Constraint rule: z # Nz? # Possible cause is the source %s and target %s are different.writediropendomain)r'typescSsg|] }|tqSr)ZTCONTEXTr.rrrr1r2zL #!!!! The source type '%s' can write to a '%s' of the following type: # %s zM #!!!! The source type '%s' can write to a '%s' of the following types: # %s )!rZAVRulerZ DONTAUDIT rule_typecommentrstrCommentexplain_accesstype audit2whyZALLOWrZBOOLEANlendatajoinZ CONSTRAINTZTERULEperms obj_classrZseinfoZ ATTRIBUTEZsesearchZSCONTEXTsrc_typeZCLASSZPERMSappendrr%)ravZrulereasonr7irrrZ __add_av_rulesV    &, $&zPolicyGenerator.__add_av_rulecCs<|jD],}t||}|jr(|j|_|jj |q dS)z5Add extended permission access vector rules. N) rkeysrZ AVExtRulerZDONTAUDITXPERMr8rr%rE)rrFopZextrulerrrZ__add_ext_av_ruless  z"PolicyGenerator.__add_ext_av_rulescCs\|jr*|j||j\}}|jj|n|}|D]$}|||jr2|jr2||q2dS)zJAdd the access from the access vector set to this module. N) r genrrr%extend_PolicyGenerator__add_av_ruler"_PolicyGenerator__add_ext_av_rules)rZav_setZ raw_allowifcallsrFrrr add_accesss   zPolicyGenerator.add_accesscCs|D]}|jj|qdSr)rr%rE)rZ role_type_set role_typerrradd_role_typesszPolicyGenerator.add_role_types)N)NN)T)r$)__name__ __module__ __qualname____doc__rrrSHORT_EXPLANATIONrr r!rr*r+rMrNrPrRrrrrr -s    5 r c sgfdd}|tkr|jD]}d|jdt|jt|jfd|jt |j fd|j |j |j ftjd|jdd d d d q |nb|rd |j|j|j|jft|jdkr|jd}d|j |j |j f|S)aExplain why a policy statement was generated. Return a string containing a text explanation of why a policy statement was generated. The string is commented and wrapped and can be directly inserted into a policy. Params: av - access vector representing the access. Should have .audit_msgs set appropriately. verbosity - the amount of explanation provided. Should be set to NO_EXPLANATION, SHORT_EXPLANATION, or LONG_EXPLANATION. Returns: list of strings - strings explaining the access or an empty string if verbosity=NO_EXPLANATION or there is not sufficient information to provide an explanation. csJsdSdD]*}t|jj}d||jfqdS)Nz Interface options:z %s # [%d])rEallcall_interface interfacerFZ to_stringZdist)matchifcallmlsrrexplain_interfacess   z*explain_access..explain_interfacesz %sz scontext="%s" tcontext="%s"z class="%s" perms="%s"z comm="%s" exe="%s" path="%s"z message=""Pz z )initial_indentsubsequent_indentz) src="%s" tgt="%s" class="%s", perms="%s"rz comm="%s" exe="%s" path="%s")LONG_EXPLANATIONZ audit_msgsrEheaderr:ZscontextZtcontextZtclassrZlist_to_space_strZaccessesZcommZexepathrLtextwrapwrapmessagerDtgt_typerCrBZ to_space_strr?)rFr^r-r`msgrr]rr<s2    r<cCsg}g}||j|jddddt}|j|_tt |D]z}||j tj krj|j |jqF||j tjkr|j |jqF||j tjkr|j |jqFt||j dsFJqFt |j dksJ|S)NcSs|jSrnumZparamrrr9r2z call_interface..Tkeyreverser)rLparamsvaluessortrZ InterfaceCallr'Zifnameranger?r=SRC_TYPEargsrErDTGT_TYPErk OBJ_CLASSrCprint)rZrFrtryr\rHrrrrY4s" rYc@s.eZdZd ddZddZddZdd ZdS) rNcCs&||_||t||_g|_dSr)ifshack_check_ifsrZ AccessMatchermatchercalls)rr}rrrrrNs  zInterfaceGenerator.__init__cCs|jD]|}g}||j|jddddtt|D]D}|d||jkr`d|_q ||j t j t j t j fvr@d|_q q@q dS)NcSs|jSrrmrorrrrp\r2z3InterfaceGenerator.hack_check_ifs..TrqrF)rrurLrtrvrwr?rnZenabledr=rrxrzr{)rr}r0rtrHrrrr~Tsz!InterfaceGenerator.hack_check_ifsc Cs||}g}|jD]>}t|j|j}|rDtt|j|||_ | ||fqg}|D]L\}}d} |D],} | |rl| j r|j r| j |j d} ql| s\| |q\||fS)NFT) r[rrYZbestrZrFrr;r<r9rEmatchesmerge) ravsr-raw_avrOr^r\dr}foundZo_ifcallrrrrKks$      zInterfaceGenerator.gencCsLg}|D]>}t}|j|j||t|r<|j|q||q|Sr)rZ MatchListrZ search_ifsr}r?rrE)rrrrFZansrrrr[s zInterfaceGenerator.match)N)rSrTrUrr~rKr[rrrrrMs rcCs"dd}|D] }||qdS)z*Add require statements to the module. cSst}|D]:}|j|j|j|j|jD]}|||j q6q| D]}|j D]}|j |q^qT| D] }|j |j|j|jqz|jd|jd|dS)Nrr)rZRequireZavrulesr7updateZ src_typesZ tgt_typesZ obj_classesZ add_obj_classrBZinterface_callsryaddZ role_typesZrolesZrolediscardr%r&)noderZavruleobjr\argrQrrrcollect_requiress      z&gen_requires..collect_requiresN)Znodes)rrrrrrrs r)rV itertoolsrhZselinux.audit2whyr>Zsetoolsr,rrrrrr r rWrer r<rYrrrrrrs,        Q7B