{"thread":{"id":"26191","subject":"debugging git clone via git-daemon \"cannot handle daemon internally\"","startedAt":"2011-01-04T16:50:55Z","lastAt":"2011-01-08T02:37:06Z","messageCount":3,"participants":["John Griessen","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158897","messageId":"4D234FEF.2030501@ecosensory.com","threadId":"26191","inReplyTo":null,"subject":"debugging git clone via git-daemon \"cannot handle daemon internally\"","fromName":"John Griessen","fromEmail":"john@ecosensory.com","sentAt":"2011-01-04T16:50:55Z","receivedAt":"2011-01-04T16:50:55Z","isPatch":false,"sender":{"key":"john@ecosensory.com","avatar":"https://gravatar.com/avatar/2716764948580f078b30fc52ca8d23f4c30516df18f2e9867bd97ef49fe6e0c2?d=mp&s=160"},"body":"I have a server running debian  git-core, gitosis,  git version 1.7.2.3 and local git version 1.7.2.3.\n\nI've uninstalled git-daemon-run from the server for testing simplicity.\n\nThe server is running this:\nsudo /usr/lib/git-core/git-daemon --verbose --strict-paths --user=git --group=gitosis /srv/gitosis/repositories  &>git-daemon-err.log\n\nwhen I try  cloning from my local machine I get these results:\n\njohn@toolbench:~/EEProjects/test$ git clone git://mail.cibolo.us/gitosis-admin.git\nCloning into gitosis-admin...\nfatal: protocol error: bad line length character: fata\n\n\n\njohn@toolbench:~/EEProjects/test$ telnet mail.cibolo.us 9418\nTrying 76.191.252.85...\nConnected to mail.cibolo.us.\nEscape character is '^]'.\nfatal: cannot handle daemon internally\nConnection closed by foreign host.\n\n\nWhat does \"cannot handle daemon internally\" signify to you all?\nThe part where telnet connects is saying the firewall is open at 9418, so that's good.\n\nWhat do you think about debian's package of gitosis?  It is working to push,\nand clone with this command:\ngit clone gitosis@mail.cibolo.us:gitosis-admin.git\nbut not these:\n\njohn@toolbench:~/EEProjects/test$ git clone git://mail.cibolo.us/gitosis-admin.git\nCloning into gitosis-admin...\nfatal: protocol error: bad line length character: fata\njohn@toolbench:~/EEProjects/test$ git clone git://mail.cibolo.us/srv/gitosis/repositories/gitosis-admin.git\nCloning into gitosis-admin...\nfatal: protocol error: bad line length character: fata\n\nit creates a gitosis user.\nShould I install gitosis from source and have a git user only?\n\nWhat can I simplify to debug this?\n\ngitweb skips this by not using port 9418, so I will be setting that up in the meantime.\n\nthanks,\n\nJohn\n\n-- \nEcosensory   Austin TX\n"},{"id":"159181","messageId":"20110107234210.GB15495@burratino","threadId":"26191","inReplyTo":"4D234FEF.2030501@ecosensory.com","subject":"Re: debugging git clone via git-daemon \"cannot handle daemon internally\"","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-01-07T23:42:10Z","receivedAt":"2011-01-07T23:42:10Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"John Griessen wrote:\n\n> john@toolbench:~/EEProjects/test$ telnet mail.cibolo.us 9418\n> Trying 76.191.252.85...\n> Connected to mail.cibolo.us.\n> Escape character is '^]'.\n> fatal: cannot handle daemon internally\n> Connection closed by foreign host.\n> \n> \n> What does \"cannot handle daemon internally\" signify to you all?\n\nProgress. :)  Interesting.\n\nThe message comes from \"main\" in git.c:\n\n      if (!prefixcmp(cmd, \"git-\")) {\n            cmd += 4;\n            argv[0] = cmd;\n            handle_internal_command(argc, argv);\n            die(\"cannot handle %s internally\", cmd);\n      }\n\nPerhaps you have inetd set up to try to run git with argv[0] set\nto git-daemon?  git-daemon (daemon.c) has its own \"main\" so it\nwould take something of that nature to produce this symptom.\n\nMaybe something like this would have made diagnosis easier.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\ndiff --git a/pkt-line.c b/pkt-line.c\nindex 295ba2b..694571d 100644\n--- a/pkt-line.c\n+++ b/pkt-line.c\n@@ -121,6 +121,22 @@ static int packet_length(const char *linelen)\n \treturn len;\n }\n \n+static void NORETURN die_bad_length(int fd, const char linelen[4])\n+{\n+\tstruct strbuf msg = STRBUF_INIT;\n+\tFILE *fp;\n+\n+\tif ((memcmp(linelen, \"fata\", 4) &&\n+\t     memcmp(linelen, \"erro\", 4) &&\n+\t     memcmp(linelen, \"warn\", 4)) ||\n+\t    !(fp = fdopen(fd, \"r\")))\n+\t\tdie(\"protocol error: bad line length character: %.4s\", linelen);\n+\n+\tstrbuf_getline(&msg, fp, '\\n');\n+\tdie(\"protocol error: bad line length character: %.4s%s\",\n+\t\tlinelen, msg.buf);\n+}\n+\n int packet_read_line(int fd, char *buffer, unsigned size)\n {\n \tint len;\n@@ -129,7 +145,7 @@ int packet_read_line(int fd, char *buffer, unsigned size)\n \tsafe_read(fd, linelen, 4);\n \tlen = packet_length(linelen);\n \tif (len < 0)\n-\t\tdie(\"protocol error: bad line length character: %.4s\", linelen);\n+\t\tdie_bad_length(fd, linelen);\n \tif (!len)\n \t\treturn 0;\n \tlen -= 4;\n"},{"id":"159196","messageId":"4D27CDD2.2050101@ecosensory.com","threadId":"26191","inReplyTo":"20110107234210.GB15495@burratino","subject":"Re: debugging git clone via git-daemon \"cannot handle daemon internally\"","fromName":"John Griessen","fromEmail":"john@ecosensory.com","sentAt":"2011-01-08T02:37:06Z","receivedAt":"2011-01-08T02:37:06Z","isPatch":false,"sender":{"key":"john@ecosensory.com","avatar":"https://gravatar.com/avatar/2716764948580f078b30fc52ca8d23f4c30516df18f2e9867bd97ef49fe6e0c2?d=mp&s=160"},"body":"On 01/07/2011 05:42 PM, Jonathan Nieder wrote:\n> Perhaps you have inetd set up to try to run git with argv[0] set\n> to git-daemon?  git-daemon (daemon.c) has its own \"main\" so it\n> would take something of that nature to produce this symptom.\n\n\nHmm..   My debian server has no control for inetd in /etc/init.d/\nso I rebooted it to see if anything is different.  I was using an\ninetd entry before...  maybe it was still running when I did that test.\n\nAfter reboot:\n\n--------------\njohn@toolbench:~/FABprojects/VRBO_apt$ telnet mail.cibolo.us 9418\nTrying 76.191.252.85...\nConnected to mail.cibolo.us.\nEscape character is '^]'.\n\n\nConnection closed by foreign host.\n\n-----------------\n\nSo, the symptom changed.  No \"cannot handle daemon internally\" response.\nYour powers of deduction are equal to any nefarious Moriarty-like character\nout there it seems!\n\nI'll test further soon.\n\nJG\n\n-- \nEcosensory   Austin TX\n"}]}