Обсуждение: Help Me !

Поиск
Список
Период
Сортировка

Help Me !

От
zhuge xiao
Дата:
Help me!

I have edited the program testlibpq.c which is copied from the
PostgreSQL document to make it become a CGI program. And I have
succeeded to compile the programme, testlibpq.c from the command line:
   [zhuge@xiao2 src]$ cc -o testlibpq testlibpq.c -lpq

And it can run from the command line:
   [zhuge@xiao2 src]$ ./testlibpq

Then, I copied the excuteable program to the CGI directory,
/var/www/cgi-bin. And let it run from the Mozilla Firefox browser whose
URL was http://localhost/cgi-bin/testlibpq. But I failed. The result was
that the below message was displayed in the browser:
could not connect to server: Permission denied
Is the server running locally and accepting connections on Unix domain
socket "/tmp/.s.PGSQL.5432"?

The above message was produced by the below code:
if (PQstatus(conn) != CONNECTION_OK)
        {
        fprintf(stdout, PQerrorMessage(conn));
                exit_nicely(conn);
        }

How can I do? Please help me!

Thank you very much.

zhuge@Rinaix.cn


Re: Help Me !

От
"Jim C. Nasby"
Дата:
On Tue, Dec 20, 2005 at 05:44:44PM +0800, zhuge xiao wrote:
> Is the server running locally and accepting connections on Unix domain
> socket "/tmp/.s.PGSQL.5432"?

So what are the permissions on /tmp/.s.PGSQL.5432? Can apache write to
it?

Actually, I think apache normally chroot's to ServerRoot (httpd.conf)
when it starts. So you probably need to create a symlink from
/tmp/.s.PGSQL.5432 to "ServerRoot"/tmp.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

Re: Help Me !

От
Scott Marlowe
Дата:
On Wed, 2005-12-21 at 14:02, Jim C. Nasby wrote:
> On Tue, Dec 20, 2005 at 05:44:44PM +0800, zhuge xiao wrote:
> > Is the server running locally and accepting connections on Unix domain
> > socket "/tmp/.s.PGSQL.5432"?
>
> So what are the permissions on /tmp/.s.PGSQL.5432? Can apache write to
> it?
>
> Actually, I think apache normally chroot's to ServerRoot (httpd.conf)
> when it starts. So you probably need to create a symlink from
> /tmp/.s.PGSQL.5432 to "ServerRoot"/tmp.

My apache doesn't do this, and it's a pretty straight forward source
compile of whatever the latest version of the 2.x branch was late this
last summer.

However, I could see SELinux getting in the way.

Re: Help Me !

От
"Jim C. Nasby"
Дата:
On Wed, Dec 21, 2005 at 02:11:18PM -0600, Scott Marlowe wrote:
> On Wed, 2005-12-21 at 14:02, Jim C. Nasby wrote:
> > On Tue, Dec 20, 2005 at 05:44:44PM +0800, zhuge xiao wrote:
> > > Is the server running locally and accepting connections on Unix domain
> > > socket "/tmp/.s.PGSQL.5432"?
> >
> > So what are the permissions on /tmp/.s.PGSQL.5432? Can apache write to
> > it?
> >
> > Actually, I think apache normally chroot's to ServerRoot (httpd.conf)
> > when it starts. So you probably need to create a symlink from
> > /tmp/.s.PGSQL.5432 to "ServerRoot"/tmp.
>
> My apache doesn't do this, and it's a pretty straight forward source
> compile of whatever the latest version of the 2.x branch was late this
> last summer.

A coworker just confirmed that it in fact does not chroot by default.
Which had I thought about it for 1/2 a second makes perfect sense,
otherwise it would often have a heck of a time getting to
/home/*/public_html.

> However, I could see SELinux getting in the way.

Definately.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461