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 1671174 - CommandRunner.run() does not prepend pacemaker_binaries directory [RHEL 7]
Summary: CommandRunner.run() does not prepend pacemaker_binaries directory [RHEL 7]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: pcs
Version: 7.6
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Tomas Jelinek
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-31 00:09 UTC by Reid Wahl
Modified: 2023-09-07 19:41 UTC (History)
8 users (show)

Fixed In Version: pcs-0.9.168-3.el7
Doc Type: Bug Fix
Doc Text:
Cause: User runs pcs in an environment with PATH variable empty or not set. Consequence: Some pcs commands fail as they are unable to run pacemaker tools. Fix: Always specify a full path to external executables when running them from pcs. Result: Pcs works even if environment variable PATH is empty or not set.
Clone Of:
: 1673825 (view as bug list)
Environment:
Last Closed: 2020-03-31 19:09:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
proposed fix (13.23 KB, patch)
2019-03-21 16:56 UTC, Tomas Jelinek
no flags Details | Diff
proposed fix 2 (1.86 KB, patch)
2019-11-04 11:09 UTC, Tomas Jelinek
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3875501 0 None None None 2019-01-31 00:59:56 UTC
Red Hat Product Errata RHBA-2020:0996 0 None None None 2020-03-31 19:10:00 UTC

Description Reid Wahl 2019-01-31 00:09:07 UTC
Description of problem:

The now-deprecated utils.run() function ran crm*, corosync*, and ccs* commands by their absolute path by prepending the appropriate binaries directory.

1011 # Run command, with environment and return (output, retval)
1012 # DEPRECATED, please use lib.external.CommandRunner via utils.cmd_runner()
1013 def run(
1014     args, ignore_stderr=False, string_for_stdin=None, env_extend=None,
1015     binary_output=False
1016 ):
...
1027     if command[0:3] == "crm" or command in ["cibadmin", "cman_tool", "iso8601"]:
1028         args[0] = settings.pacemaker_binaries + command
1029     elif command[0:8] == "corosync":
1030         args[0] = settings.corosync_binaries + command
1031     elif command == "ccs":
1032         args[0] = settings.ccs_binaries + command


The CommandRunner.run() method (called by `utils.cmd_runner().run()`) does not prepend the binaries directory and instead runs commands by their base name, forcing a search through the directories in the PATH environment variable.


Below is an example of execution using `pcs cluster status` (the cluster_status function still uses the deprecated utils.run) and `pcs status` (the full_status function uses utils.cmd_runner().run).

[root@fastvm-rhel-7-5-22 pcs]# pcs cluster status --debug | head -1
Running: /usr/sbin/crm_mon -1 -r

[root@fastvm-rhel-7-5-22 pcs]# pcs status --debug | head -1
Running: crm_mon --one-shot --inactive

--------------------

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

pcs-0.9.165-6.el7.x86_64

--------------------

How reproducible:

Always

--------------------

Steps to Reproduce:
1. Run `pcs cluster status --debug`. The cluster_status function uses utils.run.

2. Run `pcs status --debug`. The full_status function uses utils.cmd_runner().run.

--------------------

Actual results:

`pcs cluster status` calls /usr/sbin/crm_mon (absolute path).
`pcs status` calls crm_mon (relative path or base name).

--------------------

Expected results:

Both commands call /usr/sbin/crm_mon (absolute path).

--------------------

Additional info:

This can interfere with certain privilege escalation methods. One customer escalates user privileges via the suexec command provided by BoKS. The root environment is not getting set, so `crm_mon` is not found without an absolute path.

Comment 1 Tomas Jelinek 2019-02-06 15:11:44 UTC
It is intentional that CommandRunner.run() does not modify any path it is given. It is up to its caller to determine what should be run. The bug is not in the runner. The bug is in the code calling it. We should check all places calling the CommandRunner and make sure full paths are specified in all of them.

Comment 2 Tomas Jelinek 2019-03-21 16:56:23 UTC
Created attachment 1546627 [details]
proposed fix

Test:
pcs should work even if environment variable PATH is empty / not set

Commands fixed by the patch:
* pcs cluster cib-push diff-against=
* pcs cluster destroy
* pcs cluster kill
* pcs cluster stop
* pcs config restore --local
* pcs qdevice kill net
* pcs status
* pcs stonith confirm
* pcs stonith fence

Comment 4 Ivan Devat 2019-08-05 11:23:05 UTC
After Fix:

[kid76 ~] $ rpm -q pcs
pcs-0.9.168-1.el7.x86_64

[kid76 ~] $ PATH="" /usr/sbin/pcs cluster destroy
Shutting down pacemaker/corosync services...
Killing any remaining services...
Removing all cluster configuration files...
[kid76 ~] $ pcs status
Error: cluster is not currently running on this node

Comment 11 Tomas Jelinek 2019-11-04 11:09:17 UTC
Created attachment 1632505 [details]
proposed fix 2

Fix reading auth tokens when PATH is empty or not set. Fixes the 'pcs cluster status' and other commands.

Comment 12 Ivan Devat 2019-11-05 08:11:35 UTC
After Fix

[kid76 ~] $ rpm -q pcs
pcs-0.9.168-3.el7.x86_64

[kid76 ~] $ PATH=""
[kid76 ~] $ /usr/sbin/pcs cluster start --all
kid76: Starting Cluster (corosync)...
lion76: Starting Cluster (corosync)...
lion76: Starting Cluster (pacemaker)...
kid76: Starting Cluster (pacemaker)...
[kid76 ~] $ /usr/sbin/pcs cluster status
Cluster Status:
 Stack: unknown
 Current DC: NONE
 Last updated: Mon Nov  4 16:30:25 2019
 Last change: Mon Nov  4 16:30:12 2019 by hacluster via crmd on lion76
 2 nodes configured
 0 resources configured

PCSD Status:
  kid76: Online
  lion76: Online

Comment 16 errata-xmlrpc 2020-03-31 19:09:37 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/RHBA-2020:0996


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