blob: 6bfee5a33770f1646a81dc1052c87658097b8ad2 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <config.h>
#include <glib.h>
#include "selinux.h"
#include "procman.h"
#include "util.h"
static int (*getpidcon)(pid_t, char**);
static void (*freecon)(char*);
static int (*is_selinux_enabled)(void);
static gboolean has_selinux;
static gboolean load_selinux(void)
{
return load_symbols("libselinux.so.1",
"getpidcon", &getpidcon,
"freecon", &freecon,
"is_selinux_enabled", &is_selinux_enabled,
NULL);
}
void
get_process_selinux_context (ProcInfo *info)
{
char *con;
if (has_selinux && !getpidcon (info->pid, &con)) {
info->security_context = g_strdup (con);
freecon (con);
}
}
gboolean
can_show_security_context_column (void)
{
if (!(has_selinux = load_selinux()))
return FALSE;
switch (is_selinux_enabled()) {
case 1:
/* We're running on an SELinux kernel */
return TRUE;
case -1:
/* Error; hide the security context column */
case 0:
/* We're not running on an SELinux kernel:
hide the security context column */
default:
g_warning("SELinux was found but is not enabled.\n");
return FALSE;
}
}
|