Re: Minor changed needed to doc on untrusted pl/perl example

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Bob <luckyratfoot(at)gmail(dot)com>
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: Minor changed needed to doc on untrusted pl/perl example
Date: 2005-10-21 20:51:16
Message-ID: 20051021205116.GA9396@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Fri, Oct 21, 2005 at 01:06:05PM -0500, Bob wrote:
> CREATE FUNCTION badfunc() RETURNS integer AS $$
> open(TEMP, ">/tmp/badfile");
> print TEMP "Gotcha!\n";
> return 1;
> $$ LANGUAGE plperl;
>
> I believe the code snippet should look like this for it to work correctly:
>
> CREATE FUNCTION badfunc() RETURNS integer AS $$
> open(TEMP, ">/tmp/badfile");
> print TEMP "Gotcha!\n";
> close(TEMP);
> return 1;
> $$ LANGUAGE plperl;

The function should work without an explicit close (or it would,
but for the security check). The file should appear on disk
immediately after the open, although the data might not be flushed
to disk until the file is actually closed, such as when the calling
session's postmaster exits (that's how a plperlu version behaves
on my test system, anyway). Not that I disagree with adding an
explicit close, but the example should still "work" without it.

--
Michael Fuhr

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2005-10-24 15:38:17 Re: Will PQregisterThreadLock() be documented?
Previous Message Bob 2005-10-21 18:06:05 Minor changed needed to doc on untrusted pl/perl example