]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix external helps call
authorKarel Zak <kzak@redhat.com>
Tue, 4 Oct 2022 11:34:42 +0000 (13:34 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
* 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 <kzak@redhat.com>
libmount/src/context_mount.c
libmount/src/optlist.c

index 15e2b61448dabbe45a086cc14b1794c9fbca7a41..f4b718d553aa4bee12d43a3f09a27d534041de75 100644 (file)
@@ -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;
 }
 
index d8fdc8f19219154878c38467e2ffbb66ea7a2e1e..edb9594912117dcffcaeae57239eb324d3ac0428 100644 (file)
@@ -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;