Thread: ...
Hi : Im trying to run this CGI. #!/usr/bin/perl -w use Pg; print "Content-type: text/html\n\n"; $database = "henric"; $server = "iris1.ingenieria.uatx.mx"; $conn = Pg::setdb($server,5432,'','',$database); $namedb = $conn->db; $error = $conn->errorMessage; print <<EOF; <html> <head><title>Resultados de Postgres</title></head> <body> <h1>Hola mundo</h1>Conectado a la base de datos: $namedb<br> EOF if ($error ne '') { print "ERROR: ", $error; print "</body></html>\n"; exit 1; } print"Hasta aqui todo esta bien!!"; print qq ( </body> </html>); When type perl conexion.cgi <enter> i get the next result. iris1% perl conexion.cgi Content-type: text/html <html> <head><title>Resultados de Postgres</title></head> <body>Conectado a la base de datos: henric<br> Hasta aqui todo esta bien!! </body> </html>iris1% I think that all it's O.K and then i try to run it in a browser and i get the next result. Conectado a la base de datos: henric ERROR: FATAL 1: SetUserId: user 'nobody' is not in 'pg_shadow' What's wrong? Im using Pg in the new Style. Atte. Henry Ilhuicatzi Cortes Departamento de Ingenieria y Tecnologia Universidad Autonoma de Tlaxcala Mexico.
On 12-May-99 Ilhuicatzi Cortes J. Henry wrote: > Hi : > > Im trying to run this CGI. > >#!/usr/bin/perl -w > > use Pg; > > > print "Content-type: text/html\n\n"; > > $database = "henric"; > $server = "iris1.ingenieria.uatx.mx"; > $conn = Pg::setdb($server,5432,'','',$database); > $namedb = $conn->db; > $error = $conn->errorMessage; > > print <<EOF; > <html> > <head><title>Resultados de Postgres</title></head> > <body> > <h1>Hola mundo</h1> > Conectado a la base de datos: $namedb<br> > EOF > > if ($error ne '') { > print "ERROR: ", $error; > print "</body></html>\n"; > exit 1; > } > > print"Hasta aqui todo esta bien!!"; > print qq ( > </body> > </html>); > > > When type perl conexion.cgi <enter> i get the next result. > > iris1% perl conexion.cgi > Content-type: text/html > > <html> > <head><title>Resultados de Postgres</title></head> > <body> > Conectado a la base de datos: henric<br> > Hasta aqui todo esta bien!! > </body> > </html>iris1% > > I think that all it's O.K and then i try to run it in a browser and i > get the next result. > > Conectado a la base de datos: henric > ERROR: FATAL 1: SetUserId: user 'nobody' is not in 'pg_shadow' Looks like you need to run the PostgreSQL "createuser" utility to create an entry for "nobody". Then you'll have to give "nobody" read access to the data the web page is accessing. > > > What's wrong? > > > Im using Pg in the new Style. > > > Atte. > Henry Ilhuicatzi Cortes > Departamento de Ingenieria y Tecnologia > Universidad Autonoma de Tlaxcala > Mexico. > ---------------------------------- Date: 12-May-99 Time: 12:12:01 Craig Orsinger (email: <orsingerc@epg.lewis.army.mil>) Logicon RDA Bldg. 8B28 "Just another megalomaniac with ideas above his 6th & F Streets station. The Universe is full of them." Ft. Lewis, WA 98433 - The Doctor ----------------------------------
On Wed, 12 May 1999, Ilhuicatzi Cortes J. Henry wrote: > Im trying to run this CGI. > > #!/usr/bin/perl -w > > use Pg; I recommend using the CGI module for perl CGI. It'll make your life a lot easier (you don't need to use the here documents). > I think that all it's O.K and then i try to run it in a browser and i > get the next result. > > Conectado a la base de datos: henric > ERROR: FATAL 1: SetUserId: user 'nobody' is not in 'pg_shadow' > > What's wrong? > > Im using Pg in the new Style. Your web server typically intiates connections under user 'nobody', for security reasons (nobody usually has no default shell, so crackers can't use it to break into your system). You need to create a user in Postgres also called 'nobody' so it cann access your database. You will then need to grant whatever rights you need for 'nobody' to use your database (at least give SELECT rights). I'm guessing you are using Apache and some flavour of Unix, be it Linux, FreeBSD, etc. Brett W. McCoy http://www.lan2wan.com/~bmccoy ----------------------------------------------------------------------- Admiration, n.:Our polite recognition of another's resemblance to ourselves. -- Ambrose Bierce, "The Devil's Dictionary"