Skip site navigation (1) Skip section navigation (2)

Re: security hook on table creation

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
Cc: PgSQL-Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: security hook on table creation
Date: 2010-09-28 03:57:16
Message-ID: AANLkTikLcWBBqDpD2RX9KjdJ02CGh7uG4yRSM0o1gUK-@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
2010/9/1 KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>:
> This patch allows external security providers to check privileges
> to create a new relation and to inform the security labels to be
> assigned on the new one.

Review:

I took a brief look at this patch tonight and I think it's on the
wrong track.  There's no reason for the hook function to return the
list of security labels and then have the core code turn around and
apply them to the object.  If the hook function wants to label the
object, it can just as easily call SetSecurityLabel() itself.

It seems to me that there is a general pattern to the hooks that are
needed here.  For each object type for which we wish to have MAC
integration, you need the ability to get control when the object is
created and again when the object is dropped.  You might want to deny
the operation, apply labels to the newly created object, do some
logging, or whatever.  So it strikes me that you could have a hook
function with a signature like this:

typedef void (*object_access_hook_type)(ObjectType objtype, Oid oid,
int subid, ObjectAccessType op);

...where ObjectAccessType is an enum.

Then you could do something like this:

#define InvokeObjectAccessHook(objtype, oid, subid, op) \
    if (object_access_hook != NULL) \
        object_access_hook(objtype, oid, subid, op);

Then you can sprinkle calls to that macro in strategically chosen
places to trap create, drop, comment, security label, ... whatever the
object gets manipulated in a way that something like SE-Linux is apt
to care about.  So ObjectAccessType can have values like OAT_CREATE,
OAT_DROP, OAT_COMMENT, OAT_SECURITY_LABEL, ...

I would like to mark this patch Returned with Feedback, because I
think the above suggestions are going to amount to a complete rewrite.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-09-28 03:59:35
Subject: Re: Perf regression in 2.6.32 (Ubuntu 10.04 LTS)
Previous:From: Mark KirkwoodDate: 2010-09-28 03:37:09
Subject: Re: Perf regression in 2.6.32 (Ubuntu 10.04 LTS)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group