From carlajb@juno.com Mon Feb 28 05:35:26 2000 Received: from m9.boston.juno.com (m9.boston.juno.com [205.231.100.195]) by hub.org (8.9.3/8.9.3) with ESMTP id AAA58651 for ; Mon, 28 Feb 2000 00:35:26 -0500 (EST) (envelope-from carlajb@juno.com) Received: from cookie.juno.com by cookie.juno.com for <"cS4pPc56dU/ddBHy7GYC2LqVAsQdovdqkfmJbkVgCIwE9uZow5EnYQ=="> Received: (from carlajb@juno.com) by m9.boston.juno.com (queuemail) id EZVZ9LNU; Mon, 28 Feb 2000 00:34:53 EST To: pgsql-admin@postgresql.org Date: Sun, 27 Feb 2000 17:27:29 -0700 Subject: Perl Script and Postgres DB running via Apache Web Server Message-ID: <20000227.173459.-498311.0.CarlaJB@juno.com> X-Mailer: Juno 4.0.5 MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Juno-Att: 0 X-Juno-RefParts: 0 From: Carla J Breuker Hi... I have the following Perl Script (with Postgres code): #!/usr/bin/perl -w use Pg; print "

This is a testexec("insert into test_table values ('Carla', '90')"); This Script will run from the command line, and inserts values into the existing DB and table. When it is run via the web browser, nothing happens (browser hangs). The script is in the /usr/local/httpd/cgi-bin directory, owned by a user (not root), and has 755 permissions. We have exhaustively searched perl, cgi, postgres, and apache documentation both printed and web-based, and cannot determine how to correct this problem. We suspect that it may be a permissions / execution rights for the httpd, but we are stumped. Any help will be greatly appreciated. Thanks, -Carla and Chris :) ________________________________________________________________ YOU'RE PAYING TOO MUCH FOR THE INTERNET! Juno now offers FREE Internet Access! Try it today - there's no risk! For your FREE software, visit: http://dl.www.juno.com/get/tagj. From phawkins@connact.com Tue Feb 29 05:05:09 2000 Received: from ConnActivity.ConnActivity.com (ConnActivity.ConnActivity.com [206.34.200.2]) by hub.org (8.9.3/8.9.3) with ESMTP id AAA09522 for ; Tue, 29 Feb 2000 00:05:09 -0500 (EST) (envelope-from phawkins@connact.com) Received: from SKEEZIX.watercat (ppp-215-26.ConnActivity.com [206.34.215.26]) by ConnActivity.ConnActivity.com (8.9.2/8.9.2) with ESMTP id AAA09688 for ; Tue, 29 Feb 2000 00:05:02 -0500 (EST) Date: Tue, 29 Feb 2000 00:04:51 -0500 Message-Id: <1116-Tue29Feb2000000451-0500-phawkins@connact.com> X-Mailer: emacs 20.4.1 (via feedmail 8 I) From: phawkins@connact.com (Patricia Hawkins) To: pgsql-admin@hub.org In-reply-to: <200002290401.XAA04949@hub.org> (owner-pgsql-admin-digest@hub.org) Subject: Re: Perl Script and Postgres DB running via Apache Web Server References: <200002290401.XAA04949@hub.org> One: su root su - nobody Cd to the appropriate directory. Run the script. What happens? Two: (If that didn't help) Do the CGI magic to make the browser display the environment variables set for the CGI script. Su to nobody (as above) and set all the env variables (and I mean all of them, including HOME) the same as for the browser. Run the script. What happens? Three: If you got a failure, then su to nobody, and set all the env variables identically to those of the user (or situation) for which the script works. Run the script. Four: Change them one by one, running the script each time. Modify algorithm as necessary as illumination strikes. Take careful notes. Be wary of init files in home directories. >>>>> "p" == pgsql-admin-digest writes: p> Date: Sun, 27 Feb 2000 17:27:29 -0700 p> From: Carla J Breuker p> Subject: Perl Script and Postgres DB running via Apache Web Server p> Hi... p> I have the following Perl Script (with Postgres code): p> #!/usr/bin/perl -w p> use Pg; p> print "

This is a test $conn = Pg::connectdb("dbname=test"); p> $conn->exec("insert into test_table values ('Carla', '90')"); p> This Script will run from the command line, and inserts values into the p> existing DB and table. p> When it is run via the web browser, nothing happens (browser hangs). p> The script is in the /usr/local/httpd/cgi-bin directory, owned by a user p> (not root), and has 755 permissions. p> We have exhaustively searched perl, cgi, postgres, and apache p> documentation both printed and web-based, p> and cannot determine how to correct this problem. p> We suspect that it may be a permissions / execution rights for the httpd, p> but we are stumped. p> Any help will be greatly appreciated. p> Thanks, p> -Carla and Chris :) p> ________________________________________________________________ p> YOU'RE PAYING TOO MUCH FOR THE INTERNET! p> Juno now offers FREE Internet Access! p> Try it today - there's no risk! For your FREE software, visit: p> http://dl.www.juno.com/get/tagj. p> ------------------------------ p> End of pgsql-admin-digest V1 #463 p> ********************************* p> ************ From mdalphin@amgen.com Tue Feb 29 17:41:23 2000 Received: from clio.trends.ca (root@clio.trends.ca [209.47.148.2]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA86872 for ; Tue, 29 Feb 2000 12:41:23 -0500 (EST) (envelope-from mdalphin@amgen.com) Received: from castle-smtp.amgen.com (ns2.amgen.com [138.133.17.7]) by clio.trends.ca (8.9.3+Sun/8.9.3) with ESMTP id MAA19474 for ; Tue, 29 Feb 2000 12:23:59 -0500 (EST) Received: by castle-smtp.amgen.com; id JAA09716; Tue, 29 Feb 2000 09:25:10 -0800 (PST) Received: from mailbag.amgen.com(138.133.10.78) by castle-smtp.amgen.com via smap (V4.2) id xma009589; Tue, 29 Feb 00 09:24:11 -0800 Received: from amgen.com (mahunui [138.133.147.23]) by mailbag.amgen.com (8.8.5/8.8.5) with ESMTP id JAA08071; Tue, 29 Feb 2000 09:22:53 -0800 (PST) Sender: mdalphin@amgen.com Message-ID: <38BC0084.8B854CB3@amgen.com> Date: Tue, 29 Feb 2000 09:23:17 -0800 From: Mark Dalphin Organization: Amgen, Inc. X-Mailer: Mozilla 4.6 [en] (X11; U; IRIX64 6.5 IP30) X-Accept-Language: en MIME-Version: 1.0 To: carlajb@juno.com, pgsql-admin@postgresql.org Subject: Re: Perl Script and Postgres DB running via Apache Web Server Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Carla and Chris, > I have the following Perl Script (with Postgres code): > > [ stuff deleted] > This Script will run from the command line, and inserts values into the > existing DB and table. When it is run via the web browser, nothing happens > (browser hangs). The script is in the /usr/local/httpd/cgi-bin directory, > owned by a user (not root), and has 755 permissions. We have exhaustively > searched perl, cgi, postgres, and apache documentation both printed and > web-based, and cannot determine how to correct this problem. We suspect that > it may be a permissions / execution rights for the httpd, but we are stumped. > Any help will be greatly appreciated. Thanks, -Carla and Chris :) I suspect the problem is not "who owns the script", but rather "who runs the script". Usually your httpd runs as user "nobody", who also happens to have very few permissions for anything on your system. Meanwhile, your Postgres database table was create by you and probably doesn't include permissions for user "nobody" to even "SELECT" the table, much less modify it. Guessing here, but you probably don't have a Postgres user named "nobody" (see "createuser") nor have you granted permissions on any tables to user "nobody" (see the SQL command "grant"). As user "nobody" usually has no login account for security reasons, you may wish to experiment with permissions by using two standard login accounts to see who can read what and when. For what it is worth, I often find with this kind of problem (CGI scripts that mis-behave especially when interacting with a database) that changing my httpd logging "up" from a level of "warn" to "debug" and then reading both the httpd log and the postgresql log file helps greatly in tracking down the problem. Hope this helps, Mark -- Mark Dalphin email: mdalphin@amgen.com Mail Stop: 29-2-A phone: +1-805-447-4951 (work) One Amgen Center Drive +1-805-375-0680 (home) Thousand Oaks, CA 91320 fax: +1-805-499-9955 (work) From banghe@baileylink.net Tue Feb 29 18:01:54 2000 Received: from mocha2.baileylink.net (IDENT:qmailr@mocha2.baileylink.net [63.71.213.28]) by hub.org (8.9.3/8.9.3) with SMTP id NAA92343 for ; Tue, 29 Feb 2000 13:01:54 -0500 (EST) (envelope-from banghe@baileylink.net) Received: (qmail 3730 invoked from network); 29 Feb 2000 18:01:42 -0000 Received: from xindu.baileylink.net (HELO baileylink.net) (63.71.216.27) by mocha2.baileylink.net with SMTP; 29 Feb 2000 18:01:42 -0000 Message-ID: <38BC0AF1.40834E8A@baileylink.net> Date: Tue, 29 Feb 2000 12:07:45 -0600 From: bangh X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en,zh,zh-CN,zh-TW MIME-Version: 1.0 To: pgsql-admin@hub.org Subject: RE:Perl Script and Postgres DB running via Apache Web Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit Hi, I think the problem is the web process user. The cgi script is run in name of the web process, you should check what name is assigned for your web process, normally it is named as nobody, webwww, then grant access privileges (like select, insert, delete) on that table to your web process. -- Banghe Hi... >> p> I have the following Perl Script (with Postgres code): >> p> #!/usr/bin/perl -w p> use Pg; >> p> print "

This is a test> p> $conn = Pg::connectdb("dbname=test"); p> $conn->exec("insert into test_table values ('Carla', '90')"); >> p> This Script will run from the command line, and inserts values into the p> existing DB and table. p> When it is run via the web browser, nothing happens (browser hangs). >> p> The script is in the /usr/local/httpd/cgi-bin directory, owned by a user p> (not root), and has 755 permissions. >> p> We have exhaustively searched perl, cgi, postgres, and apache p> documentation both printed and web-based, p> and cannot determine how to correct this problem. >> p> We suspect that it may be a permissions / execution rights for the httpd, p> but we are stumped. >> p> Any help will be greatly appreciated. >> p> Thanks, p> -Carla and Chris :) p> ________________________________________________________________ p> YOU'RE PAYING TOO MUCH FOR THE INTERNET! p> Juno now offers FREE Internet Access! p> Try it today - there's no risk! For your FREE software, visit: p> http://dl.www.juno.com/get/tagj. >>