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 2124488 - syslog postrotate instruction terminates the service when POSIXLY_CORRECT env variable is set
Summary: syslog postrotate instruction terminates the service when POSIXLY_CORRECT env...
Keywords:
Status: CLOSED ERRATA
Alias: None
Deadline: 2023-01-17
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: rsyslog
Version: 9.1
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Attila Lakatos
QA Contact: Dalibor Pospíšil
Petr Hybl
URL:
Whiteboard:
Depends On: 2070496
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-06 10:20 UTC by Attila Lakatos
Modified: 2023-09-05 16:58 UTC (History)
6 users (show)

Fixed In Version: rsyslog-8.2102.0-109.el9
Doc Type: Bug Fix
Doc Text:
.`logrotate` no longer incorrectly signals Rsyslog in log rotation Previously, the argument order was incorrectly set in the `logrotate` script, which caused a syntax error. This resulted in `logrotate` not correctly signaling Rsyslog during log rotation. With this update, the order of the arguments in `logrotate` is fixed and `logrotate` signals Rsyslog correctly after log rotation even when the `POSIXLY_CORRECT` environment variable is set.
Clone Of: 2070496
Environment:
Last Closed: 2023-05-09 07:44:54 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-133295 0 None None None 2022-09-06 10:23:01 UTC
Red Hat Issue Tracker SECENGSP-4755 0 None None None 2022-09-06 10:23:11 UTC
Red Hat Product Errata RHBA-2023:2303 0 None None None 2023-05-09 07:45:03 UTC

Description Attila Lakatos 2022-09-06 10:20:16 UTC
+++ This bug was initially created as a clone of Bug #2070496 +++

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

rsyslog-8.2102.0-5.el8.x86_64
bash-4.4.20-2.el8.x86_64



#cat /etc/logrotate.d/syslog

/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    missingok
    sharedscripts
    postrotate
        /usr/bin/systemctl kill -s HUP rsyslog.service >/dev/null 2>&1 || true
    endscript
}



How reproducible:



[root@rhel85 ~]# echo $POSIXLY_CORRECT

[root@rhel85 ~]# /usr/bin/systemctl kill -s HUP rsyslog.service
[root@rhel85 ~]# systemctl status rsyslog.service
● rsyslog.service - System Logging Service
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2022-03-31 11:18:04 CEST; 10min ago
     Docs: man:rsyslogd(8)
           https://www.rsyslog.com/doc/
 Main PID: 877 (rsyslogd)
    Tasks: 3 (limit: 23464)
   Memory: 2.5M
   CGroup: /system.slice/rsyslog.service
           └─877 /usr/sbin/rsyslogd -n

Mar 31 11:18:04 rhel85.example.com systemd[1]: Starting System Logging Service...
Mar 31 11:18:04 rhel85.example.com systemd[1]: Started System Logging Service.
Mar 31 11:18:04 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:18:04 rhel85.example.com rsyslogd[877]: imjournal: journal files changed, reloading...  [v8.2102.0-5.e>
Mar 31 11:22:23 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:28:12 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">



[root@rhel85 ~]# export POSIXLY_CORRECT=1

[root@rhel85 ~]# /usr/bin/systemctl kill -s HUP rsyslog.service
Failed to kill unit -s.service: Unit -s.service not loaded.
Failed to kill unit HUP.service: Unit HUP.service not loaded.

[root@rhel85 ~]# systemctl status rsyslog.service
● rsyslog.service - System Logging Service
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Thu 2022-03-31 11:28:47 CEST; 4s ago
     Docs: man:rsyslogd(8)
           https://www.rsyslog.com/doc/
  Process: 877 ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 877 (code=exited, status=0/SUCCESS)

Mar 31 11:18:04 rhel85.example.com systemd[1]: Starting System Logging Service...
Mar 31 11:18:04 rhel85.example.com systemd[1]: Started System Logging Service.
Mar 31 11:18:04 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:18:04 rhel85.example.com rsyslogd[877]: imjournal: journal files changed, reloading...  [v8.2102.0-5.e>
Mar 31 11:22:23 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:28:12 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:28:47 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:28:47 rhel85.example.com rsyslogd[877]: [origin software="rsyslogd" swVersion="8.2102.0-5.el8" x-pid=">
Mar 31 11:28:47 rhel85.example.com systemd[1]: rsyslog.service: Succeeded.

--- Additional comment from Attila Lakatos on 2022-04-05 11:47:49 UTC ---

Hello,

To me, it does not seem like a bug in rsyslog, when the POSIXLY_CORRECT=1 env variable is set.
If you take a look at the command output lines:
Failed to kill unit -s.service: Unit -s.service not loaded.
Failed to kill unit HUP.service: Unit HUP.service not loaded.

You can see that it is not capable of determining which parameter represents the signal. Firstly, it tries the "-s.service"(don't know why), which probably does not exist. From the systemctl man page: --signal: When used with kill, choose which signal to send to selected processes. Must be one of the well-known signal specifiers such as SIGTERM, SIGINT or SIGSTOP. If omitted, defaults to SIGTERM.
As it was unable to process the signal part, the default is used, which is the SIGTERM signal. In that case, it is delivered to the rsyslog service. Thus, rsyslog will terminate.

Feel free to correct me if I am wrong.

--- Additional comment from Dariusz Wojewódzki on 2022-04-06 08:08:14 UTC ---

Hello, This command is in the official rsyslog package in the /etc/logrotate.d/syslog file.

As you stated, systemctl wants to kill both the -s and HUP services that do not exist and sends a SIGTERM signal to all parameters after kill, rather than interpreting -s as a switch.

On the other hand:
 "/usr/bin/systemctl -s HUP kill rsyslog.service >/dev/null 2>&1 || true" works with POSIXLY_CORRECT.

--- Additional comment from Attila Lakatos on 2022-04-07 08:38:23 UTC ---

Hello,

Now I can see the difference between the two commands:
1.  /usr/bin/systemctl kill -s HUP rsyslog.service
2.  /usr/bin/systemctl -s HUP kill rsyslog.service

So in case the POSIXLY_CORRECT=1 env var is set, only the second option is correct. Both versions work when the mentioned env variable is not set. Although I do not know the reason behind it.

According to the manual page, the syntax should be the following:
  systemctl [OPTIONS...] COMMAND [NAME...]

Thanks for noticing it.

Comment 12 errata-xmlrpc 2023-05-09 07:44:54 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 (rsyslog 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-2023:2303


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