From c7f1aecf298cacdf235c3f2e4e9268ed2630c82f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 4 Oct 2022 13:34:42 +0200 Subject: [PATCH] libmount: fix external helps call * always use rw/ro flags on helper command line * don't return MNT_ERR_APPLYFLAGS, the flags are applied in post-mount stage Signed-off-by: Karel Zak --- libmount/src/context_mount.c | 15 +++++---------- libmount/src/optlist.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 15e2b61448..f4b718d553 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -538,15 +538,8 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type) return rc; } - if (cxt->helper) { - rc = exec_helper(cxt); - - if (mnt_context_helper_executed(cxt) - && mnt_context_get_helper_status(cxt) == 0) - return -MNT_ERR_APPLYFLAGS; - - return rc; - } + if (cxt->helper) + return exec_helper(cxt); if (try_type) { ol = mnt_context_get_optlist(cxt); @@ -898,6 +891,7 @@ int mnt_context_do_mount(struct libmnt_context *cxt) if (!mnt_context_switch_ns(cxt, ns_old)) return -MNT_ERR_NAMESPACE; + DBG(CXT, ul_debugobj(cxt, "mnt_context_do_mount() done [rc=%d]", res)); return res; } @@ -1074,8 +1068,9 @@ again: mnt_context_deinit_hooksets(cxt); if (!mnt_context_switch_ns(cxt, ns_old)) - return -MNT_ERR_NAMESPACE; + rc = -MNT_ERR_NAMESPACE; + DBG(CXT, ul_debugobj(cxt, "mnt_context_mount() done [rc=%d]", rc)); return rc; } diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c index d8fdc8f192..edb9594912 100644 --- a/libmount/src/optlist.c +++ b/libmount/src/optlist.c @@ -836,7 +836,10 @@ int mnt_optlist_strdup_optstr(struct libmnt_optlist *ls, char **optstr, /* For generic options srings ro/rw is expected at the begining */ if ((!map || map == ls->linux_map) - && (what == MNT_OL_FLTR_DFLT || what == MNT_OL_FLTR_ALL)) { + && (what == MNT_OL_FLTR_DFLT || + what == MNT_OL_FLTR_ALL || + what == MNT_OL_FLTR_HELPERS)) { + rc = mnt_buffer_append_option(&buf, "rw", 2, NULL, 0); if (rc) goto fail; @@ -866,7 +869,10 @@ int mnt_optlist_strdup_optstr(struct libmnt_optlist *ls, char **optstr, /* convert 'rw' at the beginning to 'ro' if necessary */ if (str && is_rdonly && xx_wanted - && (what == MNT_OL_FLTR_DFLT || what == MNT_OL_FLTR_ALL)) { + && (what == MNT_OL_FLTR_DFLT || + what == MNT_OL_FLTR_ALL || + what == MNT_OL_FLTR_HELPERS)) { + str[0] = 'r'; str[1] = 'o'; } @@ -1233,6 +1239,12 @@ static int test_get_str(struct libmnt_test *ts, int argc, char *argv[]) rc = mnt_optlist_get_optstr(ol, &str, NULL, MNT_OL_FLTR_UNKNOWN); if (!rc) printf("Unknown: %s\n", str); + + rc = mnt_optlist_get_optstr(ol, &str, NULL, MNT_OL_FLTR_HELPERS); + if (!rc) + rc = mnt_optlist_get_optstr(ol, &str, NULL, MNT_OL_FLTR_HELPERS); + if (!rc) + printf("Helpers: %s\n", str); done: mnt_unref_optlist(ol); return rc; -- 2.47.2