Skip to content

Instantly share code, notes, and snippets.

@athoune
Created March 10, 2015 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athoune/0bdb2fcfad82a57cd22a to your computer and use it in GitHub Desktop.
Save athoune/0bdb2fcfad82a57cd22a to your computer and use it in GitHub Desktop.
Reading auditd events while testing apparmor
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect('/var/run/audispd_events')
def read(s):
buff = ""
while True:
buff += s.recv(128)
lines = buff.split("\n")
if len(lines) > 1:
for line in lines[:-1]:
yield line
buff = lines[-1]
for line in read(sock):
chunks = line[:-1].split(' ')
d = dict(a.split('=', 1) for a in chunks)
if 'apparmor' in d:
print d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment