]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (mount) de-duplicate when apply MS_SECURE
authorKarel Zak <kzak@redhat.com>
Thu, 18 Aug 2022 10:04:43 +0000 (12:04 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
The options string "users,exec" is "users,nodev,nosuid,noexec,exec",
the option "noexec" is unnecessary here. The last option is the winner
("exec" in this case).

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_mount.c

index 52abeb8aefb820a5083a521da99f48adff2e25f1..44be89ae392998e133750d1ef2136f76ca0dc1ae 100644 (file)
@@ -461,6 +461,10 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                        DBG(CXT, ul_debugobj(cxt, "perms: evaluation ends with -EPERMS [flags=0x%08lx]", user_flags));
                        return -EPERM;
                }
+
+               /* we have modified some flags (noexec, ...), let's cleanup the
+                * options to remove duplicate stuff etc.*/
+               mnt_optlist_merge_opts(ol);
        }
 
        return 0;
@@ -1920,6 +1924,7 @@ static int test_fixopts(struct libmnt_test *ts, int argc, char *argv[])
 {
        struct libmnt_context *cxt;
        struct libmnt_optlist *ls;
+       unsigned long flags = 0;
        const char *p;
        int rc;
 
@@ -1959,8 +1964,11 @@ static int test_fixopts(struct libmnt_test *ts, int argc, char *argv[])
                warn("fix options failed [rc=%d]", rc);
                return rc;
        }
+
        mnt_optlist_get_optstr(ls, &p, NULL, 0);
-       printf("options (dfl): '%s'\n", p);
+
+       mnt_optlist_get_flags(ls, &flags, mnt_get_builtin_optmap(MNT_LINUX_MAP), 0);
+       printf("options (dfl): '%s' [mount flags: %08lx]\n", p, flags);
 
        mnt_optlist_get_optstr(ls, &p, NULL, MNT_OL_FLTR_ALL);
        printf("options (ex.): '%s'\n", p);