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 :  /usr/lib64/python2.4/site-packages/sepolgen/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib64/python2.4/site-packages/sepolgen/access.pyc
mς
d&KRc@s]dZdkZd„Zdfd„ƒYZd„Zdfd„ƒYZd„Zd	„ZdS(
sV
Classes representing basic access.

SELinux - at the most basic level - represents access as
the 4-tuple subject (type or context), target (type or context),
object class, permission. The policy language elaborates this basic
access to faciliate more concise rules (e.g., allow rules can have multiple
source or target types - see refpolicy for more information).

This module has objects for representing the most basic access (AccessVector)
and sets of that access (AccessVectorSet). These objects are used in Madison
in a variety of ways, but they are the fundamental representation of access.
NcCs`t|ƒdjoE|ddjo4yt|dƒWntj
otSnXtSntSdS(s¬Determine if an id is a paramater in the form $N, where N is
    an integer.

    Returns:
      True if the id is a paramater
      False if the id is not a paramater
    iit$N(tlentidtintt
ValueErrortFalsetTrue(R((t5/usr/lib64/python2.4/site-packages/sepolgen/access.pyt
is_idparam$s$	tAccessVectorcBsGtZdZed„Zd„Zd„Zd„Zd„Zd„Z	RS(sΊ
    An access vector is the basic unit of access in SELinux.

    Access vectors are the most basic representation of access within
    SELinux. It represents the access a source type has to a target
    type in terms of an object class and a set of permissions.

    Access vectors are distinct from AVRules in that they can only
    store a single source type, target type, and object class. The
    simplicity of AccessVectors makes them useful for storing access
    in a form that is easy to search and compare.

    The source, target, and object are stored as string. No checking
    done to verify that the strings are valid SELinux identifiers.
    Identifiers in the form $N (where N is an integer) are reserved as
    interface parameters and are treated as wild cards in many
    circumstances.

    Properties:
     .src_type - The source type allowed access. [String or None]
     .tgt_type - The target type to which access is allowed. [String or None]
     .obj_class - The object class to which access is allowed. [String or None]
     .perms - The permissions allowed to the object class. [IdSet]
     .audit_msgs - The audit messages that generated this access vector [List of strings]
    cCsX|o|i|ƒn4d|_d|_d|_tiƒ|_	g|_
d|_dS(N(t	init_listtselft	from_listtNonetsrc_typettgt_typet	obj_classt	refpolicytIdSettpermst
audit_msgst
info_flow_dir(RR
((Rt__init__Os				cCsnt|ƒdjotdt|ƒƒ‚n|d|_|d|_|d|_ti	|dƒ|_
dS(sxInitialize an access vector from a list.

        Initialize an access vector from a list treating the list as
        positional arguments - i.e., 0 = src_type, 1 = tgt_type, etc.
        All of the list elements 3 and greater are treated as perms.
        For example, the list ['foo_t', 'bar_t', 'file', 'read', 'write']
        would create an access vector list with the source type 'foo_t',
        target type 'bar_t', object class 'file', and permissions 'read'
        and 'write'.

        This format is useful for very simple storage to strings or disc
        (see to_list) and for initializing access vectors.
        is+List must contain at least four elements %siiiiN(RtlistRtstrRRRRRRR(RR((RR]s



cCs,|i|i|ig}|i|iƒ|S(sξ
        Convert an access vector to a list.

        Convert an access vector to a list treating the list as positional
        values. See from_list for more information on how an access vector
        is represented in a list.
        N(RRRRtltextendR(RR((Rtto_listrscCs
|iƒS(N(Rt	to_string(R((Rt__str__~scCs&d|i|i|i|iiƒfS(Nsallow %s %s : %s %s;(RRRRRtto_space_str(R((RRscCs4|i|ijot|i|iƒSn|i|ijot|i|iƒSn|i|ijot|i|iƒSnt|iƒt|iƒjo#tt|iƒt|iƒƒSnt|iƒ}|i
ƒt|iƒ}|i
ƒx;t||ƒD]*\}}||jot||ƒSqqWdS(Ni(RRtothertcmpRRRRRtxtsorttytziptpatpb(RRR%R&R#R!((Rt__cmp__…s"#


(
t__name__t
__module__t__doc__R
RRRRRR'(((RR	5s				cCs€t|tƒo|gSng}x||iD]q}xh|iD]]}xT|iD]I}tƒ}||_||_||_	|iiƒ|_|i
|ƒqKWq;Wq+W|S(sQConvert an avrule into a list of access vectors.

    AccessVectors and AVRules are similary, but differ in that
    an AVRule can more than one source type, target type, and
    object class. This function expands a single avrule into a
    list of one or more AccessVectors representing the access
    defined in the AVRule.

    
    N(t
isinstancetavruleR	tat	src_typesRt	tgt_typesRtobj_classesRtaccessRtcopytappend(R,R-RR1RR((Rtavrule_to_access_vectors—s"



				tAccessVectorSetcBsStZdZd„Zd„Zd„Zd„Zd„Zed„Z	ed„Z
RS(s/A non-overlapping set of access vectors.

    An AccessVectorSet is designed to store one or more access vectors
    that are non-overlapping. Access can be added to the set
    incrementally and access vectors will be added or merged as
    necessary.  For example, adding the following access vectors using
    add_av:
       allow $1 etc_t : read;
       allow $1 etc_t : write;
       allow $1 var_log_t : read;
    Would result in an access vector set with the access vectors:
       allow $1 etc_t : { read write};
       allow $1 var_log_t : read;
    cCsh|_d|_dS(s)Initialize an access vector set.
        N(RtsrcR
tinfo_dir(R((RRΏs	ccsPxI|iiƒD]8}x/|iƒD]!}x|iƒD]
}|Vq6Wq#WqWdS(s9Iterate over all of the unique access vectors in the set.N(RR6tvaluesttgtstobjstav(RR9R:R;((Rt__iter__Θs

cCsKd}x>|iiƒD]-}x$|iƒD]}|t|ƒ7}q)WqW|S(s5Return the number of unique access vectors in the set.

        Because of the inernal representation of the access vector set,
        __len__ is not a constant time operation. Worst case is O(N)
        where N is the number of unique access vectors, but the common
        case is probably better.
        iN(RRR6R8R9R:R(RR9RR:((Rt__len__Οs
cCs.g}x!|D]}|i|iƒƒq
W|S(sbReturn the unique access vectors in the set as a list.

        The format of the returned list is a set of nested lists,
        each access vector represented by a list. This format is
        designed to be simply  serializable to a file.

        For example, consider an access vector set with the following
        access vectors:
          allow $1 user_t : file read;
          allow $1 etc_t : file { read write};
        to_list would return the following:
          [[$1, user_t, file, read]
           [$1, etc_t, file, read, write]]

        See AccessVector.to_list for more information.
        N(RRR;R3R(RRR;((RRέscCs(x!|D]}|it|ƒƒqWdS(sAdd access vectors stored in a list.

        See to list for more information on the list format that this
        method accepts.

        This will add all of the access from the list. Any existing
        access vectors in the set will be retained.
        N(RR;Rtadd_avR	(RRR;((RRτsc	Cs’|ii|hƒ}|i|hƒ}|i|ƒo||}n/t
ƒ}||_||_||_|||<|ii|ƒ|o|ii|ƒndS(s)Add an access vector to the set.
        N(RR6t
setdefaultRttgtRtclsthas_keyRR1R	Rtupdatet	audit_msgRR3(	RRRRRRDR@R1RA((Rtadds				
cCs&|i|i|i|i|iƒdS(s Add an access vector to the set.N(RRER;RRRR(RR;RD((RR>s(R(R)R*RR<R=RRR
RER>(((RR5°s						cCsAtiƒ}x.|D]&}|i|iƒ|i|iƒqW|S(N(RRttypestavsR;RERR(RGR;RF((Rtavs_extract_typesscCshh}x[|D]S}|i|iƒo||i}ntiƒ}|||i<|i|iƒq
W|S(N(	RRGR;RBRtsRRRC(RGRRIR;((Rtavs_extract_obj_perms s
(R*RRR	R4R5RHRJ(RJRR5R4RRHR	((Rt? s		b	h	

Anon7 - 2021