pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@gmail.com>
To: Jose Antonio Quintana/UPC <jose.antonio.quintana@upc.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Reading from file without superuser privilege
Date: Thu, 21 Mar 2013 06:40:41 -0700
Message-ID: <514B0DD9.7050204@gmail.com> (raw)
In-Reply-To: <OFC1078845.59515B29-ONC1257B35.00403BAC-C1257B35.00405D6A@upc.edu>
References: <OFC1078845.59515B29-ONC1257B35.00403BAC-C1257B35.00405D6A@upc.edu>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On 03/21/2013 04:43 AM, Jose Antonio Quintana/UPC wrote:
> I need to read from a file in order to update a table.
>
> The manual says that it is necessary to have the superuser privilege to
> read from a file.
>
> Is it possible to read files without this privilege?

What sort of file, any file or one you want to do a COPY or \copy from?

For any file you would need to use one of the untrusted languages, 
plpythonu for example. They need to be installed by a superuser. It is 
possible to create a function in an untrusted language as the superuser 
and then confer the superuser privileges to other users for that 
function by using SECURITY DEFINER, see here:

http://www.postgresql.org/docs/9.2/interactive/sql-createfunction.html

For COPY :
"The file must be accessible to the server and the name must be 
specified from the viewpoint of the server. "


http://www.postgresql.org/docs/9.2/interactive/sql-copy.html

For \copy:
"This is an operation that runs an SQL COPY command, but instead of the 
server reading or writing the specified file, psql reads or writes the 
file and routes the data between the server and the local file system. 
This means that file accessibility and privileges are those of the local 
user, not the server, and no SQL superuser privileges are required."

http://www.postgresql.org/docs/9.2/interactive/app-psql.html

>
> Thanks.
>
>
> _______________________________________________
> José Antonio Quintana Romero
> Unitat de Projectes
> Vicegerència de Desenvolupament Organitzatiu i Personal
> Edifici Vèrtex. Planta 3
> Pl. Eusebi Güell, 6
> 08034 - Barcelona


-- 
Adrian Klaver
adrian.klaver@gmail.com


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (2+ messages)

Message-ID: <514B0DD9.7050204@gmail.com>
Permalink:  ../514B0DD9.7050204@gmail.com/
Also on:    postgresql.org/message-id/514B0DD9.7050204@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@gmail.com, jose.antonio.quintana@upc.edu
  Subject: Re: Reading from file without superuser privilege
  In-Reply-To: <514B0DD9.7050204@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox