]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:kdc: Replace calls to samba_kdc_get_user_info_from_db() with calls to samba_kdc_ge...
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 2 Oct 2023 22:58:05 +0000 (11:58 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Oct 2023 23:13:32 +0000 (23:13 +0000)
The latter function behaves identically, except that it makes a shallow
copy of the returned structure, thus avoiding lifetime issues.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/kdc/db-glue.c
source4/kdc/mit_samba.c
source4/kdc/pac-glue.c

index c47aa69b0356d7dc507ec64f872e831702807fc1..4def9a9128f58900edbd5cdaa7c2143942f4a5bd 100644 (file)
@@ -1471,7 +1471,7 @@ static krb5_error_code samba_kdc_message2entry(krb5_context context,
 
        if (ent_type == SAMBA_KDC_ENT_TYPE_CLIENT && (flags & SDB_F_FOR_AS_REQ)) {
                int result;
-               const struct auth_user_info_dc *user_info_dc = NULL;
+               struct auth_user_info_dc *user_info_dc = NULL;
                /*
                 * These protections only apply to clients, so servers in the
                 * Protected Users group may still have service tickets to them
@@ -1484,7 +1484,10 @@ static krb5_error_code samba_kdc_message2entry(krb5_context context,
                 * and computers should never be members of Protected Users, or
                 * they may fail to authenticate.
                 */
-               status = samba_kdc_get_user_info_from_db(p, msg, &user_info_dc);
+               status = samba_kdc_get_user_info_dc(tmp_ctx,
+                                                   p,
+                                                   msg,
+                                                   &user_info_dc);
                if (!NT_STATUS_IS_OK(status)) {
                        ret = EINVAL;
                        goto out;
index 635f720f9ef344c7fceeee073c3d43d957bdbeb3..eb24ae8d02422b4fdf1e0c26c2bfbf244bad8deb 100644 (file)
@@ -903,7 +903,7 @@ krb5_error_code mit_samba_kpasswd_change_password(struct mit_samba_context *ctx,
        enum samPwdChangeReason reject_reason;
        struct samr_DomInfo1 *dominfo;
        const char *error_string = NULL;
-       const struct auth_user_info_dc *user_info_dc = NULL;
+       struct auth_user_info_dc *user_info_dc = NULL;
        struct samba_kdc_entry *p =
                talloc_get_type_abort(db_entry->e_data, struct samba_kdc_entry);
        krb5_error_code code = 0;
@@ -917,11 +917,12 @@ krb5_error_code mit_samba_kpasswd_change_password(struct mit_samba_context *ctx,
                return ENOMEM;
        }
 
-       status = samba_kdc_get_user_info_from_db(p,
-                                                p->msg,
-                                                &user_info_dc);
+       status = samba_kdc_get_user_info_dc(tmp_ctx,
+                                           p,
+                                           p->msg,
+                                           &user_info_dc);
        if (!NT_STATUS_IS_OK(status)) {
-               DBG_WARNING("samba_kdc_get_user_info_from_db failed: %s\n",
+               DBG_WARNING("samba_kdc_get_user_info_dc failed: %s\n",
                            nt_errstr(status));
                code = EINVAL;
                goto out;
index f3e3ef14636c13bbc498f56f7d25ccb6b0c0242e..291f9e20579db8dcb367c9f20a942a7cc443adbb 100644 (file)
@@ -2166,7 +2166,7 @@ krb5_error_code samba_kdc_verify_pac(TALLOC_CTX *mem_ctx,
        }
 
        if (!samba_krb5_pac_is_trusted(client)) {
-               const struct auth_user_info_dc *user_info_dc = NULL;
+               struct auth_user_info_dc *user_info_dc = NULL;
                WERROR werr;
 
                struct dom_sid *object_sids = NULL;
@@ -2177,9 +2177,10 @@ krb5_error_code samba_kdc_verify_pac(TALLOC_CTX *mem_ctx,
                        goto done;
                }
 
-               nt_status = samba_kdc_get_user_info_from_db(client.entry,
-                                                           client.entry->msg,
-                                                           &user_info_dc);
+               nt_status = samba_kdc_get_user_info_dc(tmp_ctx,
+                                                      client.entry,
+                                                      client.entry->msg,
+                                                      &user_info_dc);
                if (!NT_STATUS_IS_OK(nt_status)) {
                        DBG_ERR("Getting user info for PAC failed: %s\n",
                                nt_errstr(nt_status));