summaryrefslogtreecommitdiff
path: root/src/home/homework-mount.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-22 16:01:42 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-22 16:01:42 +0200
commit498abadb8c91c708ace9f05b816678893f7ac31d (patch)
tree669c58b5b8a1817b0d5615e8b87dc03340ca903a /src/home/homework-mount.c
parent197aec7e79d2f61c50b1684317c11d36968a83f2 (diff)
downloadsystemd-498abadb8c91c708ace9f05b816678893f7ac31d.tar.gz
homework: add macro for "/run/systemd/user-home-mount"
We use this work dir a various places, and it's easy to mistype, hence let the compiler detect this for us, and introduce a macro for it. No code changes, just some search/replace.
Diffstat (limited to 'src/home/homework-mount.c')
-rw-r--r--src/home/homework-mount.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/home/homework-mount.c b/src/home/homework-mount.c
index da4f14e08d..89ae58e25f 100644
--- a/src/home/homework-mount.c
+++ b/src/home/homework-mount.c
@@ -5,6 +5,7 @@
#include "alloc-util.h"
#include "homework-mount.h"
+#include "homework.h"
#include "mkdir.h"
#include "mount-util.h"
#include "path-util.h"
@@ -38,7 +39,7 @@ int home_mount_node(const char *node, const char *fstype, bool discard, unsigned
} else
options = discard_option;
- r = mount_nofollow_verbose(LOG_ERR, node, "/run/systemd/user-home-mount", fstype, flags|MS_RELATIME, strempty(options));
+ r = mount_nofollow_verbose(LOG_ERR, node, HOME_RUNTIME_WORK_DIR, fstype, flags|MS_RELATIME, strempty(options));
if (r < 0)
return r;
@@ -52,11 +53,13 @@ int home_unshare_and_mount(const char *node, const char *fstype, bool discard, u
if (unshare(CLONE_NEWNS) < 0)
return log_error_errno(errno, "Couldn't unshare file system namespace: %m");
+ assert(path_startswith(HOME_RUNTIME_WORK_DIR, "/run"));
+
r = mount_nofollow_verbose(LOG_ERR, "/run", "/run", NULL, MS_SLAVE|MS_REC, NULL); /* Mark /run as MS_SLAVE in our new namespace */
if (r < 0)
return r;
- (void) mkdir_p("/run/systemd/user-home-mount", 0700);
+ (void) mkdir_p(HOME_RUNTIME_WORK_DIR, 0700);
if (node)
return home_mount_node(node, fstype, discard, flags);
@@ -74,13 +77,13 @@ int home_move_mount(const char *user_name_and_realm, const char *target) {
/* If user_name_and_realm is set, then we'll mount a subdir of the source mount into the host. If
* it's NULL we'll move the mount itself */
if (user_name_and_realm) {
- subdir = path_join("/run/systemd/user-home-mount/", user_name_and_realm);
+ subdir = path_join(HOME_RUNTIME_WORK_DIR, user_name_and_realm);
if (!subdir)
return log_oom();
d = subdir;
} else
- d = "/run/systemd/user-home-mount/";
+ d = HOME_RUNTIME_WORK_DIR;
(void) mkdir_p(target, 0700);
@@ -88,7 +91,7 @@ int home_move_mount(const char *user_name_and_realm, const char *target) {
if (r < 0)
return r;
- r = umount_verbose(LOG_ERR, "/run/systemd/user-home-mount", UMOUNT_NOFOLLOW);
+ r = umount_verbose(LOG_ERR, HOME_RUNTIME_WORK_DIR, UMOUNT_NOFOLLOW);
if (r < 0)
return r;