Bug 813845 - name and baseName fields are not set correctly on ProcessInfo objects for processes running as a different user than the RHQ Agent
name and baseName fields are not set correctly on ProcessInfo objects for pro...
Status: CLOSED CURRENTRELEASE
Product: RHQ Project
Classification: Other
Component: Plugin Container (Show other bugs)
4.3
Unspecified Unspecified
unspecified Severity high (vote)
: ---
: RHQ 4.4.0
Assigned To: Charles Crouch
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-18 10:57 EDT by Ian Springer
Modified: 2015-02-01 18:27 EST (History)
3 users (show)

See Also:
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: ---


Attachments (Terms of Use)

  None (edit)
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:

http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=commitdiff;h=a1fd220
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.

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