mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 18:27:04 +03:00
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
This commit is contained in:
parent
e65476622d
commit
e86b3761c4
@ -879,11 +879,9 @@ static void mount_enter_unmounting(Mount *m) {
|
|||||||
m->control_command_id = MOUNT_EXEC_UNMOUNT;
|
m->control_command_id = MOUNT_EXEC_UNMOUNT;
|
||||||
m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
|
m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
|
||||||
|
|
||||||
r = exec_command_set(m->control_command,
|
r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
|
||||||
"/bin/umount",
|
if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
|
||||||
"-n",
|
r = exec_command_append(m->control_command, "-n", NULL);
|
||||||
m->where,
|
|
||||||
NULL);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -926,17 +924,18 @@ static void mount_enter_mounting(Mount *m) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (m->from_fragment)
|
if (m->from_fragment) {
|
||||||
r = exec_command_set(
|
r = exec_command_set(m->control_command, "/bin/mount",
|
||||||
m->control_command,
|
m->parameters_fragment.what, m->where, NULL);
|
||||||
"/bin/mount",
|
if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
|
||||||
m->sloppy_options ? "-ns" : "-n",
|
r = exec_command_append(m->control_command, "-n", NULL);
|
||||||
m->parameters_fragment.what,
|
if (r >= 0 && m->sloppy_options)
|
||||||
m->where,
|
r = exec_command_append(m->control_command, "-s", NULL);
|
||||||
"-t", m->parameters_fragment.fstype ? m->parameters_fragment.fstype : "auto",
|
if (r >= 0 && m->parameters_fragment.fstype)
|
||||||
m->parameters_fragment.options ? "-o" : NULL, m->parameters_fragment.options,
|
r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
|
||||||
NULL);
|
if (r >= 0 && m->parameters_fragment.options)
|
||||||
else
|
r = exec_command_append(m->control_command, "-o", m->parameters_fragment.options, NULL);
|
||||||
|
} else
|
||||||
r = -ENOENT;
|
r = -ENOENT;
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -975,15 +974,15 @@ static void mount_enter_remounting(Mount *m) {
|
|||||||
else
|
else
|
||||||
o = "remount";
|
o = "remount";
|
||||||
|
|
||||||
r = exec_command_set(
|
r = exec_command_set(m->control_command, "/bin/mount",
|
||||||
m->control_command,
|
m->parameters_fragment.what, m->where,
|
||||||
"/bin/mount",
|
"-o", o, NULL);
|
||||||
m->sloppy_options ? "-ns" : "-n",
|
if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
|
||||||
m->parameters_fragment.what,
|
r = exec_command_append(m->control_command, "-n", NULL);
|
||||||
m->where,
|
if (r >= 0 && m->sloppy_options)
|
||||||
"-t", m->parameters_fragment.fstype ? m->parameters_fragment.fstype : "auto",
|
r = exec_command_append(m->control_command, "-s", NULL);
|
||||||
"-o", o,
|
if (r >= 0 && m->parameters_fragment.fstype)
|
||||||
NULL);
|
r = exec_command_append(m->control_command, "-t", m->parameters_fragment.fstype, NULL);
|
||||||
} else
|
} else
|
||||||
r = -ENOENT;
|
r = -ENOENT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user