Changeset 479
- Timestamp:
- 05/22/08 11:35:54
(8 months ago)
- Author:
- mgoldman
- Message:
Replace sebools and sestatus function stubs with real functions
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r462 |
r479 |
|
| 12 | 12 | LOGPATH = "/var/log/audit/audit.log" |
|---|
| 13 | 13 | |
|---|
| 14 | | def se_bool_to_val(string): |
|---|
| 15 | | """ This function should take an SELinux boolean and return it's current value """ |
|---|
| 16 | | # FIXME: unimplemented. |
|---|
| 17 | | return 0; |
|---|
| | 14 | def sebools(): |
|---|
| | 15 | ''' Returns a hash of all the selinux booleans on a system ''' |
|---|
| | 16 | res = {} |
|---|
| | 17 | for i in listdir("/selinux/booleans"): |
|---|
| | 18 | f = file("/selinux/booleans/" + i, "r") |
|---|
| | 19 | val = f.read(512) |
|---|
| | 20 | res[i] = (val[0] == '1') |
|---|
| | 21 | return res |
|---|
| | 22 | |
|---|
| | 23 | def sestatus(): |
|---|
| | 24 | ''' Return selinux status ''' |
|---|
| | 25 | f = file("/selinux/enforce", "r") |
|---|
| | 26 | val = f.read(512) |
|---|
| | 27 | return (val[0] == '1') |
|---|
| | 28 | |
|---|
| | 29 | def dictsub(a, b): |
|---|
| | 30 | ''' Remove from a all elements where a[k] == b[k] ''' |
|---|
| | 31 | for key in a.keys(): |
|---|
| | 32 | if a.get(key) == b.get(key): |
|---|
| | 33 | del a[key] |
|---|
| | 34 | return a |
|---|
| 18 | 35 | |
|---|
| 19 | 36 | def insert_hash(hash, key, val): |
|---|
| … | … | |
| 26 | 43 | f(accum, seq[0]) |
|---|
| 27 | 44 | fold(f,seq[1:], accum) |
|---|
| 28 | | |
|---|
| 29 | | def selinux_status(): |
|---|
| 30 | | # FIXME: unimplemented. |
|---|
| 31 | | return "enforcing" |
|---|
| 32 | 45 | |
|---|
| 33 | 46 | class ClientD: |
|---|
| … | … | |
| 98 | 111 | # Build response message |
|---|
| 99 | 112 | msg.type = "response" |
|---|
| 100 | | msg.body = selinux_status() |
|---|
| | 113 | msg.body = sestatus() |
|---|
| 101 | 114 | return msg |
|---|
| 102 | 115 | |
|---|
| … | … | |
| 105 | 118 | msg.type = "response" |
|---|
| 106 | 119 | if(msg.body == "ALL"): |
|---|
| 107 | | msg.body = se_all_bools() |
|---|
| 108 | | bools = {} |
|---|
| 109 | | # se_bool_to_val reads the bools, either from the filesystem or the bindings and returns |
|---|
| 110 | | # the status of true or false. |
|---|
| 111 | | fold(lambda x, y: insert_hash(x,y,se_bool_to_val(y)), msg.body, bools) |
|---|
| 112 | | msg.body = bools |
|---|
| | 120 | msg.body = sebools() |
|---|
| | 121 | return msg |
|---|
| | 122 | bools = sebools() |
|---|
| | 123 | res = dict([(k,v) for (k,v) in bools.getitems() if k in msg.body]) |
|---|
| | 124 | msg.body = res |
|---|
| 113 | 125 | return msg |
|---|
| 114 | 126 | |
|---|
Download in other formats:
* Generating other formats may take time.