Thread: Problems with Postgres and PHP from command line

Problems with Postgres and PHP from command line

From
Kristopher Spencer-Yates
Date:
Hi

I have a PHP script running as a non-root user.  The non-root user will
exec PHP script via cron once per day.

Warning: pg_exec(): Query failed: ERROR:  checkout: Permission denied.
. in /usr/home/nonrootuser/script.php on line 23

Line 23 is, of course, the $result = pg_exec($db_connect, $call);

My DB connect is to a postgres server (same physical box as where script
is running).

$db_connect=pg_connect("user=nonrootuser dbname=thedatabase");

note: PHP website can connect with no problems to this local postgres
db; apache runs as nobody, connecting via a PHP db_connect as
"user=someotheruser dbname=thedatabase".

"thedatabase" looks like:
checkout | table | someotheruser

So I did a grant all priviliges for "nonrootuser" and "nobody" on all
tables in "thedatabase".  I do a \z on a table and see my grant.. but it
isnt working.  Not sure what else to provide at this time to help anyone
willing to help me.. Just ask and I'll be able to provide any info on
request.

So.. my question:  How do we get unix command line user "nonrootuser" to
run a script as "nonrootuser" and access "thedatabase"?  I searched the
docs already and so now I am here begging for help :)

Thanks,

Kris

--
Kristopher Spencer-Yates
Sr. Programmer/Systems Administration
kris@2binteractive.com



Re: Problems with Postgres and PHP from command line

From
mike g
Date:
Sounds like a permissions problem with cron.  Was the cron job created
under the non-root users account?

On Thu, 2004-06-24 at 15:47, Kristopher Spencer-Yates wrote:
> Hi
>
> I have a PHP script running as a non-root user.  The non-root user will
> exec PHP script via cron once per day.
>
> Warning: pg_exec(): Query failed: ERROR:  checkout: Permission denied.
> . in /usr/home/nonrootuser/script.php on line 23
>
> Line 23 is, of course, the $result = pg_exec($db_connect, $call);
>
> My DB connect is to a postgres server (same physical box as where script
> is running).
>
> $db_connect=pg_connect("user=nonrootuser dbname=thedatabase");
>
> note: PHP website can connect with no problems to this local postgres
> db; apache runs as nobody, connecting via a PHP db_connect as
> "user=someotheruser dbname=thedatabase".
>
> "thedatabase" looks like:
> checkout | table | someotheruser
>
> So I did a grant all priviliges for "nonrootuser" and "nobody" on all
> tables in "thedatabase".  I do a \z on a table and see my grant.. but it
> isnt working.  Not sure what else to provide at this time to help anyone
> willing to help me.. Just ask and I'll be able to provide any info on
> request.
>
> So.. my question:  How do we get unix command line user "nonrootuser" to
> run a script as "nonrootuser" and access "thedatabase"?  I searched the
> docs already and so now I am here begging for help :)
>
> Thanks,
>
> Kris