/usr/lib/python3.9/site-packages/sepolgen/__pycache__
NameSizeModeActions
access.cpython-39.opt-1.pyc113610644editdlrm
access.cpython-39.pyc113610644editdlrm
audit.cpython-39.opt-1.pyc172600644editdlrm
audit.cpython-39.pyc172600644editdlrm
classperms.cpython-39.opt-1.pyc24710644editdlrm
classperms.cpython-39.pyc24710644editdlrm
defaults.cpython-39.opt-1.pyc22980644editdlrm
defaults.cpython-39.pyc22980644editdlrm
interfaces.cpython-39.opt-1.pyc125920644editdlrm
interfaces.cpython-39.pyc125920644editdlrm
lex.cpython-39.opt-1.pyc213770644editdlrm
lex.cpython-39.pyc213770644editdlrm
matching.cpython-39.opt-1.pyc61690644editdlrm
matching.cpython-39.pyc61690644editdlrm
module.cpython-39.opt-1.pyc71700644editdlrm
module.cpython-39.pyc71700644editdlrm
objectmodel.cpython-39.opt-1.pyc39710644editdlrm
objectmodel.cpython-39.pyc39710644editdlrm
output.cpython-39.opt-1.pyc35450644editdlrm
output.cpython-39.pyc35450644editdlrm
policygen.cpython-39.opt-1.pyc128870644editdlrm
policygen.cpython-39.pyc129200644editdlrm
refparser.cpython-39.opt-1.pyc292590644editdlrm
refparser.cpython-39.pyc292590644editdlrm
refpolicy.cpython-39.opt-1.pyc401730644editdlrm
refpolicy.cpython-39.pyc401730644editdlrm
sepolgeni18n.cpython-39.opt-1.pyc3940644editdlrm
sepolgeni18n.cpython-39.pyc3940644editdlrm
util.cpython-39.opt-1.pyc63640644editdlrm
util.cpython-39.pyc63640644editdlrm
yacc.cpython-39.opt-1.pyc531330644editdlrm
yacc.cpython-39.pyc532120644editdlrm
__init__.cpython-39.opt-1.pyc1440644editdlrm
__init__.cpython-39.pyc1440644editdlrm
Edit: /usr/lib/python3.9/site-packages/sepolgen/__pycache__/interfaces.cpython-39.pyc (12592B)
a BÒiP@ã@sÂdZddlZddlZddlmZddlmZddlmZddlmZddlm Z Gd d „d ƒZ d d „Z d d„Z dd„Z dd„Zdd„ZGdd„dƒZGdd„dƒZGdd„dƒZGdd„dƒZdS)z7 Classes for representing and manipulating interfaces. éNé)Úaccess)Ú refpolicy)Ú objectmodel)Úmatching)Ú_c@sHeZdZdZdd„Zdd„Zdd„ZeeeƒZedd „d �Z d d „Z d S)ÚParamz; Object representing a parameter for an interface. cCs"d|_tj|_t ¡|_d|_dS)NÚT)Ú _Param__namerÚSRC_TYPEÚtypeÚIdSetÚ obj_classesÚrequired©Úself©rú7/usr/lib/python3.9/site-packages/sepolgen/interfaces.pyÚ__init__&s zParam.__init__cCs t |¡std|ƒ‚||_dS)NzName [%s] is not a param)rÚ is_idparamÚ ValueErrorr )rÚnamerrrÚset_name,s  zParam.set_namecCs|jS©N)r rrrrÚget_name1szParam.get_namecCst|jdd…ƒS©Nr)ÚintrrrrrÚ6ózParam.)ÚfgetcCs d|jtj|jd |j¡fS)Nz0ú )rrÚ field_to_strr ÚjoinrrrrrÚ__repr__8sÿzParam.__repr__N) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrÚpropertyrÚnumr#rrrrr"s rcCsÌd}||vrš||}||jkr"dS|tjks6|tjkr”|jtjksN|jtjkr”d}|r`|jg}ng}t |j|¡D]}|tj vrrd}qŠqrtj|_q¶d}nt ƒ}||_ ||_|||j <|rÈ|j  |j¡|S©Nrr) r rr ÚTGT_TYPEÚ obj_classÚ itertoolsÚchainrrZimplicitly_typed_objectsrrÚadd)rr ÚavÚparamsÚretÚpZavobjsÚobjrrrÚ__param_insert>s6  ÿ ÿ    r5cCs~d}d}t |j¡r.t|jtj||ƒdkr.d}t |j¡rTt|jtj||ƒdkrTd}t |j¡rzt|jtj ||ƒdkrzd}|S)ajExtract the parameters from an access vector. Extract the parameters (in the form $N) from an access vector, storing them as Param objects in a dictionary. Some attempt is made at resolving conflicts with other entries in the dict, but if an unresolvable conflict is found it is reported to the caller. The goal here is to figure out how interface parameters are actually used in the interface - e.g., that $1 is a domain used as a SRC_TYPE. In general an interface will look like this: interface(`foo', ` allow $1 foo : file read; ') This is simple to figure out - $1 is a SRC_TYPE. A few interfaces are more complex, for example: interface(`foo_trans',` domain_auto_trans($1,fingerd_exec_t,fingerd_t) allow $1 fingerd_t:fd use; allow fingerd_t $1:fd use; allow fingerd_t $1:fifo_file rw_file_perms; allow fingerd_t $1:process sigchld; ') Here the usage seems ambiguous, but it is not. $1 is still domain and therefore should be returned as a SRC_TYPE. Returns: 0 - success 1 - conflict found rFr) rrÚsrc_typer5rr Útgt_typer+r,Ú OBJ_CLASS)r0r1r2Z found_srcrrrÚav_extract_paramsjs$   r9cCs"t |j¡rt|jtjd|ƒSdSr)rrÚroler5rZROLE)r:r1rrrÚrole_extract_paramsžs r;csl‡fdd„}d}||jtjƒr"d}||jtjƒr4d}||jtjƒrFd}t |j ¡rht |j tj dˆƒrhd}|S)Ncs.d}|D] }t |¡rt||dˆƒrd}q|Sr*)rrr5)Úsetr r2Úx©r1rrÚextract_from_set£s  z2type_rule_extract_params..extract_from_setrr) Ú src_typesrr Ú tgt_typesr+rr8rrZ dest_typer5Z DEST_TYPE)Úruler1r?r2rr>rÚtype_rule_extract_params¢s  rCcCs2d}|jD]"}t |¡r t|tjd|ƒr d}q |Sr*)Úargsrrr5rr )Úifcallr1r2ÚargrrrÚifcall_extract_params»s   rGc@seZdZdd„Zdd„ZdS)ÚAttributeVectorcCsd|_t ¡|_dS)Nr )rrÚAccessVectorSetrrrrrÇszAttributeVector.__init__cCs|j |¡dSr)rÚadd_av©rr0rrrrJËszAttributeVector.add_avN)r$r%r&rrJrrrrrHÆsrHc@s$eZdZdd„Zdd„Zdd„ZdS)Ú AttributeSetcCs i|_dSr)Ú attributesrrrrrÏszAttributeSet.__init__cCs||j|j<dSr)rMr)rÚattrrrrÚadd_attrÒszAttributeSet.add_attrcCszdd„}d}|D]V}|dd…}|ddkrD|r:| |¡||ƒ}q|r| d¡}t |¡}| |¡q|rv| |¡dS)NcSsH|dd… ¡}t|ƒdks(|ddkr4td|ƒ‚tƒ}|d|_|S)NréÿÿÿÿérZ Attributez#Syntax error Attribute statement %s)ÚsplitÚlenÚ SyntaxErrorrHr)ÚlineÚfieldsÚarrrÚ parse_attrÖs   z*AttributeSet.from_file..parse_attrrPrú[ú,)rOrRrÚ AccessVectorrJ)rÚfdrXrWrUÚlr0rrrÚ from_fileÕs        zAttributeSet.from_fileN)r$r%r&rrOr^rrrrrLÎsrLc@sFeZdZdifdd„Zifdd„Zdd„Zdd „Zd d „Zd d „ZdS)ÚInterfaceVectorNcCs6d|_d|_t ¡|_i|_|r,| ||¡d|_dS)NTr F)ÚenabledrrrIr1Úfrom_interfaceÚexpanded)rÚ interfacerMrrrrîs  zInterfaceVector.__init__c Cs"|j|_| ¡D]>}|jtjjkr$qd|jvr0qt |¡}|D]}| |¡q>q|rÌ|  ¡D]n}|j D]b}||j vrvqf|j |}|jD]@} t   | ¡}|j |jkr¨|j |_ |j|jkr¼|j |_| |¡q†qfq\| ¡D]} t| |jƒrÔqÔ| ¡D]} t| |jƒrîqî| ¡D]} t| |jƒ�r�qdS)NZ dontaudit)rZavrulesZ rule_typerZAVRuleZALLOWrZavrule_to_access_vectorsrJZtypeattributesrMÚcopyr6r r7Zrolesr;r1Z typerulesrCÚinterface_callsrG) rrcrMZavruleZavsr0Z typeattributerNZattr_vecrWr:rBrErrrraÿs>                zInterfaceVector.from_interfacecCs t||jƒdkr|j |¡dSr)r9r1rrJrKrrrrJ3szInterfaceVector.add_avcCs8g}| d|j¡|jD]}| t|ƒ¡qd |¡S)Nz[InterfaceVector %s]Ú )ÚappendrrÚstrr")rÚsr0rrrÚ to_string9s  zInterfaceVector.to_stringcCs| ¡Sr)r#rrrrÚ__str__@szInterfaceVector.__str__cCsd|j|jfS)Nz)rr`rrrrr#CszInterfaceVector.__repr__) r$r%r&rrarJrjrkr#rrrrr_ís  4r_c@sxeZdZddd„Zdd„Zdd„Zdd „Zd d „Zd d „Zifdd„Z difdd„Z dd„Z dd„Z dd„Z dd„ZdS)Ú InterfaceSetNcCsi|_i|_g|_||_dSr)Ú interfacesÚ tgt_type_mapÚ tgt_type_allÚoutput)rrprrrrHszInterfaceSet.__init__cCs|jr|j |d¡dS)Nrf)rpÚwrite)rrhrrrÚoNszInterfaceSet.ocCs¤t|j ¡dd„d�D]ˆ}| d|j¡t|j ¡dd„d�D] }| d|jtj|jf¡q@| d¡t|j   ¡ƒ}|D]}| d  |¡¡| d ¡q~qdS) NcSs|jSr©r©r=rrrrSrz&InterfaceSet.to_file..)Úkeyz[InterfaceVector %s cSs|jSrrsrtrrrrUrz%s:%s z] rZrf) ÚsortedrmÚvaluesrqrr1rr!r rZto_listr")rr\ZivÚparamZavlr0rrrÚto_fileRs zInterfaceSet.to_filecCs‚dd„}d}|D]V}|dd…}|ddkrD|r:| |¡||ƒ}q|r| d¡}t |¡}| |¡q|rv| |¡| ¡dS)NcSs¸|dd… ¡}t|ƒdks(|ddkr4td|ƒ‚tƒ}|d|_t|ƒdkrTdS|dd…D]R}| d¡}t|ƒdkr†td|ƒ‚tƒ}|d|_tj|d|_||j |j<q`|S) NrrPrQrr_z)Syntax error InterfaceVector statement %sú:z-Invalid param in InterfaceVector statement %s) rRrSrTr_rrrZ str_to_fieldr r1)rUrVÚifvZfieldr3rxrrrÚ parse_ifv^s        z)InterfaceSet.from_file..parse_ifvrPrrYrZ)Úadd_ifvrRrr[rJÚindex)rr\r|r{rUr]r0rrrr^]s        zInterfaceSet.from_filecCs||j|j<dSr)rmr)rr{rrrr}€szInterfaceSet.add_ifvcCsv|j ¡D]f}tƒ}|jD]2}t |j¡r@|j |¡tƒ}qN| |j¡q|D]}|j   |g¡}| |¡qRq dSr) rmrwr<rrr7rorgr/rnÚ setdefault)rr{rAr0r r]rrrr~ƒs   zInterfaceSet.indexcCst||ƒ}| |¡dSr)r_r})rrcrMr{rrrr/‘s zInterfaceSet.addcCs<t | ¡| ¡¡D]}| ||¡q| |¡| ¡dSr)r-r.rmÚ templatesr/Úexpand_ifcallsr~)rÚheadersrprMÚirrrÚ add_headers•s zInterfaceSet.add_headerscCsZt |¡rPt|dd…ƒ}|t|jƒkr,dS|j|d}t|tƒrH|S|gSn|gSdSr)rrrrSrDÚ isinstanceÚlist)rÚidrEr)rFrrrÚ map_paramœs  zInterfaceSet.map_paramc CsÈ| |j|¡}|durdS| |j|¡}|dur4dS| |j|¡}|durNdSt ¡}|jD]&}| ||¡} | durxq\q\| | ¡q\t|ƒdkr”dS|D]*} |D] } |D]} |j   | | | |¡q¨q q˜dS)Nr) rˆr6r7r,rr ZpermsÚupdaterSrr/) rr{r0rEr@rArZ new_permsZpermr3r6r7r,rrrÚ map_add_av¬s*    zInterfaceSet.map_add_avc Csè|dfg}|j|j}d|_t|ƒdkrä| d¡\}}|j|j}||krl|jD]}| |||¡qP|jrlq| ¡D]l} | j|jkr˜|  t dƒ¡dSz|| j} Wn*t yÐ|  t d| jƒ¡YqtYn0|  | | f¡qtqdS)NTrrPzFound circular interface classz#Missing interface definition for %s) rmrrbrSÚpoprrŠreZifnamerrrÚKeyErrorrg) rrcÚ if_by_nameÚstackr{ZcurZ cur_ifcallZcur_ifvr0rEZnewifrrrÚdo_expand_ifcallsÈs*         zInterfaceSet.do_expand_ifcallscCsRi}t | ¡| ¡¡D]}|||j<qt | ¡| ¡¡D]}| ||¡qs"     ,4 Z