patch for Win2K terminal server %U issues

Robert Stuart Robert.Stuart at qsa.qld.edu.au
Tue Mar 18 00:18:03 GMT 2003


Hi,

I've attached a patch against 2.2.7 which fixes issues I had with
Terminal servers mapping home dirs off a samba PDC, its also at:
http://rjstuart.cable.nu/patch-2.2.7-userfix

Andrew, you refered to what I think is the issue on Jan 2 in a email to
the samba list:
http://lists.samba.org/pipermail/samba/2003-January/087721.html

You said:
"...You will suffer some nasty performance issues however, as Samba
has to change user between different requests (rather than the OS just
scheduling a new process)."

In source/lib/substitute.c a static var was created to hold the user
associated with a connection for 2.2.7.  I think this assumes that there
is a 1 to 1 relationship between a connection and a process.  This
certainly isn't
the case for Win2K in a terminal server environment where multiple
connections are shared by one smb process.  

I've got more details about my setup in a email regarding this:

http://lists.samba.org/pipermail/samba/2003-January/088108.html

Could someone apply this patch for the next samba release?

I'm not subscribed to the list.

Regards,

Robert Stuart
Systems Administrator
-------------- next part --------------
diff -u -r samba-2.2.7-broken/source/lib/substitute.c samba-2.2.7/source/lib/substitute.c
--- samba-2.2.7-broken/source/lib/substitute.c	Wed Nov 20 11:31:32 2002
+++ samba-2.2.7/source/lib/substitute.c	Thu Oct 10 06:27:21 2002
@@ -29,25 +29,8 @@
 BOOL sam_logon_in_ssb = False;
 fstring remote_proto="UNKNOWN";
 fstring remote_machine="";
-static fstring smb_user_name;
 
 
-/*
-  setup the string used by %U substitution 
-*/
-void sub_set_smb_name(const char *name)
-{
-	fstring tmp;
-
-	/* ignore anonymous settings */
-	if (! *name) return;
-
-	fstrcpy(tmp,name);
-	trim_string(tmp," "," ");
-	strlower(tmp);
-	alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
-}
-
 /*******************************************************************
  Given a pointer to a %$(NAME) expand it as an environment variable.
  Return the number of characters by which the pointer should be advanced.
@@ -197,12 +180,12 @@
 		
 		switch (*(p+1)) {
 		case 'U' : 
-			fstrcpy(tmp_str, sam_logon_in_ssb?samlogon_user:smb_user_name);
+			fstrcpy(tmp_str, sam_logon_in_ssb?samlogon_user:current_user_info.smb_name);
 			strlower(tmp_str);
 			string_sub(p,"%U",tmp_str,l);
 			break;
 		case 'G' :
-			fstrcpy(tmp_str, sam_logon_in_ssb?samlogon_user:smb_user_name);
+			fstrcpy(tmp_str, sam_logon_in_ssb?samlogon_user:current_user_info.smb_name);
 			if ((pass = Get_Pwnam(tmp_str, False))!=NULL) {
 				string_sub(p,"%G",gidtoname(pass->pw_gid),l);
 			} else {
diff -u -r samba-2.2.7-broken/source/nsswitch/winbindd_user.c samba-2.2.7/source/nsswitch/winbindd_user.c
--- samba-2.2.7-broken/source/nsswitch/winbindd_user.c	Wed Nov 20 11:31:33 2002
+++ samba-2.2.7/source/nsswitch/winbindd_user.c	Wed Oct 16 14:30:57 2002
@@ -70,7 +70,6 @@
 	   by lp_string() calling standard_sub_basic(). */
 
 	fstrcpy(current_user_info.smb_name, user_name);
-	sub_set_smb_name(user_name);
 	fstrcpy(current_user_info.domain, dom_name);
 
 	pstrcpy(homedir, lp_template_homedir());
diff -u -r samba-2.2.7-broken/source/smbd/reply.c samba-2.2.7/source/smbd/reply.c
--- samba-2.2.7-broken/source/smbd/reply.c	Wed Nov 20 11:31:33 2002
+++ samba-2.2.7/source/smbd/reply.c	Tue Mar 18 09:32:06 2003
@@ -893,9 +893,9 @@
     }
   }
 
-  /* setup %U substitution */
-  sub_set_smb_name(user);
-
+ 
+ 
+ 
   /* If no username is sent use the guest account */
   if (!*user) {
     pstrcpy(user,lp_guestaccount(-1));



More information about the samba-technical mailing list