threads / discuss / 26191

debugging git clone via git-daemon "cannot handle daemon internally"

Subject: debugging git clone via git-daemon "cannot handle daemon internally"

## tl;dr

3 messages between Jan 4, 2011 and Jan 8, 2011.

replies: 2people: 2as markdown or json

John Griessen· Jan 4, 2011, 16:50 UTC · lore
I have a server running debian  git-core, gitosis,  git version 1.7.2.3 and local git version 1.7.2.3.
I've uninstalled git-daemon-run from the server for testing simplicity.

The server is running this: sudo /usr/lib/git-core/git-daemon --verbose --strict-paths --user=git --group=gitosis /srv/gitosis/repositories &>git-daemon-err.log

when I try  cloning from my local machine I get these results:

john@toolbench:~/EEProjects/test$ git clone git://mail.cibolo.us/gitosis-admin.git Cloning into gitosis-admin... fatal: protocol error: bad line length character: fata

john@toolbench:~/EEProjects/test$ telnet mail.cibolo.us 9418 Trying 76.191.252.85... Connected to mail.cibolo.us. Escape character is '^]'. fatal: cannot handle daemon internally Connection closed by foreign host.

What does "cannot handle daemon internally" signify to you all? The part where telnet connects is saying the firewall is open at 9418, so that's good.

What do you think about debian's package of gitosis? It is working to push, and clone with this command: git clone gitosis@mail.cibolo.us:gitosis-admin.git but not these:

john@toolbench:~/EEProjects/test$ git clone git://mail.cibolo.us/gitosis-admin.git Cloning into gitosis-admin... fatal: protocol error: bad line length character: fata john@toolbench:~/EEProjects/test$ git clone git://mail.cibolo.us/srv/gitosis/repositories/gitosis-admin.git Cloning into gitosis-admin... fatal: protocol error: bad line length character: fata

it creates a gitosis user. Should I install gitosis from source and have a git user only?

What can I simplify to debug this?
gitweb skips this by not using port 9418, so I will be setting that up in the meantime.
thanks,
John
-- 
Ecosensory   Austin TX
Jonathan Nieder· Jan 7, 2011, 23:42 UTC · re: John Griessen · lore

Re: debugging git clone via git-daemon "cannot handle daemon internally"

John Griessen wrote:
Show 9 quoted lines
> john@toolbench:~/EEProjects/test$ telnet mail.cibolo.us 9418
> Trying 76.191.252.85...
> Connected to mail.cibolo.us.
> Escape character is '^]'.
> fatal: cannot handle daemon internally
> Connection closed by foreign host.
> 
> 
> What does "cannot handle daemon internally" signify to you all?
Progress. :)  Interesting.
The message comes from "main" in git.c:
      if (!prefixcmp(cmd, "git-")) {
            cmd += 4;
            argv[0] = cmd;
            handle_internal_command(argc, argv);
            die("cannot handle %s internally", cmd);
      }

Perhaps you have inetd set up to try to run git with argv[0] set to git-daemon? git-daemon (daemon.c) has its own "main" so it would take something of that nature to produce this symptom.

Maybe something like this would have made diagnosis easier.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/pkt-line.c b/pkt-line.c
index 295ba2b..694571d 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -121,6 +121,22 @@ static int packet_length(const char *linelen)
 	return len;
 }
 
+static void NORETURN die_bad_length(int fd, const char linelen[4])
+{
+	struct strbuf msg = STRBUF_INIT;
+	FILE *fp;
+
+	if ((memcmp(linelen, "fata", 4) &&
+	     memcmp(linelen, "erro", 4) &&
+	     memcmp(linelen, "warn", 4)) ||
+	    !(fp = fdopen(fd, "r")))
+		die("protocol error: bad line length character: %.4s", linelen);
+
+	strbuf_getline(&msg, fp, '\n');
+	die("protocol error: bad line length character: %.4s%s",
+		linelen, msg.buf);
+}
+
 int packet_read_line(int fd, char *buffer, unsigned size)
 {
 	int len;
@@ -129,7 +145,7 @@ int packet_read_line(int fd, char *buffer, unsigned size)
 	safe_read(fd, linelen, 4);
 	len = packet_length(linelen);
 	if (len < 0)
-		die("protocol error: bad line length character: %.4s", linelen);
+		die_bad_length(fd, linelen);
 	if (!len)
 		return 0;
 	len -= 4;
John Griessen· Jan 8, 2011, 02:37 UTC · re: Jonathan Nieder · lore

Re: debugging git clone via git-daemon "cannot handle daemon internally"

On 01/07/2011 05:42 PM, Jonathan Nieder wrote:
> Perhaps you have inetd set up to try to run git with argv[0] set
> to git-daemon?  git-daemon (daemon.c) has its own "main" so it
> would take something of that nature to produce this symptom.

Hmm.. My debian server has no control for inetd in /etc/init.d/ so I rebooted it to see if anything is different. I was using an inetd entry before... maybe it was still running when I did that test.

After reboot:

-------------- john@toolbench:~/FABprojects/VRBO_apt$ telnet mail.cibolo.us 9418 Trying 76.191.252.85... Connected to mail.cibolo.us. Escape character is '^]'.

Connection closed by foreign host.
-----------------

So, the symptom changed. No "cannot handle daemon internally" response. Your powers of deduction are equal to any nefarious Moriarty-like character out there it seems!

I'll test further soon.
JG
-- 
Ecosensory   Austin TX

← back to recent threads