git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] optionally deny all pushes

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2012, 22:02 UTC
Message-ID
<7vhazobto3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120121174927.GA7128@ecki>
Clemens Buchacher <drizzd@aon.at> writes:
Show 10 quoted lines
> For a mirror repository which is updated only by pulling from upstream,
> it is convenient to disallow all pushes. An accidental push from a
> downstream repository would mess up the mirror's state as well as future
> updates.
>
> Add a boolean configuration variable receive.denyAll. If enabled,
> receive-pack will deny all ref updates.
>
> Signed-off-by: Clemens Buchacher <drizzd@aon.at>
> ---
I do not like this at all.
Especially given that this seems equivalent to:
	$ echo exit 1 >.git/hooks/pre-receive
        $ chmod +x .git/hooks/pre-receive
this is a mere configuration bloat, isn't it?

Your patch however raises an interesting point. Our pre-receive rejection infrastructure does have a room for improvement.

A typical "push" exchange goes like this:
    receiver: Here are the refs I have.
    sender:   I want to update your refs with these.
    sender:   Here is the object data to complete the updated refs.
    receiver: Let's see what you are trying to do... I may say:
              - I refuse your proposal to update/delete this branch,
                as it is the current branch.
              - My hook tells me to refuse your proposal to update this
                ref, as it does not fast-forward.

We can see that we could decide to reject the push to update the current branch even before receiving the bulk of transfer. I suspect it might need a protocol extension to give the receiver a chance to speak after hearing the proposed set of updates before receiving the bulk of the data to add a clean error codepath, but at the worset case, we could immediately close the connection after hearing what the sender proposes to do tries to touch the current branch in a way we do not like. In other words, the exchange could become:

    receiver: Here are the refs I have.
    sender:   I want to update your refs with these.
    receiver: Let's see what you are trying to do... I may say:
              - I can tell you without actually looking at the commits you
                are proposing to place at the tips of my refs that I won't
                like this branch to be updated/deleted. Go away.
    sender:   Here is the object data to complete the updated refs.
    receiver: Let's see what you are trying to do...
              - My hook tells me to refuse your proposal to update this
                ref, as it does not fast-forward.

Your "reject any and all" better fits into that new rejection codepath. Just like the configuration that rejects updates to the current branch, the decision your patch wants to make can be made before we see any object data from the sender.

Another thing to consider is that you do not have to be limited to "all".

Often people want to run "git fetch" on their mothership box receiving data from their notebook, i.e.

    mothership$ git fetch notebook master:refs/remotes/notebook/master
    mothership$ git merge notebook/master

but are prevented from doing so due to networking issues (e.g. your notebook may not allow incoming connections). The right way to emulate this is to initiate the connection in the reverse direction, running "git push" on their notebook sending data into their mothership box, i.e.

    notebook$ git push mothership master:refs/remotes/notebook/master
    mothership$ git merge notebook/master

In such a situation, you may want to configure your mothership repository to reject any push outside refs/remotes/ hierarchy to prevent mistakes. We could add "receive.allowed = refs/remotes/*" or something to support this use case. It might turn out that we may even want to make this the default for non-bare repositories.

Once that happens, you can naturally say "receive.allowed = none" to do what your patch wants to do as a narrow special case. Wouldn't that be a much better approach than a "reject any and all" that can only serve a single narrow case that can already be done with a simple hook?

Previous: Clemens BuchacherNext: Clemens Buchacher
Message 2 of 16 in “optionally deny all pushes”
  1. optionally deny all pushesClemens Buchacher, Jan 21, 2012
  2. Junio C HamanoJan 21, 2012
  3. 0/5 verify refs earlyClemens Buchacher, Feb 13, 2012
  4. 1/5 git rev-list: fix invalid typecastClemens Buchacher, Feb 13, 2012
  5. Junio C HamanoFeb 13, 2012
  6. 2/5 do not override receive-pack errorsClemens Buchacher, Feb 13, 2012
  7. Junio C HamanoFeb 13, 2012
  8. Clemens BuchacherFeb 14, 2012
  9. Junio C HamanoFeb 14, 2012
  10. 3/5 git push: verify refs earlyClemens Buchacher, Feb 13, 2012
  11. Junio C HamanoFeb 13, 2012
  12. Clemens BuchacherFeb 14, 2012
  13. 4/5 t5541: use configured port numberClemens Buchacher, Feb 13, 2012
  14. Junio C HamanoFeb 13, 2012
  15. 5/5 push/fetch/clone --no-progress suppresses progress outputClemens Buchacher, Feb 13, 2012
  16. Junio C HamanoFeb 13, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.