Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 4769 - Postgresql install and init broken
Summary: Postgresql install and init broken
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Ryan Phillips (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-09 16:32 UTC by Andy Dustman
Modified: 2007-09-22 22:36 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
User and initial database creation (postgresql.ebuild.diff,1.42 KB, patch)
2002-07-10 16:08 UTC, Andy Dustman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Dustman 2002-07-09 16:32:28 UTC
In postgresql-7.2.1-r1 (yes, I unmasked this), pkg_preinst() adds the postgres
user with a /bin/true shell. Later on, pkg_config() uses su - postgres -c ... to
configure the package. Since the shell is /bin/true, nothing (useful) happens.
Similar comments apply to the startup script, /etc/init.d/postgresql.

Short-Term Workaround: Give postgres user a real shell (/bin/sh).

Long-Term Solution: Use setuidguid from daemontools instead of su, i.e. in
pkg_config():

    setuidgid postgres /usr/bin/initdb --pgdata /var/lib/postgresql/data

# /space/gentoo/cvsroot/gentoo-x86/dev-db/postgresql/postgresql-7.2.1.ebuild,v
1.2 2002/06/17 04:05:39 rphillips Exp
Comment 1 Andy Dustman 2002-07-09 17:07:59 UTC
The init script is probably ok, I think I had a old init script from an older
version of postgresql. I am testing now.

Also... pkg_preinst() tests for the non-existence of the user and group
postgresql, and then tries to add the user and group postgres. This causes
it to fail if the postgres user already exists.
Comment 2 Andy Dustman 2002-07-09 17:32:37 UTC
OK, the init script problem is due to files/7.2.1/postgresql not existing.
I copied files/7.2/postgresql to files/7.2.1/postgresql and the init script
works fine. It uses start-stop-daemon.

There is still the issue of setting up the initial database in pkg_config():
I have verified that daemontools setuidgid works fine for this. You do not
need to run daemontools' svscan for this to work.

Also, changing the test in pkg_preinst() to look for the postgres user/group
instead of postgresql fixes that problem.

If you want, I'll churn out a patch.
Comment 3 Ryan Phillips (RETIRED) gentoo-dev 2002-07-10 13:02:21 UTC
andy: does the new postgres ebuild fix this problem?
Comment 4 Andy Dustman 2002-07-10 15:46:36 UTC
I don't see how. It still uses /bin/true for the shell for the postgres user and
then uses su - postgres -c "/usr/bin/initdb --pgdata /var/lib/postgresql/data" in
pkg_config(), so all that will do is run /bin/true as postgres.

It is also (in revision 1.5) still doing this:

 pkg_preinst() {
	if ! groupmod postgresql ; then
		groupadd -g 70 postgres || die "problem adding group postgres"
	fi

	if ! id postgresql; then
		useradd -g postgres -s /dev/null -d /var/lib/postgresql -c "postgres" postgres
		assert "problem adding user postgres"
	fi
}

Note that it is testing the wrong user/group.

Also pkg_install() does this:

	exeinto /etc/init.d/
	doexe ${FILESDIR}/${PV}/${PN}

However, files/7.2.1/postgresql doesn't exist.

Finally there a bogus RCS (non-)tag in the ebuild:

# /space/gentoo/cvsroot/gentoo-x86/dev-db/postgresql/postgresql-7.2.1.ebuild,v
1.2 2002/06/17 04:05:39 rphillips Exp

Probably should be replaced with:

# $Header$
Comment 5 Andy Dustman 2002-07-10 16:08:26 UTC
Created attachment 2129 [details, diff]
User and initial database creation

This fixes the user/group creation problem and initial database creation
(adds RDEPENDS on daemontools). There are still some missing files,
particularly
the init script, and some ${P}-build.xml file.
Comment 6 Robert Blyler 2002-07-14 21:05:04 UTC
I'm not sure if this is related, but my last postgres install didn't create an
initscript in /etc/init.d. Maybe this should be a separate issue.
Comment 7 Ryan Phillips (RETIRED) gentoo-dev 2002-07-15 22:44:27 UTC
this should be fixed now... waiting confirmation.
Comment 8 Andy Dustman 2002-07-19 16:53:52 UTC
Yeah, looks good.