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

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

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 7, 2011, 23:42 UTC
Message-ID
<20110107234210.GB15495@burratino>
In-Reply-To
<4D234FEF.2030501@ecosensory.com>
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;
Previous: John GriessenNext: John Griessen
Message 2 of 3 in “debugging git clone via git-daemon "cannot handle daemon internally"”
  1. John GriessenJan 4, 2011
  2. Jonathan NiederJan 7, 2011
  3. John GriessenJan 8, 2011

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.