|
|
36e8a3 |
From f58c5ced373c2532b5cc44ba2e0c3a28b41472f2 Mon Sep 17 00:00:00 2001
|
|
|
36e8a3 |
From: Jan Synacek <jsynacek@redhat.com>
|
|
|
36e8a3 |
Date: Tue, 15 May 2018 09:24:20 +0200
|
|
|
36e8a3 |
Subject: [PATCH] Avoid /tmp being mounted as tmpfs without the user's will
|
|
|
36e8a3 |
|
|
|
36e8a3 |
Ensure PrivateTmp doesn't require tmpfs through tmp.mount, but rather
|
|
|
36e8a3 |
adds an After relationship.
|
|
|
36e8a3 |
|
|
|
36e8a3 |
rhel-only
|
|
|
36e8a3 |
|
|
|
36e8a3 |
Resolves: #1578772
|
|
|
36e8a3 |
---
|
|
|
36e8a3 |
src/core/unit.c | 12 ++++++------
|
|
|
36e8a3 |
units/basic.target | 3 ++-
|
|
|
36e8a3 |
2 files changed, 8 insertions(+), 7 deletions(-)
|
|
|
36e8a3 |
|
|
|
36e8a3 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
36e8a3 |
index 113205bf2..c9f756c9c 100644
|
|
|
36e8a3 |
--- a/src/core/unit.c
|
|
|
36e8a3 |
+++ b/src/core/unit.c
|
|
|
36e8a3 |
@@ -982,13 +982,13 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
|
|
|
36e8a3 |
return 0;
|
|
|
36e8a3 |
|
|
|
36e8a3 |
if (c->private_tmp) {
|
|
|
36e8a3 |
- const char *p;
|
|
|
36e8a3 |
+ r = unit_add_dependency_by_name(u, UNIT_AFTER, "tmp.mount", NULL, true, UNIT_DEPENDENCY_FILE);
|
|
|
36e8a3 |
+ if (r < 0)
|
|
|
36e8a3 |
+ return r;
|
|
|
36e8a3 |
|
|
|
36e8a3 |
- FOREACH_STRING(p, "/tmp", "/var/tmp") {
|
|
|
36e8a3 |
- r = unit_require_mounts_for(u, p, UNIT_DEPENDENCY_FILE);
|
|
|
36e8a3 |
- if (r < 0)
|
|
|
36e8a3 |
- return r;
|
|
|
36e8a3 |
- }
|
|
|
36e8a3 |
+ r = unit_require_mounts_for(u, "/var/tmp", UNIT_DEPENDENCY_FILE);
|
|
|
36e8a3 |
+ if (r < 0)
|
|
|
36e8a3 |
+ return r;
|
|
|
36e8a3 |
|
|
|
36e8a3 |
r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_TMPFILES_SETUP_SERVICE, NULL, true, UNIT_DEPENDENCY_FILE);
|
|
|
36e8a3 |
if (r < 0)
|
|
|
36e8a3 |
diff --git a/units/basic.target b/units/basic.target
|
|
|
36e8a3 |
index 4f4429224..8fc7c73ef 100644
|
|
|
36e8a3 |
--- a/units/basic.target
|
|
|
36e8a3 |
+++ b/units/basic.target
|
|
|
36e8a3 |
@@ -19,4 +19,5 @@ After=sysinit.target sockets.target paths.target slices.target tmp.mount
|
|
|
36e8a3 |
# require /var and /var/tmp, but only add a Wants= type dependency on /tmp, as
|
|
|
36e8a3 |
# we support that unit being masked, and this should not be considered an error.
|
|
|
36e8a3 |
RequiresMountsFor=/var /var/tmp
|
|
|
36e8a3 |
-Wants=tmp.mount
|
|
|
36e8a3 |
+# RHEL-only: Disable /tmp on tmpfs.
|
|
|
36e8a3 |
+#Wants=tmp.mount
|