Bug 236700 - sysutils/nut: Move default log location so it can be rotated without root. Allow upslog style to be set.
Summary: sysutils/nut: Move default log location so it can be rotated without root. Al...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Cy Schubert
URL:
Keywords:
: 236701 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-03-21 11:49 UTC by Daniel O'Connor
Modified: 2019-04-01 06:53 UTC (History)
3 users (show)

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


Attachments
Patch (2.98 KB, patch)
2019-03-21 11:49 UTC, Daniel O'Connor
no flags Details | Diff
Improved newsyslog file (294 bytes, text/plain)
2019-03-23 05:17 UTC, Daniel O'Connor
no flags Details
with optional formatting (3.17 KB, patch)
2019-03-23 05:51 UTC, Cy Schubert
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel O'Connor 2019-03-21 11:49:40 UTC
Created attachment 203030 [details]
Patch

As discussed in email.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2019-03-21 12:09:53 UTC
*** Bug 236701 has been marked as a duplicate of this bug. ***
Comment 2 Cy Schubert freebsd_committer freebsd_triage 2019-03-22 19:33:55 UTC
Changing the default nut upslog time format to include time, temperature and other data is a POLA violation. This will result in more PRs asking to have this removed. It will not be included.
Comment 3 Cy Schubert freebsd_committer freebsd_triage 2019-03-22 20:01:46 UTC
No infrastructure exists to create ${PREFIX}/etc/syslog.d ${PREFIX}/etc/newsyslog.conf.d. How do you propose a package create these directories?

Should they be deleted after nut is uninstalled?

If yes, what if some other package creates them. How would you deal with that?

Adding the infrastructure to FreeBSD ports to handle this would be outside of the scope of this PR. I really cannot see implementing this. Unless these issues are resolved this PR cannot go forward. Sorry.
Comment 4 Daniel O'Connor 2019-03-23 03:07:07 UTC
With respect to the log format.. Running upslog says..

format string defaults to:
%TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage% %VAR ups.load% [%VAR ups.status%] %VAR ups.temperature% %VAR input.frequency%

Which is what I used for the default in nut_upslog.in.

With respect to the directory creation - I found net-snmp uses the newsyslog directory, its port does..
.if ${PORT_OPTIONS:MNEWSYSLOG}
        @${MKDIR} ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d
        ${INSTALL_DATA} ${FILESDIR}/net-snmp.conf ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/
.endif

The net-snmp plist has the file but not the directory (so I presume it won't be deleted on removal either).

I think it is a defect that those directories aren't created by default but this PR can't change that.
Comment 5 Cy Schubert freebsd_committer freebsd_triage 2019-03-23 05:02:04 UTC
I can't say I'm enamoured with syslog.conf.d and friends.

Regarding restating the default format string, should the upline change the default format we would be required to chase that, probably through a PR. A case construct should suffice.

Regarding whether syslog.conf.d, looks like it needs to be added. I'll create a phab review to add it.

I'll take some time tomorrow to commit this, with the format string check in a case construct.
Comment 6 Daniel O'Connor 2019-03-23 05:17:29 UTC
Created attachment 203062 [details]
Improved newsyslog file

I just noticed my newsyslog file was broken, the attached version works properly..
Comment 7 Daniel O'Connor 2019-03-23 05:18:28 UTC
(In reply to Cy Schubert from comment #5)
OK, thanks - I wasn't very enamoured with that approach either for the same reason.
Comment 8 Cy Schubert freebsd_committer freebsd_triage 2019-03-23 05:51:44 UTC
Created attachment 203063 [details]
with optional formatting
Comment 9 Cy Schubert freebsd_committer freebsd_triage 2019-03-23 05:52:47 UTC
The patch makes the time format optional, fixes /var/log/nut creation, includes the newsyslog file.
Comment 10 Daniel O'Connor 2019-03-23 06:12:31 UTC
Patch looks good, thanks.
Comment 11 commit-hook freebsd_committer freebsd_triage 2019-03-23 19:34:18 UTC
A commit references this bug:

Author: cy
Date: Sat Mar 23 19:34:08 UTC 2019
New revision: 496686
URL: https://svnweb.freebsd.org/changeset/ports/496686

Log:
  Move default log location so it can be rotated without root privileges.

  Add syslog.conf and newsyslog.conf files for installation into their
  respective .d directories in $PREFIX.

  Allow upslog log format to be customized.

  PR:		236700
  Submitted by:	Daniel O'Connor <darius@dons.net.au> (90%)

Changes:
  head/sysutils/nut/Makefile
  head/sysutils/nut/files/nut.newsyslog
  head/sysutils/nut/files/nut.syslog
  head/sysutils/nut/files/nut_upslog.in
  head/sysutils/nut/pkg-plist
Comment 12 Vladimir Druzenko freebsd_committer freebsd_triage 2019-03-24 04:50:05 UTC
(In reply to commit-hook from comment #11)

12.0 amd64:
===> Staging rc.d startup script(s)
===>  Installing for nut-2.7.4_10
===>  Checking if nut is already installed
===>   Registering installation for nut-2.7.4_10
pkg-static: Unable to access file /tmp/work/usr/ports/sysutils/nut/work/stage/usr/local/etc/newsyslog.conf.d/nut.conf:No such file or directory
pkg-static: Unable to access file /tmp/work/usr/ports/sysutils/nut/work/stage/usr/local/etc/syslog.d/nut:No such file or directory
pkg-static: lstat(/tmp/work/usr/ports/sysutils/nut/work/stage/var/log/nut/): No such file or directory
*** Error code 74


OPTIONS_FILE_UNSET+=AVAHI
OPTIONS_FILE_UNSET+=BASH
OPTIONS_FILE_UNSET+=CGI
OPTIONS_FILE_UNSET+=DOCS
OPTIONS_FILE_UNSET+=NEON
OPTIONS_FILE_UNSET+=PDU
OPTIONS_FILE_SET+=SERIAL
OPTIONS_FILE_SET+=SNMP
OPTIONS_FILE_SET+=USB
OPTIONS_FILE_SET+=IPMI_OFF
OPTIONS_FILE_UNSET+=IPMIPSU
OPTIONS_FILE_UNSET+=FREEIPMI
OPTIONS_FILE_SET+=SSL_OFF
OPTIONS_FILE_UNSET+=OPENSSL
OPTIONS_FILE_UNSET+=NSS
Comment 13 Romain Tartière freebsd_committer freebsd_triage 2019-03-24 18:04:52 UTC
(In reply to VVD from comment #12)

This should be fixed in 496766:
https://svnweb.freebsd.org/ports?view=revision&revision=496766
Comment 14 Vladimir Druzenko freebsd_committer freebsd_triage 2019-03-25 00:08:38 UTC
(In reply to Romain Tartière from comment #13)
Thanks, it work now.
Comment 15 Alexander Moisseev 2019-04-01 06:53:52 UTC
The port should create ${PREFIX}/etc/syslog.d/ if it doesn't exist.

# make install
===>  Installing for nut-2.7.4_13
===>  Checking if nut is already installed
===>   Registering installation for nut-2.7.4_13
Installing nut-2.7.4_13...
cp: /usr/local/etc/syslog.d/nut: No such file or directory
===> SECURITY REPORT:

Please also consider fixing `portlint -C` warnings.