Bug 1490380 - otopi's path search is incompatible with common shells
Summary: otopi's path search is incompatible with common shells
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: otopi
Classification: oVirt
Component: Core
Version: master
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ovirt-4.2.0
: 1.7.2
Assignee: Yedidyah Bar David
QA Contact: David Necpal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-09-11 12:39 UTC by Yedidyah Bar David
Modified: 2017-12-20 11:07 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: otopi had a hard-coded search path for executables, and a non-standard behavior when searching. Consequence: Users could not affect its behavior by adding paths to the environment variable $PATH. In particular, this made it hard to support PostgreSQL 9.5 on EL7 using SCL, because SCL relies on $PATH. Fix: otopi was changed to behave like common shells wrt to $PATH. Result: It's now possible to change $PATH and make otopi search there. This affects all utilities that use otopi, including engine-setup and hosted-engine --deploy. This has a chance to have a negative effect - users that had non-standard $PATH that contained executables named the same as some of those we call from otopi-based utilities, will now have these utilities run these executables instead of standard OS-supplied ones. Such users should make sure they do not have unintended duplicates in non-standard $PATH.
Clone Of:
Environment:
Last Closed: 2017-12-20 11:07:32 UTC
oVirt Team: Integration
Embargoed:
rule-engine: ovirt-4.2+
sbonazzo: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 81623 0 master POST plugins: command: Obey env var $PATH 2017-09-11 13:12:19 UTC

Description Yedidyah Bar David 2017-09-11 12:39:04 UTC
Description of problem:

otopi does not obey the path set in the environment variable $PATH.

Also, it works with a "last win" search, contrary to common shells that do "first wins".

Its default search path is:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

So if some plugin wants to run a command 'cmd1', if both e.g. "/usr/local/bin/cmd1" and "/bin/cmd1" exist, otopi will use "/bin/cmd1". Similarly, if both "/bin/cmd1" and "/sbin/cmd1" exist, it will use "/bin/cmd1".

otopi should keep its default search path but make "first win" and obey env var $PATH.

Main risk in doing this is in systems with non-default $PATH that otopi ignored so far, but will start obeying if current bug is fixed, and run a different command.

Current bug recently became apparent due to bug 1459134 and the decision to use SCL for it, which relies on $PATH (and a few other env vars) to enable packages.

Comment 1 David Necpal 2017-10-06 14:12:06 UTC
Can you please provide verification steps?

Comment 2 Yedidyah Bar David 2017-10-15 07:05:42 UTC
Something like this should work:

yum install iproute
mkdir /tmp/mybintest
cat << __EOF__ > /tmp/mybintest/ip
#!/bin/sh
echo "fake ip command, exiting..."
exit 1
__EOF__
chmod 755 /tmp/mybintest/ip
PATH=/tmp/mybintest:$PATH otopi

With a fixed build, the output should include:

[WARNING] Cannot validate host name settings, reason: cannot enumerate interface addresses

And the log file:

2017-10-15 09:57:59,943+0300 DEBUG otopi.plugins.otopi.network.hostname plugin.executeRaw:863 execute-result: ('/tmp/mybintest/ip', 'addr', 'show'), rc=1
2017-10-15 09:57:59,944+0300 DEBUG otopi.plugins.otopi.network.hostname plugin.execute:921 execute-output: ('/tmp/mybintest/ip', 'addr', 'show') stdout:
fake ip command, exiting...

With an unfixed build (e.g. otopi-1.6), no WARNING should appear, and the log should include:

2017-10-15 09:56:15,418+0300 DEBUG otopi.plugins.otopi.network.hostname plugin.executeRaw:813 execute: ('/usr/sbin/ip', 'addr', 'show'), executable='None', cwd='None', env=None
2017-10-15 09:56:15,427+0300 DEBUG otopi.plugins.otopi.network.hostname plugin.executeRaw:863 execute-result: ('/usr/sbin/ip', 'addr', 'show'), rc=0
2017-10-15 09:56:15,427+0300 DEBUG otopi.plugins.otopi.network.hostname plugin.execute:921 execute-output: ('/usr/sbin/ip', 'addr', 'show') stdout:

Comment 3 David Necpal 2017-10-18 14:49:15 UTC
Verified on version: 
ovirt-engine-4.2.0-0.0.master.20171013142622.git15e767c.el7.centos.noarch

Verified based on suggested steps from comment #2

Comment 4 Sandro Bonazzola 2017-12-20 11:07:32 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

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


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