]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc/conf: support flag kind of mount options in lxc.mount.entry options 4547/head
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Mon, 5 May 2025 16:03:10 +0000 (18:03 +0200)
committerAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Sat, 10 May 2025 11:41:08 +0000 (13:41 +0200)
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 <aleksandr.mikhalitsyn@canonical.com>
src/lxc/conf.c

index 9c95cd020f807437dfd5049bfabf55e049df018a..6c0e3d3c9515a399dd5a0e2d9bd89b5a0e98d6e1 100644 (file)
@@ -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)