Bug 106602 - mail/milter-regex always do syslog(LOG_DEBUG, ...)
Summary: mail/milter-regex always do syslog(LOG_DEBUG, ...)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dirk Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-11 10:50 UTC by Denis Eremenko <moonshade@pnhz.kz>
Modified: 2007-02-21 05:00 UTC (History)
0 users

See Also:


Attachments
patch-no-log_debug (1.26 KB, text/plain)
2006-12-11 10:50 UTC, Denis Eremenko <moonshade@pnhz.kz>
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Eremenko <moonshade@pnhz.kz> 2006-12-11 10:50:03 UTC

mail/milter-regex always do syslog(LOG_DEBUG, ...) spamming /var/log/debug.log with each message passing through.
It should be optional.

How-To-Repeat: 

just use it
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-12-11 10:50:40 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dinoex

Over to maintainer
Comment 2 Denis Eremenko <moonshade@pnhz.kz> 2006-12-12 03:10:25 UTC
I have disabled _all_ logging w/o -v switch. Pardon.
Next one should be better - check, please:

--- milter-regex.c.orig	Mon Dec 11 15:42:26 2006
+++ milter-regex.c	Mon Dec 11 15:52:23 2006
@@ -57,6 +57,7 @@
 
 static const char	*rule_file_name = "/etc/milter-regex.conf";
 static int		 debug = 0;
+static int		 verbose = 0;
 
 struct context {
 	struct ruleset	*rs;
@@ -520,6 +521,9 @@
 	va_list ap;
 	char msg[8192];
 
+	if (LOG_PRI(priority) > LOG_INFO && !verbose)
+		return;
+
 	va_start(ap, fmt);
 	if (context != NULL)
 		snprintf(msg, sizeof(msg), "%s: ", context->host_addr);
@@ -563,13 +567,16 @@
 	tzset();
 	openlog("milter-regex", LOG_PID | LOG_NDELAY, LOG_DAEMON);
 
-	while ((ch = getopt(argc, argv, "c:dp:u:")) != -1) {
+	while ((ch = getopt(argc, argv, "c:dvp:u:")) != -1) {
 		switch (ch) {
 		case 'c':
 			rule_file_name = optarg;
 			break;
 		case 'd':
-			debug = 1;
+			debug = verbose = 1;
+			break;
+		case 'v':
+			verbose = 1;
 			break;
 		case 'p':
 			oconn = optarg;

--- milter-regex.8.orig	Sat Mar 13 23:21:23 2004
+++ milter-regex.8	Mon Dec 11 15:58:25 2006
@@ -51,7 +51,9 @@
 .Bl -tag -width "-c config"
 .It Fl d
 Don't detach from controlling terminal and produce verbose debug
-output on stdout.
+output on stdout. Implies -v.
+.It Fl v
+Do verbose LOG_DEBUG level logging.
 .It Fl c Ar config
 Use the specified configuration file instead of the default,
 /etc/milter-regex.conf.
Comment 3 Dirk Meyer freebsd_committer freebsd_triage 2006-12-15 20:46:10 UTC
State Changed
From-To: open->feedback



I contacted Daniel Hartmeier the author of this software. 

He wrote: 

> I kind of like having debug messages sent to syslog by default, even 
> though they should be dropped there in most cases. That way, you can 
> temporarily get debug messages from the running process by toggling 
> syslog.conf, and don't have to restart the process. 
>  
> Some bugs only occur after days of process lifetime, and telling the 
> user to restart the process with debug logging enabled means that it 
> will take several days longer to reach the next occurance of the bug, as 
> well has having to store debug messages over that entire period. 

a) 
I suggest to add some entries in your syslogd.conf. 

b) 
you rewwork the patch to keep the default behaivior 

c) 
you rework your patch, so it will be an option to this port.
Comment 4 Denis Eremenko <moonshade@pnhz.kz> 2006-12-26 02:49:48 UTC
I did it in b) way.

PS: I understand that author may love debug logging, but is this most
expected way for application? Does it violates POLA? I, personally, was
quite "astonished" when found my /var was eaten by /var/log/debug.log

--- milter-regex.8.orig	Thu Dec 21 17:15:05 2006
+++ milter-regex.8	Thu Dec 21 17:22:46 2006
@@ -52,6 +52,8 @@
 .It Fl d
 Don't detach from controlling terminal and produce verbose debug
 output on stdout.
+.It Fl q
+Don't send to syslog messages with priority higher than LOG_NOTICE.
 .It Fl c Ar config
 Use the specified configuration file instead of the default,
 /etc/milter-regex.conf.
--- milter-regex.c.orig	Thu Dec 21 17:13:26 2006
+++ milter-regex.c	Thu Dec 21 17:23:28 2006
@@ -57,6 +57,7 @@
 
 static const char	*rule_file_name = "/etc/milter-regex.conf";
 static int		 debug = 0;
+static int		 quiet = 0;
 
 struct context {
 	struct ruleset	*rs;
@@ -520,6 +521,9 @@
 	va_list ap;
 	char msg[8192];
 
+	if (LOG_PRI(priority) > LOG_INFO && quiet)
+		return;
+
 	va_start(ap, fmt);
 	if (context != NULL)
 		snprintf(msg, sizeof(msg), "%s: ", context->host_addr);
@@ -563,13 +567,16 @@
 	tzset();
 	openlog("milter-regex", LOG_PID | LOG_NDELAY, LOG_DAEMON);
 
-	while ((ch = getopt(argc, argv, "c:dp:u:")) != -1) {
+	while ((ch = getopt(argc, argv, "c:dqp:u:")) != -1) {
 		switch (ch) {
 		case 'c':
 			rule_file_name = optarg;
 			break;
 		case 'd':
 			debug = 1;
+			break;
+		case 'q':
+			quiet = 1;
 			break;
 		case 'p':
 			oconn = optarg;
Comment 5 Denis Eremenko <moonshade@pnhz.kz> 2007-02-05 05:57:26 UTC
Author still rejects? Even when patch doesn't change default behavior?
Comment 6 mike 2007-02-17 00:49:35 UTC
Pardon me for intruding, but I agree with the author.
Any software can send whatever it wants to syslog.
Nothing wrong with that. Syslog is configurable.

Option B is the correct solution. Modify /etc/syslog.conf
(or advise the user to do so, post-install), with something
like this:

!milter-regex
daemon.debug	/dev/null
daemon.!=debug	/var/log/maillog


I prefer to save the debug messages in another file,
so I use /etc/newsyslog.conf to manage its rotation.
That also allows you to put a cap on its size.
Comment 7 dfilter service freebsd_committer freebsd_triage 2007-02-17 09:09:48 UTC
dinoex      2007-02-17 09:09:43 UTC

  FreeBSD ports repository

  Modified files:
    mail/milter-regex    Makefile 
  Added files:
    mail/milter-regex/files patch-quiet 
  Log:
  - add flag -quiet
  PR:             106602
  Submitted by:   Denis Eremenko
  
  Revision  Changes    Path
  1.18      +1 -0      ports/mail/milter-regex/Makefile
  1.1       +51 -0     ports/mail/milter-regex/files/patch-quiet (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 8 Dirk Meyer freebsd_committer freebsd_triage 2007-02-17 09:10:10 UTC
State Changed
From-To: feedback->closed

committed, thanks.
Comment 9 Denis Eremenko <moonshade@pnhz.kz> 2007-02-21 04:51:00 UTC
> Modify /etc/syslog.conf
> (or advise the user to do so, post-install), with something
> like this:

> !milter-regex
> daemon.debug /dev/null
> daemon.!=debug /var/log/maillog

In this case many unnecessary syslog() calls and data transfers still
exists. Overhead.