Bug 248185 - [patch] Fix missing TZ env var for sysutils/rsyslog8
Summary: [patch] Fix missing TZ env var for sysutils/rsyslog8
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Matthew Seaman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-22 17:02 UTC by Ryan Steinmetz
Modified: 2020-07-22 20:38 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (matthew)


Attachments
Patch to add/set a user-configurable TZ env var (890 bytes, text/plain)
2020-07-22 17:02 UTC, Ryan Steinmetz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Steinmetz freebsd_committer freebsd_triage 2020-07-22 17:02:54 UTC
Created attachment 216676 [details]
Patch to add/set a user-configurable TZ env var

At startup, rsyslogd emits:

rsyslogd[8440] environment variable TZ is not set, auto correcting this to TZ=/etc/localtime [v8.2006.0 try https://www.rsyslog.com/e/2442 ]

This patch sets TZ, defaulting to /etc/localtime.  It also optionally allows the user to override it with rsyslogd_tz=".." in rc.conf.

- Set TZ env var at launch
- Bump PORTREVISION
Comment 1 Matthew Seaman freebsd_committer freebsd_triage 2020-07-22 18:21:00 UTC
Hi,

rsyslog is complaining too much here.  As tzset(3) says:

```
     If TZ does not appear in the environment, the best available
     approximation to local wall clock time, as specified by the
     tzfile(5)-format file /etc/localtime is used.
```

so this change is entirely cosmetic. However, I'm happy to implement this just to reduce the noise in log files.

Mind you, rc.subr(8) already has a mechanism for setting the environment of commands:

```
                 ${name}_env   A list of environment variables to run command
                               with.  This will be passed as arguments to the
                               env(1) utility.
```
so let's use that.
Comment 2 Ryan Steinmetz freebsd_committer freebsd_triage 2020-07-22 18:35:35 UTC
Yup, it's purely cosmetic.

Setting this via export seems better to me as it doesn't involve invoking an additional process.

I'd still lean towards using export for that reason.
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-07-22 20:33:12 UTC
A commit references this bug:

Author: matthew
Date: Wed Jul 22 20:32:29 UTC 2020
New revision: 542893
URL: https://svnweb.freebsd.org/changeset/ports/542893

Log:
  Prevent rsyslogd from writing log messages about TZ being unset in the
  environment.

  This is a putely cosmetic change, as the default behaviour according
  to tzset(3) is:

  ```
       If TZ does not appear in the environment, the best available
       approximation to local wall clock time, as specified by the
       tzfile(5)-format file /etc/localtime is used.
  ```

  Slightly modified from the patch supplied by zi to use the rc.subr(8)
  '${name}_env' variable.

  PR:		248185
  Submitted by:	zi

Changes:
  head/sysutils/rsyslog8/Makefile
  head/sysutils/rsyslog8/files/rsyslogd.in
Comment 4 Matthew Seaman freebsd_committer freebsd_triage 2020-07-22 20:38:13 UTC
(In reply to Ryan Steinmetz from comment #2)

One invocation of env(1) at the start of a long-running process like rsyslogd is hardly going to be measurable.
Comment 5 Matthew Seaman freebsd_committer freebsd_triage 2020-07-22 20:38:30 UTC
Committed, thanks!