From owner-freebsd-questions Sat Jun 5 18:37:49 1999 Delivered-To: freebsd-questions@freebsd.org Received: from thelab.hub.org (nat193.72.mpoweredpc.net [142.177.193.72]) by hub.freebsd.org (Postfix) with ESMTP id 61A8214FE4 for ; Sat, 5 Jun 1999 18:37:46 -0700 (PDT) (envelope-from scrappy@hub.org) Received: from localhost (scrappy@localhost) by thelab.hub.org (8.9.3/8.9.1) with ESMTP id WAA29748; Sat, 5 Jun 1999 22:38:03 -0300 (ADT) (envelope-from scrappy@hub.org) X-Authentication-Warning: thelab.hub.org: scrappy owned process doing -bs Date: Sat, 5 Jun 1999 22:38:03 -0300 (ADT) From: The Hermit Hacker To: Jim Freeze Cc: pgsql-novice@postgreSQL.org, freebsd-questions@FreeBSD.ORG Subject: Re: PostgreSQL query has permission denied error In-Reply-To: <000a01beaf74$88f55840$e06ec8d0@lexmark.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Using the psql command, connect to your database and look at who has permissions to read from it ( /z lists rights to the tables) ... You want to create a user called 'nobody', with rights to the database. To create the user, su to pgsql account and run 'createuser nobody', with no rights to create users or databases ... To grant rights to the database, connect to the database (psql mydb) and issue the GRANT command: GRANT SELECT ON mydb TO USER nobody That should get you going, unless I missed a step ... if you work in something like perl, its even easier...setuid your perl script so that the connection is made as the owner of the database... On Sat, 5 Jun 1999, Jim Freeze wrote: > I am using FreeBSD 3.1 and netscape on a standalone system. > I have the ports install of apache, php3 and postgreSQL installed. > > I have created a database called mydb with a table tableone and > two fields, fieldone and fieldtwo. I have also added two rows of > information. > My goal is to access this database from a web page. > Although I can get the name of the database, I cannot perform > queries on the databse. > > The following code > > $dbName = pg_dbname($dbc); > if (!$dbc) > { > echo "An error occured.\n"; > exit; > } > > $result = pg_Exec($dbc, "SELECT * FROM tableone"); > if (!$result) > { > echo "An error occured.\n"; > exit; > } > ?> > > produces the following error > > Warning: PostgresSQL query failed: ERROR: tableone: Permission denied. in > /usr/local/www/data/php1.php3 on line 17 > An error occured. > > where line 17 is > > 17: $result = pg_Exec($dbc, "SELECT * FROM tableone"); > > Since I don't understand what is going on here, I tried logging > into my BSD account as root, pgsql and postgres, and accessing > the web page, but I received the same error. > > In case it helps, the following is an excerpt of my passwd file. > > nobody:*:65534:65534:Unprivileged user:/nonexistent:/sbin/nologin > jfreeze:*:1001:1001:User &Jim Freeze:/usr/jfreeze:/bin/csh > pgsql:*:70:70:PostgreSQL pseudo-user:/usr/local/pgsql:/bin/sh > postgres:*:1002:1002:User &PostgreSQL SuperUser:/usr/postgres:/bin/sh > > I do not know how to list the pgsql users and privelages, if that info is > needed. > > > Thanks for any help. > > > ================== > Dr Jim D. Freeze > jim@freeze.org > ================== > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy Systems Administrator @ hub.org primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message