All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>,
	Zenobiusz Kunegunda <zenobiusz.kunegunda@interia.pl>,
	Jeff King <peff@peff.net>
Subject: Re: [PATCH] strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD
Date: Sun, 26 Mar 2017 17:40:46 -0700	[thread overview]
Message-ID: <xmqq1stj4kmp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <4026bc3b-2999-9daf-d6ab-10c6d007b1e7@web.de> ("René Scharfe"'s message of "Sun, 26 Mar 2017 15:43:50 +0200")

René Scharfe <l.s.r@web.de> writes:

> FreeBSD implements getcwd(3) as a syscall, but falls back to a version
> based on readdir(3) if it fails for some reason.  The latter requires
> permissions to read and execute path components, while the former does
> not.  That means that if our buffer is too small and we're missing
> rights we could get EACCES, but we may succeed with a bigger buffer.

WOW.  Just WOW.  Looking at the debugging exchange from the
sideline, I didn't expect this end result.

> Keep retrying if getcwd(3) indicates lack of permissions until our
> buffer can fit PATH_MAX bytes, as that's the maximum supported by the
> syscall on FreeBSD anyway.  This way we do what we can to be able to
> benefit from the syscall, but we also won't loop forever if there is a
> real permission issue.
>
> This fixes a regression introduced with 7333ed17 (setup: convert
> setup_git_directory_gently_1 et al. to strbuf, 2014-07-28) for paths
> longer than 127 bytes with components that miss read or execute
> permissions (e.g. 0711 on /home for privacy reasons); we used a fixed
> PATH_MAX-sized buffer before.
>
> Reported-by: Zenobiusz Kunegunda <zenobiusz.kunegunda@interia.pl>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---


Nicely analysed and fixed (or is the right word "worked around"?)

Thanks, will queue.

  reply	other threads:[~2017-03-27  0:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-26 13:43 [PATCH] strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD René Scharfe
2017-03-27  0:40 ` Junio C Hamano [this message]
2017-03-27  5:55   ` Zenobiusz Kunegunda
2017-03-27 18:40     ` Junio C Hamano
2017-03-28 21:15 ` Christian Couder
2017-03-28 21:24   ` Stefan Beller
2017-03-28 21:47     ` Christian Couder
2017-03-28 21:49   ` Jeff King
2017-03-29  4:54     ` Christian Couder
2017-03-30 18:01       ` René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1stj4kmp.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    --cc=zenobiusz.kunegunda@interia.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.