Re: Directory/File Access Permissions for COPY and Generic File Access Functions

From: Adam Brightwell <adam(dot)brightwell(at)crunchydatasolutions(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Directory/File Access Permissions for COPY and Generic File Access Functions
Date: 2014-10-29 16:36:40
Message-ID: CAKRt6CS1=QriJ8Br-Wf+xE4ZBDbZW6uSUp8dWvivqOEAC7Fwnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro,

I think it would make more sense if the file-accessing command specified
> the DIRALIAS (or DIRECTORY, whatever we end up calling this) and a
> pathname relative to the base one. Something like
>
> postgres=# CREATE DIRECTORY logdir ALIAS FOR '/pgsql/data/pg_log';

Following this, what do you think about simply expanding DIRALIAS out into
to DIRECTORY ALIAS? So instead:

CREATE DIRECTORY ALIAS <name> AS '<path>'

or...

CREATE DIRECTORY ALIAS <name> FOR '<path>'

My thought on this is towards the natural word order of the command. Also,
I think having it as CREATE DIRECTORY ALIAS minimizes confusion, as I think
Stephen mentioned, that we are creating an alias, not an actual directory.
Thoughts?

postgres=# GRANT READ ON DIRECTORY logdir TO logscanner;
>

I personally like this form the most, however, I think the greatest hurdle
with it is that it would require making READ (and WRITE) reserved
keywords. Obviously, I think that is a non-starter.

> logscanner=> COPY logtable FROM 'postgresql-2014-10-28.csv' IN DIRECTORY
> logdir;
>

That's an interesting thought. Would 'IN DIRECTORY' be restricted to just
the alias name? I'm not sure it would make sense to allow a directory path
there, as what would be the point? At any rate, just food for thought.

The ALTER ROLE GRANT READ idea proposed downthread is nice also,

Agreed and probably the most logical option at this point?

but one
> advantage of this is not having absolute path names in the COPY command.

Pardon my ignorance, but can you help me understand the advantage of not
having absolute path names in the COPY command?

-Adam

--
Adam Brightwell - adam(dot)brightwell(at)crunchydatasolutions(dot)com
Database Engineer - www.crunchydatasolutions.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2014-10-29 16:36:42 Re: Allow peer/ident to fall back to md5?
Previous Message Adam Brightwell 2014-10-29 16:36:06 Re: Directory/File Access Permissions for COPY and Generic File Access Functions