From: Samuel Greenfeld <gree3776@rowan.edu>
To: " <"<pgsql-admin@postgresql.org>
Subject: Controlling user table creation
Date: Sun, 28 Jan 2001 15:23:03 -0500
Message-ID: <sa74396f.040@groupwise.rowan.edu> (raw)
( I know this is slightly OT, but since I am not a highly active SQL developer, please bear with me.)
Watching this list, I have noticed several people mutter about the fact that any user with access to a database can create a table in it. I do not know if this would work, but I would like to propose a possible workaround. Use this information at your own risk; I do not know if this would work, cause more damage than good, etc.
While I am no means an SQL wizard, one of the things I know postgres supports is the ability to create rules. At least under 7.0.2, it seems that rules can be applied to a system table, such as pg_tables. Now, I don't know if SQL rules can do things a user normally could not do. But given that I could create a rule on a pg_tables, one wonders if such a rule could be used to keep users from making tables.
The rule would go something like this (more pseudo-code than SQL code):
ON INSERT pg_tables WHERE (current_user not a superuser) AND (current_user not in allowed_tablecreator_list) DO DROP (last_table added to pg_tables);
This might not exactly work, as pg_tables might not be the last thing to know about a table being added. This also might not work if the rule is executed before pg_tables gets modified, or if rules can not modify system tables (I only tried a "DO NOTHING"). If a rule is the first thing that learns about a table operation, DO INSTEAD NOTHING might work, even in the case where a user can not modify the system tables.
Historically, I have not used rules with any of my SQL databases, so I do not know if this would work. But any insight as to what can/can not be done in this area would be useful.
Sincerely,
Samuel Greenfeld
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: gree3776@rowan.edu, "<pgsql-admin@postgresql.org
Subject: Re: Controlling user table creation
In-Reply-To: <sa74396f.040@groupwise.rowan.edu>
References: <sa74396f.040@groupwise.rowan.edu>
* 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