summaryrefslogtreecommitdiff
path: root/src/core/mount.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-01 14:25:18 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-01 14:39:21 -0500
commite86b3761c42babc190a1e1b6d4288dfa7a4208b8 (patch)
tree6063a66fd79376603d903fbd804f6a8f992c3c58 /src/core/mount.c
parente65476622db43f7b9c413009072fc9603b8d6ba4 (diff)
mount: do not use -n when running in --user mode
-n is only allowed for root. /etc/mtab is nowadays almost always a link to /proc/, so in practice this does not really matter too much, but should allow .mount units to work in --user mode. https://bugs.freedesktop.org/show_bug.cgi?id=87602
Diffstat (limited to 'src/core/mount.c')
-rw-r--r--src/core/mount.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index 110eafdc49..13c634807b 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -879,11 +879,9 @@ static void mount_enter_unmounting(Mount *m) {
m->control_command_id = MOUNT_EXEC_UNMOUNT;
m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
- r = exec_command_set(m->control_command,
- "/bin/umount",
- "-n",
- m->where,
- NULL);
+ r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
+ if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
+ r = exec_command_append(m->control_command, "-n", NULL);
if (r < 0)
goto fail;
@@ -926,17 +924,18 @@ static void mount_enter_mounting(Mount *m) {
if (r < 0)
goto fail;
- if (m->from_fragment)
- r = exec_command_set(
- m->control_command,
- "/bin/mount",
- m->sloppy_options ? "-ns" : "-n",
- m->parameters_fragment.what,
- m->where,
- "-t", m->parameters_fragment.fstype ? m->parameters_fragment.fstype : "auto",
- m->parameters_fragment.options ? "-o" : NULL, m->parameters_fragment.options,
- NULL);
- else
+ if (m->from_fragment) {
+ r = exec_command_set(m->control_command, "/bin/mount",
+ m->parameters_fragment.what, m->where, NULL);
+ if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
+ r = exec_command_append(m->control_command, "-n", NULL);
+ if (r >= 0 && m->sloppy_options)
+ r = exec_command_append(m->control_command, "-s", NULL);
+ if (r >= 0 && m->parameters_fragment.fstype)
+ r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
+ if (r >= 0 && m->parameters_fragment.options)
+ r = exec_command_append(m->control_command, "-o", m->parameters_fragment.options, NULL);
+ } else
r = -ENOENT;
if (r < 0)
@@ -975,15 +974,15 @@ static void mount_enter_remounting(Mount *m) {
else
o = "remount";
- r = exec_command_set(
- m->control_command,
- "/bin/mount",
- m->sloppy_options ? "-ns" : "-n",
- m->parameters_fragment.what,
- m->where,
- "-t", m->parameters_fragment.fstype ? m->parameters_fragment.fstype : "auto",
- "-o", o,
- NULL);
+ r = exec_command_set(m->control_command, "/bin/mount",
+ m->parameters_fragment.what, m->where,
+ "-o", o, NULL);
+ if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
+ r = exec_command_append(m->control_command, "-n", NULL);
+ if (r >= 0 && m->sloppy_options)
+ r = exec_command_append(m->control_command, "-s", NULL);
+ if (r >= 0 && m->parameters_fragment.fstype)
+ r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
} else
r = -ENOENT;