This protocol has never been designed for pushing. Attempts to push
over git:// usually result in
fatal: The remote end hung up unexpectedly
That message does not really point out the reason. With this patch, we get
error: this protocol does not support pushing
error: failed to push some refs to 'git://some-host.com/my/repo'
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
I wanted to advise using remote.*.pushurl too, more friendly. But then I
had to detect if url comes from command line or config, and I gave up.
transport.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
On Sat, Oct 01, 2011 at 11:26:55AM +1000, Nguyễn Thái Ngọc Duy wrote:
This protocol has never been designed for pushing. Attempts to push
over git:// usually result in
fatal: The remote end hung up unexpectedly
That message does not really point out the reason. With this patch, we get
error: this protocol does not support pushing
error: failed to push some refs to 'git://some-host.com/my/repo'
What about sticking code to return an error to git daemon instead of this?
Here's what happens if I try to push to one of repos on this computer
over git://:
$ git push git://localhost/foobar
fatal: remote error: W access for foobar DENIED to anonymous
So send-pack can deal with ERR packet (and yes, that error message
is really from Gitolite).
Aside: git archive seemingly can't deal with ERR packets. And worse
yet, it doesn't even print what it received, resulting this:
$ git archive --remote=git://localhost/foobar HEAD
fatal: git archive: protocol error
-Ilari
What about sticking code to return an error to git daemon instead of this?
Here's what happens if I try to push to one of repos on this computer
over git://:
$ git push git://localhost/foobar
fatal: remote error: W access for foobar DENIED to anonymous
So send-pack can deal with ERR packet (and yes, that error message
is really from Gitolite).
I'm dealing with git.gnome.org and not sure what's the server behind.
I had a look at git-daemon and it does allow push, but disabled by
default. So yes, maybe updating git-daemon is better.
Aside: git archive seemingly can't deal with ERR packets. And worse
yet, it doesn't even print what it received, resulting this:
$ git archive --remote=git://localhost/foobar HEAD
fatal: git archive: protocol error
Yes, builtin/archive.c seems only recognize either ACK or NACK.
pack-protocol.txt does not mention about ERR either, which seems to be
introduced in a807328 (connect.c: add a way for git-daemon to pass an
error back to client).
--
Duy
From: Jeff King <hidden> Date: 2016-06-15 22:52:09
On Sat, Oct 01, 2011 at 11:26:55AM +1000, Nguyen Thai Ngoc Duy wrote:
This protocol has never been designed for pushing. Attempts to push
over git:// usually result in
fatal: The remote end hung up unexpectedly
That message does not really point out the reason. With this patch, we get
error: this protocol does not support pushing
error: failed to push some refs to 'git://some-host.com/my/repo'
I thought pushing over git:// _is_ supported. It's just that most
servers don't have it turned on, for the obvious lack-of-authentication
reasons.
See 4b3b1e1 (git-push through git protocol, 2007-01-21), and the
discussion here:
http://thread.gmane.org/gmane.comp.version-control.git/37325
Your patch shuts it off at the client level, so even with it turned on
for the server, the client can never get to it.
I still think push-over-git:// is a bit insane, and especially now with
smart-http, you'd be crazy to run it. And in that sense, I wouldn't mind
seeing it deprecated. But just shutting it off without a deprecation
period seems unnecessarily harsh.
The real problem here seems to be that instead of communicating "no, we
don't support that", git-daemon just hangs up. It would be a much nicer
fix if we could change that. I'm not sure it's possible, though. There's
not much room in the beginning of the room to make that communication in
a way that's backwards compatible.
-Peff
From: Johannes Sixt <hidden> Date: 2016-06-15 22:52:09
Am 10/3/2011 9:42, schrieb Jeff King:
I still think push-over-git:// is a bit insane, and especially now with
smart-http, you'd be crazy to run it. And in that sense, I wouldn't mind
seeing it deprecated.
You must be kidding ;) It is so much easier to type
git daemon --export-all --enable=receive-pack
for a one-shot, temporary git connection compared to setting up a
smart-http, ssh, or even a rsh server.
-- Hannes
Tests aside, are there any problems with the patch? I don't see any
followup discussions. Personally I don't see much value in adding the
description though.
--
Duy
From: Jeff King <hidden> Date: 2016-06-15 22:52:09
On Mon, Oct 03, 2011 at 10:44:23AM +0200, Johannes Sixt wrote:
Am 10/3/2011 9:42, schrieb Jeff King:
quoted
I still think push-over-git:// is a bit insane, and especially now with
smart-http, you'd be crazy to run it. And in that sense, I wouldn't mind
seeing it deprecated.
You must be kidding ;) It is so much easier to type
git daemon --export-all --enable=receive-pack
for a one-shot, temporary git connection compared to setting up a
smart-http, ssh, or even a rsh server.
Ah, yeah, I didn't think about one-shot invocations like that (I think
the original motivation was somebody actually running it all the time).
So yeah, that makes it even worse for the client to start refusing this
without even contacting the server. I forgot that we added the "ERR"
response way back in a807328 (connect.c: add a way for git-daemon to
pass an error back to client, 2008-11-01).
GitHub uses it to make nice messages:
$ git push origin
fatal: remote error:
You can't push to git://github.com/gitster/git.git
Use git@github.com:gitster/git.git
We should maybe do something like the patch below:
@@ -255,6 +255,7 @@ static int run_service(char *dir, struct daemon_service *service)loginfo("Request %s for '%s'",service->name,dir);if(!enabled&&!service->overridable){+packet_write(1,"ERR %s: service not enabled",service->name);logerror("'%s': service not enabled.",service->name);errno=EACCES;return-1;
@@ -288,6 +289,8 @@ static int run_service(char *dir, struct daemon_service *service)enabled=service_enabled;}if(!enabled){+packet_write(1,"ERR %s: service not enabled for '%s'",+service->name,path);logerror("'%s': service not enabled for '%s'",service->name,path);errno=EACCES;
but:
1. There is some information leakage there. In particular, one can
tell the difference now between "repo does not exist" and
"receive-pack is not turned on". Personally, I think the tradeoff
to have actual error messages is worth it. HTTP has had real error
codes for decades, and I don't think anybody is too up-in-arms that
I can probe which pages are 404, and which are 401.
2. It probably makes sense to have a more human-friendly error
message.
3. It may be worth adding error messages for lots of other conditions
(e.g., no such repo). Assuming we accept the information leakage
for (1).
-Peff
So yeah, that makes it even worse for the client to start refusing this
without even contacting the server. I forgot that we added the "ERR"
response way back in a807328 (connect.c: add a way for git-daemon to
pass an error back to client, 2008-11-01).
GitHub uses it to make nice messages:
$ git push origin
fatal: remote error:
You can't push to git://github.com/gitster/git.git
Use git@github.com:gitster/git.git
We should maybe do something like the patch below:
but:
1. There is some information leakage there. In particular, one can
tell the difference now between "repo does not exist" and
"receive-pack is not turned on". Personally, I think the tradeoff
to have actual error messages is worth it. HTTP has had real error
codes for decades, and I don't think anybody is too up-in-arms that
I can probe which pages are 404, and which are 401.
To me, just "<service>: access denied" is enough. Not particularly
friendly but should be a good enough clue.
--
Duy
From: Jeff King <hidden> Date: 2016-06-15 22:52:09
On Mon, Oct 03, 2011 at 08:44:22PM +1100, Nguyen Thai Ngoc Duy wrote:
quoted
GitHub uses it to make nice messages:
$ git push origin
fatal: remote error:
You can't push to git://github.com/gitster/git.git
Use git@github.com:gitster/git.git
We should maybe do something like the patch below:
Yeah, I was just reading that. Sorry, I should have read the rest of the
thread more carefully. :)
quoted
1. There is some information leakage there. In particular, one can
tell the difference now between "repo does not exist" and
"receive-pack is not turned on". Personally, I think the tradeoff
to have actual error messages is worth it. HTTP has had real error
codes for decades, and I don't think anybody is too up-in-arms that
I can probe which pages are 404, and which are 401.
To me, just "<service>: access denied" is enough. Not particularly
friendly but should be a good enough clue.
Yeah, maybe. Certainly it's better than "the remote end hung up
unexpectedly".
However, the leakage is still there. You would get "the remote hung up"
for no-such-repo, and "access denied" for this. Or were you just
proposing that _all_ errors give "access denied". Certainly it's better
than just hanging up, too, and there is no leakage there.
It might be nice to default to that, and let sites easily enable
friendlier messages, though.
-Peff
From: Jakub Narebski <hidden> Date: 2016-06-15 22:52:09
Johannes Sixt [off-list ref] writes:
Am 10/3/2011 9:42, schrieb Jeff King:
quoted
I still think push-over-git:// is a bit insane, and especially now with
smart-http, you'd be crazy to run it. And in that sense, I wouldn't mind
seeing it deprecated.
You must be kidding ;) It is so much easier to type
git daemon --export-all --enable=receive-pack
for a one-shot, temporary git connection compared to setting up a
smart-http, ssh, or even a rsh server.
I wonder if that is the case... but 48% responders of "Git User's
Survey 2011" (3424 out of 7100 responders who answered queston
"23) How do you publish/propagate your changes?") answered that they
use push via git protocol.
See https://www.survs.com/results/Q5CA9SKQ/P7DE07F0PL
--
Jakub Narębski
On Mon, Oct 3, 2011 at 8:47 PM, Jeff King [off-list ref] wrote:
quoted
To me, just "<service>: access denied" is enough. Not particularly
friendly but should be a good enough clue.
Yeah, maybe. Certainly it's better than "the remote end hung up
unexpectedly".
However, the leakage is still there. You would get "the remote hung up"
for no-such-repo, and "access denied" for this. Or were you just
proposing that _all_ errors give "access denied". Certainly it's better
than just hanging up, too, and there is no leakage there.
All of them. At least it's good to know my request has reached (and
rejected by) the server, not dropped on the floor by some random
firewall along the line.
It might be nice to default to that, and let sites easily enable
friendlier messages, though.
I'm thinking of passing "verbose" option back to server to get more
helpful messages, the option would be turned off by default. It's up
to admin to decide (would be actually helpful during deployment test,
for example). Or is it possible already?
--
Duy
From: Jeff King <hidden> Date: 2016-06-15 22:52:09
On Mon, Oct 03, 2011 at 02:49:15AM -0700, Jakub Narebski wrote:
I wonder if that is the case... but 48% responders of "Git User's
Survey 2011" (3424 out of 7100 responders who answered queston
"23) How do you publish/propagate your changes?") answered that they
use push via git protocol.
See https://www.survs.com/results/Q5CA9SKQ/P7DE07F0PL
I refuse to believe that 48% of people are using git:// to push. Surely
they are interpreting that response to overlap with "git over ssh" and
"git over http".
-Peff
On Mon, Oct 03, 2011 at 03:42:51AM -0400, Jeff King wrote:
On Sat, Oct 01, 2011 at 11:26:55AM +1000, Nguyen Thai Ngoc Duy wrote:
The real problem here seems to be that instead of communicating "no, we
don't support that", git-daemon just hangs up. It would be a much nicer
fix if we could change that. I'm not sure it's possible, though. There's
not much room in the beginning of the room to make that communication in
a way that's backwards compatible.
Oh, sure it is possible (except for remote snapshot):
$ /usr/bin/git fetch git://localhost/foobar
fatal: remote error: R access for foobar DENIED to anonymous
$ /usr/bin/git push git://localhost/foobar
fatal: remote error: W access for foobar DENIED to anonymous
$ /usr/bin/git archive --remote=git://localhost/foobar HEAD
fatal: git archive: protocol error
$ /usr/bin/git --version
git version 1.7.6.3
Supported for fetch and push since 1.6.1-rc1 (And 1.6.1 was over
2.5 years ago). Oh, and even before that, but with slightly more
ugly error message.
Oh, and adding interpretation of ERR packets to git archive is easy
(and I even happen to have git:// server that can send those to
test against):
$ git archive --remote=git://localhost/foobar HEAD
fatal: remote error: R access for foobar DENIED to anonymous
(I also tested that remote snapshotting of repository that should be
readable succeeds, it does).
--- >8 ----
From ce3a402e4fa72cf603f92801d6f021ff89d3ac35 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <redacted>
Date: Mon, 3 Oct 2011 13:55:37 +0300
Subject: [PATCH] Support ERR in remote archive like in fetch/push
Make ERR as first packet of remote snapshot reply work like it does in
fetch/push. Lets servers decline remote snapshot with message the same
way as declining fetch/push with a message.
Signed-off-by: Ilari Liusvaara <redacted>
---
builtin/archive.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:52:09
Nguyen Thai Ngoc Duy wrote:
To me, just "<service>: access denied" is enough. Not particularly
friendly but should be a good enough clue.
Yes, I think you're right. It also has the benefit of being easily
parsable, so some day the client might learn to give a friendly
message in the operator's chosen language.
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:52:09
Ilari Liusvaara wrote:
Oh, and adding interpretation of ERR packets to git archive is easy
(and I even happen to have git:// server that can send those to
test against):
$ git archive --remote=git://localhost/foobar HEAD
fatal: remote error: R access for foobar DENIED to anonymous
(I also tested that remote snapshotting of repository that should be
readable succeeds, it does).
Sounds like a good idea to me. Let's see what René thinks; also
changing the subject line to attract other reviewers.
quoted hunk
--- >8 ----
From: Ilari Liusvaara <redacted>
Date: Mon, 3 Oct 2011 13:55:37 +0300
Subject: [PATCH] Support ERR in remote archive like in fetch/push
Make ERR as first packet of remote snapshot reply work like it does in
fetch/push. Lets servers decline remote snapshot with message the same
way as declining fetch/push with a message.
Signed-off-by: Ilari Liusvaara <redacted>
---
builtin/archive.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
From: René Scharfe <hidden> Date: 2016-06-15 22:52:09
Am 03.10.2011 13:26, schrieb Jonathan Nieder:
Ilari Liusvaara wrote:
quoted
Oh, and adding interpretation of ERR packets to git archive is easy
(and I even happen to have git:// server that can send those to
test against):
$ git archive --remote=git://localhost/foobar HEAD
fatal: remote error: R access for foobar DENIED to anonymous
(I also tested that remote snapshotting of repository that should be
readable succeeds, it does).
Sounds like a good idea to me. Let's see what René thinks; also
changing the subject line to attract other reviewers.
Looks good to me, but I'm not too familiar with the remote protocol.
quoted
--- >8 ----
From: Ilari Liusvaara <redacted>
Date: Mon, 3 Oct 2011 13:55:37 +0300
Subject: [PATCH] Support ERR in remote archive like in fetch/push
Make ERR as first packet of remote snapshot reply work like it does in
fetch/push. Lets servers decline remote snapshot with message the same
way as declining fetch/push with a message.
Signed-off-by: Ilari Liusvaara <redacted>
---
builtin/archive.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
On Mon, Oct 03, 2011 at 02:01:59PM +0300, Ilari Liusvaara wrote:
quoted hunk
On Mon, Oct 03, 2011 at 03:42:51AM -0400, Jeff King wrote:
quoted
On Sat, Oct 01, 2011 at 11:26:55AM +1000, Nguyen Thai Ngoc Duy wrote:
The real problem here seems to be that instead of communicating "no, we
don't support that", git-daemon just hangs up. It would be a much nicer
fix if we could change that. I'm not sure it's possible, though. There's
not much room in the beginning of the room to make that communication in
a way that's backwards compatible.
Oh, sure it is possible (except for remote snapshot):
$ /usr/bin/git fetch git://localhost/foobar
fatal: remote error: R access for foobar DENIED to anonymous
$ /usr/bin/git push git://localhost/foobar
fatal: remote error: W access for foobar DENIED to anonymous
$ /usr/bin/git archive --remote=git://localhost/foobar HEAD
fatal: git archive: protocol error
$ /usr/bin/git --version
git version 1.7.6.3
Supported for fetch and push since 1.6.1-rc1 (And 1.6.1 was over
2.5 years ago). Oh, and even before that, but with slightly more
ugly error message.
Oh, and adding interpretation of ERR packets to git archive is easy
(and I even happen to have git:// server that can send those to
test against):
$ git archive --remote=git://localhost/foobar HEAD
fatal: remote error: R access for foobar DENIED to anonymous
(I also tested that remote snapshotting of repository that should be
readable succeeds, it does).
--- >8 ----
From ce3a402e4fa72cf603f92801d6f021ff89d3ac35 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <redacted>
Date: Mon, 3 Oct 2011 13:55:37 +0300
Subject: [PATCH] Support ERR in remote archive like in fetch/push
Make ERR as first packet of remote snapshot reply work like it does in
fetch/push. Lets servers decline remote snapshot with message the same
way as declining fetch/push with a message.
Signed-off-by: Ilari Liusvaara <redacted>
Yeah, maybe with this patch also?
-- 8< --
Subject: [PATCH] pack-protocol: document "ERR" line
Since a807328 (connect.c: add a way for git-daemon to pass an error
back to client), git client recognizes "ERR" line and prints a
friendly message to user if an error happens at server side.
Document this.
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
Documentation/technical/pack-protocol.txt | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
@@ -60,6 +60,13 @@ process on the server side over the Git protocol is this: "0039git-upload-pack /schacon/gitbook.git\0host=example.com\0" | nc -v example.com 9418+If the server refuses the request for some reasons, it could abort+gracefully with an error message.++----+ error-line = PKT-LINE("ERR" SP explanation-text)+----+ SSH Transport -------------
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
Note that if a service fails, then "access denied" is printed too.
Not sure if it's a good thing, the service in question may have
responded to user already. On the other hand, this catches faults
from start_command() in run_service_command().
daemon.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:52:10
Nguyễn Thái Ngọc Duy wrote:
quoted hunk
--- a/daemon.c+++ b/daemon.c
@@ -562,7 +562,10 @@ static int execute(void)*Note:Thedirectoryhereisprobablycontextsensitive,*andmightdependontheactualservicebeingperformed.*/-returnrun_service(line+namelen+5,s);+if(!run_service(line+namelen+5,s))+return0;+packet_write(1,"ERR %s: access denied",line+namelen+5);+return-1;}
At first I liked the simplification relative to the patch I sent.
This means the error message is shown when
1. the service is not enabled at all
2. path not allowed (for example because it doesn't exist, because
of permission problems, or because it is blacklisted)
3. the repository is not exported
4. the service is not enabled for $path
5. the service command exited with nonzero status
Unfortunately I think that last case (#5) would be confusing and would
break protocol, especially when the command dies at an inconvenient
moment. Better for the service command to send an appropriate error
indicator and to just hang up when it fails to do so.