r8686: Revert %LOGONSERVER%-substitution. The substition is done on the client,
authorGünther Deschner <gd@samba.org>
Thu, 21 Jul 2005 17:40:20 +0000 (17:40 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:00:15 +0000 (11:00 -0500)
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
(This used to be commit dccf777f42ce1d3f788548842fb8a606bed5708c)

source3/lib/substitute.c
source3/lib/util_str.c
source3/printing/printing.c

index f25e5468aad2b8b79d1da51f8c0a09f0a1e2a737..15862f7a9666a1753f8e9d32adc1a1994ea8cb0c 100644 (file)
@@ -385,20 +385,20 @@ void standard_sub_basic(const char *smb_name, char *str,size_t len)
                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' :
index 6b91a0d625e1a49804f41ba2c38158847845a654..1401d6d85349de0f8e17f34451c89e1bfa30f28b 100644 (file)
@@ -909,14 +909,15 @@ BOOL string_set(char **dest,const char *src)
  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 @@ void string_sub2(char *s,const char *pattern, const char *insert, size_t len, BO
                }
                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)
index b49f0716ea4a9e70df57d1a32860263e6e2159b8..2a7cd5d3a74377ba67af8e65255448ec3fd09462 100644 (file)
@@ -1383,7 +1383,7 @@ static void print_queue_update(int snum, BOOL force)
        /* 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) );
        
        /*