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

Re: gitosis question: identifying/logging remote user

From
Sitaram Chamarty <sitaramc@gmail.com>
Date
Jun 2, 2009, 13:19 UTC
Message-ID
<2e24e5b90906020619o1bef150k43eba2870ff4fc4e@mail.gmail.com>
In-Reply-To
<robbat2-20090602T062332-128740789Z@orbis-terrarum.net>
On Tue, Jun 2, 2009 at 12:01 PM, Robin H. Johnson <robbat2@gentoo.org> wrote:
Show 8 quoted lines
> On Tue, Jun 02, 2009 at 09:32:40AM +0530, Sitaram Chamarty wrote:
>> I want to be able to log the information that the post-receive hook
>> receives, but I *also* want, along with that, the name of the pubkey
>> that was used in this particular "push".
> I've got a partial patch that I never finished for using this with the
> gitosis-gentoo fork that powers git.overlays.gentoo.org. It needs
> re-implementation from scratch, but here's the design notes:
> 1. Use the username to open the file in keydir again.
This is the directory that contains all the *.pub files, so ok...
> 2. At the top, look for RFC822 headers with a leading "# " as padding:
>   Examples from my own patch:
>   # Full-Name: "Robin H. Johnson (robbat2)" <robbat2@gentoo.org>
>   # cia-vc-username: robbat2

Hmmm... is this a significantly different gitosis? The files in my keydir mostly contain just one line (some have two, for people who work from different machines), looking like this:

ssh-rsa [long series of base64 type characters]== some.one@company.com
Show 10 quoted lines
>   The headers are followed by a blank line then further text is free-form
>   and not parsed. Continuation lines are NOT supported.
> 3. The header field names are transformed to enviornoment variable names
>   as follows:
>   - y/[[:lower:]]/[[:upper:]]/g
>   - s/-/_/g
> 4. Export the environment variables, named per above, with the full
>   content of the rest of the line.
>
> (We need to export the CIA.vc data, and also send off a commit mail).

Nope, I'm completely lost. Perhaps I failed miserably in explaining what I want... !

----------
I'm thinking along the lines of a simple change to this:
    TEMPLATE=('command="gitosis-serve %(user)s",no-port-forwarding,'
              +'no-X11-forwarding,no-agent-forwarding,no-pty %(key)s')

(in function generateAuthorizedKeys of gitosis/ssh.py) to generate an additional ssh directive in the authorized_keys file:

    environment="REMOTEUSER=%(user)s"

I haven't tested it yet, but I'm expecting that this will pass on the name of the user (like "sitaram" in my case) as an env var so that I can do whatever I want with it in the hooks.

Thanks,
Sitaram
Previous: Robin H. JohnsonNext: Robin H. Johnson
Message 3 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.