RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 980134 - 'service httpd status' as non root, returns incorrect status
Summary: 'service httpd status' as non root, returns incorrect status
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: initscripts
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: pre-dev-freeze
: 6.6
Assignee: Lukáš Nykrýn
QA Contact: Jan Ščotka
URL:
Whiteboard:
Depends On: 971606
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-01 13:44 UTC by Pádraig Brady
Modified: 2016-11-25 13:03 UTC (History)
4 users (show)

Fixed In Version: initscripts-9.03.44-1.el6
Doc Type: Bug Fix
Doc Text:
Previously when checking for running service only permission for pidfile were checked. When the parent directory for that pidfile was not accessible initscript returned wrong return code. Now we are also checking for permission for the parent directory.
Clone Of: 971606
Environment:
Last Closed: 2014-10-14 06:27:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1448 0 normal SHIPPED_LIVE initscripts bug fix and enhancement update 2014-10-14 01:05:44 UTC

Description Pádraig Brady 2013-07-01 13:44:33 UTC
+++ This bug was initially created as a clone of Bug #971606 +++

When checking service status as a non root user...

  $ service httpd status
  httpd dead but subsys locked

Aside from the fact that this really shouldn't need root access,
the bug here is that the init script return code is incorrect:

  $ echo $?
  2

http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
states that "2" means the service is dead.
In this case "4" should be returned so that status
for this service can be presented correctly.

--- Additional comment from Jan Kaluža on 2013-06-07 00:50:23 EDT ---

I have checked httpd initscript and it uses "status" function from /etc/rc.d/init.d/functions (from package "initscripts") and returns its return code.

This function checks if the /var/run/httpd/httpd.pid exists, but /var/run/httpd directory has mode 0710, so as a user, you are not allowed to read its content. status function in /etc/init.d/functions should probably check for this case and return 4. I think this should be filed as a bug against initscripts package.

Comment 2 Lukáš Nykrýn 2013-07-10 11:41:42 UTC
In ideal case we should check whole path, but I think that parent dir of pid file should be enough.

untested patch:
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index fc5914c..e7725dd 100644
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -148,6 +148,9 @@ __umount_loopback_loop() {
 __pids_var_run() {
        local base=${1##*/}
        local pid_file=${2:-/var/run/$base.pid}
+        local pid_dir=$(/usr/bin/dirname $pid_file)
+
+        [ -d "$pid_dir" -a ! -r "$pid_dir" ] && return 4
 
        pid=
        if [ -f "$pid_file" ] ; then

Comment 6 Pádraig Brady 2014-06-05 14:14:35 UTC
The patch above looks incorrect. There is a redirect to >/dev/null ?
I.E. I'd change:

  /usr/bin/dirname $pid_file > /dev/null

to:

  dirname "$pid_file"

Comment 10 errata-xmlrpc 2014-10-14 06:27:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1448.html


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