Thread: Warning: PostgreSQL query failed: ERROR: [my_tabel]: Permission denied in [my_php_program]

Can someone tell me why my PHP command [pg_exec ($database, $line );]
causes the "Permission denied" error.
I am trying to use PostgreSQL 7.2, PHP4, and Web-based apache user
I have focused on pg_hba.conf; -i option; and making sure that
user apache is a valid Unix user.
I have included the parts that may be helpful.

------------------------
Error Message:
octave ... INSERT INTO use VALUES ('2002-08-08', '18:04:34',
'136.183.17.43', '3222', 'Mozilla/4.72
[en] (X11; U; Linux 2.2.14-5.0 i686)' );

Warning: PostgreSQL query failed: ERROR: use: Permission denied. in
/var/www/html/octave/A2.php
on line 113

-----------------------
A2.php:  (lines 112 & 113)
       print("$dbName ... $line<p>");    /* TEST */
       pg_exec ($database, $line );

------------------------------------
pg_hba.conf:
host   all     0.0.0.0 0.0.0.0 trust
host       all         127.0.0.1     255.255.255.255    trust
local   all                     trust

------------------------------------
/etc/rc.d/init.d/postgresql:
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -o "-i"  -D $PGDATA -p
/usr/bin/postmaster start  > /dev/null 2>&1" < /dev/null

-------------------------------------
firewall off

-----------------------
Proof that apache user is authorized as a Unix user:
bash-2.05a$ psql -U apache octave
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
      \? for help on internal
       \g or terminate with semicolon to execute query
       \q to quit

-----------------------------

Thanks,
Steve Barker




Hi Steve

Does the webserver have the privileges to insert records in your
tables?
Maybe you have to grant this rights.

See the GRANT statement in the pg docs for information.

regards
Conni


Re: Warning: PostgreSQL query failed: ERROR: [my_tabel]:

From
Barker
Date:
Yes, the webserver is apache, and read/write permission is granted
as seen below.

The example below shows that the permission-denied problem happens
in the Unix mode too for the apache user, but not for the postgres
superuser.

--------------------------------------------------------
[root@linux5 octave]# psql --version
psql (PostgreSQL) 7.2.1
...

[root@linux5 octave]# psql -U apache octave
Welcome to psql, the PostgreSQL interactive terminal.
...

octave=> \z
Access privileges for database "octave"
 Table |       Access privileges
-------+--------------------------------
 form  | {=,postgres=arwdRxt,apache=rw}
 use   | {=,postgres=arwdRxt,apache=rw}
(2 rows)

octave=> INSERT INTO use VALUES ('date', 'time', 'ip', 'port', 'Mozilla'
);
ERROR:  use: Permission denied.

-------------------------------------------------------------------

Thanks for helping,
Steve Barker

On Fri, 9 Aug 2002, Cornelia Boenigk wrote:

> Hi Steve
>
> Does the webserver have the privileges to insert records in your
> tables?
> Maybe you have to grant this rights.
>
> See the GRANT statement in the pg docs for information.
>
> regards
> Conni
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


Re: Warning: PostgreSQL query failed: ERROR: [my_tabel]:

From
"Nigel J. Andrews"
Date:
On Fri, 9 Aug 2002, Barker wrote:

>
> Yes, the webserver is apache, and read/write permission is granted
> as seen below.
>
> The example below shows that the permission-denied problem happens
> in the Unix mode too for the apache user, but not for the postgres
> superuser.
>
> --------------------------------------------------------
> [root@linux5 octave]# psql --version
> psql (PostgreSQL) 7.2.1
> ...
>
> [root@linux5 octave]# psql -U apache octave
> Welcome to psql, the PostgreSQL interactive terminal.
> ...
>
> octave=> \z
> Access privileges for database "octave"
>  Table |       Access privileges
> -------+--------------------------------
>  form  | {=,postgres=arwdRxt,apache=rw}
>  use   | {=,postgres=arwdRxt,apache=rw}
> (2 rows)
>
> octave=> INSERT INTO use VALUES ('date', 'time', 'ip', 'port', 'Mozilla'
> );
> ERROR:  use: Permission denied.
>

Are you sure used GRANT correctly. I've checked on a fresh table and when I:

GRANT SELECT,INSERT ON fresh_table TO a_user;

I get \z showing:

fresh_table | {=,a_user=ar,the_creator=arwdRxt}

and a_user can happily insert.

Another possibility could be that there's a trigger doing something that is
giving rise to that error.


--
Nigel J. Andrews
Director

---
Logictree Systems Limited
Computer Consultants


Re: Warning: PostgreSQL query failed: ERROR: [my_tabel]:

From
frbn
Date:
Barker a écrit:
> Yes, the webserver is apache, and read/write permission is granted
> as seen below.
>
> The example below shows that the permission-denied problem happens
> in the Unix mode too for the apache user, but not for the postgres
> superuser.
>
> --------------------------------------------------------
> [root@linux5 octave]# psql --version
> psql (PostgreSQL) 7.2.1
> ...
>
> [root@linux5 octave]# psql -U apache octave
> Welcome to psql, the PostgreSQL interactive terminal.
> ...
>
> octave=> \z
> Access privileges for database "octave"
>  Table |       Access privileges
> -------+--------------------------------
>  form  | {=,postgres=arwdRxt,apache=rw}
>  use   | {=,postgres=arwdRxt,apache=rw}
> (2 rows)
>
> octave=> INSERT INTO use VALUES ('date', 'time', 'ip', 'port', 'Mozilla'
> );
> ERROR:  use: Permission denied.

apache needs to have the "a"ppend privilege on the table "use"

nd: "w"rite privilege is for updates/deletes