Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jun 1999 22:38:03 -0300 (ADT)
From:      The Hermit Hacker <scrappy@hub.org>
To:        Jim Freeze <jim@freeze.org>
Cc:        pgsql-novice@postgreSQL.org, freebsd-questions@FreeBSD.ORG
Subject:   Re: PostgreSQL query has permission denied error
Message-ID:  <Pine.BSF.4.05.9906052235400.413-100000@thelab.hub.org>
In-Reply-To: <000a01beaf74$88f55840$e06ec8d0@lexmark.com>

next in thread | previous in thread | raw e-mail | index | archive | help

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
> 
>  <?php
>  $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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9906052235400.413-100000>