Re: Feature request: include script file into function body

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Steve White" <swhite(at)aip(dot)de>
Cc: <pgsql-bugs(at)postgresql(dot)org>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Feature request: include script file into function body
Date: 2011-02-01 18:53:19
Message-ID: 4D48023F020000250003A104@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Steve White <swhite(at)aip(dot)de> wrote:
> On 1.02.11, Kevin Grittner wrote:
>> Steve White <swhite(at)aip(dot)de> wrote:

>>> Isn't the \i command a similar security hole?
>>
>> That is run by a client program on a client machine.
>
> Sorry I don't understand this remark.

The CREATE FUNCTION statement is parsed and executed on the
*server*, so implementing the feature as you describe it would
involved reading files on the database server machine. With the
security of the OS user which owns the database's data directory.
Outside of development, the client is generally (in my experience,
anyway) on another machine, or at least not running under the user
ID with rights to the PostgreSQL data directory.

It seems to me that something which let you pull the body of a
script file into the statement on the *client* side of the
connection, before sending the CREATE FUNCTION statement to the
server would not only be a lot more secure (you could only read
files that the OS would let your login read anyway), but would be
more *useful*.

> Are you saying that \i is disabled to user postgres?

I'm saying it runs on the client side of the connection to the
database, running with the rights of whatever user executed psql.

> If I understand what you're proposing: write a PostgreSQL function
> with LANGUAGE PLPYTHONU, and inside the function body load the
> file with \i. Is that it?

Well, \i inside the string literal obviously won't work. I'm saying
some logical equivalent with new syntax. Something which pulls the
file into the client software. I don't have any particularly clever
suggestions to offer for syntax.

-Kevin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Gary Doades 2011-02-01 18:55:20 Re: Feature request: include script file into function body
Previous Message Steve White 2011-02-01 18:50:04 Re: Feature request: include script file into function body