Bug 964333 - rhn-satellite-activate --disconnect fails because driver_postgresql.py sets host=None instead of host=localhost
Summary: rhn-satellite-activate --disconnect fails because driver_postgresql.py sets h...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Spacewalk
Classification: Community
Component: Installation
Version: 1.10
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jan Pazdziora
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space27
TreeView+ depends on / blocked
 
Reported: 2013-05-17 21:44 UTC by Michele Baldessari
Modified: 2017-09-28 18:08 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-05-18 13:14:38 UTC
Embargoed:


Attachments (Terms of Use)

Description Michele Baldessari 2013-05-17 21:44:33 UTC
Description of problem:
In my postgresq DB I have "ident" as auth method when using Unix sockets and "md5" for anything else. In this scenario, rhn-satellite-activate will fail because /usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py has the following code:

class Database(sql_base.Database):
    """ Class for PostgreSQL database operations. """

    def __init__(self, host=None, port=None, username=None,
                 password=None, database=None):

        if host is None or host == '' or host == 'localhost':
            self.host = None
            self.port = None
        else:
            self.host = host
            self.port = port


I have host = localhost in /etc/rhn/rhn.conf and the above will try to connect without having set 'host' to anything and the connect will fail due to wrong auth:
init.py:179:connect:SQLConnectError: (None, None, 'spacewalk', 'Attempting Re-Connect to the database failed')

Traceback (most recent call last):
  File "/usr/bin/rhn-satellite-activate", line 42, in <module>
    sys.exit(abs(mod.main() or 0))
  File "/usr/lib/python2.7/site-packages/spacewalk/satellite_tools/rhn_satellite_activate.py", line 580, in main
    rhnSQL.initDB()
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/init.py", line 102, in initDB
    initDB(backend, host, port, username, password, database)
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/init.py", line 55, in initDB
    __DB.connect()
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 174, in connect
    return self.connect(reconnect=0)
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 163, in connect
    password=self.password)
  File "/usr/lib64/python2.7/site-packages/psycopg2/init.py", line 179, in connect
    connection_factory=connection_factory, async=async)
SQLConnectError: (None, None, 'spacewalk', 'Attempting Re-Connect to the database failed')

If I change the line "if host is None or host == '' or host == 'localhost':"
to " if host is None or host == ''": things are fine.

Version-Release number of selected component (if applicable):
# rpm -qf /usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py
spacewalk-backend-sql-postgresql-1.10.32-1.fc18.noarch

Comment 1 Jan Pazdziora 2013-05-18 13:14:38 UTC
(In reply to comment #0)
> Description of problem:
> In my postgresq DB I have "ident" as auth method when using Unix sockets and

You PostgreSQL setup is incorrect then -- please consult

   https://fedorahosted.org/spacewalk/wiki/PostgreSQLServerSetup

for the settings that work with Spacewalk.

Comment 2 Eric Herget 2017-09-28 18:08:00 UTC
This BZ closed some time during 2.5, 2.6 or 2.7.  Adding to 2.7 tracking bug.


Note You need to log in before you can comment on or make changes to this bug.