Re: a trigger that sends an email - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: a trigger that sends an email
Date
Msg-id 27815.955043564@sss.pgh.pa.us
Whole thread Raw
In response to Re: a trigger that sends an email  ("Moray McConnachie" <moray.mcconnachie@computing-services.oxford.ac.uk>)
List pgsql-interfaces
"Moray McConnachie" <moray.mcconnachie@computing-services.oxford.ac.uk> writes:
>> programming languages we offer are "trusted", which means you can't do
>> anything that would affect files or programs outside the database.
>> Sending email is right out.

> Could one do a rule that used a dummy function, where the function called
> the Perl routine which generates the email?

If it's in plperl then it's going to be running in a "safe" interpreter,
which should mean that you won't be able to do anything to send mail.

> CREATE RULE emailer AS ON INSERT TO new_accounts
>     DO SELECT new_account_email_function(NEW.emailaddress);

> or something like that? Or is this subject to the same restrictions?

Wouldn't be much of a security system if it were that easy to get
around, would it?

The problem here is that anything done by the backend is done with the
full permissions of user postgres (or whatever the backend is running
as).  So we don't want ordinary users to have access to programming
languages that will allow them to muck around with postgres' files.
The only way to escape the restrictions is to write a C-language
extension.  That has to be installed by the database admin, and we
expect him to exercise some caution in what he will install...
        regards, tom lane


pgsql-interfaces by date:

Previous
From: "Moray McConnachie"
Date:
Subject: Re: a trigger that sends an email
Next
From: Craig Orsinger
Date:
Subject: Re: a trigger that sends an email