Gentoo Archives: gentoo-hardened

From: Sven Vermeulen <swift@g.o>
To: gentoo-hardened@l.g.o
Subject: Re: [gentoo-hardened] Can't get fully functional (kde) desktop with SELinux
Date: Tue, 28 Aug 2012 18:02:29
Message-Id: 20120828172711.GB11250@gentoo.org
In Reply to: Re: [gentoo-hardened] Can't get fully functional (kde) desktop with SELinux by Paolo Barile
1 On Mon, Aug 27, 2012 at 08:28:20PM +0200, Paolo Barile wrote:
2 > Well I only had a policykit crash window. But It disappeared when,
3 > following your suggestion, I've made a rule with audit2allow only on
4 > the execute denials. But even with that rule the problems of audio card
5 > and powerdevil weren't solved.
6 [...]
7
8 Okay. I'll take a look at the AVCs earlier and draft up a possible fix for
9 you to try out (you can use audit2allow but I'm not sure yet if the result
10 is correct or not).
11
12 > > What does "semanage login -l" say?
13 > Semanage login -l outputs only:
14 > __default__ unconfined_u
15 > system_u system_u
16 >
17 > Anyway I think that I "solved" this problem (probably it's rather a
18 > workaround) using the context you wrote: "semanage fcontext -a -t
19 > user_home_dir_t /root". In fact the su delay disappeared.
20
21 Looks like we need to declare the root user for unconfined_u anyhow. You
22 might want to run the following to do so:
23
24 ~# semanage login -a -s unconfined_u root
25
26 It seems that genhomedircon (well, it's now part of the semodule command but
27 the genhomedircon command still works) only looks at users with a UID of 500
28 and more. By not explicitly declaring root as an interactive user, the tools
29 just ignore it (and as a result don't generate the proper contexts).
30
31 If you do that, then genhomedircon and then look at the output of the
32 following command again, I hope you get enough output?
33
34 ~# grep root /etc/selinux/*/contexts/files/file_contexts.homedirs
35
36 > There is one more problem. As I wrote in the previous mail two folders
37 > in /run are mislabeled: /run/ConsoleKit and /run/console. For the first,
38 > the mislabeling was solved by using the script for the initramfs users
39 > (of course addin restorecon -R /run). But I couldn't relabel permanently
40 > the second dir. I think it's because it belongs to pam, so perhaps it is
41 > created after a login, but the script runs before it. Am I right?
42
43 Sounds probable. We'll need to figure out what is creating the console
44 directory. From the label (consolekit_var_run_t) I imagine it is something
45 of ConsoleKit.
46
47 I can probably create a named file transition for this. The ConsoleKit stuff
48 is acknowledged already, perhaps the /run/console is solved with something
49 like the following?
50
51 #v+
52 policy_module(localconsolekit, 1.0)
53
54 gen_require(`
55 type pam_var_console_t;
56 type consolekit_t;
57 ')
58
59 files_pid_filetrans(consolekit_t, pam_var_console_t, dir, "console")
60 #v-
61
62 This basically sais that, if a domain "consolekit_t" creates a
63 dir(ectory) with name "console" in a location with label var_run_t ("pid"),
64 then that directory would be labeled "pam_var_console_t" immediately.
65
66 It is possible however that consolekit_t doesn't hold the rights to do so,
67 so you might need to add in:
68
69 #v+
70 create_dirs_pattern(consolekit_t, pam_var_console_t, pam_var_console_t)
71 #v-
72
73 Thanks for your patience on this so far ;-)
74
75 Wkr,
76 Sven Vermeulen

Replies

Subject Author
Re: [gentoo-hardened] Can't get fully functional (kde) desktop with SELinux Paolo Barile <f.p.barile@×××××.com>