Changeset 492

Show
Ignore:
Timestamp:
05/27/08 10:38:35 (8 months ago)
Author:
mgoldman
Message:

changed agent to use libselinux

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/trunk-pmd-intproto/agent/agent.py

    r490 r492  
    1010import agent_storage 
    1111import agent_log 
     12import selinux 
    1213 
    1314LOGPATH = "/var/log/audit/audit.log" 
     
    1617        ''' Returns a hash of all the selinux booleans on a system ''' 
    1718        res = {} 
    18         for i in os.listdir("/selinux/booleans"): 
    19                 f = file("/selinux/booleans/" + i, "r") 
    20                 val = f.read(512) 
    21                 res[i] = (val[2] == '1') 
     19        for i in selinux.security_get_boolean_names()[1]: 
     20                # for now only detect changes in pending booleans, so we can 
     21                # change them with impunity and not blow up our testing systems 
     22                # replace this with get_boolean_active() when going live. 
     23                res[i] = selinux.security_get_boolean_pending(i) == 1 
    2224        return res 
    2325 
    2426def sestatus(): 
    2527        ''' Return selinux status ''' 
    26         f = file("/selinux/enforce", "r") 
    27         val = f.read(512) 
    28         return (val[0] == '1') 
     28        return (selinux.security_getenforce() == '1') 
    2929 
    3030def dictsub(a, b):