Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1148186 - rhq-agent-wrapper's config and cleanconfig commands source RHQ_AGENT_START_COMMAND instead of executing it resulting in failures
rhq-agent-wrapper's config and cleanconfig commands source RHQ_AGENT_START_CO...
Status: CLOSED CURRENTRELEASE
Product: JBoss Operations Network
Classification: JBoss
Component: Agent, Launch Scripts (Show other bugs)
JON 3.2.3,JON 3.3.0
Unspecified Unspecified
unspecified Severity medium
: ER05
: JON 3.3.0
Assigned To: Stefan Negrea
Armine Hovsepyan
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-30 17:39 EDT by Larry O'Leary
Modified: 2015-09-02 20:03 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Users were unable to use the config and cleanconfig commands with the JBoss ON rhq-agent-wrapper if they were using the su or sudo commands in the RHQ_AGENT_START_COMMAND value. JBoss ON encountered errors when attempting to execute these commands with the rhq-agent-wrapper. An environment variable field has been added to the RHQ_AGENT_START_COMMAND value. The RHQ_AGENT_START_COMMAND value can be used with the su or sudo commands to start JBoss ON.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-12-11 09:00:37 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
agent_config.log (2.15 KB, text/plain)
2014-10-24 08:43 EDT, Armine Hovsepyan
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 1216313 None None None Never
Red Hat Knowledge Base (Solution) 1216333 None None None Never

  None (edit)
Description Larry O'Leary 2014-09-30 17:39:23 EDT
Description of problem:
If you use a command other then a shell script in the value for RHQ_AGENT_START_COMMAND -- such as su or nohup or time -- the config and cleanconfig commands can not be executed from rhq-agent-wrapper.

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

How reproducible:
Always

Steps to Reproduce:
1. Install and configure JBoss ON system.
2. Update rhq-agent-env.sh to and define RHQ_AGENT_START_COMMAND value such as:

   RHQ_AGENT_START_COMMAND="su -m jonadmin -c '${RHQ_AGENT_HOME}/bin/rhq-agent.sh'"

3. Be sure user jonadmin exists.
4. Chown the JBoss ON agent installation and its contents to the jonadmin user.
5. Run rhq-agent-wrapper.sh config

Actual results:
Fails with strange output or error similar to:
    ./rhq-agent-wrapper.sh: line 293: .: /usr/bin/su: cannot execute binary file

Expected results:
Should be prompted for agent configuration and the agent should be successfully configured.

Additional info:
This is due to the config and cleanconfig options in the rhq-agent-wrapper.sh case statement attempting to source the RHQ_AGENT_START_COMMAND value. This is not a valid script command when a binary file or arguments are being used. Even in the case that RHQ_AGENT_START_COMMAND is not explicitly defined, this is probably still not what we want to do. the . or source commands copy the contents of the specified file into the script at the execution point. This is really bad if the contents is binary and still bad if it was an actual executable script as it will result in very bad script nesting and scope issues.
Comment 1 Stefan Negrea 2014-10-07 23:31:02 EDT
Here are the three commits that need to be cherry-picked to the release branch:


commit 1df956d314083e10660c173cbfd562778e4f16b5
Author: Stefan Negrea <snegrea@redhat.com>
Date:   Mon Oct 6 16:36:23 2014 -0500

    [BZ 1148186] One more update to the initial commit:
    
    - Switch to use $_DOLLARZERO variable to correctly identify the location of the script.



commit ca21dac99551fbb62d33db7e66b154857a96a68c
Author: Stefan Negrea <snegrea@redhat.com>
Date:   Mon Oct 6 14:47:39 2014 -0500

    [BZ 1148186] More updates for the initial commit:
    1) Only assign the pwd to RHQ_AGENT_HOME not already defined
    2) Use a temp variable to extract pwd before dirname



commit d583b234429ca466e3e067dc02635394f711a8fd
Author: Stefan Negrea <snegrea@redhat.com>
Date:   Wed Oct 1 17:15:12 2014 -0500

    [BZ 1148186] Use eval to execute the RHQ agent start command. It was incorrectly source
Comment 2 Thomas Segismont 2014-10-09 11:44:36 EDT
Cherry-picked over to release/jon3.3.x



  Branch: refs/heads/release/jon3.3.x
  Home:   https://github.com/rhq-project/rhq
  Commit: c30b551dd4608b92d16f57b6715d14ca64958bc2
      https://github.com/rhq-project/rhq/commit/c30b551dd4608b92d16f57b6715d14ca64958bc2
  Author: Stefan Negrea <snegrea@redhat.com>
  Date:   2014-10-09 (Thu, 09 Oct 2014)

  Changed paths:
    M modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh

  Log Message:
  -----------
  [BZ 1148186] Use eval to execute the RHQ agent start command. It was incorrectly sourced in the current script. Note that only config and full config were affected. Also, adjusted the order for defining and export RHQ home to allow proper overrides int RHQ environment script.

(cherry picked from commit d583b234429ca466e3e067dc02635394f711a8fd)
Signed-off-by: Thomas Segismont <tsegismo@redhat.com>


  Commit: e214e93387a7f815ecef66260dbd4220d489f9b6
      https://github.com/rhq-project/rhq/commit/e214e93387a7f815ecef66260dbd4220d489f9b6
  Author: Stefan Negrea <snegrea@redhat.com>
  Date:   2014-10-09 (Thu, 09 Oct 2014)

  Changed paths:
    M modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh

  Log Message:
  -----------
  [BZ 1148186] More updates for the initial commit:
1) Only assign the pwd to RHQ_AGENT_HOME not already defined
2) Use a temp variable to extract pwd before dirname

(cherry picked from commit ca21dac99551fbb62d33db7e66b154857a96a68c)
Signed-off-by: Thomas Segismont <tsegismo@redhat.com>


  Commit: 806230cd33d43817509f72fddcc8fe97703faed9
      https://github.com/rhq-project/rhq/commit/806230cd33d43817509f72fddcc8fe97703faed9
  Author: Stefan Negrea <snegrea@redhat.com>
  Date:   2014-10-09 (Thu, 09 Oct 2014)

  Changed paths:
    M modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh

  Log Message:
  -----------
  [BZ 1148186] One more update to the initial commit:

- Switch to use $_DOLLARZERO variable to correctly identify the location of the script.

(cherry picked from commit 1df956d314083e10660c173cbfd562778e4f16b5)
Signed-off-by: Thomas Segismont <tsegismo@redhat.com>


Compare: https://github.com/rhq-project/rhq/compare/3a5701178868...806230cd33d4
Comment 4 John Mazzitelli 2014-10-15 17:46:37 EDT
FYI: this fix broke the dev-container build on Mac - see bug #1153373
Comment 5 Stefan Negrea 2014-10-21 10:59:06 EDT
bug 1153373 does not impact JON since OSX is not a supported platform. A fix has already been deployed for the RHQ community release but will not be backported to JON 3.3.
Comment 6 Simeon Pinder 2014-10-21 16:24:41 EDT
Moving to ON_QA as available to test with the latest brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=394734
Comment 7 Armine Hovsepyan 2014-10-24 08:43:28 EDT
Created attachment 950382 [details]
agent_config.log
Comment 8 Armine Hovsepyan 2014-10-24 08:43:57 EDT
verified in JON 3.3 ER05
log attached

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