Skip to contentSkip to conversation

Allow 'debug' configuration option to accept '0' and '1'

PATCH In review Frank Sorenson 2 participants 2 messages Oct 4, 2022 – Oct 17, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow 'debug' configuration option to accept '0' and '1'

In the example /etc/nfs.conf file, most sections include a commented-out 'debug = 0' line, suggesting that '0' is the default. In addition, the manpages for some of the utilities state that debugging can be enabled by setting 'debug = 1' in the nfs.conf file.

However, neither '0' nor '1' is accepted as a valid option for 'debug' while parsing the nfs.conf file.

Add '0' and '1' to the valid strings when parsing 'debug', with '0' not changing any debugging settings, and '1' enabling all debugging.

---
 support/nfs/xlog.c   | 7 +++++--
 systemd/nfs.conf.man | 6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
support/nfs/xlog.c +5 -2
index e5861b9d..fa125cef 100644
@@ -46,11 +46,13 @@ int export_errno = 0;
 
 static void	xlog_toggle(int sig);
 static struct xlog_debugfac	debugnames[] = {
+	{ "0",		0, },
 	{ "general",	D_GENERAL, },
 	{ "call",	D_CALL, },
 	{ "auth",	D_AUTH, },
 	{ "parse",	D_PARSE, },
 	{ "all",	D_ALL, },
+	{ "1",		D_ALL, },
 	{ NULL,		0, },
 };
 
@@ -119,13 +121,14 @@ xlog_sconfig(char *kind, int on)
 {
 	struct xlog_debugfac	*tbl = debugnames;
 
-	while (tbl->df_name != NULL && strcasecmp(tbl->df_name, kind)) 
+	while (tbl->df_name != NULL && strcasecmp(tbl->df_name, kind))
 		tbl++;
 	if (!tbl->df_name) {
 		xlog (L_WARNING, "Invalid debug facility: %s\n", kind);
 		return;
 	}
-	xlog_config(tbl->df_fac, on);
+	if (tbl->df_fac)
+		xlog_config(tbl->df_fac, on);
 }
 
 void
systemd/nfs.conf.man +6 -0
index e74083e9..b95c05a6 100644
@@ -98,6 +98,12 @@ value, which can be one or more from the list
 .BR parse ,
 .BR all .
 When a list is given, the members should be comma-separated.
+The values
+.BR 0
+and
+.BR 1
+are also accepted, with '0' making no changes to the debug level, and '1' equivalent to specifying 'all'.
+
 .TP
 .B general
 Recognized values:
Signature · 1 line
2.37.2
#1 lore raw
Quoted 6 lines · Frank Sorenson

In the example /etc/nfs.conf file, most sections include a commented-out 'debug = 0' line, suggesting that '0' is the default. In addition, the manpages for some of the utilities state that debugging can be enabled by setting 'debug = 1' in the nfs.conf file.

Quoted 8 lines

However, neither '0' nor '1' is accepted as a valid option for 'debug' while parsing the nfs.conf file.

Add '0' and '1' to the valid strings when parsing 'debug', with '0' not changing any debugging settings, and '1' enabling all debugging.

Committed!!

steved.

Quoted 57 lines
---
  support/nfs/xlog.c   | 7 +++++--
  systemd/nfs.conf.man | 6 ++++++
  2 files changed, 11 insertions(+), 2 deletions(-)
support/nfs/xlog.c +5 -2
index e5861b9d..fa125cef 100644
@@ -46,11 +46,13 @@ int export_errno = 0;
 
  static void	xlog_toggle(int sig);
  static struct xlog_debugfac	debugnames[] = {
+	{ "0",		0, },
  	{ "general",	D_GENERAL, },
  	{ "call",	D_CALL, },
  	{ "auth",	D_AUTH, },
  	{ "parse",	D_PARSE, },
  	{ "all",	D_ALL, },
+	{ "1",		D_ALL, },
  	{ NULL,		0, },
  };
 
@@ -119,13 +121,14 @@ xlog_sconfig(char *kind, int on)
  {
  	struct xlog_debugfac	*tbl = debugnames;
 
-	while (tbl->df_name != NULL && strcasecmp(tbl->df_name, kind))
+	while (tbl->df_name != NULL && strcasecmp(tbl->df_name, kind))
  		tbl++;
  	if (!tbl->df_name) {
  		xlog (L_WARNING, "Invalid debug facility: %s\n", kind);
  		return;
  	}
-	xlog_config(tbl->df_fac, on);
+	if (tbl->df_fac)
+		xlog_config(tbl->df_fac, on);
  }
 
  void
systemd/nfs.conf.man +6 -0
index e74083e9..b95c05a6 100644
@@ -98,6 +98,12 @@ value, which can be one or more from the list
  .BR parse ,
  .BR all .
  When a list is given, the members should be comma-separated.
+The values
+.BR 0
+and
+.BR 1
+are also accepted, with '0' making no changes to the debug level, and '1' equivalent to specifying 'all'.
+
  .TP
  .B general
  Recognized values: