Subject: Re: [PATCH] daemon: accept "git program" as well

From: Olivier Marin <[email-masked]>
Date: Fri, 27 Jun 2008 01:38:20 +0200

Hi,

Tommi Virtanen a écrit :
> On Wed, Jun 25, 2008 at 04:26:46PM -0700, Junio C Hamano wrote:
>>
>> In gitosis/serve.py, there are COMMANDS_READONLY and COMMANDS_WRITE array
>> that holds 'git-upload-pack' and 'git-receive-pack' commands, and they are
>> compared with user commands after doing:
> 
> Yeah, that's pretty much a trivial change, doing it now to future-proof
> gitosis.
> 

This just happened to me with a dashless client, so I tried your patch but it
does not work. The problem comes from git-shell that do not support dashless
argument, yet (IOW: git shell -c 'git upload-pack ...' give an error).

The following patch on top of yours fix the problem. The s/git-shell/git shell/
part is not really necessary, but why not?

diff --git a/gitosis/serve.py b/gitosis/serve.py
index 9a91fcb..5aac355 100644
--- a/gitosis/serve.py
+++ b/gitosis/serve.py
@@ -21,12 +21,10 @@ ALLOW_RE = re.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-z
 
 COMMANDS_READONLY = [
     'git-upload-pack',
-    'git upload-pack',
     ]
 
 COMMANDS_WRITE = [
     'git-receive-pack',
-    'git receive-pack',
     ]
 
 class ServingError(Exception):
@@ -75,7 +73,7 @@ def serve(
             # all known "git foo" commands take one argument; improve
             # if/when needed
             raise UnknownCommandError()
-        verb = '%s %s' % (verb, subverb)
+        verb = '%s-%s' % (verb, subverb)
 
     if (verb not in COMMANDS_WRITE
         and verb not in COMMANDS_READONLY):
@@ -201,6 +199,6 @@ class Main(app.App):
             sys.exit(1)
 
         main_log.debug('Serving %s', newcmd)
-        os.execvp('git-shell', ['git-shell', '-c', newcmd])
-        main_log.error('Cannot execute git-shell.')
+        os.execvp('git', ['git', 'shell', '-c', newcmd])
+        main_log.error('Cannot execute git.')
         sys.exit(1)

Olivier.