KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21585/root/usr/lib64/python2.4/site-packages/sepolgen/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21585/root/usr/lib64/python2.4/site-packages/sepolgen/matching.pyc
mò
d&KRc@s^dZdkZdkZdkZdfd„ƒYZdfd„ƒYZdfd„ƒYZdS(sI
Classes and algorithms for matching requested access to access vectors.
NtMatchcBs tZddd„Zd„ZRS(NicCs||_||_t|_dS(N(t	interfacetselftdisttFalsetinfo_dir_change(RRR((t7/usr/lib64/python2.4/site-packages/sepolgen/matching.pyt__init__s		cCst|i|ijo>|io|iodSqMdSqp|iodSqpdSn |i|ijodSndSdS(Niiiÿÿÿÿ(RRtotherR(RR((Rt__cmp__"s


(t__name__t
__module__tNoneRR	(((RRst	MatchListcBsMtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(	NixcCs4g|_g|_|i|_t|_d|_dS(N(	RtchildrentbastardstDEFAULT_THRESHOLDt	thresholdRtallow_info_dir_changeRtav(R((RR6s
			cCs't|iƒo|idSndSdS(Ni(tlenRRR(R((Rtbest?scCs
t|iƒS(N(RRR(R((Rt__len__EscCs
t|iƒS(N(titerRR(R((Rt__iter__KscCsti|i|iƒS(N(t	itertoolstchainRRR(R((RtallNscCsd|i|ijo=|ip
|io|ii|ƒq`|ii|ƒn|ii|ƒdS(N(	tmatchRRRRRRtappendR(RR((RRQs
cCs|iiƒ|iiƒdS(N(RRtsortR(R((RRZs
(
R
RRRRRRRRR(((RR
4s								t
AccessMatchercBsAtZdd„Zd„Zd„Zd„Zd„Zd„ZRS(NcCsBd|_d|_|o
||_ntiƒ|_d|_dS(Ni
id(Rttype_penaltytobj_penaltyt	perm_mapstobjectmodeltPermMappingstinfo_dir_penalty(RR"((RR`s		
cCs1||jpti|ƒodSn	|iSdS(Ni(tatbtaccesst
is_idparamRR (RR&R'((Rt
type_distancelscCsx|ii|iƒ}t|ƒdjo!|ii|i	|ƒ}|Sn,|ii|iƒ}|ii|i	|ƒSdS(Ni(tav_reqtpermst
differencetav_provtdiffRRR"tgetdefault_distancet	obj_classttotal(RR+R.R/R2((Rt
perm_distancess	cCsd}||i|i|iƒ7}||i|i|iƒ7}|i|ijo%ti	|iƒo||i
8}n|djo|ii|i|i
ƒ}n|i||ƒ}|djo%|djo||Sq||Sn3|djo%|djo||Sq||SndS(s+Determine the 'distance' between 2 access vectors.

        This function is used to find an access vector that matches
        a 'required' access. To do this we comput a signed numeric
        value that indicates how close the req access is to the
        'provided' access vector. The closer the value is to 0
        the closer the match, with 0 being an exact match.

        A value over 0 indicates that the prov access vector provides more
        access than the req (in practice, this means that the source type,
        target type, and object class is the same and the perms in prov is
        a superset of those in req.

        A value under 0 indicates that the prov access less - or unrelated
        - access to the req access. A different type or object class will
        result in a very low value.

        The values other than 0 should only be interpreted relative to
        one another - they have no exact meaning and are likely to
        change.

        Params:
          req - [AccessVector] The access that is required. This is the
                access being matched.
          prov - [AccessVector] The access provided. This is the potential
                 match that is being evaluated for req.
        Returns:
          0   : Exact match between the acess vectors.

          < 0 : The prov av does not provide all of the access in req.
                A smaller value indicates that the access is further.

          > 0 : The prov av provides more access than req. The larger
                the value the more access over req.
        iN(RRR*treqtsrc_typetprovttgt_typeR1R(R)R!R"R0R,tpdistR3(RR4R6RR8((Rtav_distance~s"#'




cCsed}x“|D]‹}|i||ƒ}|djo
|}q
|djo*|djo||7}q˜||}q
|djo||7}q
||8}q
W|ii	|i
|iƒ}|i
djoFti|_
x7|D]+}|i
|ii	|i
|iƒB|_
qÚWn|ti@djo@|i
ti@o/|djo||i8}qa||i7}n|S(s


        iN(RRtav_settxRR9RttmpR"tgetdefault_directionR1R,tav_dirtinfo_dirR#t	FLOW_NONEt
FLOW_WRITER%(RR:RR<RR;R>((Rtav_set_matchÆs2




-%
cCsœ||_x‚ti|i|ii|igƒƒD]Y}|i
pq1n|i|i
|ƒ}|djo t||ƒ}|i|ƒq1q1W|iƒdS(Ni(Rt
match_listRRtifsetttgt_type_allttgt_type_maptgetR7tivtenabledRRBR(RRtmRR(RRDRRCRRJRH((Rt
search_ifsîs	

(	R
RRRR*R3R9RBRK(((RR_s			H	((t__doc__R(R#RRR
R(R
R#R(RRR((Rt?s			+

Anon7 - 2021