BUG #8139: initdb: Misleading error message when current user not in /etc/passwd

Поиск
Список
Период
Сортировка
От nicolas@marchildon.net
Тема BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Дата
Msg-id E1UZk2V-0005oP-Eh@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      8139
Logged by:          Nicolas Marchildon
Email address:      nicolas@marchildon.net
PostgreSQL version: 9.2.4
Operating system:   RHEL 6
Description:        =


Running initdb while logged in as a user that has no entry in /etc/passwd,
which happens when authenticating with Kerberos, and missing sssd-client
prints a misleading error message:

"initdb: could not obtain information about current user: Success"

The misleading part is the "Success". This comes from errno:

        pw =3D getpwuid(geteuid());
        if (!pw)
        {
                fprintf(stderr,
                          _("%s: could not obtain information about current
user: %s\n"),
                                progname, strerror(errno));
                exit(1);
        }

The man page says:

RETURN VALUE
       The  getpwnam()  and  getpwuid() functions return a pointer to a
passwd
       structure, or NULL if the matching entry  is  not  found  or  an =

error
       occurs.   If an error occurs, errno is set appropriately.  If one
wants
       to check errno after the call, it should be  set  to  zero  before =

the
       call.

First, initdb's get_id function does not set errno to zero, which is a bug.
Second, when the return value is NULL, it should only print strerror(errno)
when errno !=3D 0.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: BUG #8043: 9.2.4 doesn't open WAL files from archive, only looks in pg_xlog
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #8139: initdb: Misleading error message when current user not in /etc/passwd