From: Karel Zak Date: Thu, 18 Aug 2022 10:04:43 +0000 (+0200) Subject: libmount: (mount) de-duplicate when apply MS_SECURE X-Git-Tag: v2.39-rc1~312 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ed18d0370834121ac4798815e248eeb606e8555;p=thirdparty%2Futil-linux.git libmount: (mount) de-duplicate when apply MS_SECURE 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 --- diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 52abeb8aef..44be89ae39 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -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);