Skip to content

Commit

Permalink
Ensure full path when using timeout command (#3508)
Browse files Browse the repository at this point in the history
* util/subproc was already using which to get the full path for timeout, but the command spec was not.  This change uses the which util to ensure the full path is obtained for the timeout command
* Fix #1130

Signed-off-by: Bob Fahr <[email protected]>
(cherry picked from commit c101690)
  • Loading branch information
bfahr authored and xiangce committed Sep 8, 2022
1 parent 0e502c3 commit 9fcaa85
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions insights/client/insights_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys
from subprocess import Popen, PIPE, STDOUT
from tempfile import NamedTemporaryFile
from insights.util import mangle
from insights.util import mangle, which

from .constants import InsightsConstants as constants
from .utilities import determine_hostname
Expand Down Expand Up @@ -61,13 +61,15 @@ def get_output(self):
else:
signal = 'KILL'

timeout_command = 'timeout -s %s %s %s' % (
signal, self.config.cmd_timeout, self.command)

# ensure consistent locale for collected command output
cmd_env = {'LC_ALL': 'C',
'PATH': '/sbin:/bin:/usr/sbin:/usr/bin',
'PYTHONPATH': os.getenv('PYTHONPATH')}

timeout = which('timeout', env=cmd_env)
timeout_command = '%s -s %s %s %s' % (
timeout, signal, self.config.cmd_timeout, self.command)

args = shlex.split(timeout_command)

# never execute this stuff
Expand Down

0 comments on commit 9fcaa85

Please sign in to comment.