Bug 589668 - pidof failed to get the pid with full path
Summary: pidof failed to get the pid with full path
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: SysVinit
Version: 5.2
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Petr Lautrbach
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-05-06 16:08 UTC by kwz
Modified: 2018-11-14 19:00 UTC (History)
5 users (show)

Fixed In Version: SysVinit-2.86-16.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-21 11:00:33 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1040 0 normal SHIPPED_LIVE SysVinit bug fix update 2011-07-20 15:43:51 UTC

Description kwz 2010-05-06 16:08:01 UTC
Description of problem:
pidof failed to get the pid with full path. This could be a same problem in bug#567295.

Version-Release number of selected component (if applicable):
SysVinit-2.86-14

How reproducible:
Not easy.  

Steps to Reproduce:
1.write a small program use readlink(path,pathname,maxbuf) and print out pathname for all processes. See killall5.c readproc() method for example.
2.If lucky enough, one could see some junk character after the pathname print out. Example /path1/path2/path3/program@@@.
3.With the pathname from step 2, run pidof with it. Example /sbin/pidof /path1/path2/path3/program.  One shouldn't see any PID return.
  
Actual results:
can not find the PID

Expected results:
should find the PID

Additional info:
readlink doesn't seems to add end of string to pathname.
The problem is in killall5.c function readproc(), 
		if (readlink(path, p->pathname, PATH_MAX) == -1) {
		if(pathnameLength==-1){
			p->pathname = NULL;
		} else {
			p->pathname[PATH_MAX-1] = '\0';
		}
believe it should change to
		int pathnameLength=readlink(path, p->pathname, PATH_MAX);
		if(pathnameLength==-1){
			p->pathname = NULL;
		} else {
			p->pathname[pathnameLength] = '\0';
		}

Comment 1 Bill Nottingham 2010-05-06 17:16:59 UTC
Are you using MLS policy?

Comment 2 kwz 2010-05-07 20:49:01 UTC
(In reply to comment #1)
> Are you using MLS policy?    

New guy here.  What's MLS policy?

Comment 3 Bill Nottingham 2010-05-07 20:53:54 UTC
If you need to ask, you aren't. :)

Comment 4 kwz 2010-05-07 21:07:47 UTC
(In reply to comment #3)
> If you need to ask, you aren't. :)    

It has been working very well with the change. See Additional info. Let me know if I could provide more help.

Comment 9 errata-xmlrpc 2011-07-21 11:00:33 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1040.html


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