Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
| От | Bruce Momjian |
|---|---|
| Тема | Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd |
| Дата | |
| Msg-id | 20131210004630.GD2119@momjian.us обсуждение исходный текст |
| Ответ на | Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd (Tom Lane <tgl@sss.pgh.pa.us>) |
| Список | pgsql-bugs |
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. +
В списке pgsql-bugs по дате отправления: