install failure if user postgres already exists and group postgres is missing

Bug #162606 reported by parvez
6
Affects Status Importance Assigned to Milestone
postgresql-common (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

Binary package hint: postgresql-common

Hi
I was trying to install postgresql-8.2 on an AMD64 bit machine on Ubutnu 7.04. But its broken in the middle of installation. The following is the output:

~# apt-get install postgresql-8.2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  postgresql-common
Suggested packages:
  oidentd ident-server
The following NEW packages will be installed
  postgresql-8.2 postgresql-common
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
Need to get 0B/3798kB of archives.
After unpacking 18.6MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Preconfiguring packages ...
Selecting previously deselected package postgresql-common.
(Reading database ... 113340 files and directories currently installed.)
Unpacking postgresql-common (from .../postgresql-common_73_all.deb) ...
Selecting previously deselected package postgresql-8.2.
Unpacking postgresql-8.2 (from .../postgresql-8.2_8.2.5-0ubuntu0.7.04.1_amd64.deb) ...
Setting up postgresql-common (73) ...
chown: `postgres:postgres': invalid group
dpkg: error processing postgresql-common (--configure):
 subprocess post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of postgresql-8.2:
 postgresql-8.2 depends on postgresql-common (>= 63); however:
  Package postgresql-common is not configured yet.
dpkg: error processing postgresql-8.2 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 postgresql-common
 postgresql-8.2
E: Sub-process /usr/bin/dpkg returned an error code (1)

Thanks for your valuable time

Revision history for this message
parvez (golam-parvez) wrote :

For some useful information:
I am using NIS services for sharing account information. When postinstallation script of postgresql-common is running the following command

"if ! getent passwd postgres > /dev/null"

its giving the wrong information. So the following command is not executing properly

 adduser --system --quiet --home /var/lib/postgresql --no-create-home \
            --shell /bin/bash --group --gecos "PostgreSQL administrator" postgres

I already had user postgres in the shadowpassword. So the following command is giving the user id which is right

~# id -u postgres
1004

but postgres user is not assign to group postgres. Besically there was no group called postgres. So when postgresql-common installation script is checking for group id its getting wrong value. The following command is not getting the right value

~# id -g postgres
100

These commands are besically giving a totaly wrong output to the postgresql-common installation.
if [ "`id -g postgres`" -eq 0 ]; then
        echo "The postgres system user must not have root as primary group.
Please fix this and reinstall this package." >&2
        exit 1
    fi

Because of that the following command is not executing

` chown postgres:postgres /var/lib/postgresql`

and giving an error exit status 1 and which stopping the script to execute. As a result the whole installation is breaking down.

My other packages are depend on postgresql-8.2 package. So if it does not installed all other breakdown. So I hope you will do something about it. Possible add something to the script to overcome this situation. I will be very grateful to you if you solve this problem. Thanks

Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote :

Thanks for taking time reporting this bug.
I set the importance for this bug to Medium because there is a workaround (see answer #17811 - https://answers.launchpad.net/ubuntu/+question/17811).

Changed in postgresql-common:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

So, did I understand this correctly? User postgres already existed, but group postgres didn't? adduser will not create the group only in this case.

I could create the group separately, but usually this situation means that you have a half-broken installation already. If you use NIS authentication, then you should have both users and groups in nis, not just users. Will 'addgroup postgresql' create the group in NIS for you or just locally?

Changed in postgresql-common:
status: Confirmed → Incomplete
Revision history for this message
parvez (golam-parvez) wrote :

If the groups does not exits in nis or in any where, I think it should create the groups in locally.

Martin Pitt (pitti)
Changed in postgresql-common:
status: Incomplete → Triaged
Revision history for this message
Martin Pitt (pitti) wrote :

Since as you reported, "id -g postgres" already gives "100", testing for the group would succeed, and thus even explicitly creating the group wouldn't be done. I think you should just fix your NIS setup to be consistent. Working around those problems will only aggravate the problem by creating a wild mix of local and NIS groups amongst machines, leading to broken file permissions.

Changed in postgresql-common:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.