git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Guillaume Castagnino <casta@xwing.info>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] use filetest pragma to work with ACL
Date: Thu, 19 Oct 2017 09:53:28 +0200	[thread overview]
Message-ID: <1508399608.4529.10.camel@xwing.info> (raw)
In-Reply-To: <20171018212451.goqxu4qq6aqe4tpl@sigill.intra.peff.net>

[-- Attachment #1: Type: text/plain, Size: 2245 bytes --]

Hi,

Le mercredi 18 octobre 2017 à 17:24 -0400, Jeff King a écrit :
> On Wed, Oct 18, 2017 at 07:55:31PM +0000, Guillaume Castagnino wrote:
> 
> > From: Guillaume Castagnino <casta@xwing.info>
> > [...]
> 
> Stefan raised a few meta issues, all of which I agree with. But I had
> some questions about the patch itself:
> 
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index 9208f42ed1753..0ee7f304ce2b1 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -3072,6 +3072,7 @@ sub git_get_projects_list {
> >  				# only directories can be git
> > repositories
> >  				return unless (-d $_);
> >  				# need search permission
> > +				use filetest 'access';
> >  				return unless (-x $_);
> 
> This "use" will unconditionally at compile-time (such as "compile" is
> for perl, anyway). Which raises a few questions:
> 
>   - would we want to use "require" instead to avoid loading when we
>     don't enter this function?

I was under the impression that as this is a pragma affecting perl
“compiler”, you have to always use “use”, not require, as the pragma
initialisation has to be done before code is run.

>   - If the answer to the above is "no" (e.g., because we basically
>     always need it; I didn't check), should it go at the top of the
>     script with the other "use" directives?
> 
>     I think this is a scoped pragma, so what you have here affects
> only
>     this particular "-x". But wouldn't other uses of "-x" potentially
>     want the same benefit?

I quickly grepped the code, I did not see other calls that could
benefits from the pragma, but it could be indeed nice to move it at the
top to avoid future issues with such tests and POSIX ACL.

>   - Do all relevant versions of perl ship with filetest? According to
>     Module::Corelist, it first shipped with perl 5.6. In general I
> think
>     we treat that as a minimum for our perl scripts, though I do
> notice
>     that the gitweb script says "use 5.008". I'm not sure how
> realistic
>     that is.

So the CGI already requires perl 5.8, so it’s fine I think.

Attached a cleanup proposal and moving the use at the top.

Thanks
Guillaume

-- 
Guillaume Castagnino
    casta@xwing.info / guillaume@castagnino.org

[-- Attachment #2: 0001-gitweb-use-filetest-to-allow-ACLs.patch --]
[-- Type: text/x-patch, Size: 842 bytes --]

From 4d5a082970063b34d3dbdf5b9a577624310057d6 Mon Sep 17 00:00:00 2001
From: Guillaume Castagnino <casta@xwing.info>
Date: Thu, 19 Oct 2017 09:32:46 +0200
Subject: [PATCH] gitweb: use filetest to allow ACLs

In commit 46a1385 (gitweb: skip unreadable subdirectories, 2017-07-18)
we forgot to handle non-unix ACLs as well. Fix this.

Signed-off-by: Guillaume Castagnino <casta@xwing.info>
---
 gitweb/gitweb.perl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9208f42ed..6ac49eaf3 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -10,6 +10,8 @@
 use 5.008;
 use strict;
 use warnings;
+# handle ACL in file access tests
+use filetest 'access';
 use CGI qw(:standard :escapeHTML -nosticky);
 use CGI::Util qw(unescape);
 use CGI::Carp qw(fatalsToBrowser set_message);
-- 
2.14.2


  reply	other threads:[~2017-10-19  8:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 19:55 [PATCH] use filetest pragma to work with ACL Guillaume Castagnino
2017-10-18 20:05 ` Stefan Beller
2017-10-18 21:24 ` Jeff King
2017-10-19  7:53   ` Guillaume Castagnino [this message]
2017-10-19 16:13     ` Jeff King
2017-10-24  5:02       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1508399608.4529.10.camel@xwing.info \
    --to=casta@xwing.info \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).