From: Karel Zak Date: Thu, 25 Aug 2022 12:33:32 +0000 (+0200) Subject: libmount: (umount) use optlist when evaluate permissions X-Git-Tag: v2.39-rc1~280 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e635daafd8dda1550d90d65882e6d117cf914271;p=thirdparty%2Futil-linux.git libmount: (umount) use optlist when evaluate permissions Signed-off-by: Karel Zak --- diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index 2bb48aea32..736cc7e5d6 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -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); }