Bug 813845

Summary: name and baseName fields are not set correctly on ProcessInfo objects for processes running as a different user than the RHQ Agent
Product: [Other] RHQ Project Reporter: Ian Springer <ian.springer>
Component: Plugin ContainerAssignee: Charles Crouch <ccrouch>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.3CC: ccrouch, hbrock, hrupp
Target Milestone: ---   
Target Release: RHQ 4.4.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-01 06:05:52 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Ian Springer 2012-04-18 10:57:39 EDT
For example, I started an Apache server on Fedora as follows:

sudo /usr/sbin/httpd

In the ProcessInfo that gets created for the corresponding process, the name field is set to "?", and the baseName field is set to "/use/sbin/httpd". This is incorrect - name should be "/usr/sbin/httpd", and baseName should be "httpd". The problem is the logic for initializing these fields is faulty. 

The name logic is:

this.name = (procExe != null) ? procExe.getName() : UNKNOWN;

procExe is always null for processes running as different users, so instead we should be used procArgs[0] as our first choice, since that is pretty much always set. 

The basename logic is similar, except it tries to user procState.getName() as a fallback if procExe is null. It should also be using procArgs[0] as its first choice, i.e.:

this.baseName = new File(procArgs[0]).getName();
Comment 1 Ian Springer 2012-04-18 11:02:25 EDT
I forgot to mention the symptom of this bug that I encountered. When Apache httpd is running as root, and the RHQ Agent is running as another user, the Apache server is not discovered. The reason is that the ProcessInfo's baseName is incorrectly set to "/usr/sbin/httpd", and the process scan from the apache plugin's rhq-plugin.xml is:

<process-scan name="HttpdOnUnix"     query="process|basename|match=httpd.*,process|basename|nomatch|parent=httpd.*"/>

Notice it's looking for a basename that matches the regex "httpd.*", and "/usr/sbin/httpd" will not match that.
Comment 2 Ian Springer 2012-04-18 11:05:34 EDT
Fixed in master:

Comment 5 Heiko W. Rupp 2013-09-01 06:05:52 EDT
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.