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.
Here are the three commits that need to be cherry-picked to the release branch: commit 1df956d314083e10660c173cbfd562778e4f16b5 Author: Stefan Negrea <snegrea> 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> 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> Date: Wed Oct 1 17:15:12 2014 -0500 [BZ 1148186] Use eval to execute the RHQ agent start command. It was incorrectly source
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> 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> Commit: e214e93387a7f815ecef66260dbd4220d489f9b6 https://github.com/rhq-project/rhq/commit/e214e93387a7f815ecef66260dbd4220d489f9b6 Author: Stefan Negrea <snegrea> 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> Commit: 806230cd33d43817509f72fddcc8fe97703faed9 https://github.com/rhq-project/rhq/commit/806230cd33d43817509f72fddcc8fe97703faed9 Author: Stefan Negrea <snegrea> 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> Compare: https://github.com/rhq-project/rhq/compare/3a5701178868...806230cd33d4
FYI: this fix broke the dev-container build on Mac - see bug #1153373
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.
Moving to ON_QA as available to test with the latest brew build: https://brewweb.devel.redhat.com//buildinfo?buildID=394734
Created attachment 950382 [details] agent_config.log
verified in JON 3.3 ER05 log attached