]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (mkdir) cannonicalize after mkdir
authorKarel Zak <kzak@redhat.com>
Mon, 23 May 2022 10:58:08 +0000 (12:58 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:53:12 +0000 (12:53 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_mkdir.c

index ba1a8a4ccb761e3de8910aef1de190daa451d991..191899f303bcc888fb2f95f56b651dc9d1da8d90 100644 (file)
@@ -107,6 +107,8 @@ static int hook_prepare_target(
                cxt->user_mountflags & MNT_MS_XFSTABCOMM)
            && is_mkdir_required(tgt, cxt->fs, &mode, &rc)) {
 
+               struct libmnt_cache *cache;
+
                /* supported only for root or non-suid mount(8) */
                if (!mnt_context_is_restricted(cxt)) {
                        rc = ul_mkdir_p(tgt, mode);
@@ -114,6 +116,15 @@ static int hook_prepare_target(
                                DBG(HOOK, ul_debugobj(hs, "mkdir %s failed: %m", tgt));
                } else
                        rc = -EPERM;
+
+               if (rc == 0) {
+                       cache = mnt_context_get_cache(cxt);
+                       if (cache) {
+                               char *path = mnt_resolve_path(tgt, cache);
+                               if (path && strcmp(path, tgt) != 0)
+                                       rc = mnt_fs_set_target(cxt->fs, path);
+                       }
+               }
        }
 
        return rc;