diff options
author | Karel Zak <kzak@redhat.com> | 2007-03-19 21:02:40 +0100 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2007-03-20 14:30:42 +1100 |
commit | 6facb22402a0bd8cd49be2ed1a0856b24fef42f4 (patch) | |
tree | cf7cb7f96b8e36726f9506270436b25e7395b080 /utils/mount/mount.c | |
parent | b3b111b1bd5fbc678419bf1964b6093045081139 (diff) | |
download | nfs-utils-6facb22402a0bd8cd49be2ed1a0856b24fef42f4.tar.gz nfs-utils-6facb22402a0bd8cd49be2ed1a0856b24fef42f4.tar.xz nfs-utils-6facb22402a0bd8cd49be2ed1a0856b24fef42f4.zip |
Add support for quoted mount options
The patch avoid the collision between commas in security contexts and the
delimiter between mount options.
Try:
mount.nfs foo://mnt/bar /mnt/bar -o context=\"aaa,bbb,ccc\",ro
Signed-off-by: Cory Olmo <colmo@TrustedCS.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils/mount/mount.c')
-rw-r--r-- | utils/mount/mount.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/utils/mount/mount.c b/utils/mount/mount.c index c6644b1..487c0a6 100644 --- a/utils/mount/mount.c +++ b/utils/mount/mount.c @@ -261,18 +261,30 @@ static void parse_opts (const char *options, int *flags, char **extra_opts) { if (options != NULL) { char *opts = xstrdup(options); - char *opt; - int len = strlen(opts) + 20; + char *opt, *p; + int len = strlen(opts); + int open_quote = 0; *extra_opts = xmalloc(len); **extra_opts = '\0'; - for (opt = strtok(opts, ","); opt; opt = strtok(NULL, ",")) - parse_opt(opt, flags, *extra_opts, len); - + for (p=opts, opt=NULL; p && *p; p++) { + if (!opt) + opt = p; /* begin of the option item */ + if (*p == '"') + open_quote ^= 1; /* reverse the status */ + if (open_quote) + continue; /* still in a quoted block */ + if (*p == ',') + *p = '\0'; /* terminate the option item */ + /* end of option item or last item */ + if (*p == '\0' || *(p+1) == '\0') { + parse_opt(opt, flags, *extra_opts, len); + opt = NULL; + } + } free(opts); } - } static void mount_error(char *node) |