Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 586454 - net-dns/dnsmasq: please add logrotate support
Summary: net-dns/dnsmasq: please add logrotate support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Patrick McLean
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-20 11:31 UTC by Paul Tobias
Modified: 2018-03-19 18:11 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to add rotate option to the dnsmasq init script (dnsmasq-init-add-rotate.patch,1.24 KB, patch)
2016-06-20 11:31 UTC, Paul Tobias
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Tobias 2016-06-20 11:31:21 UTC
Created attachment 438092 [details, diff]
Patch to add rotate option to the dnsmasq init script

When using dnsmasq with the log-facility=/file option there is no trivial way of rotating the log file. The /etc/init.d/dnsmasq reload command sends a HUP signal, but that does not reopen the log files. For that the USR2 signal is needed. So I'd like to do something like this in logrotate.d:
/var/log/dnsmasq.log {
	create 640 dnsmasq root
	notifempty
	postrotate
		/etc/init.d/dnsmasq --quiet --ifstarted rotate
	endscript
}

Attached is a patch to add the rotate option to the dnsmasq initscript. First I tried to add it to /etc/conf.d/dnsmasq, but unfortunately that doesn't work.
Comment 1 BT 2017-03-16 22:55:55 UTC
Instead of modifying the the init.d script, you can use the following logrotate config to have dnsmasq reopen the log file after rotation.

/var/log/dnsmasq.log {
  compress
  delaycompress
  missingok
  monthly
  nomail
  noolddir
  notifempty
  rotate 3
  sharedscripts
  create 0640 dnsmasq root
  postrotate
    [ ! -f /var/run/dnsmasq.pid ] || kill -USR2 $(cat /var/run/dnsmasq.pid)
  endscript
}
Comment 2 Larry the Git Cow gentoo-dev 2018-03-19 18:11:53 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=36950876fc0da1b5ced6a6c58508f5bc2c8be572

commit 36950876fc0da1b5ced6a6c58508f5bc2c8be572
Author:     Patrick McLean <chutzpah@gentoo.org>
AuthorDate: 2018-03-19 18:10:03 +0000
Commit:     Patrick McLean <chutzpah@gentoo.org>
CommitDate: 2018-03-19 18:11:38 +0000

    net-dns/dnsmasq: Version bump to 2.79
    
    Closes: https://bugs.gentoo.org/586454
    Closes: https://bugs.gentoo.org/633496
    Closes: https://bugs.gentoo.org/643670
    Gentoo-Bug: https://bugs.gentoo.org/645704
    Package-Manager: Portage-2.3.24, Repoman-2.3.6

 net-dns/dnsmasq/Manifest                   |   1 +
 net-dns/dnsmasq/dnsmasq-2.79.ebuild        | 198 +++++++++++++++++++++++++++++
 net-dns/dnsmasq/files/dnsmasq-init-dhcp-r3 |  35 +++++
 net-dns/dnsmasq/files/dnsmasq-init-r4      |  29 +++++
 net-dns/dnsmasq/files/dnsmasq.logrotate    |   7 +
 5 files changed, 270 insertions(+)