{"thread":{"id":"34026","subject":"git-daemon: needs /root/.config/git/config?","startedAt":"2013-06-04T14:13:14Z","lastAt":"2013-06-10T12:06:53Z","messageCount":12,"participants":["Ian Kumlien","Jeff King","Johannes Sixt","Jonathan Nieder","Junio C Hamano","Andreas Krey","Bernhard R. Link"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"219371","messageId":"20130604141314.GD22308@pomac.netswarm.net","threadId":"34026","inReplyTo":null,"subject":"git-daemon: needs /root/.config/git/config?","fromName":"Ian Kumlien","fromEmail":"pomac@vapor.com","sentAt":"2013-06-04T14:13:14Z","receivedAt":"2013-06-04T14:13:14Z","isPatch":false,"sender":{"key":"pomac@vapor.com","avatar":null},"body":"Hi again, \n\nDue to the earlier problem I upgraded git on all machines \nand eneded up with a ubunut machine running in to problems.\n\nI started getting errors like:\n\"fatal: protocol error: bad line length character: fata\"\n\nWhich after some head scratching caused me to tell xinetd to directly\nlaunch git-daemon, eventually it worked fine, but i did get this error\nmessage:\n\nJun  4 16:12:05 xyz git-daemon[10246]: unable to access\n'/root/.config/git/config': Permission denied\n\nIt's not the first time i've seen it but i've been able to ignore it\nbefore. This is running as a local user (as in not root) and this user\nshouldn't have access to /root. But i eventually had to do chown o+x\n/root to workaround this error.\n\nNow, this must be wrong somehow? Or does --user work in inetd mode now?\n\nSo... comments, ideas?\n"},{"id":"219375","messageId":"20130604160815.GB15953@sigill.intra.peff.net","threadId":"34026","inReplyTo":"20130604141314.GD22308@pomac.netswarm.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-06-04T16:08:15Z","receivedAt":"2013-06-04T16:08:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jun 04, 2013 at 04:13:14PM +0200, Ian Kumlien wrote:\n\n> Due to the earlier problem I upgraded git on all machines \n> and eneded up with a ubunut machine running in to problems.\n> \n> I started getting errors like:\n> \"fatal: protocol error: bad line length character: fata\"\n> \n> Which after some head scratching caused me to tell xinetd to directly\n> launch git-daemon, eventually it worked fine, but i did get this error\n> message:\n\nLooks like your stderr was being redirected to your stdout; this\nparticular error aside, that is likely to cause weird protocol problems\nfor any error that git outputs.\n\n> Jun  4 16:12:05 xyz git-daemon[10246]: unable to access\n> '/root/.config/git/config': Permission denied\n> \n> It's not the first time i've seen it but i've been able to ignore it\n> before. This is running as a local user (as in not root) and this user\n> shouldn't have access to /root. But i eventually had to do chown o+x\n> /root to workaround this error.\n\nThe problem is that you have presumably dropped privileges in the daemon\ninstance, but your $HOME environment variable still points to /root. Git\ncannot read all of its config files (nor even find out if they exist),\nso it bails rather than continue.\n\nOlder versions of git silently ignored errors reading config files, but\nit was tightened in v1.8.1.1, as there can be quite serious implications\nto failing to read expected config (e.g., imagine transfer.fsckobjects,\nor receive.deny* is ignored).\n\nHowever, since changing user id and leaving $HOME is so common, there is\na patch under consideration to loosen the check only for the case of\nEACCES on files in $HOME. That commit is 4698c8f (config: allow\ninaccessible configuration under $HOME, 2013-04-12); it's not yet in any\nreleased version of git, though.\n\nIn the meantime, the suggested workaround is to set $HOME for the\ngit-daemon user, rather than loosening /root.\n\n-Peff\n"},{"id":"219396","messageId":"51AE3A88.2080203@kdbg.org","threadId":"34026","inReplyTo":"20130604160815.GB15953@sigill.intra.peff.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2013-06-04T19:05:44Z","receivedAt":"2013-06-04T19:05:44Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 04.06.2013 18:08, schrieb Jeff King:\n> Older versions of git silently ignored errors reading config files, but\n> it was tightened in v1.8.1.1, as there can be quite serious implications\n> to failing to read expected config (e.g., imagine transfer.fsckobjects,\n> or receive.deny* is ignored).\n> \n> However, since changing user id and leaving $HOME is so common, there is\n> a patch under consideration to loosen the check only for the case of\n> EACCES on files in $HOME. That commit is 4698c8f (config: allow\n> inaccessible configuration under $HOME, 2013-04-12); it's not yet in any\n> released version of git, though.\n> \n> In the meantime, the suggested workaround is to set $HOME for the\n> git-daemon user, rather than loosening /root.\n\nI've a PHP script in ~/public_html that runs git. Without the mentioned\npatch, the script bails out due to this error. This time it's Apache\nthat gets me into trouble because at the time the PHP script and git\nrun, $HOME is still /root, but the user identity is not root anymore.\nThe patch is direly needed; without it, I need to use 'env\nHOME=/home/j6t /usr/local/bin/git' in my script.\n\n-- Hannes\n"},{"id":"219398","messageId":"20130604191025.GG28153@google.com","threadId":"34026","inReplyTo":"51AE3A88.2080203@kdbg.org","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-06-04T19:10:25Z","receivedAt":"2013-06-04T19:10:25Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Johannes Sixt wrote:\n> Am 04.06.2013 18:08, schrieb Jeff King:\n\n>> However, since changing user id and leaving $HOME is so common, there is\n>> a patch under consideration to loosen the check only for the case of\n>> EACCES on files in $HOME. That commit is 4698c8f (config: allow\n>> inaccessible configuration under $HOME, 2013-04-12); it's not yet in any\n>> released version of git, though.\n[...]\n> I've a PHP script in ~/public_html that runs git. Without the mentioned\n> patch, the script bails out due to this error. This time it's Apache\n> that gets me into trouble because at the time the PHP script and git\n> run, $HOME is still /root, but the user identity is not root anymore.\n> The patch is direly needed; without it, I need to use 'env\n> HOME=/home/j6t /usr/local/bin/git' in my script.\n\nI could be remembering wrong, but I thought it was not so much \"under\nconsideration\" as \"accepted for 1.8.4\".  I haven't heard any\ncompelling reasons not to apply it.\n\nWould it would make sense against earlier releases as well?\n\nThanks,\nJonathan\n"},{"id":"219400","messageId":"7vehch7kdo.fsf@alter.siamese.dyndns.org","threadId":"34026","inReplyTo":"20130604191025.GG28153@google.com","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-04T19:20:51Z","receivedAt":"2013-06-04T19:20:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> I could be remembering wrong, but I thought it was not so much \"under\n> consideration\" as \"accepted for 1.8.4\".  I haven't heard any\n> compelling reasons not to apply it.\n>\n> Would it would make sense against earlier releases as well?\n\nTrue; the patch is queued on a topic that forks from maint-1.8.2\nexactly for this reason.\n"},{"id":"219405","messageId":"20130604210600.GA3271@sigill.intra.peff.net","threadId":"34026","inReplyTo":"20130604191025.GG28153@google.com","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-06-04T21:06:00Z","receivedAt":"2013-06-04T21:06:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jun 04, 2013 at 12:10:25PM -0700, Jonathan Nieder wrote:\n\n> >> However, since changing user id and leaving $HOME is so common, there is\n> >> a patch under consideration to loosen the check only for the case of\n> >> EACCES on files in $HOME. That commit is 4698c8f (config: allow\n> >> inaccessible configuration under $HOME, 2013-04-12); it's not yet in any\n> >> released version of git, though.\n> [...]\n> > I've a PHP script in ~/public_html that runs git. Without the mentioned\n> > patch, the script bails out due to this error. This time it's Apache\n> > that gets me into trouble because at the time the PHP script and git\n> > run, $HOME is still /root, but the user identity is not root anymore.\n> > The patch is direly needed; without it, I need to use 'env\n> > HOME=/home/j6t /usr/local/bin/git' in my script.\n> \n> I could be remembering wrong, but I thought it was not so much \"under\n> consideration\" as \"accepted for 1.8.4\".  I haven't heard any\n> compelling reasons not to apply it.\n> \n> Would it would make sense against earlier releases as well?\n\nYeah, I think it would. I only said \"under consideration\" because I saw\nthat it was in \"next\" and not elsewhere, and did not hunt down the exact\nstatus in \"What's Cooking\".\n\n-Peff\n"},{"id":"219414","messageId":"7vk3m9603f.fsf@alter.siamese.dyndns.org","threadId":"34026","inReplyTo":"20130604210600.GA3271@sigill.intra.peff.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-04T21:24:20Z","receivedAt":"2013-06-04T21:24:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Jun 04, 2013 at 12:10:25PM -0700, Jonathan Nieder wrote:\n>\n>> >> However, since changing user id and leaving $HOME is so common, there is\n>> >> a patch under consideration to loosen the check only for the case of\n>> >> EACCES on files in $HOME. That commit is 4698c8f (config: allow\n>> >> inaccessible configuration under $HOME, 2013-04-12); it's not yet in any\n>> >> released version of git, though.\n>> [...]\n>> > I've a PHP script in ~/public_html that runs git. Without the mentioned\n>> > patch, the script bails out due to this error. This time it's Apache\n>> > that gets me into trouble because at the time the PHP script and git\n>> > run, $HOME is still /root, but the user identity is not root anymore.\n>> > The patch is direly needed; without it, I need to use 'env\n>> > HOME=/home/j6t /usr/local/bin/git' in my script.\n>> \n>> I could be remembering wrong, but I thought it was not so much \"under\n>> consideration\" as \"accepted for 1.8.4\".  I haven't heard any\n>> compelling reasons not to apply it.\n>> \n>> Would it would make sense against earlier releases as well?\n>\n> Yeah, I think it would. I only said \"under consideration\" because I saw\n> that it was in \"next\" and not elsewhere, and did not hunt down the exact\n> status in \"What's Cooking\".\n\nSorry about that; it is in 'master' but \"What's cooking\" for that\npushout hasn't been published yet (the description of what I did\nyesterday will be rolled into today's issue together with the\ndescription of what I did today at the end of day).\n"},{"id":"219449","messageId":"20130605111918.GE22308@pomac.netswarm.net","threadId":"34026","inReplyTo":"20130604160815.GB15953@sigill.intra.peff.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Ian Kumlien","fromEmail":"pomac@vapor.com","sentAt":"2013-06-05T11:19:18Z","receivedAt":"2013-06-05T11:19:18Z","isPatch":false,"sender":{"key":"pomac@vapor.com","avatar":null},"body":"On Tue, Jun 04, 2013 at 12:08:15PM -0400, Jeff King wrote:\n> On Tue, Jun 04, 2013 at 04:13:14PM +0200, Ian Kumlien wrote:\n> \n> > Due to the earlier problem I upgraded git on all machines \n> > and eneded up with a ubunut machine running in to problems.\n> > \n> > I started getting errors like:\n> > \"fatal: protocol error: bad line length character: fata\"\n> > \n> > Which after some head scratching caused me to tell xinetd to directly\n> > launch git-daemon, eventually it worked fine, but i did get this error\n> > message:\n> \n> Looks like your stderr was being redirected to your stdout; this\n> particular error aside, that is likely to cause weird protocol problems\n> for any error that git outputs.\n\nYeah =)\n\n> > Jun  4 16:12:05 xyz git-daemon[10246]: unable to access\n> > '/root/.config/git/config': Permission denied\n> > \n> > It's not the first time i've seen it but i've been able to ignore it\n> > before. This is running as a local user (as in not root) and this user\n> > shouldn't have access to /root. But i eventually had to do chown o+x\n> > /root to workaround this error.\n> \n> The problem is that you have presumably dropped privileges in the daemon\n> instance, but your $HOME environment variable still points to /root. Git\n> cannot read all of its config files (nor even find out if they exist),\n> so it bails rather than continue.\n\nYeah, assumed =P\n\n> Older versions of git silently ignored errors reading config files, but\n> it was tightened in v1.8.1.1, as there can be quite serious implications\n> to failing to read expected config (e.g., imagine transfer.fsckobjects,\n> or receive.deny* is ignored).\n\nYes, i agree, it's suboptimal but I for one would use getpwuid to get\nthe home directory of the executing user to avoid this - though i don't\nknow how portable it is (or if there is any other issues)\n\nIt's a bit hard to control this with xinetd doing it behind the\nscenes... \n\n> However, since changing user id and leaving $HOME is so common, there is\n> a patch under consideration to loosen the check only for the case of\n> EACCES on files in $HOME. That commit is 4698c8f (config: allow\n> inaccessible configuration under $HOME, 2013-04-12); it's not yet in any\n> released version of git, though.\n\nAh, ok, thanks, I'll have a look - maybe i can actually contribute\nsomething for once =)\n\n> In the meantime, the suggested workaround is to set $HOME for the\n> git-daemon user, rather than loosening /root.\n\nWell, I have no idea of how to control HOME in xinetd - access to the\nmachine is limited and x doesn't give that much access (nothing really\nimportant is actually stored in /root)\n\nFor now, this is the workaround we have =P\n\n> -Peff\n"},{"id":"219450","messageId":"20130605114359.GA1675@inner.h.apk.li","threadId":"34026","inReplyTo":"20130605111918.GE22308@pomac.netswarm.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2013-06-05T11:43:59Z","receivedAt":"2013-06-05T11:43:59Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"On Wed, 05 Jun 2013 13:19:18 +0000, Ian Kumlien wrote:\n...\n> Well, I have no idea of how to control HOME in xinetd - access to the\n> machine is limited and x doesn't give that much access (nothing really\n> important is actually stored in /root)\n\nMake xinetd execute '/usr/bin/env HOME=/home/yourstruly git ...'\ninstead of 'git ...'.\n\nAndreas\n\n-- \n\"Totally trivial. Famous last words.\"\nFrom: Linus Torvalds <torvalds@*.org>\nDate: Fri, 22 Jan 2010 07:29:21 -0800\n"},{"id":"219456","messageId":"20130605154344.GA8664@sigill.intra.peff.net","threadId":"34026","inReplyTo":"20130605111918.GE22308@pomac.netswarm.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-06-05T15:43:45Z","receivedAt":"2013-06-05T15:43:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jun 05, 2013 at 01:19:18PM +0200, Ian Kumlien wrote:\n\n> > Older versions of git silently ignored errors reading config files, but\n> > it was tightened in v1.8.1.1, as there can be quite serious implications\n> > to failing to read expected config (e.g., imagine transfer.fsckobjects,\n> > or receive.deny* is ignored).\n> \n> Yes, i agree, it's suboptimal but I for one would use getpwuid to get\n> the home directory of the executing user to avoid this - though i don't\n> know how portable it is (or if there is any other issues)\n\nWe considered having git-daemon's \"--user\" option do that, but:\n\n  1. It would be a regression for people who are intentionally setting\n     HOME to get different config profiles. And it would be a surprise\n     to admins, as other user-switching daemons (e.g., inetd) do not\n     tweak HOME.\n\n  2. It would not have covered all cases, including yours. xinetd is the\n     one doing the user-switching here.\n\n-Peff\n"},{"id":"219958","messageId":"20130609124757.GA3347@client.brlink.eu","threadId":"34026","inReplyTo":"20130605111918.GE22308@pomac.netswarm.net","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Bernhard R. Link","fromEmail":"brl+git@mail.brlink.eu","sentAt":"2013-06-09T12:47:57Z","receivedAt":"2013-06-09T12:47:57Z","isPatch":false,"sender":{"key":"brl+git@mail.brlink.eu","avatar":null},"body":"* Ian Kumlien <pomac@vapor.com> [130605 13:31]:\n> Yes, i agree, it's suboptimal but I for one would use getpwuid to get\n> the home directory of the executing user to avoid this - though i don't\n> know how portable it is (or if there is any other issues)\n\nIt's not only suboptimal but simply wrong. getpwuid gives at best the\ninitial home directory, and even there it is only a guess. (If you are\nlooking for some home directory of a different user it might be a good\nguess). But using getpwuid(getuid())->pw_dir if HOME is set is a serious\nmistake, as you throw out the good value for some almost but not quite\ntotally unrelated value.\n\n        Bernhard R. Link\n"},{"id":"220276","messageId":"20130610120653.GA14168@pomac.netswarm.net","threadId":"34026","inReplyTo":"20130609124757.GA3347@client.brlink.eu","subject":"Re: git-daemon: needs /root/.config/git/config?","fromName":"Ian Kumlien","fromEmail":"pomac@vapor.com","sentAt":"2013-06-10T12:06:53Z","receivedAt":"2013-06-10T12:06:53Z","isPatch":false,"sender":{"key":"pomac@vapor.com","avatar":null},"body":"On Sun, Jun 09, 2013 at 02:47:57PM +0200, Bernhard R. Link wrote:\n> * Ian Kumlien <pomac@vapor.com> [130605 13:31]:\n> > Yes, i agree, it's suboptimal but I for one would use getpwuid to get\n> > the home directory of the executing user to avoid this - though i don't\n> > know how portable it is (or if there is any other issues)\n> \n> It's not only suboptimal but simply wrong. getpwuid gives at best the\n> initial home directory, and even there it is only a guess. (If you are\n> looking for some home directory of a different user it might be a good\n> guess). But using getpwuid(getuid())->pw_dir if HOME is set is a serious\n> mistake, as you throw out the good value for some almost but not quite\n> totally unrelated value.\n\nWell i never intended for it to replace the environment variable, it was\nmore intended as a fallback - if there will be a \"less strict\" mode then\nperhaps a fallback would be a more controled way of doing it.\n\n>         Bernhard R. Link\n"}]}