Author: jerry
Date: 2005-11-10 21:10:24 +0000 (Thu, 10 Nov 2005)
New Revision: 11655

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

Log:
Two small fixes

* remove redundant call to sub_set_smb_name() in session setup code.
* Fix lockup when running 'wbinfo -t' on a Samba PDC.  Cause
  was new authenticated session setup from winbindd which 
  resulted in a mangled username (machine_) that was not found
  in the local files and so was queiued up to nss_winbindd.
  Deadlock....
  So now make sure to keep the trailing '$' for machine account 
  names when calling sub_set_smb_name().


Modified:
   branches/SAMBA_3_0/source/lib/substitute.c
   branches/SAMBA_3_0/source/smbd/sesssetup.c
   trunk/source/lib/substitute.c
   trunk/source/smbd/sesssetup.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/substitute.c
===================================================================
--- branches/SAMBA_3_0/source/lib/substitute.c  2005-11-10 20:33:32 UTC (rev 
11654)
+++ branches/SAMBA_3_0/source/lib/substitute.c  2005-11-10 21:10:24 UTC (rev 
11655)
@@ -107,15 +107,37 @@
 void sub_set_smb_name(const char *name)
 {
        fstring tmp;
+       int len;
+       BOOL is_machine_account = False;
 
        /* don't let anonymous logins override the name */
        if (! *name)
                return;
 
-       fstrcpy(tmp,name);
-       trim_char(tmp,' ',' ');
-       strlower_m(tmp);
-       
alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
+
+       fstrcpy( tmp, name );
+       trim_char( tmp, ' ', ' ' );
+       strlower_m( tmp );
+
+       len = strlen( tmp );
+
+       if ( len == 0 )
+               return;
+
+       /* long story but here goes....we have to allow usernames
+          ending in '$' as they are valid machine account names.
+          So check for a machine account and re-add the '$'
+          at the end after the call to alpha_strcpy().   --jerry  */
+          
+       if ( tmp[len-1] == '$' )
+               is_machine_account = True;
+       
+       alpha_strcpy( smb_user_name, tmp, SAFE_NETBIOS_CHARS, 
sizeof(smb_user_name)-1 );
+
+       if ( is_machine_account ) {
+               len = strlen( smb_user_name );
+               smb_user_name[len-1] = '$';
+       }
 }
 
 char* sub_get_smb_name( void )

Modified: branches/SAMBA_3_0/source/smbd/sesssetup.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/sesssetup.c  2005-11-10 20:33:32 UTC (rev 
11654)
+++ branches/SAMBA_3_0/source/smbd/sesssetup.c  2005-11-10 21:10:24 UTC (rev 
11655)
@@ -954,9 +954,6 @@
                        return ERROR_NT(NT_STATUS_LOGON_FAILURE);
                }
                fstrcpy(sub_user, user);
-
-               /* setup the string used by %U */
-               sub_set_smb_name(user);
        } else {
                fstrcpy(sub_user, lp_guestaccount());
        }

Modified: trunk/source/lib/substitute.c
===================================================================
--- trunk/source/lib/substitute.c       2005-11-10 20:33:32 UTC (rev 11654)
+++ trunk/source/lib/substitute.c       2005-11-10 21:10:24 UTC (rev 11655)
@@ -107,15 +107,37 @@
 void sub_set_smb_name(const char *name)
 {
        fstring tmp;
+       int len;
+       BOOL is_machine_account = False;
 
        /* don't let anonymous logins override the name */
        if (! *name)
                return;
 
-       fstrcpy(tmp,name);
-       trim_char(tmp,' ',' ');
-       strlower_m(tmp);
-       
alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
+
+       fstrcpy( tmp, name );
+       trim_char( tmp, ' ', ' ' );
+       strlower_m( tmp );
+
+       len = strlen( tmp );
+
+       if ( len == 0 )
+               return;
+
+       /* long story but here goes....we have to allow usernames
+          ending in '$' as they are valid machine account names.
+          So check for a machine account and re-add the '$'
+          at the end after the call to alpha_strcpy().   --jerry  */
+          
+       if ( tmp[len-1] == '$' )
+               is_machine_account = True;
+       
+       alpha_strcpy( smb_user_name, tmp, SAFE_NETBIOS_CHARS, 
sizeof(smb_user_name)-1 );
+
+       if ( is_machine_account ) {
+               len = strlen( smb_user_name );
+               smb_user_name[len-1] = '$';
+       }
 }
 
 char* sub_get_smb_name( void )

Modified: trunk/source/smbd/sesssetup.c
===================================================================
--- trunk/source/smbd/sesssetup.c       2005-11-10 20:33:32 UTC (rev 11654)
+++ trunk/source/smbd/sesssetup.c       2005-11-10 21:10:24 UTC (rev 11655)
@@ -954,9 +954,6 @@
                        return ERROR_NT(NT_STATUS_LOGON_FAILURE);
                }
                fstrcpy(sub_user, user);
-
-               /* setup the string used by %U */
-               sub_set_smb_name(user);
        } else {
                fstrcpy(sub_user, lp_guestaccount());
        }

Reply via email to