svn commit: samba r8686 - branches/SAMBA_3_0/source/lib branches/SAMBA_3_0/source/printing trunk/source/lib trunk/source/printing

gd at samba.org gd at samba.org
Thu Jul 21 17:40:22 GMT 2005


Author: gd
Date: 2005-07-21 17:40:20 +0000 (Thu, 21 Jul 2005)
New Revision: 8686

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

Log:
Revert %LOGONSERVER%-substitution. The substition is done on the client,
not on the server.

We now preserve this windows variable (important for vampired setups)
and correctly substitute only the "%L"s in strings like:

        "%LOGONSERVER% %L %lOgOnSeRvEr% %L".

Guenther
        

Modified:
   branches/SAMBA_3_0/source/lib/substitute.c
   branches/SAMBA_3_0/source/lib/util_str.c
   branches/SAMBA_3_0/source/printing/printing.c
   trunk/source/lib/substitute.c
   trunk/source/lib/util_str.c
   trunk/source/printing/printing.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/substitute.c
===================================================================
--- branches/SAMBA_3_0/source/lib/substitute.c	2005-07-21 14:04:13 UTC (rev 8685)
+++ branches/SAMBA_3_0/source/lib/substitute.c	2005-07-21 17:40:20 UTC (rev 8686)
@@ -385,20 +385,20 @@
 		case 'i' :
 			string_sub(p,"%i", client_socket_addr(),l);
 			break;
-		case 'L' : 
+		case 'L' :
+			if (!StrnCaseCmp(p, "\%LOGONSERVER\%", 13)) {
+				p++;
+				break;
+			}
+
 			if (local_machine_name && *local_machine_name) {
-				if (IS_DC)
-					string_sub(p, "\%LOGONSERVER\%", local_machine_name, l);
-				string_sub(p,"%L", local_machine_name,l); 
+				string_sub_once(p, "%L", local_machine_name, l); 
 			} else {
 				pstring temp_name;
 
 				pstrcpy(temp_name, global_myname());
 				strlower_m(temp_name);
-				if (IS_DC)
-					string_sub(p, "\%LOGONSERVER\%", temp_name,l); 
-					
-				string_sub(p,"%L", temp_name,l); 
+				string_sub_once(p, "%L", temp_name, l); 
 			}
 			break;
 		case 'M' :

Modified: branches/SAMBA_3_0/source/lib/util_str.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util_str.c	2005-07-21 14:04:13 UTC (rev 8685)
+++ branches/SAMBA_3_0/source/lib/util_str.c	2005-07-21 17:40:20 UTC (rev 8686)
@@ -909,14 +909,15 @@
  enough room!
 
  This routine looks for pattern in s and replaces it with 
- insert. It may do multiple replacements.
+ insert. It may do multiple replacements or just one.
 
  Any of " ; ' $ or ` in the insert string are replaced with _
  if len==0 then the string cannot be extended. This is different from the old
  use of len==0 which was for no length checks to be done.
 **/
 
-void string_sub2(char *s,const char *pattern, const char *insert, size_t len, BOOL remove_unsafe_characters)
+void string_sub2(char *s,const char *pattern, const char *insert, size_t len, 
+		 BOOL remove_unsafe_characters, BOOL replace_once)
 {
 	char *p;
 	ssize_t ls,lp,li, i;
@@ -963,12 +964,20 @@
 		}
 		s = p + li;
 		ls += (li-lp);
+
+		if (replace_once)
+			break;
 	}
 }
 
+void string_sub_once(char *s, const char *pattern, const char *insert, size_t len)
+{
+	string_sub2( s, pattern, insert, len, True, True );
+}
+
 void string_sub(char *s,const char *pattern, const char *insert, size_t len)
 {
-	string_sub2( s, pattern, insert, len, True );
+	string_sub2( s, pattern, insert, len, True, False );
 }
 
 void fstring_sub(char *s,const char *pattern,const char *insert)

Modified: branches/SAMBA_3_0/source/printing/printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/printing.c	2005-07-21 14:04:13 UTC (rev 8685)
+++ branches/SAMBA_3_0/source/printing/printing.c	2005-07-21 17:40:20 UTC (rev 8686)
@@ -1383,7 +1383,7 @@
 	/* don't strip out characters like '$' from the printername */
 	
 	pstrcpy( lpqcommand, lp_lpqcommand(snum));
-	string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand), False );
+	string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand), False, False );
 	standard_sub_snum( snum, lpqcommand, sizeof(lpqcommand) );
 	
 	/* 

Modified: trunk/source/lib/substitute.c
===================================================================
--- trunk/source/lib/substitute.c	2005-07-21 14:04:13 UTC (rev 8685)
+++ trunk/source/lib/substitute.c	2005-07-21 17:40:20 UTC (rev 8686)
@@ -385,20 +385,20 @@
 		case 'i' :
 			string_sub(p,"%i", client_socket_addr(),l);
 			break;
-		case 'L' : 
+		case 'L' :
+			if (!StrnCaseCmp(p, "\%LOGONSERVER\%", 13)) {
+				p++;
+				break;
+			}
+
 			if (local_machine_name && *local_machine_name) {
-				if (IS_DC)
-					string_sub(p, "\%LOGONSERVER\%", local_machine_name, l);
-				string_sub(p,"%L", local_machine_name,l); 
+				string_sub_once(p, "%L", local_machine_name, l); 
 			} else {
 				pstring temp_name;
 
 				pstrcpy(temp_name, global_myname());
 				strlower_m(temp_name);
-				if (IS_DC)
-					string_sub(p, "\%LOGONSERVER\%", temp_name,l); 
-					
-				string_sub(p,"%L", temp_name,l); 
+				string_sub_once(p, "%L", temp_name, l); 
 			}
 			break;
 		case 'M' :

Modified: trunk/source/lib/util_str.c
===================================================================
--- trunk/source/lib/util_str.c	2005-07-21 14:04:13 UTC (rev 8685)
+++ trunk/source/lib/util_str.c	2005-07-21 17:40:20 UTC (rev 8686)
@@ -909,14 +909,15 @@
  enough room!
 
  This routine looks for pattern in s and replaces it with 
- insert. It may do multiple replacements.
+ insert. It may do multiple replacements or just one.
 
  Any of " ; ' $ or ` in the insert string are replaced with _
  if len==0 then the string cannot be extended. This is different from the old
  use of len==0 which was for no length checks to be done.
 **/
 
-void string_sub2(char *s,const char *pattern, const char *insert, size_t len, BOOL remove_unsafe_characters)
+void string_sub2(char *s,const char *pattern, const char *insert, size_t len, 
+		 BOOL remove_unsafe_characters, BOOL replace_once)
 {
 	char *p;
 	ssize_t ls,lp,li, i;
@@ -963,12 +964,20 @@
 		}
 		s = p + li;
 		ls += (li-lp);
+
+		if (replace_once)
+			break;
 	}
 }
 
+void string_sub_once(char *s, const char *pattern, const char *insert, size_t len)
+{
+	string_sub2( s, pattern, insert, len, True, True );
+}
+
 void string_sub(char *s,const char *pattern, const char *insert, size_t len)
 {
-	string_sub2( s, pattern, insert, len, True );
+	string_sub2( s, pattern, insert, len, True, False );
 }
 
 void fstring_sub(char *s,const char *pattern,const char *insert)

Modified: trunk/source/printing/printing.c
===================================================================
--- trunk/source/printing/printing.c	2005-07-21 14:04:13 UTC (rev 8685)
+++ trunk/source/printing/printing.c	2005-07-21 17:40:20 UTC (rev 8686)
@@ -1383,7 +1383,7 @@
 	/* don't strip out characters like '$' from the printername */
 	
 	pstrcpy( lpqcommand, lp_lpqcommand(snum));
-	string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand), False );
+	string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand), False, False );
 	standard_sub_snum( snum, lpqcommand, sizeof(lpqcommand) );
 	
 	/* 



More information about the samba-cvs mailing list