diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-02-07 13:08:56 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-08 17:20:35 +0100 |
commit | d5cc4be28f9d678dab441e7cf332fedf47917ea5 (patch) | |
tree | 4aa1be6ea8a8f335da97c5c57491d0c1aa7a301d /src/fstab-generator | |
parent | b53ede699cdc5233041a22591f18863fb3fe2672 (diff) |
fstab-generator: Options= applies specifier expansion
Let's document that this is the case, and properly escape % when we
generate Options= in the generator.
Fixes: #5086
Diffstat (limited to 'src/fstab-generator')
-rw-r--r-- | src/fstab-generator/fstab-generator.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 3c601a63e2..00c6b2d37b 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -57,6 +57,23 @@ static char *arg_usr_fstype = NULL; static char *arg_usr_options = NULL; static VolatileMode arg_volatile_mode = _VOLATILE_MODE_INVALID; +static int write_options(FILE *f, const char *options) { + _cleanup_free_ char *o = NULL; + + if (isempty(options)) + return 0; + + if (streq(options, "defaults")) + return 0; + + o = strreplace(options, "%", "%%"); + if (!o) + return log_oom(); + + fprintf(f, "Options=%s\n", o); + return 1; +} + static int add_swap( const char *what, struct mntent *me, @@ -105,8 +122,9 @@ static int add_swap( "What=%s\n", what); - if (!isempty(me->mnt_opts) && !streq(me->mnt_opts, "defaults")) - fprintf(f, "Options=%s\n", me->mnt_opts); + r = write_options(f, me->mnt_opts); + if (r < 0) + return r; r = fflush_and_check(f); if (r < 0) @@ -347,8 +365,9 @@ static int add_mount( if (r < 0) return r; - if (!isempty(filtered) && !streq(filtered, "defaults")) - fprintf(f, "Options=%s\n", filtered); + r = write_options(f, filtered); + if (r < 0) + return r; r = fflush_and_check(f); if (r < 0) |