From: Ian Kumlien Date: Mon, 10 Jun 2013 12:06:53 GMT Subject: Re: git-daemon: needs /root/.config/git/config? Message-ID: <20130610120653.GA14168@pomac.netswarm.net> In-Reply-To: <20130609124757.GA3347@client.brlink.eu> On Sun, Jun 09, 2013 at 02:47:57PM +0200, Bernhard R. Link wrote: > * Ian Kumlien [130605 13:31]: > > Yes, i agree, it's suboptimal but I for one would use getpwuid to get > > the home directory of the executing user to avoid this - though i don't > > know how portable it is (or if there is any other issues) > > It's not only suboptimal but simply wrong. getpwuid gives at best the > initial home directory, and even there it is only a guess. (If you are > looking for some home directory of a different user it might be a good > guess). But using getpwuid(getuid())->pw_dir if HOME is set is a serious > mistake, as you throw out the good value for some almost but not quite > totally unrelated value. Well i never intended for it to replace the environment variable, it was more intended as a fallback - if there will be a "less strict" mode then perhaps a fallback would be a more controled way of doing it. > Bernhard R. Link