From 0e49e1ec1be168cb7aa179f28150dc0a93541d52 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Thu, 5 Dec 2024 16:03:17 +0100 Subject: [PATCH] Small fixes in adding Kerberos to targets The not found error for the Kerberos credential in create_target now uses the correct id. For create_target the mutual exclusion of SMB and Kerberos is checked earlier. If the type check for the Kerberos credential in create_target or modify_target fails, the type string is now freed. --- src/gmp.c | 14 +++++++------- src/manage_sql.c | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gmp.c b/src/gmp.c index 08ea2b9ef..6648af6c8 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -23094,6 +23094,12 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context, (XML_ERROR_SYNTAX ("create_target", "Hosts must be at least one" " character long")); + else if (create_target_data->smb_credential_id + && create_target_data->krb5_credential_id) + SEND_TO_CLIENT_OR_FAIL + (XML_ERROR_SYNTAX ("create_target", + "Targets cannot have both an SMB and" + " Kerberos 5 credential")); else if (create_target_data->ssh_credential_id && find_credential_with_permission (create_target_data->ssh_credential_id, @@ -23213,19 +23219,13 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context, { if (send_find_error_to_client ("create_target", "Credential", - create_target_data->snmp_credential_id, + create_target_data->krb5_credential_id, gmp_parser)) { error_send_to_client (error); return; } } - else if (create_target_data->smb_credential_id - && create_target_data->krb5_credential_id) - SEND_TO_CLIENT_OR_FAIL - (XML_ERROR_SYNTAX ("create_target", - "Targets cannot have both an SMB and" - " Kerberos 5 credential")); /* Create target from host string. */ else switch (create_target diff --git a/src/manage_sql.c b/src/manage_sql.c index 53a08370f..320a427ae 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -32946,6 +32946,7 @@ create_target (const char* name, const char* asset_hosts_filter, if (strcmp (type, "krb5")) { sql_rollback (); + g_free (type); return 16; } g_free (type); @@ -33600,6 +33601,7 @@ modify_target (const char *target_id, const char *name, const char *hosts, if (strcmp (type, "krb5")) { sql_rollback (); + g_free (type); return 27; } g_free (type);