Warning: Cannot modify header information - headers already sent by (output started at /var/www/jonas-eriksen.dk/pic/private/index.php:1) in /var/www/jonas-eriksen.dk/pic/private/index.php on line 215
3
KlfU @ s d dl Z d dlZddlmZ ddlmZ ddlmZ dd Zdd Zd
d ZG dd
d
Z G dd de Z
G dd de Zd dlj
Z
i ZG dd de ZG dd de ZG dd de ZG dd de ZG dd dZG dd dZG dd dZdS ) N ) refpolicy)access)utilc C s ddl } ddl}tdd}t|j j d }|j |j|j | }|jd|}|jd|}| j ddd d
||g| j
dj d }tj
rtj|}|S )a
Obtain all of the avc and policy load messages from the audit
log. This function uses ausearch and requires that the current
process have sufficient rights to run ausearch.
Returns:
string contain all of the audit messages returned by ausearch.
r Nz/proc/uptimerz%xz%Xz/sbin/ausearchz-mz5AVC,USER_AVC,MAC_POLICY_LOAD,DAEMON_START,SELINUX_ERRz-ts)stdout)
subprocesstimeopenfloatreadsplitcloseZ localtimeZstrftimePopenPIPEcommunicater PY3decode_input)r r fdZoffsZbootdateZboottimeoutput r /usr/lib/python3.6/audit.pyget_audit_boot_msgs s
r c C s: ddl } | jdddg| jdj d }tjr6tj|}|S )a
Obtain all of the avc and policy load messages from the audit
log. This function uses ausearch and requires that the current
process have sufficient rights to run ausearch.
Returns:
string contain all of the audit messages returned by ausearch.
r Nz/sbin/ausearchz-mz5AVC,USER_AVC,MAC_POLICY_LOAD,DAEMON_START,SELINUX_ERR)r )r r r r r r r )r r r r r get_audit_msgs2 s
r c C s6 ddl } | jdg| jdj d }tjr2tj|}|S )zObtain all of the avc and policy load messages from /bin/dmesg.
Returns:
string contain all of the audit messages returned by dmesg.
r Nz
/bin/dmesg)r )r r r r r r r )r r r r r get_dmesg_msgsA s
r c @ s e Zd ZdZdd Zdd ZdS )AuditMessagezBase class for all objects representing audit messages.
AuditMessage is a base class for all audit messages and only
provides storage for the raw message (as a string) and a
parsing function that does nothing.
c C s || _ d| _d S )N )messageheader)selfr r r r __init__W s zAuditMessage.__init__c C s^ xX|D ]P}|j d}t|dkr<|dd dkr|| _dS q|d dkr|d | _dS qW dS ) zParse a string that has been split into records by space into
an audit message.
This method should be overridden by subclasses. Error reporting
should be done by raise ValueError exceptions.
= N zaudit(r msgr )r
lenr )r recsr% fieldsr r r from_split_string[ s
zAuditMessage.from_split_stringN)__name__
__module____qualname____doc__r! r) r r r r r P s r c @ s e Zd ZdZdd ZdS )InvalidMessagezClass representing invalid audit messages. This is used to differentiate
between audit messages that aren't recognized (that should return None from
the audit message parser) and a message that is recognized but is malformed
in some way.
c C s t j| | d S )N)r r! )r r r r r r! v s zInvalidMessage.__init__N)r* r+ r, r- r! r r r r r. p s r. c @ s e Zd ZdZdd Zdd ZdS )PathMessagez!Class representing a path messagec C s t j| | d| _d S )Nr )r r! path)r r r r r r! { s zPathMessage.__init__c C sX t j| | xF|D ]>}|jd}t|dkr.q|d dkr|d dd | _d S qW d S )Nr" r# r r0 r )r r) r
r&