Author: jerry
Date: 2005-11-11 03:03:41 +0000 (Fri, 11 Nov 2005)
New Revision: 11661

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11661

Log:
Store the INFO3 in the PAC data into the netsamlogon_cache.
Also remove the mem_ctx from the netsamlogon_cache_store() API.

Guenther, what should we be doing with the other fields in 
the PAC_LOGON_INFO?



Modified:
   branches/SAMBA_3_0/source/auth/auth_domain.c
   branches/SAMBA_3_0/source/libsmb/samlogon_cache.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_pam.c
   branches/SAMBA_3_0/source/smbd/sesssetup.c
   trunk/source/auth/auth_domain.c
   trunk/source/libsmb/samlogon_cache.c
   trunk/source/nsswitch/winbindd_pam.c
   trunk/source/smbd/sesssetup.c


Changeset:
Modified: branches/SAMBA_3_0/source/auth/auth_domain.c
===================================================================
--- branches/SAMBA_3_0/source/auth/auth_domain.c        2005-11-11 01:38:39 UTC 
(rev 11660)
+++ branches/SAMBA_3_0/source/auth/auth_domain.c        2005-11-11 03:03:41 UTC 
(rev 11661)
@@ -253,7 +253,7 @@
                                                server_info,
                                                &info3);
 
-               netsamlogon_cache_store( mem_ctx, user_info->smb_name.str, 
&info3 );
+               netsamlogon_cache_store( user_info->smb_name.str, &info3 );
        }
 
        /* Note - once the cli stream is shutdown the mem_ctx used

Modified: branches/SAMBA_3_0/source/libsmb/samlogon_cache.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/samlogon_cache.c   2005-11-11 01:38:39 UTC 
(rev 11660)
+++ branches/SAMBA_3_0/source/libsmb/samlogon_cache.c   2005-11-11 03:03:41 UTC 
(rev 11661)
@@ -109,7 +109,7 @@
  username should be in UTF-8 format
 ***********************************************************************/
 
-BOOL netsamlogon_cache_store(TALLOC_CTX *mem_ctx, const char * username, 
NET_USER_INFO_3 *user)
+BOOL netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user )
 {
        TDB_DATA        data;
         fstring        keystr;
@@ -117,6 +117,7 @@
        BOOL            result = False;
        DOM_SID         user_sid;
        time_t          t = time(NULL);
+       TALLOC_CTX      *mem_ctx;
        
 
        if (!netsamlogon_cache_init()) {
@@ -142,6 +143,11 @@
                
        /* Prepare data */
        
+       if ( !(mem_ctx = TALLOC_P( NULL, int )) ) {
+               DEBUG(0,("netsamlogon_cache_store: talloc() failed!\n"));
+               return False;
+       }
+
        prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
        
        if ( !prs_uint32( "timestamp", &ps, 0, (uint32*)&t ) )
@@ -157,6 +163,8 @@
                
                prs_mem_free( &ps );
        }
+
+       TALLOC_FREE( mem_ctx );
                
        return result;
 }
@@ -175,7 +183,7 @@
        uint32          t;
        
        if (!netsamlogon_cache_init()) {
-               DEBUG(0,("netsamlogon_cache_store: cannot open %s for 
write!\n", NETSAMLOGON_TDB));
+               DEBUG(0,("netsamlogon_cache_get: cannot open %s for write!\n", 
NETSAMLOGON_TDB));
                return False;
        }
 

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_pam.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_pam.c   2005-11-11 01:38:39 UTC 
(rev 11660)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_pam.c   2005-11-11 03:03:41 UTC 
(rev 11661)
@@ -382,7 +382,7 @@
        } while ( (attempts < 2) && retry );
 
        if (NT_STATUS_IS_OK(result)) {
-               netsamlogon_cache_store(state->mem_ctx, name_user, &info3);
+               netsamlogon_cache_store(name_user, &info3);
                wcache_invalidate_samlogon(find_domain_from_name(name_domain), 
&info3);
 
                /* Check if the user is in the right group */
@@ -667,7 +667,7 @@
        } while ( (attempts < 2) && retry );
 
        if (NT_STATUS_IS_OK(result)) {
-               netsamlogon_cache_store(state->mem_ctx, name_user, &info3);
+               netsamlogon_cache_store(name_user, &info3);
                wcache_invalidate_samlogon(find_domain_from_name(name_domain), 
&info3);
 
                /* Check if the user is in the right group */

Modified: branches/SAMBA_3_0/source/smbd/sesssetup.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/sesssetup.c  2005-11-11 01:38:39 UTC (rev 
11660)
+++ branches/SAMBA_3_0/source/smbd/sesssetup.c  2005-11-11 03:03:41 UTC (rev 
11661)
@@ -180,10 +180,6 @@
                return ERROR_NT(NT_STATUS_LOGON_FAILURE);
        }
 
-       if (pac_data) {
-               logon_info = get_logon_info_from_pac(pac_data);
-       }
-
        DEBUG(3,("Ticket name is [%s]\n", client));
 
        p = strchr_m(client, '@');
@@ -196,6 +192,14 @@
        }
 
        *p = 0;
+
+       /* save the PAC data if we have it */
+
+       if (pac_data) {
+               logon_info = get_logon_info_from_pac(pac_data);
+               netsamlogon_cache_store( client, &logon_info->info3 );
+       }
+
        if (!strequal(p+1, lp_realm())) {
                DEBUG(3,("Ticket for foreign realm [EMAIL PROTECTED]", client, 
p+1));
                if (!lp_allow_trusted_domains()) {

Modified: trunk/source/auth/auth_domain.c
===================================================================
--- trunk/source/auth/auth_domain.c     2005-11-11 01:38:39 UTC (rev 11660)
+++ trunk/source/auth/auth_domain.c     2005-11-11 03:03:41 UTC (rev 11661)
@@ -253,7 +253,7 @@
                                                server_info,
                                                &info3);
 
-               netsamlogon_cache_store( mem_ctx, user_info->smb_name.str, 
&info3 );
+               netsamlogon_cache_store( user_info->smb_name.str, &info3 );
        }
 
        /* Note - once the cli stream is shutdown the mem_ctx used

Modified: trunk/source/libsmb/samlogon_cache.c
===================================================================
--- trunk/source/libsmb/samlogon_cache.c        2005-11-11 01:38:39 UTC (rev 
11660)
+++ trunk/source/libsmb/samlogon_cache.c        2005-11-11 03:03:41 UTC (rev 
11661)
@@ -109,7 +109,7 @@
  username should be in UTF-8 format
 ***********************************************************************/
 
-BOOL netsamlogon_cache_store(TALLOC_CTX *mem_ctx, const char * username, 
NET_USER_INFO_3 *user)
+BOOL netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user )
 {
        TDB_DATA        data;
         fstring        keystr;
@@ -117,6 +117,7 @@
        BOOL            result = False;
        DOM_SID         user_sid;
        time_t          t = time(NULL);
+       TALLOC_CTX      *mem_ctx;
        
 
        if (!netsamlogon_cache_init()) {
@@ -142,6 +143,11 @@
                
        /* Prepare data */
        
+       if ( !(mem_ctx = TALLOC_P( NULL, int )) ) {
+               DEBUG(0,("netsamlogon_cache_store: talloc() failed!\n"));
+               return False;
+       }
+
        prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
        
        if ( !prs_uint32( "timestamp", &ps, 0, (uint32*)&t ) )
@@ -157,6 +163,8 @@
                
                prs_mem_free( &ps );
        }
+
+       TALLOC_FREE( mem_ctx );
                
        return result;
 }
@@ -175,7 +183,7 @@
        uint32          t;
        
        if (!netsamlogon_cache_init()) {
-               DEBUG(0,("netsamlogon_cache_store: cannot open %s for 
write!\n", NETSAMLOGON_TDB));
+               DEBUG(0,("netsamlogon_cache_get: cannot open %s for write!\n", 
NETSAMLOGON_TDB));
                return False;
        }
 

Modified: trunk/source/nsswitch/winbindd_pam.c
===================================================================
--- trunk/source/nsswitch/winbindd_pam.c        2005-11-11 01:38:39 UTC (rev 
11660)
+++ trunk/source/nsswitch/winbindd_pam.c        2005-11-11 03:03:41 UTC (rev 
11661)
@@ -382,7 +382,7 @@
        } while ( (attempts < 2) && retry );
 
        if (NT_STATUS_IS_OK(result)) {
-               netsamlogon_cache_store(state->mem_ctx, name_user, &info3);
+               netsamlogon_cache_store(name_user, &info3);
                wcache_invalidate_samlogon(find_domain_from_name(name_domain), 
&info3);
 
                /* Check if the user is in the right group */
@@ -667,7 +667,7 @@
        } while ( (attempts < 2) && retry );
 
        if (NT_STATUS_IS_OK(result)) {
-               netsamlogon_cache_store(state->mem_ctx, name_user, &info3);
+               netsamlogon_cache_store(name_user, &info3);
                wcache_invalidate_samlogon(find_domain_from_name(name_domain), 
&info3);
 
                /* Check if the user is in the right group */

Modified: trunk/source/smbd/sesssetup.c
===================================================================
--- trunk/source/smbd/sesssetup.c       2005-11-11 01:38:39 UTC (rev 11660)
+++ trunk/source/smbd/sesssetup.c       2005-11-11 03:03:41 UTC (rev 11661)
@@ -180,10 +180,6 @@
                return ERROR_NT(NT_STATUS_LOGON_FAILURE);
        }
 
-       if (pac_data) {
-               logon_info = get_logon_info_from_pac(pac_data);
-       }
-
        DEBUG(3,("Ticket name is [%s]\n", client));
 
        p = strchr_m(client, '@');
@@ -196,6 +192,14 @@
        }
 
        *p = 0;
+
+       /* save the PAC data if we have it */
+
+       if (pac_data) {
+               logon_info = get_logon_info_from_pac(pac_data);
+               netsamlogon_cache_store( client, &logon_info->info3 );
+       }
+
        if (!strequal(p+1, lp_realm())) {
                DEBUG(3,("Ticket for foreign realm [EMAIL PROTECTED]", client, 
p+1));
                if (!lp_allow_trusted_domains()) {

Reply via email to