git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: William Pursell <bill.pursell@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: William Pursell <bill.pursell@gmail.com>,
	Alex Riesen <raa.lkml@gmail.com>,
	Andreas Schwab <schwab@linux-m68k.org>,
	git@vger.kernel.org
Subject: Re: permissions
Date: Tue, 08 Jun 2010 00:25:53 -1000	[thread overview]
Message-ID: <4C0E1AB1.2030702@wpursell.net> (raw)
In-Reply-To: <7vvd9wvswy.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:

> I think it is sane to abort with "permission denied", as it is "not a git
> repository" but it is "we cannot even determine if that .git we see is a
> git repository, and if it is, then we cannot do any git operation here as
> we cannot read it".  As to what you call "the current work flow", I think
> it is not like we _support_ such usage, but more like it _happens to_ work
> that way.

Here's a patch.  This doesn't address the issue of a damaged
repository, but just catches access errors and permissions.

>From 8f1c8f4d572fe62a26d1fca47abc976e78942697 Mon Sep 17 00:00:00 2001
From: William Pursell <bill.pursell@gmail.com>
Date: Tue, 8 Jun 2010 00:16:43 -1000
Subject: [PATCH] Terminate on access errors

This changes the way git finds a repository.  Previously, if
access is denied to .git (or $GIT_DIR), git will use the object
directory in a higher level directory.  With this patch, git will
instead terminate and emit an error message indicating the access
failure.  Also, other errors (such as soft-link loops in
GIT_OBJECT_DIRECTORIES) will cause termination.

Signed-off-by: William Pursell <bill.pursell@gmail.com>
---
 setup.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/setup.c b/setup.c
index 7e04602..a53331c 100644
--- a/setup.c
+++ b/setup.c
@@ -155,6 +155,18 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
 }

 /*
+ * Wrapper around access that terminates on
+ * errors other than ENOENT.
+ */
+static int xaccess(const char *path, int amode)
+{
+	int status = access(path, amode);
+	if (status && errno != ENOENT)
+		die_errno("%s", path);
+	return status;
+}
+
+/*
  * Test if it looks like we're at a git directory.
  * We want to see:
  *
@@ -172,17 +184,17 @@ static int is_git_directory(const char *suspect)

 	strcpy(path, suspect);
 	if (getenv(DB_ENVIRONMENT)) {
-		if (access(getenv(DB_ENVIRONMENT), X_OK))
+		if (xaccess(getenv(DB_ENVIRONMENT), X_OK))
 			return 0;
 	}
 	else {
 		strcpy(path + len, "/objects");
-		if (access(path, X_OK))
+		if (xaccess(path, X_OK))
 			return 0;
 	}

 	strcpy(path + len, "/refs");
-	if (access(path, X_OK))
+	if (xaccess(path, X_OK))
 		return 0;

 	strcpy(path + len, "/HEAD");
-- 
1.7.1.245.g7c42e.dirty



-- 
William Pursell

  reply	other threads:[~2010-06-08 10:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-05  9:33 permissions William Pursell
2010-06-05  9:50 ` permissions Andreas Schwab
2010-06-05 18:23   ` permissions William Pursell
2010-06-06  6:45     ` permissions Alex Riesen
2010-06-06  9:36       ` permissions William Pursell
2010-06-06 12:45         ` permissions Alex Riesen
2010-06-06 19:54         ` permissions Junio C Hamano
2010-06-08 10:25           ` William Pursell [this message]
2010-06-08 14:52             ` permissions Alex Riesen
2010-06-08 21:05               ` permissions Junio C Hamano
2010-06-08 22:27                 ` permissions William Pursell
2010-06-09  7:20                   ` permissions Alex Riesen
2010-06-09 10:29                     ` permissions William Pursell
2010-06-09 12:06                       ` permissions Thomas Rast
2010-06-09 13:00                         ` permissions Alex Riesen
2010-06-09 12:56                       ` permissions Alex Riesen
2010-06-09 10:39                     ` permissions Steven Michalske

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=4C0E1AB1.2030702@wpursell.net \
    --to=bill.pursell@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=raa.lkml@gmail.com \
    --cc=schwab@linux-m68k.org \
    /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).