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

[PATCH] Add USER environment variable to executed git commands when serving

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Jun 2, 2009, 13:56 UTC
Message-ID
<20090602135659.GA4320@macbook.lan>
In-Reply-To
<2e24e5b90906012102y4e1e6281p437e4d88da517c08@mail.gmail.com>

This is useful if you want to implement access rights by branchname. The update hook can check this variable and react accordingly.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
On Tue, Jun 02, 2009 at 09:32:40AM +0530, Sitaram Chamarty wrote:
> I'd like it to set an additional env var which will contain "username"
> so that hooks etc can get that info and use it as they they see fit.

Here is a trivial patch. This is totally untested as I wanted to implement something similar but never had the time to work more on it.

cheers Heiko
 gitosis/serve.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/gitosis/serve.py b/gitosis/serve.py
index 867249e..0e2c4af 100644
--- a/gitosis/serve.py
+++ b/gitosis/serve.py
@@ -201,6 +201,7 @@ class Main(app.App):
             sys.exit(1)
 
         main_log.debug('Serving %s', newcmd)
+        os.putenv('USER', user)
         os.execvp('git', ['git', 'shell', '-c', newcmd])
         main_log.error('Cannot execute git-shell.')
         sys.exit(1)
-- 
1.6.2.1.424.g0b27.dirty
Previous: Sitaram ChamartyNext: Sitaram Chamarty
Message 6 of 11 in “gitosis question: identifying/logging remote user”
  1. Sitaram ChamartyJun 2, 2009
  2. Robin H. JohnsonJun 2, 2009
  3. Sitaram ChamartyJun 2, 2009
  4. Robin H. JohnsonJun 2, 2009
  5. Sitaram ChamartyJun 3, 2009
  6. Add USER environment variable to executed git commands when servingHeiko Voigt, Jun 2, 2009
  7. Sitaram ChamartyJun 3, 2009
  8. Sitaram ChamartyJun 3, 2009
  9. Heiko VoigtJun 3, 2009
  10. Robin H. JohnsonJun 3, 2009
  11. Shawn O. PearceJun 3, 2009

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.