Обсуждение: Granting COPY FROM access

Поиск
Список
Период
Сортировка

Granting COPY FROM access

От
"Jim Cser"
Дата:

>>> Chris <dmagick@gmail.com> 07/05/06 7:49 PM >>>
> Jim Cser wrote:
> [post header corrected, sorry]
>
> I have an application that uses ODBC to access a PostGreSQL 8.0.3
> database.  To load in text files (comma separated, with column
headers),
> I use the SQL statement COPY FROM, which requires me to be a
superuser.
> I don't need full superuser access, so I would like to restrict the
> permissions to only those necessary.  The GRANT doc says that INSERT
> privilege allows COPY FROM, so as a superuser I did something like
> "GRANT INSERT ON my_database TO regular_user".
>
> Unfortunately, when I login to my_database as regular_user, I don't
> have permission to do COPY FROM.  So, my question is:  can COPY FROM
> permission be granted to a non-superuser, or is there something else
> that I missed?

>Are you trying from a file or stdin? What error message do you get
when
>you try?

>pg_dump does it like this:

>COPY table (field1, field2) FROM stdin;
>1    1
>2    2
>\.

>maybe you can use that method instead of from a file?

>See http://www.postgresql.org/docs/8.0/static/sql-copy.html in case
you
>haven't before.


As I mentioned above, I am loading CSV files, and yes, I do read
documentation. It all works just fine as a superuser, I just wanted to
know if the COPY permission is enabled with GRANT SELECT.  I'm sending
SQL statemens through ODBC, so the stdin or \copy options aren't quite
what I need.

This was the error message:
ERROR:  must be superuser to COPY to or from a file
HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command
also works for anyone.

-Jim Cser


Re: Granting COPY FROM access

От
Scott Marlowe
Дата:
On Thu, 2006-07-06 at 13:28, Jim Cser wrote:
> >>> Chris <dmagick@gmail.com> 07/05/06 7:49 PM >>>
>
> >Are you trying from a file or stdin? What error message do you get
> when
> >you try?

> As I mentioned above, I am loading CSV files, and yes, I do read
> documentation. It all works just fine as a superuser, I just wanted to
> know if the COPY permission is enabled with GRANT SELECT.  I'm sending
> SQL statemens through ODBC, so the stdin or \copy options aren't quite
> what I need.
>
> This was the error message:
> ERROR:  must be superuser to COPY to or from a file
> HINT:  Anyone can COPY to stdout or from stdin. psql's \copy command
> also works for anyone.

The problem isn't permission for copy, it permission to access files.
only the super user can access the file system through pgsql, because of
security concerns.

copy can be run by anybody.  copy from/to a FILE can only be done by the
super user.

Have you tried queueing up copy from stdin and a stream of data and \.
in ODBC?  I'm pretty sure that'll work, but I've never tried it.