1 |
commit: 96374d9bff64bcee64340f6572cca9f1cc3f696d |
2 |
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jun 8 15:08:54 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 7 15:31:07 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=96374d9b |
7 |
|
8 |
libsandbox: adjust hard-coded denial for /var/log/sandbox |
9 |
|
10 |
Move this hack after the read checks, but before the write checks. This |
11 |
allows processes to read the log directory, but not write to it. |
12 |
|
13 |
This is helpful in case a process does something like this: |
14 |
|
15 |
find /var/log -name system.journal |
16 |
|
17 |
Bug: https://bugs.gentoo.org/794949 |
18 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
19 |
Closes: https://bugs.gentoo.org/794949 |
20 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
21 |
|
22 |
libsandbox/libsandbox.c | 18 +++++++++--------- |
23 |
1 file changed, 9 insertions(+), 9 deletions(-) |
24 |
|
25 |
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c |
26 |
index 3d55dd7..758c0dc 100644 |
27 |
--- a/libsandbox/libsandbox.c |
28 |
+++ b/libsandbox/libsandbox.c |
29 |
@@ -714,15 +714,6 @@ static int check_access(sbcontext_t *sbcontext, int sb_nr, const char *func, |
30 |
goto out; |
31 |
} |
32 |
|
33 |
- /* Hardcode denying write to the whole log dir. While this is a |
34 |
- * parial match and so rejects paths that also start with this |
35 |
- * string, that isn't going to happen in real life so live with |
36 |
- * it. We can't append a slash to this path either as that would |
37 |
- * allow people to open the dir itself for writing. |
38 |
- */ |
39 |
- if (!strncmp(resolv_path, SANDBOX_LOG_LOCATION, strlen(SANDBOX_LOG_LOCATION))) |
40 |
- goto out; |
41 |
- |
42 |
if (sbcontext->read_prefixes && |
43 |
(sb_nr == SB_NR_ACCESS_RD || |
44 |
sb_nr == SB_NR_OPEN_RD || |
45 |
@@ -754,6 +745,15 @@ static int check_access(sbcontext_t *sbcontext, int sb_nr, const char *func, |
46 |
} |
47 |
} |
48 |
|
49 |
+ /* Hardcode denying write to the whole log dir. While this is a |
50 |
+ * parial match and so rejects paths that also start with this |
51 |
+ * string, that isn't going to happen in real life so live with |
52 |
+ * it. We can't append a slash to this path either as that would |
53 |
+ * allow people to open the dir itself for writing. |
54 |
+ */ |
55 |
+ if (!strncmp(resolv_path, SANDBOX_LOG_LOCATION, strlen(SANDBOX_LOG_LOCATION))) |
56 |
+ goto out; |
57 |
+ |
58 |
if (sb_nr == SB_NR_ACCESS_WR || |
59 |
sb_nr == SB_NR_CHMOD || |
60 |
sb_nr == SB_NR_CHOWN || |