On Mon, Dec 9, 2013 at 04:35:56PM -0500, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Updated patch attached, with centralized checking for errno and more
> > consistent behavior for username lookups.
>
> This bit is not good:
>
> + errno = 0; /* clear errno before call */
> + pw = getpwuid(geteuid());
> + if (!pw)
> + {
> + *errstr = psprintf(_("effective user id %d lookup failure: %s"),
> + (int) geteuid(), errno ? strerror(errno) :
> + _("user does not exist"));
>
> The second call of geteuid() could clobber errno before strerror can see it.
> You should compute geteuid() just once and keep it in a variable.
Good point --- fixed.
> Also, I don't think that error message meets our style guidelines.
> Maybe "failed to look up user id %d: ..." ?
OK, updated.
Updated patch attached to Alvaro's email reply.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +