[network-manager-vpnc/th/vpn-plugin-debug-bgo766872: 7/8] service: configure Debug option for vpnc based on log-level



commit eeaef406f4e865d17b9414fc9dc12cee747bc269
Author: Thomas Haller <thaller redhat com>
Date:   Tue May 24 23:42:15 2016 +0200

    service: configure Debug option for vpnc based on log-level

 src/nm-vpnc-service.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/nm-vpnc-service.c b/src/nm-vpnc-service.c
index 492e8d6..53aeb4c 100644
--- a/src/nm-vpnc-service.c
+++ b/src/nm-vpnc-service.c
@@ -814,6 +814,7 @@ nm_vpnc_config_write (gint vpnc_fd,
        const char *local_port;
        const char *interface_name;
        NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
+       int debug_level;
 
        if (bus_name) {
                g_assert (g_dbus_is_name (bus_name));
@@ -825,8 +826,20 @@ nm_vpnc_config_write (gint vpnc_fd,
 
        default_username = nm_setting_vpn_get_user_name (s_vpn);
 
-       if (gl.debug)
-               write_config_option (vpnc_fd, "Debug 3");
+       if (gl.log_level <= 0)
+               debug_level = 0;
+       else if (gl.log_level <= LOG_WARNING)
+               debug_level = 1;
+       else if (gl.log_level <= LOG_NOTICE)
+               debug_level = 2;
+       else if (gl.log_level <= LOG_INFO)
+               debug_level = 3;
+       else {
+               /* level 99 prints passwords. We don't want that even for the highest
+                * level. So, choose one below. */
+               debug_level = 98;
+       }
+       write_config_option (vpnc_fd, "Debug %d", debug_level);
 
        if (interface_name && strlen(interface_name) > 0)
                write_config_option (vpnc_fd, "Interface name %s", interface_name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]