pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Controlling user table creation
2+ messages / 2 participants
[nested] [flat]

* Controlling user table creation
@ 2001-01-28 20:23  Samuel Greenfeld <gree3776@rowan.edu>
  0 siblings, 1 reply; 2+ messages in thread

From: Samuel Greenfeld @ 2001-01-28 20:23 UTC (permalink / raw)
  To: " <"<pgsql-admin@postgresql.org>


( 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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Controlling user table creation
@ 2001-01-28 20:48  Peter Eisentraut <peter_e@gmx.net>
  parent: Samuel Greenfeld <gree3776@rowan.edu>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2001-01-28 20:48 UTC (permalink / raw)
  To: Samuel Greenfeld <gree3776@rowan.edu>; +Cc: " <" <pgsql-admin@postgresql.org>

Samuel Greenfeld writes:

>    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.

It couldn't, because the CREATE TABLE code does not go through the rule
system.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-01-28 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-28 20:23 Controlling user table creation Samuel Greenfeld <gree3776@rowan.edu>
2001-01-28 20:48 ` Peter Eisentraut <peter_e@gmx.net>

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