Patchwork pathutil: resurrect comment about path auditing order

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 1, 2020, 5:29 a.m.
Message ID <c30168a6a58660a11937.1580534977@mimosa>
Download mbox | patch
Permalink /patch/44855/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 1, 2020, 5:29 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1580529452 -32400
#      Sat Feb 01 12:57:32 2020 +0900
# Node ID c30168a6a58660a119379c36e83c41ad7535d129
# Parent  6b7aef44274b457847d912cf1eada1dd8396f650
pathutil: resurrect comment about path auditing order

It was removed at 51c86c6167c1, but expensive symlink traversal isn't the
only reason we should walk path components from the root.
Augie Fackler - Feb. 12, 2020, 7:35 p.m.
queued, thanks

> On Feb 1, 2020, at 00:29, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1580529452 -32400
> #      Sat Feb 01 12:57:32 2020 +0900
> # Node ID c30168a6a58660a119379c36e83c41ad7535d129
> # Parent  6b7aef44274b457847d912cf1eada1dd8396f650
> pathutil: resurrect comment about path auditing order
> 
> It was removed at 51c86c6167c1, but expensive symlink traversal isn't the
> only reason we should walk path components from the root.
> 
> diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py
> --- a/mercurial/pathutil.py
> +++ b/mercurial/pathutil.py
> @@ -100,8 +100,10 @@ class pathauditor(object):
>         parts.pop()
>         normparts.pop()
>         # It's important that we check the path parts starting from the root.
> -        # This means we won't accidentally traverse a symlink into some other
> -        # filesystem (which is potentially expensive to access).
> +        # We don't want to add "foo/bar/baz" to auditeddir before checking if
> +        # there's a "foo/.hg" directory. This also means we won't accidentally
> +        # traverse a symlink into some other filesystem (which is potentially
> +        # expensive to access).
>         for i in range(len(parts)):
>             prefix = pycompat.ossep.join(parts[: i + 1])
>             normprefix = pycompat.ossep.join(normparts[: i + 1])
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py
--- a/mercurial/pathutil.py
+++ b/mercurial/pathutil.py
@@ -100,8 +100,10 @@  class pathauditor(object):
         parts.pop()
         normparts.pop()
         # It's important that we check the path parts starting from the root.
-        # This means we won't accidentally traverse a symlink into some other
-        # filesystem (which is potentially expensive to access).
+        # We don't want to add "foo/bar/baz" to auditeddir before checking if
+        # there's a "foo/.hg" directory. This also means we won't accidentally
+        # traverse a symlink into some other filesystem (which is potentially
+        # expensive to access).
         for i in range(len(parts)):
             prefix = pycompat.ossep.join(parts[: i + 1])
             normprefix = pycompat.ossep.join(normparts[: i + 1])