Re: AW: AW: AW: [PATCH] Re: Setuid functions

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Mark Volpe <volpe(dot)mark(at)epa(dot)gov>, "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: AW: AW: AW: [PATCH] Re: Setuid functions
Date: 2001-06-25 16:34:03
Message-ID: Pine.LNX.4.30.0106251826410.724-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Zeugswetter Andreas SB writes:

> Hmm? A non-setuid function can execute code written by another user,
> but is only allowed to do things the "invoker" has privileges for.
> Thus it is a convenience, but does not allow the invoker to do anything
> he could not type himself.
> Not so with setuid functions, that is exactly why they are handy.
> Without making the "definer" need an additional grant for creating such
> a function, it would be like giving him all the privs he has
> "with grant option".

SQL99 has an answer for this:

[11.49 GR1]

1) If R is a schema-level routine, then a privilege descriptor
is created that defines the EXECUTE privilege on R to the
<authorization identifier> that owns the schema that includes R.
The grantor for the privilege descriptor is set to the special
grantor value "_SYSTEM". This privilege is grantable if and only
if one of the following is satisfied:

a) R is an SQL routine and all of the privileges necessary
for the <authorization identifier> to successfully execute
the <SQL procedure statement> contained in the <routine
body> are grantable. The necessary privileges include the
EXECUTE privilege on every subject routine of every <routine
invocation> contained in the <SQL procedure statement>.

What this means (to me) is that unless you have grantable privileges for
all the things that your function does, you can't grant the EXECUTE
privilege to anyone.

This rule, while logical, isn't exactly pleasant, since we can hardly
evaluate statically what a function will do (shades of the halting
problem).

I think your concern is valid. Maybe we can do this:

1. The proposed commands only work in "setuid" functions (like in Unix)

2. To create a setuid function you need some privilege.

Part 2 will be a problem, but both the implementation process and the
implementation itself might terminate in finite time. ;-)

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-06-25 17:01:15 Re: [COMMITTERS] pgsql/src/bin/initdb initdb.sh
Previous Message Peter Eisentraut 2001-06-25 16:14:59 Re: AW: AW: AW: [PATCH] Re: Setuid functions

Browse pgsql-patches by date

  From Date Subject
Next Message Barry Lind 2001-06-25 17:41:31 Re: RE: [ADMIN] High memory usage [PATCH]
Previous Message Peter Eisentraut 2001-06-25 16:14:59 Re: AW: AW: AW: [PATCH] Re: Setuid functions