pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Chad R. Larson <chad@DCFinc.com>
Cc: C. Bensend <benny@bennyvision.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Multiple Servers
Date: Tue, 21 Aug 2001 09:35:41 -0400
Message-ID: <28937.998400941@sss.pgh.pa.us> (raw)
In-Reply-To: <4.2.2.20010820220921.00a55ac0@smtp.eldocomp.com>
References: <27213.998361211@sss.pgh.pa.us>
	<4.2.2.20010820220921.00a55ac0@smtp.eldocomp.com>

"Chad R. Larson" <chad@DCFinc.com> writes:
> So, create a database for the user as the user, but deny him the ability to 
> create databases or users.

This is actually a tad easier said than done, since the only way we
provide to create a database owned by a user is to create it *as* that
user.  (CREATE DATABASE probably ought to have an OWNER option available
only to superusers, now that I think about it.)  So you have two
possible approaches:

1. create user with createdb option, become user, create his database,
become superuser again, ALTER USER user NOCREATEDB.

2. create user without createdb option, create his database (as
yourself), then alter pg_database to make him the owner:

	update pg_database set datdba =
	(select usesysid from pg_shadow where usename = 'foo')
	where datname = 'foo';

> Then he can dick with his own database to his heart's desire, but that 
> would be his only sandbox.

You'll probably also want to ensure that each user can only connect to
his own database.  The 'sameuser' option in pg_hba.conf will help here.
Don't forget to leave an escape hatch for the superuser (ie, you) to
connect to anything.

			regards, tom lane



view thread (16+ messages)  latest in thread

Message-ID: <28937.998400941@sss.pgh.pa.us>
Permalink:  ../28937.998400941@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28937.998400941@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, chad@DCFinc.com, benny@bennyvision.com
  Subject: Re: Multiple Servers
  In-Reply-To: <28937.998400941@sss.pgh.pa.us>
  References: <27213.998361211@sss.pgh.pa.us> <4.2.2.20010820220921.00a55ac0@smtp.eldocomp.com> <28937.998400941@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox