From ab9281b9070d17851e00691ae60268dd4ca6270e Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Tue, 9 Mar 2021 18:00:35 +0100 Subject: [PATCH 1/3] Add CHANGELOG message for ldap_enable_debug (cherry picked from commit 5ea6c687918194ee746268e553f921aacdef1923) # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a743627ca..7f56995bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [21.04] (unreleased) ### Added +<<<<<<< HEAD - Use dedicated port list for alive detection (Boreas only) if supplied via OSP. [#391](https://github.com/greenbone/gvm-libs/pull/391) - Allow to re allocate the finish flag in the host queue for alive tests. [#407](https://github.com/greenbone/gvm-libs/pull/407) @@ -16,6 +17,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add v3 handling to get_cvss_score_from_base_metrics. [#411](https://github.com/greenbone/gvm-libs/pull/411) - Add severity_date tag in epoch time format. [#412](https://github.com/greenbone/gvm-libs/pull/412) - Make more scanner preferences available to openvas-nasl. [#413](https://github.com/greenbone/gvm-libs/pull/413) +======= +- Add function ldap_enable_debug () [#453](https://github.com/greenbone/gvm-libs/pull/453) +>>>>>>> 5ea6c68... Add CHANGELOG message for ldap_enable_debug ### Changed - Add separators for a new (ip address) field in ERRMSG and DEADHOST messages. [#376](https://github.com/greenbone/gvm-libs/pull/376) From c6eab500631fb517d1c343a22c92e7ce72357708 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Tue, 9 Mar 2021 17:36:24 +0100 Subject: [PATCH 2/3] Add function ldap_enable_debug () This function enables LDAP debug logging via the glib logging, which can be used for debugging LDAP connection issues, for example. (cherry picked from commit 3c77434b9b381fc8e1a7801c2f8c0adfa863b1fe) --- util/ldaputils.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ util/ldaputils.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/util/ldaputils.c b/util/ldaputils.c index d99f0da5a..9065cca3a 100644 --- a/util/ldaputils.c +++ b/util/ldaputils.c @@ -50,6 +50,45 @@ * LDAP directory server. */ +/** + * @brief Wrapper function to use glib logging for LDAP debug logging. + */ +static void +ldap_log (const char *message) +{ + g_debug ("OpenLDAP: %s", message); +} + +/** + * @brief Enable OpenLDAP debug logging. + * + * @return 0 success, -1 error. + */ +int +ldap_enable_debug () +{ + int ret; + static int debug_level = 65535; + + ret = ber_set_option (NULL, LBER_OPT_LOG_PRINT_FN, ldap_log); + if (ret != LBER_OPT_SUCCESS) + { + g_warning ("%s: Failed to set LDAP debug print function: %s", + __func__, ldap_err2string (ret)); + return -1; + } + + ret = ldap_set_option (NULL, LDAP_OPT_DEBUG_LEVEL, &debug_level); + if (ret != LDAP_OPT_SUCCESS) + { + g_warning ("%s: Failed to set LDAP debug level: %s", + __func__, ldap_err2string (ret)); + return -1; + } + + return 0; +} + /** * @brief Authenticate against an ldap directory server. * @@ -455,6 +494,18 @@ ldap_auth_dn_is_good (const gchar *authdn) #else +/** + * @brief Dummy function for enabling LDAP debugging for manager. + * + * @return Always -1 for failure. + */ +int +ldap_enable_debug () +{ + g_warning ("%s: GVM-libs compiled without LDAP", __func__); + return -1; +} + /** * @brief Dummy function for manager. * diff --git a/util/ldaputils.h b/util/ldaputils.h index 5d22b2f3b..27c0392fb 100644 --- a/util/ldaputils.h +++ b/util/ldaputils.h @@ -43,6 +43,9 @@ struct ldap_auth_info gboolean allow_plaintext; ///< !Whether or not StartTLS is required. }; +int +ldap_enable_debug (); + int ldap_connect_authenticate (const gchar *, const gchar *, /* ldap_auth_info_t */ void *, const gchar *); From aa124be201a2d39ae7a41dd0bb5f19f9b35a902f Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Wed, 10 Mar 2021 17:14:38 +0100 Subject: [PATCH 3/3] Resolve CHANGELOG conflict for ldap_enable_debug The "Added" subsection for 20.8.2 was missing, so the entry could not be added there. --- CHANGELOG.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f56995bf..8f3ce5176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [21.04] (unreleased) ### Added -<<<<<<< HEAD - Use dedicated port list for alive detection (Boreas only) if supplied via OSP. [#391](https://github.com/greenbone/gvm-libs/pull/391) - Allow to re allocate the finish flag in the host queue for alive tests. [#407](https://github.com/greenbone/gvm-libs/pull/407) @@ -17,9 +16,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add v3 handling to get_cvss_score_from_base_metrics. [#411](https://github.com/greenbone/gvm-libs/pull/411) - Add severity_date tag in epoch time format. [#412](https://github.com/greenbone/gvm-libs/pull/412) - Make more scanner preferences available to openvas-nasl. [#413](https://github.com/greenbone/gvm-libs/pull/413) -======= -- Add function ldap_enable_debug () [#453](https://github.com/greenbone/gvm-libs/pull/453) ->>>>>>> 5ea6c68... Add CHANGELOG message for ldap_enable_debug ### Changed - Add separators for a new (ip address) field in ERRMSG and DEADHOST messages. [#376](https://github.com/greenbone/gvm-libs/pull/376) @@ -38,6 +34,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [20.8.2] (unreleased) +### Added +- Add function ldap_enable_debug () [#453](https://github.com/greenbone/gvm-libs/pull/453) + ### Changed - Use a char pointer instead of an zero-lenght array as kb_redis struct member. [443](https://github.com/greenbone/gvm-libs/pull/443)