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 1336432 - journald: SYSLOG_IDENTIFIER is invalid when running logger
Summary: journald: SYSLOG_IDENTIFIER is invalid when running logger
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: util-linux
Version: 7.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Karel Zak
QA Contact: Radka Brychtova
URL:
Whiteboard:
Depends On:
Blocks: 1465901
TreeView+ depends on / blocked
 
Reported: 2016-05-16 13:02 UTC by Branislav Blaškovič
Modified: 2018-04-10 17:26 UTC (History)
1 user (show)

Fixed In Version: util-linux-2.23.2-44.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 17:25:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0936 0 None None None 2018-04-10 17:26:58 UTC

Description Branislav Blaškovič 2016-05-16 13:02:58 UTC
Description of problem:
Journald logs invalid SYSLOG_IDENTIFIER when running logger. It somehow contains "root" which is not even user, because if I run it under different user, _UID and _GUID is changed but SYSLOG_IDENTIFIER is still root.

According to systemd.journal-fields man page it should contain logger:
    Note that the tag is usually derived from glibc's
    program_invocation_short_name variable, see program_invocation_short_name(3).

Version-Release number of selected component (if applicable):
systemd-219-20.el7.x86_64

Steps to Reproduce:
1. logger testlogger
2. journalctl -o json-pretty MESSAGE=testlogger


Actual results:
# journalctl -o json-pretty MESSAGE=testlogger | grep SYSLOG_IDENTIFIER
	"SYSLOG_IDENTIFIER" : "root",

Additional info:
    If putting username is a default behaviour for logger, please document this in man page, at least.

Comment 1 Karel Zak 2016-05-16 13:25:19 UTC
(In reply to Branislav Blaškovič from comment #0)
> Journald logs invalid SYSLOG_IDENTIFIER when running logger. It somehow
> contains "root" which is not even user, because if I run it under different
> user, _UID and _GUID is changed but SYSLOG_IDENTIFIER is still root.

logger uses getlogin(3) function to get username. I guess the attempt has been with su(1). This seems like a valid behaviour.

> According to systemd.journal-fields man page it should contain logger:
>     Note that the tag is usually derived from glibc's
>     program_invocation_short_name variable, see
> program_invocation_short_name(3).

The systemd man page is right, the described behaviour is valid and default for syslog(3), but logger(1) overrides this default and it uses username rather than the program name. 

(It makes sense, because logger(1) is just tool to deliver users/script messages and you don't want to see unified "logger: ..."  lines in your log files. It's possible to change it by --tag command line option.)

> Additional info:
>     If putting username is a default behaviour for logger, please document
> this in man page, at least.

Good point, note added to the upstream logger man page -- commit 28b6c76f8a4ea1faa80fe779c2011bc433de28c6.

Comment 2 Branislav Blaškovič 2016-05-18 08:06:54 UTC
(In reply to Karel Zak from comment #1)
> (In reply to Branislav Blaškovič from comment #0)
> > Journald logs invalid SYSLOG_IDENTIFIER when running logger. It somehow
> > contains "root" which is not even user, because if I run it under different
> > user, _UID and _GUID is changed but SYSLOG_IDENTIFIER is still root.
> 
> logger uses getlogin(3) function to get username. I guess the attempt has
> been with su(1). This seems like a valid behaviour.

Ok, so I rescheduled the test in beaker and I got:

    "SYSLOG_IDENTIFIER" : "logger",

See full log: http://beaker-archive.app.eng.bos.redhat.com/beaker-logs/2016/05/13409/1340966/2730961/41205554/TESTOUT.log
Beaker task: https://beaker.engineering.redhat.com/jobs/1340966

Running on systemd-219-19.el7.x86_64 and util-linux-2.23.2-26.el7.x86_64

Comment 3 Karel Zak 2016-05-18 10:03:44 UTC
It's possible that getlogin() returns NULL when executed without a terminal, in this case logger uses NULL for openlog() and it defaults to program name.

The current upstream version has fallback solution for getlogin() and it uses geteuid() if necessary. Maybe we can backport it to RHEL7 to keep things more consistent.

You can try:

  ltrace logger --stderr Message

to see getlogin() and openlog() behaviour.

Comment 9 errata-xmlrpc 2018-04-10 17:25:50 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.

https://access.redhat.com/errata/RHBA-2018:0936


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