Skip to contentSkip to conversation

rngd: fix --debug to also filter syslog() calls

PATCH Superseded Yann Dirson 2 participants 4 messages Oct 9, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rngd: fix --debug to also filter syslog() calls

From: Yann Dirson <[email protected]>

Debug logs were only controlled by --debug flag while in --foreground mode. In --daemon mode (the default for us) /var/log/message got stuffed with details of entropy pool refilling, which is useless in production, and hamful when log rotation then gets rid of the more useful logs.

This change makes the two modes consistently only produce debug logs when --debug is specified.

---
 .../rng-tools/rngd-debug-filter.patch         | 22 +++++++++++++++++++
 .../rng-tools/rng-tools_6.10.bb               |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch
meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +22 -0
new file mode 100644
index 0000000000..320f0257e6
@@ -0,0 +1,22 @@
+Index: git/rngd.h
+===================================================================
+--- git.orig/rngd.h
++++ git/rngd.h
+@@ -145,13 +145,13 @@ extern bool quiet;
+ #define message(priority,fmt,args...) do { \
+ 	if (quiet) \
+ 		break;\
++	if (arguments->debug == false && LOG_PRI(priority) == LOG_DEBUG) \
++		break;\
+ 	if (am_daemon) { \
+ 		syslog((priority), fmt, ##args); \
+ 	} else if (!msg_squash) { \
+-		if ((LOG_PRI(priority) != LOG_DEBUG) || (arguments->debug == true)) {\
+-			fprintf(stderr, fmt, ##args); \
+-			fflush(stderr); \
+-		} \
++		fprintf(stderr, fmt, ##args); \
++		fflush(stderr); \
+ 	} \
+ } while (0)
+ 
meta/recipes-support/rng-tools/rng-tools_6.10.bb +1 -0
index 3f9720e406..98fb7aa775 100644
@@ -12,6 +12,7 @@ SRC_URI = "\
     git://github.com/nhorman/rng-tools.git \
     file://a4b6d9ce64f132e463b9091d0536913ddaf11516.patch \
     file://dab16a5fd4efde8ef569b358e19b1fcbc7d0d938.patch \
+    file://rngd-debug-filter.patch \
     file://init \
     file://default \
     file://rngd.service \
Signature · 1 line
2.28.0
#1 lore raw
Quoted 20 lines · Yann Dirson

From: Yann Dirson <[email protected]>

Debug logs were only controlled by --debug flag while in --foreground mode. In --daemon mode (the default for us) /var/log/message got stuffed with details of entropy pool refilling, which is useless in production, and hamful when log rotation then gets rid of the more useful logs.

This change makes the two modes consistently only produce debug logs when --debug is specified.

---
 .../rng-tools/rngd-debug-filter.patch         | 22 +++++++++++++++++++
 .../rng-tools/rng-tools_6.10.bb               |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch
meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +0 -0
new file mode 100644
index 0000000000..320f0257e6

meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch

Quoted 1 line
meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +0 -1
--- /dev/null

This patch has no description, author or Upstream-Status: information in it. It needs such information to be considered. It would be helpful if the change was submitted upstream too, not sure if you've looked at that? We try not to carry patches if we can.

Cheers,

Richard

Quoted 38 lines

+++ b/meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch

meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +22 -0
@@ -0,0 +1,22 @@
+Index: git/rngd.h
+===================================================================
+--- git.orig/rngd.h
++++ git/rngd.h
+@@ -145,13 +145,13 @@ extern bool quiet;
+ #define message(priority,fmt,args...) do { \
+ 	if (quiet) \
+ 		break;\
++	if (arguments->debug == false && LOG_PRI(priority) == LOG_DEBUG) \
++		break;\
+ 	if (am_daemon) { \
+ 		syslog((priority), fmt, ##args); \
+ 	} else if (!msg_squash) { \
+-		if ((LOG_PRI(priority) != LOG_DEBUG) || (arguments->debug == true)) {\
+-			fprintf(stderr, fmt, ##args); \
+-			fflush(stderr); \
+-		} \
++		fprintf(stderr, fmt, ##args); \
++		fflush(stderr); \
+ 	} \
+ } while (0)
+ 
meta/recipes-support/rng-tools/rng-tools_6.10.bb +1 -0
index 3f9720e406..98fb7aa775 100644
@@ -12,6 +12,7 @@ SRC_URI = "\
     git://github.com/nhorman/rng-tools.git \
     file://a4b6d9ce64f132e463b9091d0536913ddaf11516.patch \
     file://dab16a5fd4efde8ef569b358e19b1fcbc7d0d938.patch \
+    file://rngd-debug-filter.patch \
     file://init \
     file://default \
     file://rngd.service \
#2 lore raw
Quoted 28 lines · Richard Purdie
Quoted 3 lines · Yann Dirson

From: Yann Dirson <[email protected]>

Debug logs were only controlled by --debug flag while in --foreground

mode.

Quoted 7 lines

In --daemon mode (the default for us) /var/log/message got stuffed with details of entropy pool refilling, which is useless in production, and hamful when log rotation then gets rid of the more useful logs.

This change makes the two modes consistently only produce debug logs when --debug is specified.

Quoted 6 lines
---
 .../rng-tools/rngd-debug-filter.patch         | 22 +++++++++++++++++++
 .../rng-tools/rng-tools_6.10.bb               |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644

meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch

Quoted 2 lines

diff --git

a/meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch b/meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch

Quoted 3 lines

new file mode 100644
index 0000000000..320f0257e6
--- /dev/null

Quoted 5 lines

This patch has no description, author or Upstream-Status: information in it. It needs such information to be considered. It would be helpful if the change was submitted upstream too, not sure if you've looked at that? We try not to carry patches if we can.

Lignthnig-speed upstream merged the patch after I re-rolled, is it worth a v3 tagged "accepted" ?

Quoted 46 lines

Cheers,

Richard

Quoted 6 lines

+++ b/meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch

meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +4 -0
@@ -0,0 +1,22 @@
+Index: git/rngd.h
+===================================================================
+--- git.orig/rngd.h
++++ git/rngd.h

meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch line 14

Quoted 10 lines
meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +10 -0
+@@ -145,13 +145,13 @@ extern bool quiet;
+ #define message(priority,fmt,args...) do { \
+     if (quiet) \
+             break;\
++    if (arguments->debug == false && LOG_PRI(priority) == LOG_DEBUG) \
++            break;\
+     if (am_daemon) { \
+             syslog((priority), fmt, ##args); \
+     } else if (!msg_squash) { \
+-            if ((LOG_PRI(priority) != LOG_DEBUG) || (arguments->debug

== true)) {\

Review

Quoted 9 lines
meta/recipes-support/rng-tools/rng-tools/rngd-debug-filter.patch new file +8 -0
+-                    fprintf(stderr, fmt, ##args); \
+-                    fflush(stderr); \
+-            } \
++            fprintf(stderr, fmt, ##args); \
++            fflush(stderr); \
+     } \
+ } while (0)
+
(quoted diff) +0 -0

b/meta/recipes-support/rng-tools/rng-tools_6.10.bb

Quoted 13 lines

index 3f9720e406..98fb7aa775 100644

meta/recipes-support/rng-tools/rng-tools_6.10.bb +1 -0
@@ -12,6 +12,7 @@ SRC_URI = "\
     git://github.com/nhorman/rng-tools.git \
     file://a4b6d9ce64f132e463b9091d0536913ddaf11516.patch \
     file://dab16a5fd4efde8ef569b358e19b1fcbc7d0d938.patch \
+    file://rngd-debug-filter.patch \
     file://init \
     file://default \
     file://rngd.service \
Signature · 2 lines
Yann Dirson <[email protected]>
Blade / Shadow -- http://shadow.tech
#3 lore raw
Quoted 44 lines · Yann Dirson
Quoted 32 lines · Richard Purdie
Quoted 3 lines · Yann Dirson

From: Yann Dirson <[email protected]>

Debug logs were only controlled by --debug flag while in --

foreground mode.

Quoted 1 line

In --daemon mode (the default for us) /var/log/message got

stuffed with

Quoted 1 line

details of entropy pool refilling, which is useless in

production, and

Quoted 3 lines

hamful when log rotation then gets rid of the more useful logs.

This change makes the two modes consistently only produce debug

logs when

Quoted 5 lines

--debug is specified.

---
 .../rng-tools/rngd-debug-filter.patch         | 22

+++++++++++++++++++

Quoted 3 lines
 .../rng-tools/rng-tools_6.10.bb               |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 meta/recipes-support/rng-tools/rng-

tools/rngd-debug-filter.patch

Review

Quoted 2 lines
(quoted diff) +0 -0

filter.patch b/meta/recipes-support/rng-tools/rng-tools/rngd-debug- filter.patch

Quoted 3 lines

new file mode 100644
index 0000000000..320f0257e6
--- /dev/null

Quoted 7 lines

This patch has no description, author or Upstream-Status:
information
in it. It needs such information to be considered. It would be helpful
if the change was submitted upstream too, not sure if you've looked at
that? We try not to carry patches if we can.

Quoted 2 lines

Lignthnig-speed upstream merged the patch after I re-rolled, is it worth a v3 tagged "accepted" ?

Please, it can be "Backport" now since it is!

Thanks for sending it, saves us carrying the patch and helps upstream too.

Cheers,

Richard