Re: BUG #2904: COPY FROM -> permisson denied

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Izsak Rudolf" <rudolf_izsak(at)yahoo(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2904: COPY FROM -> permisson denied
Date: 2007-01-19 17:35:01
Message-ID: 17049.1169228101@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Izsak Rudolf" <rudolf_izsak(at)yahoo(dot)de> writes:
> Operating system: Fedora Core 6
> Description: COPY FROM -> permisson denied

> I wanted to COPY the content of the sample data file /home/csakmost.txt to
> my data table t_crdc1 using the following command:
> exp03038=# COPY t_crdc1 FROM '/home/csakmost.txt' WITH DELIMITER ' ' NULL
> 'NULL';

> But I have got the error message:
> ERROR: could not open file "/home/csakmost.txt" for reading: Hozzfrs
> megtagadva

> I have set the permissons of the file "/home/csakmost.txt" also, so that it
> can be read by any users (both of the file and the directory). Also if I try
> to read the file as user postgres, it works:

You're getting burnt by SELinux restrictions: network-accessible daemons
such as postgresql are normally constrained to not be able to read or
write portions of the filesystem outside what they're "supposed" to be
touching, which for postgres is just /var/lib/pgsql/. This is
considered a good thing since it limits the damages if someone is able
to subvert one of those server processes.

The quick answer might be to temporarily turn off SELinux (see
"setenforce") while you load the file. A more security-aware approach
would be to modify the SELinux policy to let postgres read some
chosen directory for dropping files-to-load into.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Adriaan van Os 2007-01-19 20:45:33 Re: BUG #2906: slow windows network performance
Previous Message Adriaan van Os 2007-01-19 16:01:33 Re: BUG #2905: min and max return incorrect text type