Dump problems with superusers

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Dump problems with superusers
Date: 2004-05-25 03:49:19
Message-ID: 40B2C23F.7050509@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

There are several objects in PostgreSQL that you can only create if you
are a superuser, eg. procedural languages.

If you do this, you break the dump:

1. create a superuser
2. install a language as that superuser
3. drop the superuser privs from that superuser
4. dump the database
5. attempt to restore the database

It fails because this is what gets dumped:

CREATE USER test WITH SYSID 100 NOCREATEDB NOCREATEUSER;
...
SET SESSION AUTHORIZATION 'test';

CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler
AS '$libdir/plpgsql', 'plpgsql_call_handler'
LANGUAGE c;

CREATE FUNCTION plpgsql_validator(oid) RETURNS void
AS '$libdir/plpgsql', 'plpgsql_validator'
LANGUAGE c;

SET SESSION AUTHORIZATION DEFAULT;

CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler
VALIDATOR plpgsql_validator;

Now it cannot restore the dump as the 'test' user no longer has
permissions to do so.

Chris

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2004-05-25 03:51:49 Re: New horology failure
Previous Message Tom Lane 2004-05-25 03:36:29 Re: Timezone fun (bugs and a request)