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

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:50

"Shawn O. Pearce" [off-list ref] writes:
Junio C Hamano [off-list ref] wrote:
quoted
This is a step to futureproof git-daemon to accept clients that
ask for "git upload-pack" and friends, instead of using the more
traditional dash-form "git-upload-pack".  By allowing both, it
makes the client side easier to handle, as it makes "git" the only
thing necessary to be on $PATH when invoking the remote command
directly via ssh.

Signed-off-by: Junio C Hamano <redacted>
Obviously correct.  Ack.  Thanks Junio.
By the way I looked at gitosis (Tommi CC'ed).

    http://repo.or.cz/w/gitosis.git?a=blob;f=gitosis/serve.py;h=c0b7135bf45305ee1079b0dcab3b4ed1ce988aab;hb=38561aa6a51a2ef6cc04aa119481df62d213ffa4

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:

	verb, args = command.split(None, 1)

(and "verb" is looked up in the set of valid commands).  It should not be
too involved to notice verb is 'git' and then re-split the args part to
see if they are upload-pack/receive-pack, which would be the equivalent
change to this patch.  It needs to be done before the clients are
updated.

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

From: Tommi Virtanen <hidden>
Date: 2016-06-15 22:44:50

On Wed, Jun 25, 2008 at 04:26:46PM -0700, Junio C Hamano wrote:
By the way I looked at gitosis (Tommi CC'ed).

    http://repo.or.cz/w/gitosis.git?a=blob;f=gitosis/serve.py;h=c0b7135bf45305ee1079b0dcab3b4ed1ce988aab;hb=38561aa6a51a2ef6cc04aa119481df62d213ffa4

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.

-- 
:(){ :|:&};:

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

From: Olivier Marin <hidden>
Date: 2016-06-15 22:44:50

Hi,

Tommi Virtanen a écrit :
On Wed, Jun 25, 2008 at 04:26:46PM -0700, Junio C Hamano wrote:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help