aboutsummaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-09 17:06:55 -0700
committerJunio C Hamano <gitster@pobox.com>2013-06-09 17:06:56 -0700
commitb1c418e155a86a1a6104c20e5424d847e516c8d7 (patch)
treed6a2a3e4a380b93d97fc451035b6dc3691e6ef0a /wrapper.c
parentfd500302096b5b4e45d78c14d6ea9a704f556a16 (diff)
parent4698c8feb1bb56497215e0c10003dd046df352fa (diff)
downloadgit-b1c418e155a86a1a6104c20e5424d847e516c8d7.tar.gz
git-b1c418e155a86a1a6104c20e5424d847e516c8d7.tar.xz
Merge branch 'jn/config-ignore-inaccessible' into maint
A git daemon that starts as "root" and then drops privilege often leaves $HOME set to that of the root user, which is unreadable by the daemon process, which was diagnosed as a configuration error. Make per-user configuration files that are inaccessible due to EACCES as though these files do not exist to avoid this issue, as the tightening which was originally meant as an additional security has annoyed enough sysadmins. * jn/config-ignore-inaccessible: config: allow inaccessible configuration under $HOME
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/wrapper.c b/wrapper.c
index bac59d2c4..dd7ecbb11 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -408,18 +408,24 @@ void warn_on_inaccessible(const char *path)
warning(_("unable to access '%s': %s"), path, strerror(errno));
}
-int access_or_warn(const char *path, int mode)
+static int access_error_is_ok(int err, unsigned flag)
+{
+ return err == ENOENT || err == ENOTDIR ||
+ ((flag & ACCESS_EACCES_OK) && err == EACCES);
+}
+
+int access_or_warn(const char *path, int mode, unsigned flag)
{
int ret = access(path, mode);
- if (ret && errno != ENOENT && errno != ENOTDIR)
+ if (ret && !access_error_is_ok(errno, flag))
warn_on_inaccessible(path);
return ret;
}
-int access_or_die(const char *path, int mode)
+int access_or_die(const char *path, int mode, unsigned flag)
{
int ret = access(path, mode);
- if (ret && errno != ENOENT && errno != ENOTDIR)
+ if (ret && !access_error_is_ok(errno, flag))
die_errno(_("unable to access '%s'"), path);
return ret;
}