cifs.upcall: add option to enable debug logs
Subsystems (2)
PATCH v3 1/3 cifs.upcall: add option to enable debug logs
cifs.upcall uses two levels of logs, DEBUG and ERR. However, when using systemd, these logs will always be recorded. When the system does a lot of upcalls, the journal could be filled with debug logs, which may not be useful at that time. Added then a new option '-d' to enable debug logs only when needed. This will set a logmask up to LOG_DEBUG instead of the default of LOG_ERR, thus reducing the amount of logs when no debug is needed.
--- cifs.upcall.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
cifs.upcall.c +11 -2
@@ -1356,10 +1356,11 @@ lowercase_string(char *c)static void usage (void ) { -fprintf (stderr,"Usage: %s [ -K /path/to/keytab] [-k /path/to/krb5.conf] [-E] [-t] [-v] [-l] [-e nsecs] key_serial\n" , prog); +fprintf (stderr,"Usage: %s [ -K /path/to/keytab] [-k /path/to/krb5.conf] [-d] [-E] [-t] [-v] [-l] [-e nsecs] key_serial\n" , prog); }static const struct option long_options[] = { + {"debug" ,0 ,NULL ,'d' }, {"no-env-probe" ,0 ,NULL ,'E' }, {"krb5conf" ,1 ,NULL ,'k' }, {"legacy-uid" ,0 ,NULL ,'l' },
@@ -1379,6 +1380,7 @@ int main(const int argc, char *const argv[])size_t datalen;long rc =1 ;int c; +int mask;bool try_dns = false, legacy_uid = false , env_probe = true;char *buf;char hostbuf[NI_MAXHOST ], *host;
@@ -1395,12 +1397,19 @@ int main(const int argc, char *const argv[]) hostbuf[0 ] ='\0' ;openlog (prog,0 ,LOG_DAEMON ); + mask =LOG_UPTO (LOG_ERR ); +setlogmask (mask); -while ((c =getopt_long (argc, argv,"cEk:K:ltve:" , long_options,NULL )) !=-1 ) { +while ((c =getopt_long (argc, argv,"cdEk:K:ltve:" , long_options,NULL )) !=-1 ) {switch (c) {case 'c' :/* legacy option -- skip it */ break ; +case 'd' : +/* enable debug logs */ + mask =LOG_UPTO (LOG_DEBUG ); +setlogmask (mask); +break ;case 'E' :/* skip probing initiating process env */ env_probe = false;
Signature · 1 line
2.52.0
PATCH v3 2/3 docs: Enable debug logs
Documented a new option '-d' to enable debug logs. By default only error logs are enabled, with this new option debug logs can be enabled when needed.
--- cifs.upcall.rst.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
cifs.upcall.rst.in +4 -1
@@ -11,7 +11,7 @@ Userspace upcall helper for Common Internet File System (CIFS) SYNOPSIS ******** - cifs.upcall [--trust-dns|-t] [--version|-v] [--legacy-uid|-l] + cifs.upcall [--trust-dns|-t] [--version|-v] [--legacy-uid|-l] [--debug|-d] [--krb5conf=/path/to/krb5.conf|-k /path/to/krb5.conf] [--keytab=/path/to/keytab|-K /path/to/keytab] [--expire|-e nsecs] {keyid}
@@ -38,6 +38,9 @@ OPTIONS -c This option is deprecated and is currently ignored. +--debug|-d + Enable debug logs. By default no debug messages are logged, only errors. + --no-env-probe|-E Normally, ``cifs.upcall`` will probe the environment variable space of the process that initiated the upcall in order to fetch the value of
Signature · 1 line
2.52.0
PATCH v3 3/3 cifs.upcall: Adjust log level
In reply to Pierguido LambriBecause now only error message are logged, let's switch some messages from DEBUG to ERROR level.
This will help see when an error occurred with cifs.upcall and eventually turn on the debug mode.
--- cifs.upcall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
cifs.upcall.c +2 -2
@@ -1618,7 +1618,7 @@ int main(const int argc, char *const argv[]) __func__); }else {if (!get_tgt_time (ccache)) { -syslog (LOG_DEBUG ,"%s: valid TGT is not present in credential cache" , +syslog (LOG_ERR ,"%s: valid TGT is not present in credential cache" , __func__);krb5_cc_close (context, ccache); ccache =NULL ;
@@ -1721,7 +1721,7 @@ retry_new_hostname: }if (rc) { -syslog (LOG_DEBUG ,"Unable to obtain service ticket" ); +syslog (LOG_ERR ,"Unable to obtain service ticket" ); goto out; }
Signature · 1 line
2.52.0