summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 00:27:37 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 23:41:42 -0500
commit17a1c597c5f9be1c25431a764155cd50c0d074b7 (patch)
tree76dc87c40c63d5de2d8a2b2a9a55606d0bb38bf5 /src
parentb9f111b93f9f442f00266f338b14f25ca8685352 (diff)
core/mount: filter out noauto,auto,nofail,fail options
We passed the full option string from fstab to /bin/mount. It would in turn pass the full option string to its helper, if it needed to invoke one. Some helpers would ignore things like "nofail", but others would be confused. We could try to get all helpers to ignore those "meta-options", but it seems better to simply filter them out. In our model, /bin/mount simply has no business in knowing whether the mount was configured as fail or nofail, auto or noauto, in the fstab. If systemd tells invokes a command to mount something, and it fails, it should always return an error. It seems cleaner to filter out the option, since then there's no doubt how the command should behave. https://bugzilla.redhat.com/show_bug.cgi?id=1177823
Diffstat (limited to 'src')
-rw-r--r--src/core/mount.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index a551235f13..9f7c4d20b3 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -917,6 +917,13 @@ static void mount_enter_mounting(Mount *m) {
goto fail;
if (m->from_fragment) {
+ _cleanup_free_ char *opts = NULL;
+
+ r = fstab_filter_options(m->parameters_fragment.options,
+ "nofail\0" "fail\0" "noauto\0" "auto\0", NULL, NULL, &opts);
+ if (r < 0)
+ goto fail;
+
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)
@@ -925,8 +932,8 @@ static void mount_enter_mounting(Mount *m) {
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);
+ if (r >= 0 && !strempty(opts))
+ r = exec_command_append(m->control_command, "-o", opts, NULL);
} else
r = -ENOENT;