cifs.upcall: add option to enable debug logs
Subsystems (2)
PATCH 1/1 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.
Signed-off-by Pierguido Lambri <[email protected]>
Reviewed-by Paulo Alcantara (Red Hat) <[email protected]>
--- cifs.upcall.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
cifs.upcall.c +11 -2
@@ -25,6 +25,7 @@* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <sys/syslog.h> #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */
@@ -1356,7 +1357,7 @@ 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[] = {
@@ -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