Description of problem: When Agent is being upgraded automatically, the installer attempts to install the agent to the parent of the agent home directory. If the Agent is run as a non-root user, this fails. If for example, RHQ_AGENT_HOME is /usr/local/rhq-agent, then it will attempt to download to /usr/local. This directory is typically owned by root and it will fail. Version-Release number of selected component (if applicable): 4.1 update to 4.4 How reproducible: Always Steps to Reproduce: 1. Install 4.1 agent and server, running as 'rhq' user. 2. Update server to 4.4, attempt to update agent. Additional info: Agent should download to java.io.tmpdir instead, since this is always available to any user. I don't see any potential downside to this. Suggested fix: diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateDownload.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateDownload.java index 9edad7f..709875e 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateDownload.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateDownload.java @@ -83,18 +83,7 @@ public class AgentUpdateDownload { * @return local file system location where the downloaded files are stored */ public File getLocalDownloadDirectory() { - String agentHome = this.agent.getAgentHomeDirectory(); - File dir = null; - - if (agentHome != null && agentHome.length() > 0) { - dir = (new File(agentHome)).getParentFile(); - } - - if (dir == null) { - dir = new File(System.getProperty("java.io.tmpdir")); - } - - return dir; + return new File(System.getProperty("java.io.tmpdir")); } /**
Note that this has been a requirement that is already documented in the Installation documentation: https://docs.jboss.org/author/display/RHQ/RHQ+Agent+Installation#RHQAgentInstallation-InstallTheAgentInAWritableDirectory "Install The Agent In A Writable Directory During the update process, files will need to be written in the directory where the agent is currently installed. This means that the parent directory of the agent's install directory must be writable by the user that is running the agent. As an example, if the agent's $RHQ_AGENT_HOME (i.e. where the agent is installed) is the directory called "/opt/rhq-agent-parent/rhq-agent", the agent will need to write files to the "/opt/rhq-agent-parent" directory and therefore must have write permissions there." I haven't looked at the side effects of the proposed patch, but the issue that requires this writable parent dir (IIRC) was that the ant script that runs the agent update expects the binary jar to be in the parent location of the agent installation home directory.
Sorry I didn't carefully read the documentation. I migrated several instances from running the agent as root to rhq and failed to consider this. The patch is also incomplete as you note as the ant script will fail to run.