samlogon_cache: avoid overwriting info3->base.full_name.string.
authorAndreas Schneider <asn@samba.org>
Thu, 3 Jul 2014 14:17:46 +0000 (16:17 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 15 Jul 2014 16:25:28 +0000 (18:25 +0200)
This field servers as a source for the gecos field. We should not overwrite it
when a info3 struct from a samlogon network level gets saved in which case this
field is always NULL.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Tue Jul 15 18:25:28 CEST 2014 on sn-devel-104

source3/libsmb/samlogon_cache.c

index f7457aedc686a1365a7376782b85bedc8485dd56..0a157d48463bad8ee290056f979408c0bec50cb4 100644 (file)
@@ -149,6 +149,20 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
 
        /* Prepare data */
 
+       if (info3->base.full_name.string == NULL) {
+               struct netr_SamInfo3 *cached_info3;
+               const char *full_name = NULL;
+
+               cached_info3 = netsamlogon_cache_get(tmp_ctx, &user_sid);
+               if (cached_info3 != NULL) {
+                       full_name = cached_info3->base.full_name.string;
+               }
+
+               if (full_name != NULL) {
+                       info3->base.full_name.string = talloc_strdup(info3, full_name);
+               }
+       }
+
        /* only Samba fills in the username, not sure why NT doesn't */
        /* so we fill it in since winbindd_getpwnam() makes use of it */