Package: postgresql-7.4
Version: 1:7.4.8-4
Severity: normal

pg_ctrlcluster get the postmaster uid and gid from the cluster.
It was 31:32 when i created it.

I had deleted and recreated the postgres account to update it
(you removed its shell and maybe other things so not to miss any
part i used the postinst adduser command to recreate it).
The new uid/gid where (fake ones) 122:122.

Thus running the postgresql-7.4 init script fired pg_ctrcluster
which retrieved the old uid/gid from the cluster (31:32) and
changed the process uid/gid to match the cluster one before
calling pg_ctl. 
pg_ctl was running with an inexistant account. This leads to this
error:

 * Starting PostgreSQL 7.4 database server: main
/usr/lib/postgresql/7.4/bin/pg_id: Success
/usr/lib/postgresql/7.4/bin/pg_ctl: line 114: [: -eq: unary operator expected


the problem is that in pg_id code, l.105:
        if (!pw)
        {
                perror(argv[0]);
                exit(1);
        }

perror returns pg_id program name and success as (!pw) is true
and no other errors happened.

And in pg_ctl , l.114 :
if [ `$PGPATH/pg_id -u` -eq 0 ]
then
    echo "$CMDNAME: cannot be run as root" 1>&2
(...)


here `$PGPATH/pg_id -u` is not a integer anymore but ".../pg_id:
Success".


A quick hack to let it work would be to use:
if $PGPATH/pg_id -u;
then
    echo "$CMDNAME: cannot be run as root" 1>&2

though it would be better if it errors in case the cluster is in
fact owned by "no account". I though about:

uid=$( $PGPATH/pg_id -u 2>/dev/null);
$status=$?

if [ $status -eq 0 ]
then
    if [ $uid -eq 0 ];
    then
      echo "$CMDNAME: cannot be run as root" 1>&2
      (...)
      exit 1
    fi
else
  echo "This user does not exists . You may have changed the uid
of the account used to create this database cluster. You should
dump, drop and reinit a the cluster."
fi



This is a matter of talks as i wonder if pg_id should not return
the uid even if the account does not exists. 
  uid=31(invalid user) 
and let us manage the error in pg_ctl as we wish.


Maybe all this is too much for a special case which may not
appear often as the problem never arise as far as i searched for
this error. Please close this bug if you think so.

Regards
Alban




-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-rc5usb-serial
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=UTF-8)

Versions of packages postgresql-7.4 depends on:
ii  libc6               2.3.5-1              GNU C Library: Shared libraries an
ii  libcomerr2          1.37+1.38-WIP-0509-1 common error description library
ii  libkrb53            1.3.6-3              MIT Kerberos runtime libraries
ii  libpam0g            0.76-22              Pluggable Authentication Modules l
ii  libpq3              1:7.4.8-4            PostgreSQL C client library
ii  libreadline4        4.3-15               GNU readline and history libraries
ii  libssl0.9.7         0.9.7g-1             SSL shared libraries
ii  postgresql-client-7 1:7.4.8-4            front-end programs for PostgreSQL 
ii  postgresql-common   12                   manager for PostgreSQL database cl
ii  zlib1g              1:1.2.2-4            compression library - runtime

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to