]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add mnt_context_within_helper() wrapper
authorKarel Zak <kzak@redhat.com>
Wed, 3 Jan 2024 11:38:21 +0000 (12:38 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Jan 2024 11:38:21 +0000 (12:38 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
libmount/src/context_umount.c
libmount/src/mountP.h

index 6db71f4e4777f4b072765893aa40c75cae05a9b7..93fc3dbdcb6f35bce1e6ec1e66fb508c76ea8cb2 100644 (file)
@@ -2737,7 +2737,6 @@ int mnt_context_get_excode(
        return rc;
 }
 
-
 /**
  * mnt_context_init_helper
  * @cxt: mount context
@@ -2773,6 +2772,14 @@ int mnt_context_init_helper(struct libmnt_context *cxt, int action,
        return rc;
 }
 
+/*
+ * libmount used in /sbin/[u]mount.<type> helper
+ */
+int mnt_context_within_helper(struct libmnt_context *cxt)
+{
+       return cxt && (cxt->flags & MNT_FL_HELPER);
+}
+
 /**
  * mnt_context_helper_setopt:
  * @cxt: context
index 26394d51efb71e04b5dfe612ba2fe322fbcd20d8..79b62378d8d33957abac0b7b85208e2c68d6bf93 100644 (file)
@@ -270,7 +270,7 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg
         */
        if (mnt_context_is_restricted(cxt)
            || *tgt != '/'
-           || (cxt->flags & MNT_FL_HELPER)
+           || mnt_context_within_helper(cxt)
            || mnt_context_is_force(cxt)
            || mnt_context_is_lazy(cxt)
            || mnt_context_is_nocanonicalize(cxt)
index 59921cf7405f4009668eb085fcb6a5fe216473fa..2385e191dbe4cce3482732af6a58f1988b248007 100644 (file)
@@ -620,6 +620,8 @@ extern struct libmnt_context *mnt_copy_context(struct libmnt_context *o);
 extern int mnt_context_utab_writable(struct libmnt_context *cxt);
 extern const char *mnt_context_get_writable_tabpath(struct libmnt_context *cxt);
 
+extern int mnt_context_within_helper(struct libmnt_context *cxt);
+
 extern int mnt_context_get_mountinfo(struct libmnt_context *cxt, struct libmnt_table **tb);
 extern int mnt_context_get_mountinfo_for_target(struct libmnt_context *cxt,
                                    struct libmnt_table **mountinfo, const char *tgt);