Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-26 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > I've committed changes to add a "rolinherit" flag to pg_authid as per > discussion. The pg_has_role function now distinguishes USAGE rights > on a role (do you currently have the privileges of that role) from > MEMBER rights (do you have the ability to SET R

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-26 Thread Tom Lane
I've committed changes to add a "rolinherit" flag to pg_authid as per discussion. The pg_has_role function now distinguishes USAGE rights on a role (do you currently have the privileges of that role) from MEMBER rights (do you have the ability to SET ROLE to that role). A couple of loose ends rema

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-25 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > My understanding of things is that per spec, a SECURITY DEFINER function > can be owned by either a user or a role, and so within the function > either CURRENT_USER or CURRENT_ROLE would return the owner and the other > would return NULL. Emulating this woul

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-25 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > * Tom Lane ([EMAIL PROTECTED]) wrote: >> The problem I have with the spec's way is that it creates a disconnect >> between the privilege environment seen at the outer level and the >> environment seen within SECURITY DEFINER functions > Essentially the u

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-25 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > The problem I have with the spec's way is that it creates a disconnect > between the privilege environment seen at the outer level and the > environment seen within SECURITY DEFINER functions --- unless you want > to allow SET ROLE to have the union behavior

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-25 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > * Tom Lane ([EMAIL PROTECTED]) wrote: >> everything behaves per spec, except that I don't want to support the >> aspect of the spec that says you can SET ROLE at the outer level and >> still have the privileges of the SESSION_USER. I think SET ROLE shoul

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-25 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > [ getting back to this thread... ] Happy to, was getting worried you'd forgotten or ignored it. ;) > * rolinherit = false: role does not automatically have the privileges of > roles it is a member of. It must do SET ROLE to gain the privileges of > a role

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-25 Thread Tom Lane
[ getting back to this thread... ] Stephen Frost <[EMAIL PROTECTED]> writes: > * Tom Lane ([EMAIL PROTECTED]) wrote: >> I think a better answer is to have a "rolinherit" flag in pg_authid, >> which people can set "off" for spec compatibility or "on" for backwards >> compatibility to the GROUP feat

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-22 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > It sounds like this is essentially if 'SET ROLE all;' is allowed or not. > > If you disallow 'SET ROLE all;' (and therefore not do it on session > > start) then you would get this behaviour. I certainly see that

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-22 Thread Stephen Frost
* Stephen Frost ([EMAIL PROTECTED]) wrote: > * Tom Lane ([EMAIL PROTECTED]) wrote: > > If we don't do it that way then we have a bunch of API that breaks down: > > all of the has_foo_privilege functions stop working, because they don't > > have a signature that allows both a user and a role to be p

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-22 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > It sounds like this is essentially if 'SET ROLE all;' is allowed or not. > If you disallow 'SET ROLE all;' (and therefore not do it on session > start) then you would get this behaviour. I certainly see that as a > reasonable option though I think we'd w

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-22 Thread Stephen Frost
* Peter Eisentraut ([EMAIL PROTECTED]) wrote: > Am Donnerstag, 21. Juli 2005 22:55 schrieb Tom Lane: > > What this says is that when a role A is a member of another role B, A > > automatically has all of B's privileges. But when a user U is a member > > of role R, U does *not* have R's privileges

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-22 Thread Peter Eisentraut
Am Donnerstag, 21. Juli 2005 22:55 schrieb Tom Lane: > What this says is that when a role A is a member of another role B, A > automatically has all of B's privileges. But when a user U is a member > of role R, U does *not* have R's privileges automatically. What he has > is the right to do SET R

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > To support having certain roles turned on and certain roles turned off > > would be some additional effort. I think we'd need a list of > > 'ENABLED_ROLES' and then correct recursion based off of that list > > in

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > To support having certain roles turned on and certain roles turned off > would be some additional effort. I think we'd need a list of > 'ENABLED_ROLES' and then correct recursion based off of that list > instead of just starting from a single point like

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Stephen Frost ([EMAIL PROTECTED]) wrote: > Doing this doesn't seem entirely unreasonable but we don't currently > have a way of handling 'SET ROLE none;'. We'd need to make some changes > but I think we could handle it, and correctly handle a specific > 'SET ROLE ', which under Oracle does appe

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Yeah, let's take a look. This wouldn't be the first part of the spec > we've come across that is mostly honored in the breach... Oracle appears to mostly follow it, except there's an implicit 'SET ROLE all;', at least in the instance I'm looking at. I'm g

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > Perhaps the specification isn't but I'm pretty sure other > > implementations follow the SET ROLE -> current authorization > > identifier (and thus dropping other rights granted to the CURRENT_USER). > > My curre

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > * Tom Lane ([EMAIL PROTECTED]) wrote: >> My current reading of 4.31 is that SET ROLE *doesn't* drop rights, which >> means we need to rethink all of this. However, on this point: > Yeah, it seems to add them. Honestly, my recollection from working on >

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > Perhaps the specification isn't but I'm pretty sure other > > implementations follow the SET ROLE -> current authorization > > identifier (and thus dropping other rights granted to the CURRENT_USER). > > My curre

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > What this says is that when a role A is a member of another role B, A > automatically has all of B's privileges. But when a user U is a member > of role R, U does *not* have R's privileges automatically. What he has > is the right to do SET ROLE R, after wh

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > Sorry about the existing applications, but this does go directly against > > the SQL2003 specification. > > The spec isn't sufficiently well-designed in this area to make me > willing to insert security holes int

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > Perhaps the specification isn't but I'm pretty sure other > implementations follow the SET ROLE -> current authorization > identifier (and thus dropping other rights granted to the CURRENT_USER). My current reading of 4.31 is that SET ROLE *doesn't* drop

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Tom Lane
I wrote: > ... the implication of that is that you cannot drop any of > your "login ID"'s privileges by doing SET ROLE, which surely is not > the intended behavior (else you might as well not have SET ROLE at all; > the only possible use of SET ROLE is to *restrict* your privileges, > since any rol

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Tom Lane
Stephen Frost <[EMAIL PROTECTED]> writes: > * Tom Lane ([EMAIL PROTECTED]) wrote: >> It's possible for CURRENT_ROLE to be null according to the spec; if you >> like we could implement that as returning what the current outer-level >> SET ROLE value is (which would then make it semantically more lik

Re: [HACKERS] [PATCHES] Roles - SET ROLE Updated

2005-07-21 Thread Stephen Frost
* Tom Lane ([EMAIL PROTECTED]) wrote: > Stephen Frost <[EMAIL PROTECTED]> writes: > > * Tom Lane ([EMAIL PROTECTED]) wrote: > >> After rereading SQL99 4.31, I don't think there is any need to > >> distinguish CURRENT_USER from CURRENT_ROLE, mainly because our > >> implementation does not distinguis