# Permission denied on home dir results in fatal error as of 1.8.1.1

4 messages from 2013-02-09 to 2013-02-09. Participants: Nick Muerdter, Junio C Hamano, Jonathan Nieder.
Thread: https://gitlist.dev/t/32864

## Nick Muerdter, 2013-02-09 00:40

Subject: Permission denied on home dir results in fatal error as of 1.8.1.1
Message-ID: <CAECnihxpvtE1XejzHDCRBF=GkyBHmb53WDLa16Suiq=4SeYzvA@mail.gmail.com>
URL: https://gitlist.dev/e/CAECnihxpvtE1XejzHDCRBF%3DGkyBHmb53WDLa16Suiq%3D4SeYzvA%40mail.gmail.com

```
As of git 1.8.1.1 and above (tested up to 1.8.1.3), if the home
directory can't be accessed, it results in a fatal error. In git 1.8.1
and below this same setup just resulted in warnings. Was this an
intentional change?

I ran into this in a situation where sudo is being used to execute a
script as root and then git ends up getting executed as a different
user. In this case HOME ends up being /root when git is called as this
different user. This home value is obviously incorrect, so there's an
issue there, but it would be perhaps be nice if this still just
resulted in warnings.

Here's a simple way to reproduce if run as a non-root user:

git 1.8.1.1 (fatal error, doesn't work):

$ env HOME=/root git ls-remote http://github.com/sstephenson/rbenv.git v0.4.0
fatal: unable to access '/root/.config/git/config': Permission denied

git 1.8.1 (warnings, but still works):

$ env HOME=/root git ls-remote http://github.com/sstephenson/rbenv.git v0.4.0
warning: unable to access '/root/.config/git/config': Permission denied
warning: unable to access '/root/.gitconfig': Permission denied
warning: unable to access '/root/.config/git/config': Permission denied
warning: unable to access '/root/.gitconfig': Permission denied
warning: unable to access '/root/.config/git/config': Permission denied
warning: unable to access '/root/.gitconfig': Permission denied
warning: unable to access '/root/.config/git/config': Permission denied
warning: unable to access '/root/.gitconfig': Permission denied
9375e99f921f428849f19efe2a2e500b3295d1a7 refs/tags/v0.4.0

Thanks,
Nick

```

## Junio C Hamano, 2013-02-09 00:50

Subject: Re: Permission denied on home dir results in fatal error as of 1.8.1.1
Message-ID: <7v6222xqc4.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v6222xqc4.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAECnihxpvtE1XejzHDCRBF=GkyBHmb53WDLa16Suiq=4SeYzvA@mail.gmail.com>

```
Nick Muerdter <stuff@nickm.org> writes:

> As of git 1.8.1.1 and above (tested up to 1.8.1.3), if the home
> directory can't be accessed, it results in a fatal error. In git 1.8.1
> and below this same setup just resulted in warnings. Was this an
> intentional change?

I think this was done to not just help diagnosing misconfiguration,
but to prevent an unintended misconfiguration from causing problems
(e.g. the user thinks user.name is set up correctly, but forbids Git
from reading it from the configuration files, and ends up creating
commits under wrong names).

Somebody please correct me if this weren't the case...

```

## Jonathan Nieder, 2013-02-09 01:05

Subject: Re: Permission denied on home dir results in fatal error as of 1.8.1.1
Message-ID: <20130209010534.GC8461@google.com>
URL: https://gitlist.dev/e/20130209010534.GC8461%40google.com
In-Reply-To: <7v6222xqc4.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano wrote:
> Nick Muerdter <stuff@nickm.org> writes:

>> As of git 1.8.1.1 and above (tested up to 1.8.1.3), if the home
>> directory can't be accessed, it results in a fatal error. In git 1.8.1
>> and below this same setup just resulted in warnings. Was this an
>> intentional change?
>
> I think this was done to not just help diagnosing misconfiguration,
> but to prevent an unintended misconfiguration from causing problems
> (e.g. the user thinks user.name is set up correctly, but forbids Git
> from reading it from the configuration files, and ends up creating
> commits under wrong names).

Yes, that's right.  Sometimes ignoring settings has bad consequences,
so git errors out to let the user intervene and decide whether the
inaccessible settings are important.

Thanks,
Jonathan

```

## Nick Muerdter, 2013-02-09 02:33

Subject: Re: Permission denied on home dir results in fatal error as of 1.8.1.1
Message-ID: <CAECnihwGK8+cHJYQCVMtTwRnrh5V3T-v2-8dM2rd=ziRUA2x5A@mail.gmail.com>
URL: https://gitlist.dev/e/CAECnihwGK8%2BcHJYQCVMtTwRnrh5V3T-v2-8dM2rd%3DziRUA2x5A%40mail.gmail.com
In-Reply-To: <20130209010534.GC8461@google.com>

```
On Fri, Feb 8, 2013 at 6:05 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Junio C Hamano wrote:
>> Nick Muerdter <stuff@nickm.org> writes:
>
>>> As of git 1.8.1.1 and above (tested up to 1.8.1.3), if the home
>>> directory can't be accessed, it results in a fatal error. In git 1.8.1
>>> and below this same setup just resulted in warnings. Was this an
>>> intentional change?
>>
>> I think this was done to not just help diagnosing misconfiguration,
>> but to prevent an unintended misconfiguration from causing problems
>> (e.g. the user thinks user.name is set up correctly, but forbids Git
>> from reading it from the configuration files, and ends up creating
>> commits under wrong names).
>
> Yes, that's right.  Sometimes ignoring settings has bad consequences,
> so git errors out to let the user intervene and decide whether the
> inaccessible settings are important.

Thanks for the quick response.

Just for reference, the specific issue I ran into stems from using
Chef to provision servers. Chef gets run as root but can perform the
git commands as a different user on the system. The way this appears
to be implemented is to fork, set the uid, and then execute git. But
since the HOME environment variable is still set to /root, this leads
to this fatal error. This can obviously be fixed on the script's end
by properly determining and setting the HOME before executing git, but
more care has to be taken, and I'm not sure how common this fork + set
uid + exec approach in other programs might be. But I'll file a bug
with Chef to get it fixed there.

Thanks again,
Nick

```
