1 |
commit: f6a604430f3cc0948d3d7fc97066ad65ba62e5c4 |
2 |
Author: Guido Trentalancia <guido <AT> trentalancia <DOT> net> |
3 |
AuthorDate: Wed Dec 28 19:43:23 2016 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 1 16:31:26 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=f6a60443 |
7 |
|
8 |
xserver: introduce new fc and interface to manage X session logs |
9 |
|
10 |
The following patch (split in two parts, one for base and |
11 |
another one for contrib) introduces a new file context for |
12 |
the X session log files and two new interface to manage |
13 |
them (instead of allowing to manage the whole user home |
14 |
content files). |
15 |
|
16 |
It is required after the recent confinement of graphical |
17 |
desktop components (e.g. wm, xscreensaver). |
18 |
|
19 |
The second version of the patch correctly uses file type |
20 |
transitions and uses more tight permissions. |
21 |
|
22 |
The third version simply moves some interface calls. |
23 |
|
24 |
The fourth version introduces the new template for |
25 |
username-dependent file contexts. |
26 |
|
27 |
The fifth version moves other interface calls thanks to |
28 |
further revisions from Christopher PeBenito (the corresponding |
29 |
contrib policy part remains unchanged at version 4). |
30 |
|
31 |
This sixth version, adds the missing diff relative to the |
32 |
xserver.te policy file to declare the new xsession_log_t type. |
33 |
|
34 |
The corresponding base policy patch is at version 4. |
35 |
|
36 |
Signed-off-by: Guido Trentalancia <guido <AT> trentalancia.net> |
37 |
|
38 |
policy/modules/services/xserver.fc | 2 ++ |
39 |
policy/modules/services/xserver.if | 65 ++++++++++++++++++++++++++++++++++++-- |
40 |
policy/modules/services/xserver.te | 3 ++ |
41 |
3 files changed, 68 insertions(+), 2 deletions(-) |
42 |
|
43 |
diff --git a/policy/modules/services/xserver.fc b/policy/modules/services/xserver.fc |
44 |
index 5b218c6..389b74f 100644 |
45 |
--- a/policy/modules/services/xserver.fc |
46 |
+++ b/policy/modules/services/xserver.fc |
47 |
@@ -10,6 +10,7 @@ HOME_DIR/\.fontconfig(/.*)? gen_context(system_u:object_r:user_fonts_cache_t,s0) |
48 |
HOME_DIR/\.ICEauthority.* -- gen_context(system_u:object_r:iceauth_home_t,s0) |
49 |
HOME_DIR/\.serverauth.* -- gen_context(system_u:object_r:xauth_home_t,s0) |
50 |
HOME_DIR/\.xauth.* -- gen_context(system_u:object_r:xauth_home_t,s0) |
51 |
+HOME_DIR/\.xsession-errors -- gen_context(system_u:object_r:xsession_log_t,s0) |
52 |
HOME_DIR/\.Xauthority.* -- gen_context(system_u:object_r:xauth_home_t,s0) |
53 |
|
54 |
# |
55 |
@@ -55,6 +56,7 @@ HOME_DIR/\.Xauthority.* -- gen_context(system_u:object_r:xauth_home_t,s0) |
56 |
/tmp/\.X0-lock -- gen_context(system_u:object_r:xserver_tmp_t,s0) |
57 |
/tmp/\.X11-unix -d gen_context(system_u:object_r:xdm_tmp_t,s0) |
58 |
/tmp/\.X11-unix/.* -s <<none>> |
59 |
+/tmp/xses-%{USERNAME} -- gen_context(system_u:object_r:xsession_log_t,s0) |
60 |
|
61 |
# |
62 |
# /usr |
63 |
|
64 |
diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if |
65 |
index c1d41b5..59d5821 100644 |
66 |
--- a/policy/modules/services/xserver.if |
67 |
+++ b/policy/modules/services/xserver.if |
68 |
@@ -107,6 +107,10 @@ interface(`xserver_restricted_role',` |
69 |
# Needed for escd, remove if we get escd policy |
70 |
xserver_manage_xdm_tmp_files($2) |
71 |
|
72 |
+ # for the .xsession-errors log file |
73 |
+ xserver_user_home_dir_filetrans_user_xsession_log($2) |
74 |
+ xserver_manage_xsession_log($2) |
75 |
+ |
76 |
# Client write xserver shm |
77 |
tunable_policy(`allow_write_xshm',` |
78 |
allow $2 xserver_t:shm rw_shm_perms; |
79 |
@@ -307,7 +311,7 @@ interface(`xserver_user_client',` |
80 |
|
81 |
userdom_search_user_home_dirs($1) |
82 |
# for .xsession-errors |
83 |
- userdom_dontaudit_write_user_home_content_files($1) |
84 |
+ xserver_rw_xsession_log($1) |
85 |
|
86 |
xserver_ro_session($1,$2) |
87 |
xserver_use_user_fonts($1) |
88 |
@@ -469,7 +473,7 @@ template(`xserver_user_x_domain_template',` |
89 |
|
90 |
userdom_search_user_home_dirs($2) |
91 |
# for .xsession-errors |
92 |
- userdom_dontaudit_write_user_home_content_files($2) |
93 |
+ xserver_rw_xsession_log($2) |
94 |
|
95 |
xserver_ro_session($2,$3) |
96 |
xserver_use_user_fonts($2) |
97 |
@@ -566,6 +570,25 @@ interface(`xserver_user_home_dir_filetrans_user_xauth',` |
98 |
|
99 |
######################################## |
100 |
## <summary> |
101 |
+## Create a .xsession-errors log |
102 |
+## file in the user home directory. |
103 |
+## </summary> |
104 |
+## <param name="domain"> |
105 |
+## <summary> |
106 |
+## Domain allowed access. |
107 |
+## </summary> |
108 |
+## </param> |
109 |
+# |
110 |
+interface(`xserver_user_home_dir_filetrans_user_xsession_log',` |
111 |
+ gen_require(` |
112 |
+ type xsession_log_t; |
113 |
+ ') |
114 |
+ |
115 |
+ userdom_user_home_dir_filetrans($1, xsession_log_t, file, ".xsession-errors") |
116 |
+') |
117 |
+ |
118 |
+######################################## |
119 |
+## <summary> |
120 |
## Read all users fonts, user font configurations, |
121 |
## and manage all users font caches. |
122 |
## </summary> |
123 |
@@ -1001,6 +1024,44 @@ interface(`xserver_xsession_spec_domtrans',` |
124 |
|
125 |
######################################## |
126 |
## <summary> |
127 |
+## Read and write xsession log |
128 |
+## files such as .xsession-errors. |
129 |
+## </summary> |
130 |
+## <param name="domain"> |
131 |
+## <summary> |
132 |
+## Domain allowed access. |
133 |
+## </summary> |
134 |
+## </param> |
135 |
+# |
136 |
+interface(`xserver_rw_xsession_log',` |
137 |
+ gen_require(` |
138 |
+ type xsession_log_t; |
139 |
+ ') |
140 |
+ |
141 |
+ allow $1 xsession_log_t:file rw_file_perms; |
142 |
+') |
143 |
+ |
144 |
+######################################## |
145 |
+## <summary> |
146 |
+## Manage xsession log files such |
147 |
+## as .xsession-errors. |
148 |
+## </summary> |
149 |
+## <param name="domain"> |
150 |
+## <summary> |
151 |
+## Domain allowed access. |
152 |
+## </summary> |
153 |
+## </param> |
154 |
+# |
155 |
+interface(`xserver_manage_xsession_log',` |
156 |
+ gen_require(` |
157 |
+ type xsession_log_t; |
158 |
+ ') |
159 |
+ |
160 |
+ allow $1 xsession_log_t:file manage_file_perms; |
161 |
+') |
162 |
+ |
163 |
+######################################## |
164 |
+## <summary> |
165 |
## Get the attributes of X server logs. |
166 |
## </summary> |
167 |
## <param name="domain"> |
168 |
|
169 |
diff --git a/policy/modules/services/xserver.te b/policy/modules/services/xserver.te |
170 |
index ba96a78..1956ddb 100644 |
171 |
--- a/policy/modules/services/xserver.te |
172 |
+++ b/policy/modules/services/xserver.te |
173 |
@@ -210,6 +210,9 @@ userdom_user_tmpfs_file(xserver_tmpfs_t) |
174 |
type xsession_exec_t; |
175 |
corecmd_executable_file(xsession_exec_t) |
176 |
|
177 |
+type xsession_log_t; |
178 |
+userdom_user_home_content(xsession_log_t) |
179 |
+ |
180 |
# Type for the X server log file. |
181 |
type xserver_log_t; |
182 |
logging_log_file(xserver_log_t) |