]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (umount) use optlist when evaluate permissions
authorKarel Zak <kzak@redhat.com>
Thu, 25 Aug 2022 12:33:32 +0000 (14:33 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_umount.c

index 2bb48aea32955dbfd699ef1aac518e725b2feb47..736cc7e5d6c05b5d873541d2f06368c0a14a226c 100644 (file)
@@ -619,9 +619,9 @@ static int evaluate_permissions(struct libmnt_context *cxt)
         */
        if (fstab_flags & (MNT_MS_USER | MNT_MS_OWNER | MNT_MS_GROUP)) {
 
-               char *curr_user;
-               char *utab_user = NULL;
-               size_t sz;
+               struct libmnt_optlist *ol;
+               struct libmnt_opt *opt;
+               char *curr_user = NULL;
                struct libmnt_ns *ns_old;
 
                DBG(CXT, ul_debugobj(cxt,
@@ -643,11 +643,13 @@ static int evaluate_permissions(struct libmnt_context *cxt)
                        goto eperm;
                }
 
-               /* get options from utab */
-               optstr = mnt_fs_get_user_options(cxt->fs);
-               if (optstr && !mnt_optstr_get_option(optstr,
-                                       "user", &utab_user, &sz) && sz)
-                       ok = !strncmp(curr_user, utab_user, sz);
+               /* get "user=" from utab */
+               ol = mnt_context_get_optlist(cxt);
+               if (!ol)
+                       return -ENOMEM;
+               opt = mnt_optlist_get_named(ol, "user", cxt->map_userspace);
+               if (opt && mnt_opt_has_value(opt))
+                       ok = !strcmp(curr_user, mnt_opt_get_value(opt));
 
                free(curr_user);
        }