From: Frank Finner <postgresql@finner.de>
To: Todd Lewis <lewis-todd@comcast.net>
Cc: pgsql-php@postgresql.org
Subject: Re: How to create a new Table in prostgresql from a
Date: Sat, 2 Oct 2004 11:46:07 +0200
Message-ID: <20041002114607.1ed2e9b4.postgresql@finner.de> (raw)
In-Reply-To: <41210DDD.11261.C76F7FC@localhost>
References: <20040816171128.GD25345@freenet.de>
<41210DDD.11261.C76F7FC@localhost>
On Mon, 16 Aug 2004 19:41:17 -0500 "Todd Lewis" <lewis-todd@comcast.net> sat
down, thought long and then wrote:
> Just a followup question.
>
> I'm fairly new to using PHP and pg. Security wise how could I limit a request
> such as this? I'm assuming that if you have given a PHP user the ability to
> create tables, the user also has the ability to truncate and delete tables as
> well.
>
A database user has not much in common with a PHP user (or a UNIX- or other
system user). The tables will be created with the database user you have
connected with (if you use authentication other than trust or ident, see
pg_hba.conf for details).
So if you create tables within PHP, you create them as the connecting database
user, and of course the creator may destroy them as well.
But if you have a database, in which the tables are owned by user A and you
connect with user B, user B may create tables owned by himself, but usually may
not drop tables owned by user A, if he has not explicitly been granted so.
What I do is: I have a database, in which all tables are owned by user A (a
superuser) and user B (the PHP connecting user) has the right to read, write,
update the tables, so he can work with them. But user B is not able to drop a
table of user A. User B, however, is allowed to create and drop his own tables,
if he likes.
If you connect every PHP user as a different database user, no database user is
able (if not explicitly granted) to drop other users“ tables. If not granted so,
he is not even able to touch them (he could see their existence, however).
Regards,
--
Frank Finner
Memory follows memory, memory defeats memory; some things are banished
only into the realms of our rich imaginings - but this does not mean
that they do not or cannot or will not exist - they exist! They exist!
(M. Moorcock, "The Revenge Of The Rose")
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-php@postgresql.org
Cc: postgresql@finner.de, lewis-todd@comcast.net
Subject: Re: How to create a new Table in prostgresql from a
In-Reply-To: <20041002114607.1ed2e9b4.postgresql@finner.de>
References: <20040816171128.GD25345@freenet.de> <41210DDD.11261.C76F7FC@localhost> <20041002114607.1ed2e9b4.postgresql@finner.de>
* 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