-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
yum-plugin-rkhunter.py
executable file
·36 lines (32 loc) · 1.07 KB
/
yum-plugin-rkhunter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import re
import os
import os.path
import yum
from yum.plugins import TYPE_INTERACTIVE
requires_api_version = '2.1'
plugin_type = (TYPE_INTERACTIVE,)
active = False
def init_hook(conduit):
global active
active = False
exe = '/usr/bin/rkhunter'
try:
content = open('/etc/rkhunter.conf').read()
if not re.match('^DISABLE_TESTS=.*(hashes.*attributes|attributes.*hashes|properties)', content) or re.match('^ENABLE_TESTS=.*(hashes|attributes|properties)', content):
active = True
except:
pass
if active and os.path.isfile(exe):
conduit.info(2, 'running rkhunter check')
command = '%s --check --report-warnings-only' % exe
if os.system(command) != 0:
raise Exception('rkhunter POSITIVE')
else:
conduit.info(2, 'rkhunter OK')
def posttrans_hook(conduit):
global active
exe = '/usr/bin/rkhunter'
if active and os.path.isfile(exe):
conduit.info(2, 'running rkhunter --propupd')
command = '%s --propupd --pkgmgr RPM --nolog ' % exe
os.system(command)