Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 19/20 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 2nd July 2012, 02:18 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
phpPgAdmin unable to connect after update to FC17

I have PostgreSQL and Apache running happily on my machine. To administer my database, I use phpPgAdmin.

Prior to going to FC17, all was OK. Now, phpPgAdmin reports 'Login Failed', no matter which username and password I try. I can access the database using psql from a command line and by using the PgAdminIII GUI, but phpPgAdmin cannot connect.

I have attached the relevant fragments from the httpd error log and access log. I cannot interpret these to identify the underlying problem. My suspicion is that it is something to do with SELinux, but that is an unexplored wilderness to me.

Any ideas would be gratefully received.
Attached Files
File Type: txt http_access_log.txt (6.7 KB, 97 views)
File Type: txt http_error_log.txt (1.3 KB, 106 views)
Reply With Quote
  #2  
Old 2nd July 2012, 04:30 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

I tried using setenforce 0, to temporarliy disable SELinux, confirmed it was now Permissive, then tried logging in again, but I still get the same problem. AFAICT, that excludes SELinux from the set of possible causes for the login failing. Now I am totally baffled. Sigh.

Incidentally, my web-based application, which uses Perl, can get in perfectly OK, so I don't think it is a httpd problem, but I am willing to be proved wrong.
Reply With Quote
  #3  
Old 11th July 2012, 12:57 AM
cswaim Offline
Registered User
 
Join Date: Jul 2012
Location: USA
Posts: 4
windows_xp_2003firefox
Re: phpPgAdmin unable to connect after update to FC17

I was able to solve this by setting the SELinux boolean option apache-Allow HTTPD scripts and modules to connect to databases

I also upgraded all software to current release, but that did not solve the problem.
Reply With Quote
  #4  
Old 11th July 2012, 02:11 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

Thanks for replying, cswaim.

I tried the following:
Code:
[root@cardraeh ~]# setsebool -P httpd_enable_cgi 1
[root@cardraeh ~]# setsebool -P httpd_can_network_connect 1
phpPgAdmin still cannot log in.

At this page, I have given a bit more info, specifically:
Quote:
I have just upgraded my platform from Fedora 15 to Fedora 17. Now, phpPgAdmin cannot log in to my server. The error being raised is:
[Sun Jul 08 12:12:01 2012] [error] [client 127.0.0.1] PHP Strict standards: Only variables should be assigned by reference in /usr/share/phpPgAdmin/classes/database/Connection.php on line 23, referer: http://localhost/phpPgAdmin/redirect.php

Line 23 of /usr/share/phpPgAdmin/classes/database/Connection.php reads:$this->conn = &ADONewConnection(\'postgres7\');
From my limited knowledge of phpPgAdmin and SELinux, it does not seem to be an SELinux issue, but relates to the assignment of a variable (or a reference to a variable?) on line 23 of /usr/share/phpPgAdmin/classes/database/Connection.php. My guess is that PHP variable assignment has become more strictly policed under Fedora 17 and this line 23 is doing something that is no longer allowed. What that something is and how to correct/work around it is beyond my limited knowledge of PHP and Apache.

Stretching my understanding, I can see how the error might be raised if either $this->conn is not regarded as a variable which may be assigned to, or &ADONewConnection('postgres7') is not returning a valid value: perhaps it is returning a constant, or a null, or some other value that cannot be assigned to $this->conn?

The only thing I am sure of is that I am out of my depth in trying to figure this out by myself.
Reply With Quote
  #5  
Old 11th July 2012, 03:30 PM
cswaim Offline
Registered User
 
Join Date: Jul 2012
Location: USA
Posts: 4
windows_xp_2003firefox
Re: phpPgAdmin unable to connect after update to FC17

try setting this value
Code:
setsebool -P httpd_can_network_connect_db 1
Reply With Quote
  #6  
Old 11th July 2012, 04:06 PM
Fenrin Offline
Registered User
 
Join Date: Apr 2010
Location: Earth
Posts: 891
linuxopera
Re: phpPgAdmin unable to connect after update to FC17

phpPgAdmin works for me, I did set it up several month ago, when F17 was still Beta.

maybe you just need to enter this:
Code:
setsebool -P allow_user_postgresql_connect on
if it still doesn't work, maybe take a look in the config file of phpPgAdmin:
it's in the phpPGAdmin folder below ./conf/config.inc.php

there is probably a line: $conf['extra_login_security'] = true;
set it to false

Last edited by Fenrin; 11th July 2012 at 04:17 PM.
Reply With Quote
  #7  
Old 12th July 2012, 03:08 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

Quote:
Originally Posted by cswaim;1590978[CODE
setsebool -P httpd_can_network_connect_db 1[/CODE]
Quote:
Originally Posted by Fenrin View Post
Code:
setsebool -P allow_user_postgresql_connect on
...
there is probably a line: $conf['extra_login_security'] = true;
set it to false
Thank you both for your responses. I tried all the above, without success. I'm glad Fenrin has phpPgAdmin working under FC17, because that means I am not wasting my time trying to get it working here.

I'm still stuck with "PHP Strict standards: Only variables should be assigned by reference in /usr/share/phpPgAdmin/classes/database/Connection.php on line 23". I appreciate your input, but I'm having difficulty understanding what component is triggering the error. If it was a security problem, I would expect a more helpful message, like "User not authorised to log in", or something of the sort. The fact that it is reporting a variable assignment error makes me suspicious that some PHP code is broken, but I am certainly not a PHP guru.

The full error message and stack trace in /var/log/httpd/error.log says:
Code:
[Thu Jul 12 09:29:22 2012] [error] [client 127.0.0.1] PHP Strict standards:  Only variables should be assigned by reference in /usr/share/phpPgAdmin/classes/database/Connection.php on line 23, referer: http://localhost/phpPgAdmin/redirect.php
[Thu Jul 12 09:29:22 2012] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://localhost/phpPgAdmin/redirect.php
[Thu Jul 12 09:29:22 2012] [error] [client 127.0.0.1] PHP   1. {main}() /usr/share/phpPgAdmin/redirect.php:0, referer: http://localhost/phpPgAdmin/redirect.php
[Thu Jul 12 09:29:22 2012] [error] [client 127.0.0.1] PHP   2. include_once() /usr/share/phpPgAdmin/redirect.php:7, referer: http://localhost/phpPgAdmin/redirect.php
[Thu Jul 12 09:29:22 2012] [error] [client 127.0.0.1] PHP   3. Misc->getDatabaseAccessor() /usr/share/phpPgAdmin/libraries/lib.inc.php:210, referer: http://localhost/phpPgAdmin/redirect.php
[Thu Jul 12 09:29:22 2012] [error] [client 127.0.0.1] PHP   4. Connection->Connection() /usr/share/phpPgAdmin/classes/Misc.php:508, referer: http://localhost/phpPgAdmin/redirect.php
Looking at the code referenced by the stack trace, I see the following:
/usr/share/phpPgAdmin/classes/database/Connection.php on line 23 reads
Quote:
:$this->conn = &ADONewConnection(\'postgres7\');
ADONewConnection accepts a string as the database identifier and attempts to return a connection object. It is well fenced with error detection and reporting code, so it seems to me that any error encountered should be reported in a log somewhere. The fact that no such error is identified within ADONewConnection seems to imply that the function is working, so I am guessing that the database is identified as type 'postgres7' and the connection object is correctly created. The problem seems to occur at /usr/share/phpPgAdmin/classes/database/Connection.php on line 23, where the object returned by ADONewConnection is being assigned to the conn member of the $this object. I m not a php programmer, so cannot tell if the assignment makes sense, but my C background causes me to wonder whether the conn member of the $this object is expecting a reference (the ampersand in &ADONewConnection makes it look like a reference to something in C), where ADONewConnection is returning an object, not a reference to an object.

The other possibility, much simpler, is that ADONewConnection is never getting called, because the parser is identifying a language problem in the expression $this->conn = &ADONewConnection(\'postgres7\').

I am at a stage where I need to debug PHP, to discover whether ADONewConnection is actually getting called. What is the best way to do this?
Reply With Quote
  #8  
Old 12th July 2012, 09:23 AM
Fenrin Offline
Registered User
 
Join Date: Apr 2010
Location: Earth
Posts: 891
linuxopera
Re: phpPgAdmin unable to connect after update to FC17

hm I don't get this strict error message.

this line:
Code:
:$this->conn = &ADONewConnection(\'postgres7\');
should be without the ":" on the beginning, but I guess this was only a typo(?).

by default there is probably a line: "$conf['servers'][0]['host'] = '';" in the config file. You probably included localhost here already, did you? When you edit the config file, you must restart the postgresql server, you know that probably already (command: "service postgresql restart").

I'm not a php expert either, but I think the php code of phpPgAdmin can still work even if it is not 100% standard conform, "PHP Strict standards" shouldn't be very critical I would think.
Reply With Quote
  #9  
Old 12th July 2012, 09:43 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

Quote:
Originally Posted by Fenrin View Post
I guess this was only a typo(?).
Doh! Typo alert! Quite right.

I will examing my conf setup tomorrow. Thanks for the support.
Reply With Quote
  #10  
Old 13th July 2012, 03:54 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

I tweaked the settings in the config files, to allow access from any server on my network and restarted postgresql, but the problem persists.

Here is a clue for someone smarter than me: When I try logging on using username and password, I get "Login failed" and the trace is written to /var/log/httpd/error_log; if I try with username only, I get "Login disallowed for security reasons." and nothing is written to any log I can find under /var/log.

I'm still suspicious that it is a PHP problem on my machine, because my own Perl CGI scripts can log in and manipulate data without any problems. Weird!

Last edited by Doug Hutcheson; 13th July 2012 at 03:55 AM. Reason: typo
Reply With Quote
  #11  
Old 13th July 2012, 04:59 AM
cswaim Offline
Registered User
 
Join Date: Jul 2012
Location: USA
Posts: 4
windows_xp_2003firefox
Re: phpPgAdmin unable to connect after update to FC17

After I upgraded to F17, I could not log in with phpPgAdmin, but could use PgAdminIII. I was able to connect from the local computer and from a remote computer. However, when logging in with phpPgAdmin, it threw the Strict PHP error in the httpd error log file.

here is a summary of my install changes

Code:
edit  /var/lib/psql/data/postgresql.conf
    
    listen_address='*'

    log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

edit /var/lib/psql/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             0.0.0.0 0.0.0.0         md5 
#                                       127.0.0.1/32
host    all             all             127.0.0.1 255.0.0.0     md5  
# IPv6 local connections:
host    all             all             ::1/128                 md5


restart service
# systemctl restart postgresql.service

phpPgAdmin Config

# cd /etc/phpPgAdmin/config.inc.php

edit 

    $conf['servers'][0]['desc'] = 'YourServerName';

	$conf['servers'][0]['host'] = 'localhost';


create report db
    psql template1 < /usr/share/phpPgAdmin/sql/reports-pgsql.sql
	
SeLinux
	apache Allow HTTPD scripts & modules to connect to db
Beyond that, the following SELinux settings are on
htppd_enable_cgi
httpd_can_network_connect_db
httpd_tty_comm
httpd_graceful_shutdown
httpd_builtin_scripting
sepgsql_unconfined_dbadm
allow_user_postgresql_connect

The difference in error messages with passwords may be a function of having the 'extra_login_security' set to true which prevents pgsql, root, postgres... from loggin in and requires a password.

I also ran a yum update to get all software patches applied and there were quiet a few.
Reply With Quote
  #12  
Old 13th July 2012, 07:32 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

Hi, cswaim. Thank you for replying.

In /etc/phpPgAdmin/config.inc.php, I have tried changing the $conf['servers'][0]['host'] value to either 'localhost, or '127.0.0.1/32', including the single quote marks. In either case, I now get a different response:
Quote:
Attempt to connect with invalid server parameter, possibly someone is trying to hack your system.
I am thinking the key to my puzzle must be in config.inc.php.

This is the relevant part of config.inc.php:
Code:
        // Display name for the server on the login screen
        $conf['servers'][0]['desc'] = 'PostgreSQL';

        // Hostname or IP address for server.  Use '' for UNIX domain socket.
        // use 'localhost' for TCP/IP connection on this computer
        // $conf['servers'][0]['host'] = 'localhost';
        // $conf['servers'][0]['host'] = '127.0.0.1/32';
        $conf['servers'][0]['host'] = '';

        // Database port on server (5432 is the PostgreSQL default)
        $conf['servers'][0]['port'] = 5432;

        // Database SSL mode
        // Possible options: disable, allow, prefer, require
        // To require SSL on older servers use option: legacy
        // To ignore the SSL mode, use option: unspecified
        $conf['servers'][0]['sslmode'] = 'allow';

        // Change the default database only if you cannot connect to template1.
        // For a PostgreSQL 8.1+ server, you can set this to 'postgres'.
        $conf['servers'][0]['defaultdb'] = 'template1';

        // Specify the path to the database dump utilities for this server.
        // You can set these to '' if no dumper is available.
        $conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
        $conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';

        // Slony (www.slony.info) support?
        $conf['servers'][0]['slony_support'] = false;
        // Specify the path to the Slony SQL scripts (where slony1_base.sql is located, etc.)
        // No trailing slash.
        $conf['servers'][0]['slony_sql'] = '/usr/share/pgsql';
I'm not sure of what you mean by the line in your message "apache Allow HTTPD scripts & modules to connect to db": how do I do that?

I ran getsebool and checked that all the bools you listed are switched on.
Reply With Quote
  #13  
Old 13th July 2012, 09:13 AM
Fenrin Offline
Registered User
 
Join Date: Apr 2010
Location: Earth
Posts: 891
linuxopera
Re: phpPgAdmin unable to connect after update to FC17

Quote:
Originally Posted by Doug Hutcheson View Post
[...]

In /etc/phpPgAdmin/config.inc.php, I have tried changing the $conf['servers'][0]['host'] value to either 'localhost, or '127.0.0.1/32', including the single quote marks. In either case, I now get a different response:I am thinking the key to my puzzle must be in config.inc.php.

This is the relevant part of config.inc.php:
[...]
you probably forgot to restart the postgresql service. If you forgot to do this and changed the file config.inc.php, you will get that message "probably someone is trying to hack your system".

I have this line in the config file:
Code:
$conf['servers'][0]['host'] = 'localhost';
the other lines you quoted above look the same.

and make sure you set extra_login_security to false. For me the login doesn't work either, if I set this option to true.

in the file /var/lib/pgsql/data/pg_hba.conf I have just this two lines (for login I use the postgres user):
Code:
host all postgres 127.0.0.1/32 md5
local all postgres md5

Last edited by Fenrin; 13th July 2012 at 09:28 AM.
Reply With Quote
  #14  
Old 13th July 2012, 06:16 PM
cswaim Offline
Registered User
 
Join Date: Jul 2012
Location: USA
Posts: 4
windows_xp_2003firefox
Re: phpPgAdmin unable to connect after update to FC17

Quote:
Originally Posted by Doug Hutcheson View Post

I'm not sure of what you mean by the line in your message "apache Allow HTTPD scripts & modules to connect to db": how do I do that?
I use the gui SELinux management tool and the options are grouped by category such as apache and then the description of the option -- this is the same as the httpd_can_network_connect_db option.

If it is on you are set.

If you have your conf set to localhost='', I think that is telling phpPgAdmin to use the unix socket to connect. That is new territory for me and can not assist much with that.

Postgres security requires that hba, config files and SELinux are all set up correctly. Thus the error can be caused by any of the three components which makes it a pain to trace and the error log files were my best help at determining which component was complaining. Unfortunately, it was a brute force approach and the details have been forgotten.
Reply With Quote
  #15  
Old 14th July 2012, 06:17 AM
Doug Hutcheson Offline
Registered User
 
Join Date: Jun 2009
Location: Queensland
Posts: 164
linuxfirefox
Re: phpPgAdmin unable to connect after update to FC17

Quote:
Originally Posted by cswaim View Post
I use the gui SELinux management tool and the options are grouped by category such as apache and then the description of the option -- this is the same as the httpd_can_network_connect_db option.

If it is on you are set.
Thanks for bringing this to my attention. For lurkers, the package on my system was policycoreutils-gui.x86_64 and I used yum to install it. The GUI takes several seconds to fire up, but is easy to use when it comes to life.

Quote:
Originally Posted by cswaim View Post
If you have your conf set to localhost='', I think that is telling phpPgAdmin to use the unix socket to connect. That is new territory for me and can not assist much with that.
I'm also out of my depth with sockets.

Quote:
Originally Posted by cswaim View Post
Postgres security requires that hba, config files and SELinux are all set up correctly. Thus the error can be caused by any of the three components which makes it a pain to trace and the error log files were my best help at determining which component was complaining. Unfortunately, it was a brute force approach and the details have been forgotten.
One of my troubles is that I can't find helpful error logs - helpful to someone at my level of inexperience, anyway. The idea that hba, configs, SELinux and php.ini are all inter-related is only slightly daunting, so I will spend some time tweaking and see what result I can get.

The really frustrating thing is that all this worked fine under Fedora 15 and I only noticed it was broken when I went up to Fedora 17. The fact that my own Perl CGI scripts can access the database suggests to me that the glitch is in the PHP set-up somewhere. I base this conclusion on the fact that it is only PHP that is failing to connect. I will keep fiddling and see what damage I can do.

---------- Post added at 03:17 PM ---------- Previous post was at 01:28 PM ----------

Thanks everyone for your help. The problem went away when I set extra_login_security to false in config.inc.php and restarted PostgreSQL.. To be sure I was working in the right area, however, I set it back to True and restarted PostgreSQL, but I can still log in: I can't now replicate the failure behaviour! Groan! Still, it is all working now (touch wood). I really appreciate all the good advice given in this thread.
Reply With Quote
Reply

Tags
connect, fc17, phppgadmin, unable, update, x86_64

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] unable to install/update kmod 7-2.fc17 hakova Using Fedora 3 18th June 2012 09:02 PM
Won't boot after update FC17 darkside Using Fedora 2 3rd June 2012 12:26 PM
Fresh FC17 Install : gnome_control_control-center-3.4.2-1.fc17.i686 CORE DUMP reflex Installation, Upgrades and Live Media 1 2nd June 2012 03:05 AM
Unable to connect to network after update BrillianceLin Using Fedora 10 31st October 2010 01:43 AM
Kexi: Unable to connect to database servers after update Whitewater Using Fedora 0 26th April 2006 10:04 PM


Current GMT-time: 23:00 (Thursday, 24-07-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat