git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "David C. Rankin" <drankinatty@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Local git server can't serve https until repos owned by http, can't serve ssh unless repos owned by user after 2.45.1
Date: Mon, 24 Jun 2024 07:53:42 -0700	[thread overview]
Message-ID: <xmqqo77qgznt.fsf@gitster.g> (raw)
In-Reply-To: <d5ff3629-ef8c-472b-886a-3ec0dd6a2c9a@gmail.com> (David C. Rankin's message of "Mon, 17 Jun 2024 20:08:07 -0500")

"David C. Rankin" <drankinatty@gmail.com> writes:

>   I read the error from the server log and then attempted to add the
>   suggested config to ~/.gitconfig, e.g.:
>
> [safe]
> 	directory = /srv/git/embedded.git
> ...
> drwxr-xr-x  7 david david 4096 Jun 15 02:42 embedded.git

You say ~/.gitconfig here.  Whose home directory does "~" refer to?

The primary reason I wrote the message you are responding to was to
find this piece of information out (and tell you that it would be
different from the repository owner's), and I am still not sure if I
extracted that piece of information out of you, after reading the
message I am responding to twice.

In short, the above has to be in ~http/.gitconfig (if 'http' is the
user Apache runs as).  Listing it in ~david/.gitconfig would not
work.  It has to come from the user who runs Git in a directory the
user does not own (in this case, that is the 'http' user.  That user
runs, via the CGI interface, the server side Git programs to respond
to pushes and fetches, serving a repository not owned by 'http'),

The mechanism is about protecting the user that runs Git (i.e.
'http' in the context of "git push/fetch is responded by the Apache
web server via the CGI mechanism spawning 'git http-backend'") from
potentially malicious repositories owned by users that are *not*
'http' (i.e. /srv/git/embedded.git that is owned by david:david in
this case), as such repositories can contain hooks and other
configuration settings that would end up running programs as 'http'
user with 'http' user's priviledge, potentially writing into files
owned by 'http' user to attack 'http' user.

Hence, the "I am OK to run Git as myself in these repositories, even
though they are not owned by me" acceptance, which is an snippet in
gitconfig file you showed above, has to come from the 'http' user,
and certainly not from the 'david' user.  The configuration is about
protecting 'http' from 'david' and not about protecting 'david' from
'http', so configuration files in 'david' user's home directory
should have no say in who 'http' user is willing to trust.

So, back to the original question.  You said ~/.gitconfig/ has the
safe.directory settings.  Whose ~/.gitconfig/?

I would have expected that the only thing you'd need to do is to let
your 'http' user tell Git that it does not want the paranoid safety
more recent versions of Git offers with the safe.directory setting
in ~http/.gitconfig, and have repositories owned by individual users
that come over ssh as they themselves.  For those who are accessing
their own repositories over ssh as themselves, everything should
work just as before.

      reply	other threads:[~2024-06-24 14:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17  0:36 Local git server can't serve https until repos owned by http, can't serve ssh unless repos owned by user after 2.45.1 David C. Rankin
2024-06-17 18:47 ` Junio C Hamano
2024-06-17 21:15   ` Michal Suchánek
2024-06-25  7:24     ` Michal Suchánek
2024-06-25 16:12       ` Junio C Hamano
2024-06-25 18:34         ` Michal Suchánek
2024-06-26 13:03           ` Phillip Wood
2024-06-26 18:14             ` Junio C Hamano
2024-06-26 18:35               ` Phillip Wood
2024-06-26 18:51                 ` Junio C Hamano
2024-09-25 11:34                   ` Michal Suchánek
2024-08-29 20:34             ` Joey Hess
2024-07-26  0:38         ` Jamie Landeg-Jones
2024-07-26  5:58           ` David C. Rankin
2024-07-28  3:46             ` Jamie Landeg-Jones
2024-07-28  6:57               ` David C. Rankin
2024-08-01  0:15                 ` [SOLVED] " Jamie Landeg-Jones
2024-08-02 19:31                   ` Junio C Hamano
2024-06-18  1:08   ` David C. Rankin
2024-06-24 14:53     ` Junio C Hamano [this message]

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=xmqqo77qgznt.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=drankinatty@gmail.com \
    --cc=git@vger.kernel.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.
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 NNTP newsgroup(s).