Bug 695723 - rhncfg-client causes TypeError
Summary: rhncfg-client causes TypeError
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: rhncfg
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-04-12 14:20 UTC by Marcus Moeller
Modified: 2012-01-17 10:36 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-01-17 10:36:52 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Marcus Moeller 2011-04-12 14:20:28 UTC
Description of problem:
Neither:
rhncfg-client-5.9.48-2.fc15

nor the 1.4 RC Clients:
rhncfg-client-5.9.52-1.fc14

seem to work correctly on F15 (Nightly).

Traceback (most recent call last):
  File "/usr/bin/rhncfg-client", line 34, in <module>
    sys.exit(Main().main() or 0)
  File "/usr/share/rhn/config_common/rhn_main.py", line 145, in main
    local_config.init(self.config_section, defaults=up2date_cfg)
  File "/usr/share/rhn/config_common/local_config.py", line 99, in init
    cp.read_config_files(overrides)
  File "/usr/share/rhn/config_common/local_config.py", line 39, in read_config_files
    self.read(self._get_config_files())
  File "/usr/lib64/python2.7/ConfigParser.py", line 297, in read
    self._read(fp, filename)
  File "/usr/lib64/python2.7/ConfigParser.py", line 546, in _read
    options[name] = '\n'.join(val)
TypeError: sequence item 0: expected string, dict found

Comment 1 Jan Pazdziora 2011-04-12 14:27:43 UTC
The /usr/lib64/python2.7/ConfigParser.py is owned by python, not
rhncfg-client or other Spacewalk code. Could you work with Fedora
python maintainer to have this investigated?

Comment 2 Marcus Moeller 2011-04-12 14:37:10 UTC
contacted Toshio

Comment 3 Dave Malcolm 2011-04-12 14:45:41 UTC
Thanks for filing this bug report.

I'm able to reproduce this on a vanilla install of rhncfg-client (i.e. without touching any config files) by running:

   $ rhncfg-client list

This is with:
  rhncfg-5.9.48-2.fc15.noarch
  rhncfg-client-5.9.48-2.fc15.noarch
  python-2.7.1-5.fc15.x86_64
  python-libs-2.7.1-5.fc15.x86_64

Am investigating.

Comment 4 Dave Malcolm 2011-04-12 14:55:37 UTC
Running under pdb:

  $ python -m pdb /usr/bin/rhncfg-client list

shows that the code in question is:

  540  	        # join the multi-line values collected while reading
  541  	        all_sections = [self._defaults]
  542  	        all_sections.extend(self._sections.values())
  543  	        for options in all_sections:
  544  	            for name, val in options.items():
  545  	                if isinstance(val, list):
  546  ->	                    options[name] = '\n'.join(val)
  547  	

and that "name" is:
  'serverurl'

and that "val" is:
  [{'server_name': 'enter.your.server.url.here', 'proto': 'https'}]

i.e. the first entry is indeed a dict, not a string.

The file is "/etc/sysconfig/rhn/rhncfg-client.conf"

Looking at that file, I see:
  # to use a server other than what up2date is configured to use,
  # do something along the lines of:
  # server_url = https://some.example.com%(server_handler)s
  # server_url = http://another.example.net:8080%(server_handler)s
  # server_url = https://yet.another.example.org:8081/CONFIG-MANAGEMENT
  server_url = %(proto)s://%(server_name)s%(server_handler)s

Comment 5 Dave Malcolm 2011-04-12 15:06:17 UTC
From my reading of the code/debugging in pdb, it seems:
  - that this is coming from the "defaults" for the config parser.

  - that the defaults are coming from:
       /usr/share/rhn/config_common/rhn_main.py(145):main()
145  ->	            local_config.init(self.config_section, defaults=up2date_cfg)

  - that up2date_cfg is set up in that function by:
130            up2date_cfg = utils.get_up2date_config()

  - and that that's coming from some complex-looking logic in
      /usr/share/rhn/config_common/utils.py:get_up2date_config

Comment 6 Dave Malcolm 2011-04-12 15:13:02 UTC
(Pdb) p up2date_cfg
{'stagingContentWindow': '24', 'versionOverride': '', 'stagingContent': '1', 'server_name': 'enter.your.server.url.here', 'networkRetries': '1', 'hostedWhitelist': '', 'enableProxy': '0', 'proto': 'https', 'tmpDir': '/tmp', 'serverURL': [{'server_name': 'enter.your.server.url.here', 'proto': 'https'}], 'skipNetwork': '0', 'disallowConfChanges': ['noReboot', 'sslCACert', 'useNoSSLForPackages', 'noSSLServerURL', 'serverURL', 'disallowConfChanges'], 'sslCACert': '/usr/share/rhn/RHNS-CA-CERT', 'retrieveOnly': '0', 'debug': '0', 'httpProxy': '', 'useNoSSLForPackages': '0', 'systemIdPath': '/etc/sysconfig/rhn/systemid', 'writeChangesToLog': '0', 'noReboot': '0'}

Looks like the defaults for a ConfigParser:
  - must be a dictionary
    - where the keys must be strings, and
    - the values must be either strings or lists of strings

The problem is that up2date_cfg['serverURL'] is a list containing a dict.

Admittedly, from my reading of
  http://docs.python.org/library/configparser.html
the precise types expected by the API aren't clear.

Looks like a bug in rhncfg; reassigning component accordingly.

I suggest adding a validation step to the rhncfg code to assert that the defaults for the ConfigParser are sane.

Comment 7 Toshio Ernie Kuratomi 2011-04-12 15:23:56 UTC
I can confirm that python-2.7 ConfigParser only takes string keys and values as it's bitten me before.  The upstream author considers the ability to take non-string values in previous versions to have been a bug.

Comment 8 Miroslav Suchý 2011-04-12 20:27:09 UTC
rhncfg* has its own code for handling configs. If I use
from up2date_client import config
cfg = config.initUp2dateConfig()
cfg["serverURL"]
I will get correctly:
'http://enter.your.server.url.here/XMLRPC'

I will the the transition to use rhn-client-tools code. I have to do it for work on IDN anyway.

Comment 9 Marcus Moeller 2011-04-13 15:21:41 UTC
Dear Miroslav,

do you think you could make that happen for the 1.4 client tools, as we are in need to deploy Fedora 15 when it's released.

Greets
Marcus

Comment 10 Miroslav Suchý 2011-04-13 15:29:00 UTC
Nope, it will for sure dit not make it to Spacewalk 1.4.
Sorry.

Comment 11 Jan Pazdziora 2011-07-21 14:50:58 UTC
Removing from space15 as this is Fedora bugzilla.

Comment 12 Miroslav Suchý 2012-01-17 10:36:52 UTC
It is fixed in Fedora 17. If not, please reopen this bug.
Solution is more complex and therefore will not be backported to older Fedora.


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