Bug 1964255

Summary: libpcp/pmproxy: authentication is unsuccessful if the password contains special characters
Product: Red Hat Enterprise Linux 8 Reporter: Mark Keir <mkeir>
Component: pcpAssignee: Andreas Gerstmayr <agerstmayr>
Status: CLOSED ERRATA QA Contact: Jan Kurik <jkurik>
Severity: low Docs Contact: Apurva Bhide <abhide>
Priority: unspecified    
Version: 8.4CC: agerstmayr, jkurik, nathans, yuokada
Target Milestone: betaKeywords: Bugfix, Triaged
Target Release: 8.6Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: pcp-5.3.4-1.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 13:30:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1991763    
Attachments:
Description Flags
bpftrace.conf none

Description Mark Keir 2021-05-25 06:29:41 UTC
Description of problem:
Unable to configure PCP bpftrace Grafana Datasource, authentication or other failure

Version-Release number of selected component (if applicable):
3.0.2.1

How reproducible:

Always

Steps to Reproduce:
1. Follow steps at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/monitoring_and_managing_system_status_and_performance/setting-up-graphical-representation-of-pcp-metrics_monitoring-and-managing-system-status-and-performance#creating-panel-and-alerts-in-pcp-redis-data-source_setting-up-graphical-representation-of-pcp-metrics or https://grafana-pcp.readthedocs.io/en/latest/datasources/authentication.html
2. Test credential access from command line
3. Try to use same credentials in configuring the Datasource

Actual results:
Command line succeeds, eg:
pminfo -f -h "pcp://127.0.0.1?username=metrics" disk.dev.read
Password: 

disk.dev.read
    inst [0 or "nvme0n1"] value 97607

Datasource save and test fails:
cannot connect to PMCD: Authentication - bad protocol / cancel. To use this data source, please configure the URL in the query editor.

Expected results:

Command line succeeds, Datasource save and test succeeds

Additional info:

Comment 1 Jan Kurik 2021-05-25 09:13:29 UTC
Hi Mark,

I was trying to reproduce the issue, but everything works for me. Can you please share content of your /etc/pcp/bpftrace/bpftrace.conf file ?

Comment 2 Mark Keir 2021-05-25 09:40:58 UTC
Created attachment 1786781 [details]
bpftrace.conf

Requested configuration file attached.

Comment 3 Andreas Gerstmayr 2021-05-25 10:08:43 UTC
Can you check the datasource settings if only "Basic Auth" is selected in the Auth section?
And please check /var/log/pcp/pmproxy/pmproxy.log for anything unusual.

Also, can you try creating another user with an "easy" password, as in just letters and digits (the error you're seeing also shows up when the username/password doesn't match)? Possibly some special character gets lost.


fwiw, I also couldn't reproduce this, just fishing for things which could get wrong.

Comment 4 Mark Keir 2021-05-26 05:34:24 UTC
A failed "Save & Test" created a log entry in /var/log/pcp/pmproxy/pmproxy.log such as the following event.

[Wed May 26 15:32:16] pmproxy(110882) Error: opening input terminal for read

Moving on to try a user/password with less complexity.

Comment 5 Mark Keir 2021-05-26 05:48:25 UTC
Creating a password with this command, the Datasource could be configured.

mkpasswd -s 0 -l 15

Using the following also worked for a fresh value.

mkpasswd -s 3 -l 15

By substituting the special characters in the starting password, I was able to determine that a special character of "=" broke the Datasource configuration for any attempted location in the string.

Comment 6 Andreas Gerstmayr 2021-05-26 13:17:56 UTC
Thanks a lot for your analysis!

I'll fix this bug in RHEL 8.5.

Comment 7 Andreas Gerstmayr 2021-05-26 16:07:27 UTC
I thought it's a quick and easy fix in pmproxy or grafana-pcp, but after diving down to the root cause, I realized that the issue is in a core part of PCP (the handling of hostspecs [1]), so I moved the component to pcp.

I cannot guarantee that I've the time to properly implement and test this for 8.5, so I cleared the DTM/ITM. Sorry for the hasty triaging.


[1] https://github.com/performancecopilot/pcp/issues/1305

Comment 9 Andreas Gerstmayr 2021-10-01 17:10:25 UTC
fixed upstream and will be part of the next rebase of PCP:

commit 2ff22e302de22f62cbd6cee1bf8f2aad775da866
Author: Andreas Gerstmayr <agerstmayr>
Date:   Tue Sep 14 19:55:28 2021 +0200
 
    libpcp: use urlencoding for hostspec parameter values
    
    Resolves: #1305

Comment 14 errata-xmlrpc 2022-05-10 13:30:36 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 (pcp bug fix and enhancement update), 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/RHBA-2022:1765