From afb35f3dea366264893470ca43e971ba2b022c6c Mon Sep 17 00:00:00 2001 From: Alexander Mikhalitsyn Date: Mon, 5 May 2025 18:03:10 +0200 Subject: [PATCH] lxc/conf: support flag kind of mount options in lxc.mount.entry options Currently, if user wants to use a flag-like mount option in lxc.mount.entry, for example "userxattr" with overlayfs then it will be silently ignored. Let's fix that by making parse_vfs_attr() to process all mount options. Signed-off-by: Alexander Mikhalitsyn --- src/lxc/conf.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 9c95cd020..6c0e3d3c9 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -2035,6 +2035,11 @@ int parse_mntopts_legacy(const char *mntopts, unsigned long *mntflags, char **mn return 0; } +/* Parses generic VFS option (opt) and puts results into (opts). + * + * @return 1 if opt is not a generic VFS option + * @return 0 if opt was processed + */ static int parse_vfs_attr(struct lxc_mount_options *opts, char *opt, size_t size) { /* @@ -2091,7 +2096,8 @@ static int parse_vfs_attr(struct lxc_mount_options *opts, char *opt, size_t size return 0; } - return 0; + /* opt was skipped */ + return 1; } int parse_mount_attrs(struct lxc_mount_options *opts, const char *mntopts) @@ -2117,22 +2123,22 @@ int parse_mount_attrs(struct lxc_mount_options *opts, const char *mntopts) return ret_errno(ENOMEM); lxc_iterate_parts(mntopt_cur, mntopts_dup, ",") { - /* This is a filesystem specific option. */ - if (strchr(mntopt_cur, '=')) { - if (!end) { - end = stpcpy(mntopts_new, mntopt_cur); - } else { - end = stpcpy(end, ","); - end = stpcpy(end, mntopt_cur); - } - - continue; - } - /* This is a generic vfs option. */ ret = parse_vfs_attr(opts, mntopt_cur, size); if (ret < 0) return syserror("Failed to parse mount attributes: \"%s\"", mntopt_cur); + + /* (mntopt_cur) was processed in parse_vfs_attr() */ + if (ret == 0) + continue; + + /* This is a filesystem specific option. */ + if (!end) { + end = stpcpy(mntopts_new, mntopt_cur); + } else { + end = stpcpy(end, ","); + end = stpcpy(end, mntopt_cur); + } } if (*mntopts_new) -- 2.47.2