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 1798128 - pidofproc uses pidof with -m that does not exist anymore with pidof from procps-ng
Summary: pidofproc uses pidof with -m that does not exist anymore with pidof from proc...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: initscripts
Version: 8.2
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: 8.0
Assignee: Jan Macku
QA Contact: Daniel Rusek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-04 15:54 UTC by Welterlen Benoit
Modified: 2023-12-15 17:16 UTC (History)
2 users (show)

Fixed In Version: initscripts-10.00.7-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 01:41:25 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 5640741 0 None None None 2020-12-11 09:25:34 UTC
Red Hat Product Errata RHBA-2020:4463 0 None None None 2020-11-04 01:41:39 UTC

Description Welterlen Benoit 2020-02-04 15:54:51 UTC
Description of problem:
When starting an initscript directly (without systemctl) and if it checks the pid with pidofproc, the output of pidofproc is always true as pidof in /etc/init.d/functions is called with -m that does not exist anymore, and thus the initial script is not omitted.

Version-Release number of selected component (if applicable):
RHEL 8 
procps-ng-3.3.15-1.el8.x86_64
initscripts-10.00.4-1.el8.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Use an init scrips with pidofproc $progname
2. the output will always be true if the service is run through /etc/init.d/service start
3.

Actual results:
the service does not start if not called with systemctl

Expected results:
the service should start with /etc/init.d/service start

Additional info:
A workaround is to run "sh /etc/init.d/service start" as the script will be omitted by pidof.

- Script: 
--------------------------
#!/bin/bash
#
# chkconfig: 2345 50 50
#
# description: The dummy daemon
#
### BEGIN INIT INFO
# Provides: foo
# Short-Description: Dummy Daemon
# Description: The dummy daemon
### END INIT INFO

. /etc/init.d/functions

set -o functrace
set -x

PROGNAME=foo
PROGPATH=/usr/local/bin/foo
RETVAL=0

start() {
        echo -n $"Starting $PROGNAME: $$"
        echo pidof ` pidof $PROGNAME`
        if [ $UID -ne 0 ]; then
                # insufficient privilege
                RETVAL=1
                failure
        elif pidofproc $PROGPATH >/dev/null 3>&1 2>&1; then
                echo "Already runnning $PROGPATH" >> /tmp/foo
                #sleep 1000
                # already running
                RETVAL=1
                failure
        else
                #sleep 1000
                daemon $PROGPATH
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROGNAME
        fi
        echo
}

stop() {
        echo -n $"Stopping $PROGNAME: "
        if [ $UID -ne 0 ]; then
                # insufficient privilege
                RETVAL=1
                failure
        else
                killproc $PROGPATH
                RETVAL=$?
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROGNAME
        fi
        echo
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
esac

exit $RETVAL
------------------

- the daemon:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>

int main(int argc, char* argv[])
{
        pid_t process_id = 0;
        pid_t sid = 0;

        // Create child process
        process_id = fork();
        // Indication of fork() failure
        if (process_id < 0) {
                printf("fork failed!\n");
                // Return failure in exit status
                exit(1);
        }
        // PARENT PROCESS. Need to kill it.
        if (process_id > 0) {
                printf("process_id of child process %d \n", process_id);
                // return success in exit status
                exit(0);
        }
        //unmask the file mode
        umask(0);
        //set new session
        sid = setsid();
        if(sid < 0) {
                // Return failure
                exit(1);
        }
        // Change the current working directory to root.
        chdir("/");
        // Close stdin. stdout and stderr
        close(STDIN_FILENO);
        close(STDOUT_FILENO);
        close(STDERR_FILENO);
        while (1) {
                sleep(3600);
        }

        return (0);
}

Comment 3 Jan Macku 2020-03-11 11:45:57 UTC
Bug will be fixed in RHEL 8.3.0

Upstream PR: https://github.com/fedora-sysv/initscripts/pull/314

Comment 9 errata-xmlrpc 2020-11-04 01:41:25 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 (initscripts bug fix and enhancement update), and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHBA-2020:4463


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