]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbind: Store canonical principal and realm in ccache entry
authorSamuel Cabrero <scabrero@suse.de>
Tue, 22 Feb 2022 12:19:02 +0000 (13:19 +0100)
committerJule Anger <janger@samba.org>
Fri, 25 Feb 2022 10:31:13 +0000 (10:31 +0000)
They will be used later to refresh the tickets.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14979

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 0f4f330773d272b4d28ff3ba5a41bdd4ba569c8b)

source3/winbindd/winbindd.h
source3/winbindd/winbindd_cred_cache.c
source3/winbindd/winbindd_pam.c
source3/winbindd/winbindd_proto.h

index 480ba4f1282296c74bd43aebf7c048fb09959b07..6e3dec997981f4a803347fb18b6b6c669f4d272e 100644 (file)
@@ -350,6 +350,8 @@ struct WINBINDD_CCACHE_ENTRY {
        const char *service;
        const char *username;
        const char *realm;
+       const char *canon_principal;
+       const char *canon_realm;
        struct WINBINDD_MEMORY_CREDS *cred_ptr;
        int ref_count;
        uid_t uid;
index c3077e219893d62785ef8c4bdeb44772fc9619a6..88847b1ab97ce2595a5c56cbdf2d8caa04937c19 100644 (file)
@@ -501,7 +501,9 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
                            time_t create_time,
                            time_t ticket_end,
                            time_t renew_until,
-                           bool postponed_request)
+                           bool postponed_request,
+                           const char *canon_principal,
+                           const char *canon_realm)
 {
        struct WINBINDD_CCACHE_ENTRY *entry = NULL;
        struct timeval t;
@@ -617,6 +619,18 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
                        goto no_mem;
                }
        }
+       if (canon_principal != NULL) {
+               entry->canon_principal = talloc_strdup(entry, canon_principal);
+               if (entry->canon_principal == NULL) {
+                       goto no_mem;
+               }
+       }
+       if (canon_realm != NULL) {
+               entry->canon_realm = talloc_strdup(entry, canon_realm);
+               if (entry->canon_realm == NULL) {
+                       goto no_mem;
+               }
+       }
 
        entry->ccname = talloc_strdup(entry, ccname);
        if (!entry->ccname) {
index 001c711911bd01d8b578d23211844e120c62b1c3..d50439de4245e27b8cdba49ef73b7bb4a29bbcb1 100644 (file)
@@ -687,6 +687,8 @@ static NTSTATUS winbindd_raw_kerberos_login(TALLOC_CTX *mem_ctx,
        const char *local_service;
        uint32_t i;
        struct netr_SamInfo6 *info6_copy = NULL;
+       char *canon_principal = NULL;
+       char *canon_realm = NULL;
        bool ok;
 
        *info6 = NULL;
@@ -789,8 +791,8 @@ static NTSTATUS winbindd_raw_kerberos_login(TALLOC_CTX *mem_ctx,
                                     WINBINDD_PAM_AUTH_KRB5_RENEW_TIME,
                                     NULL,
                                     local_service,
-                                    NULL,
-                                    NULL,
+                                    &canon_principal,
+                                    &canon_realm,
                                     &pac_data_ctr);
        if (user_ccache_file != NULL) {
                gain_root_privilege();
@@ -856,7 +858,9 @@ static NTSTATUS winbindd_raw_kerberos_login(TALLOC_CTX *mem_ctx,
                                            time(NULL),
                                            ticket_lifetime,
                                            renewal_until,
-                                           false);
+                                           false,
+                                           canon_principal,
+                                           canon_realm);
 
                if (!NT_STATUS_IS_OK(result)) {
                        DEBUG(10,("winbindd_raw_kerberos_login: failed to add ccache to list: %s\n",
@@ -1233,7 +1237,9 @@ static NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
                                                            time(NULL),
                                                            time(NULL) + lp_winbind_cache_time(),
                                                            time(NULL) + WINBINDD_PAM_AUTH_KRB5_RENEW_TIME,
-                                                           true);
+                                                           true,
+                                                           principal_s,
+                                                           realm);
 
                                if (!NT_STATUS_IS_OK(result)) {
                                        DEBUG(10,("winbindd_dual_pam_auth_cached: failed "
index 12a113ed63621d23a2fd5729f7b36588fae62787..96d32cc741ee15151336a402ca8b62861f4df062 100644 (file)
@@ -236,7 +236,9 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
                            time_t create_time,
                            time_t ticket_end,
                            time_t renew_until,
-                           bool postponed_request);
+                           bool postponed_request,
+                           const char *canon_principal,
+                           const char *canon_realm);
 NTSTATUS remove_ccache(const char *username);
 struct WINBINDD_MEMORY_CREDS *find_memory_creds_by_name(const char *username);
 NTSTATUS winbindd_add_memory_creds(const char *username,