RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1698763 - pcs exits with traceback when port with invalid value was given to the auth command
Summary: pcs exits with traceback when port with invalid value was given to the auth c...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pcs
Version: 8.0
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: rc
: 8.0
Assignee: Miroslav Lisik
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-04-11 08:17 UTC by Miroslav Lisik
Modified: 2020-04-28 15:28 UTC (History)
6 users (show)

Fixed In Version: pcs-0.10.3-1.el8
Doc Type: Bug Fix
Doc Text:
Cause: The `pcs host auth` command does not validate network port. Consequence: Python traceback is propagated to the user in the case when invalid port was given. Fix: Catch an exeption in case when port is invalid and display proper error message to the user. Result: The user is informed about invalid port by error message and proper port range is displayed.
Clone Of:
Environment:
Last Closed: 2020-04-28 15:27:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
proposed fix (7.39 KB, patch)
2019-10-16 16:12 UTC, Miroslav Lisik
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2020:1568 0 None None None 2020-04-28 15:28:35 UTC

Description Miroslav Lisik 2019-04-11 08:17:17 UTC
Description of problem:
Pcs exits with traceback when port with invalid value was given to the auth command.

Version-Release number of selected component (if applicable):
pcs-0.10.1-4.el8

How reproducible:
always

Steps to Reproduce:
1. run auth command with some invalid port value

[root@virt-157 ~]# pcs host auth node-01 -u hacluster -p password addr=virt-157.cluster-qe.lab.eng.brq.redhat.com:70000
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 11, in <module>
    load_entry_point('pcs==0.10.1', 'console_scripts', 'pcs')()
  File "/usr/lib/python3.6/site-packages/pcs/app.py", line 178, in main
    utils.get_input_modifiers(),
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 22, in host_cmd
    auth_cmd(lib, argv_next, modifiers)
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 73, in auth_cmd
    "host name"
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 71, in <dictcomp>
    for host, opts in parse_args.split_list_by_any_keywords(
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 45, in _parse_host_options
    addr, port = _parse_addr(parsed_options.get(ADDR_OPT_KEYWORD, host))
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 55, in _parse_addr
    return url.hostname, (url.port if url.port else settings.pcsd_default_port)
  File "/usr/lib64/python3.6/urllib/parse.py", line 171, in port
    raise ValueError("Port out of range 0-65535")
ValueError: Port out of range 0-65535
[root@virt-157 ~]# echo $?
1
[root@virt-157 ~]# pcs host auth node-01 -u hacluster -p password addr=virt-157.cluster-qe.lab.eng.brq.redhat.com:port
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 11, in <module>
    load_entry_point('pcs==0.10.1', 'console_scripts', 'pcs')()
  File "/usr/lib/python3.6/site-packages/pcs/app.py", line 178, in main
    utils.get_input_modifiers(),
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 22, in host_cmd
    auth_cmd(lib, argv_next, modifiers)
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 73, in auth_cmd
    "host name"
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 71, in <dictcomp>
    for host, opts in parse_args.split_list_by_any_keywords(
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 45, in _parse_host_options
    addr, port = _parse_addr(parsed_options.get(ADDR_OPT_KEYWORD, host))
  File "/usr/lib/python3.6/site-packages/pcs/host.py", line 55, in _parse_addr
    return url.hostname, (url.port if url.port else settings.pcsd_default_port)
  File "/usr/lib64/python3.6/urllib/parse.py", line 169, in port
    port = int(port, 10)
ValueError: invalid literal for int() with base 10: 'port'
[root@virt-157 ~]# echo $?
1

Actual results:
pcs exits with a traceback.

Expected results:
pcs exits with some error message.

Additional info:

Comment 2 Miroslav Lisik 2019-10-16 16:12:59 UTC
Created attachment 1626534 [details]
proposed fix

Test:
1. Use some port out of range with address specified in `pcs auth host` command.
2. Error message should be displayed instead of python traceback.

[root@r81-node-01 pcs]# lpcs host auth node-001 -u hacluster -p password addr=virt-001.cluster-qe.lab.eng.brq.redhat.com:65536
Error: Invalid port number in address 'virt-001.cluster-qe.lab.eng.brq.redhat.com:65536', use 1..65535
[root@r81-node-01 pcs]# lpcs host auth node-001 -u hacluster -p password addr=virt-001.cluster-qe.lab.eng.brq.redhat.com:notaportnumber
Error: Invalid port number in address 'virt-001.cluster-qe.lab.eng.brq.redhat.com:notaportnumber', use 1..65535

Comment 3 Miroslav Lisik 2019-10-23 15:30:55 UTC
After fix:

[root@r81-node-01 ~]# rpm -q pcs
pcs-0.10.3-1.el8.x86_64


[root@r81-node-01 ~]# pcs host auth -u hacluster -p password r81-node-01 addr=r81-node-01:65536
Error: Invalid port number in address 'r81-node-01:65536', use 1..65535
[root@r81-node-01 ~]# echo $?
1
[root@r81-node-01 ~]# pcs host auth -u hacluster -p password r81-node-01 addr=r81-node-01:65535 r81-node-02 addr=192.168.122.82:string
Error: Invalid port number in address '192.168.122.82:string', use 1..65535
[root@r81-node-01 ~]# echo $?
1

Comment 7 errata-xmlrpc 2020-04-28 15:27:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:1568


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