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

Re: what are the chances of a 'pre-upload' hook?

From
Jeff King <peff@peff.net>
Date
Nov 26, 2011, 23:31 UTC
Message-ID
<20111126233133.GA31129@sigill.intra.peff.net>
In-Reply-To
<7vr50uwk7x.fsf@alter.siamese.dyndns.org>
On Sat, Nov 26, 2011 at 03:13:38PM -0800, Junio C Hamano wrote:
Show 9 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Bob could run a specialized server for (b) that listens on a unix socket
> > and triggers his hook. But why? Why not just do the whole thing over
> > git-daemon or smart http, which already exist?
> 
> If that "whole thing" is "to allow an arbitrary code to run anywhere as
> incoming user", I would apply the "why?" to a different part of the
> statemennt. Why allow running an arbitrary code at all?

Because there are useful hooks that Bob wants to run when somebody fetches or pushes to/from his repository?

> A pre-anything hook wants to see if the accessing user, not the owner of
> the repository, can or cannot do something to the repository and decide
> what to do.

It depends on what you want your hook to do. I thought Sitaram's use-case was putting something like "git fetch upstream" into a hook that runs before upload-pack, to create a transparent proxy. That has nothing to do with the accessing user.

At GitHub, we run a pre-upload-pack hook to keep statistics. That has nothing to do with the accessing user. We have to patch git to provide the hook.

And even if you _did_ want to know something about the accessing user, that doesn't mean you necessarily can or want to be running code as them. If I'm running a smart-http server, I might have verified the user already via cookie, client cert, or basic auth. That information could be passed down to a pre-upload-pack hook where it could make a decision.

But we don't _have_ a pre-upload-pack hook, because it can be dangerous in some situations. My point is to make it available, give it safe semantics by default, and let people who are running daemon-like service (i.e., where the admin controls the daemon and arbitrary users can't write into the hooks directory) use it by setting an environment variable, rather than patching git.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 23 in “what are the chances of a 'pre-upload' hook?”
  1. Sitaram ChamartyNov 25, 2011
  2. Martin FickNov 25, 2011
  3. Martin FickNov 25, 2011
  4. Sitaram ChamartyNov 25, 2011
  5. Andreas EricssonNov 25, 2011
  6. Sitaram ChamartyNov 25, 2011
  7. Jeff KingNov 25, 2011
  8. Junio C HamanoNov 26, 2011
  9. Jeff KingNov 26, 2011
  10. Junio C HamanoNov 26, 2011
  11. Jeff KingNov 26, 2011
  12. Junio C HamanoNov 27, 2011
  13. Jeff KingNov 26, 2011
  14. Jeff KingNov 27, 2011
  15. Junio C HamanoNov 27, 2011
  16. Sitaram ChamartyNov 27, 2011
  17. Junio C HamanoNov 28, 2011
  18. Jeff KingNov 28, 2011
  19. Sitaram ChamartyNov 28, 2011
  20. Sitaram ChamartyNov 28, 2011
  21. Jeff KingNov 28, 2011
  22. Jeff KingNov 28, 2011
  23. Jeff KingNov 28, 2011

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.