loadparm.c: Fix from "Marty Leisner" <leisner@sdsp.mc.xerox.com> to allow
authorJeremy Allison <jra@samba.org>
Tue, 7 Apr 1998 01:48:57 +0000 (01:48 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 7 Apr 1998 01:48:57 +0000 (01:48 +0000)
server string to be expanded at run time, not load time.
nmblib.c: Integrated the fix to make us RFC1002 complient, as it works
in the main branch.
server.c: Fix from Josef Hinteregger <joehtg@joehtg.co.at> to stop
static string being overwritten in recursive call.
Jeremy.

source/libsmb/nmblib.c
source/param/loadparm.c
source/smbd/server.c

index 1400b88434247cd8b6a4b6f80f26e24e546c7332..f2aee12615eb247adb8a2371bedcea32e0752a03 100644 (file)
@@ -362,6 +362,27 @@ static int put_res_rec(char *buf,int offset,struct res_rec *recs,int count)
   return(ret);
 }
 
+/*******************************************************************
+  put a compressed name pointer record into a packet
+  ******************************************************************/
+static int put_compressed_name_ptr(unsigned char *buf,int offset,struct res_rec *rec,int ptr_offset)
+{  
+  int ret=0;
+  buf[offset] = (0xC0 | ((ptr_offset >> 8) & 0xFF));
+  buf[offset+1] = (ptr_offset & 0xFF);
+  offset += 2;
+  ret += 2;
+  RSSVAL(buf,offset,rec->rr_type);
+  RSSVAL(buf,offset+2,rec->rr_class);
+  RSIVAL(buf,offset+4,rec->ttl);
+  RSSVAL(buf,offset+8,rec->rdlength);
+  memcpy(buf+offset+10,rec->rdata,rec->rdlength);
+  offset += 10+rec->rdlength;
+  ret += 10+rec->rdlength;
+    
+  return(ret);
+}
+
 /*******************************************************************
   parse a dgram packet. Return False if the packet can't be parsed 
   or is invalid for some reason, True otherwise 
@@ -808,10 +829,27 @@ static int build_nmb(char *buf,struct packet_struct *p)
     offset += put_res_rec((char *)ubuf,offset,nmb->nsrecs,
                          nmb->header.nscount);
 
-  if (nmb->header.arcount)
+  /*
+   * The spec says we must put compressed name pointers
+   * in the following outgoing packets :
+   * NAME_REGISTRATION_REQUEST, NAME_REFRESH_REQUEST,
+   * NAME_RELEASE_REQUEST.
+   */
+
+  if((nmb->header.response == False) &&
+     ((nmb->header.opcode == NMB_NAME_REG_OPCODE) ||
+      (nmb->header.opcode == NMB_NAME_RELEASE_OPCODE) ||
+      (nmb->header.opcode == NMB_NAME_REFRESH_OPCODE_8) ||
+      (nmb->header.opcode == NMB_NAME_REFRESH_OPCODE_9) ||
+      (nmb->header.opcode == NMB_NAME_MULTIHOMED_REG_OPCODE)) &&
+     (nmb->header.arcount == 1)) {
+
+    offset += put_compressed_name_ptr(ubuf,offset,nmb->additional,12);
+
+  } else if (nmb->header.arcount) {
     offset += put_res_rec((char *)ubuf,offset,nmb->additional,
                          nmb->header.arcount);  
-
+  }
   return(offset);
 }
 
index 1d534d818e411b5910eb1cdc0d4994cb69c1d115..7fcc40ef76fcd11d7e7f369f08399a7b10786f38 100644 (file)
@@ -1234,7 +1234,7 @@ static BOOL lp_add_ipc(void)
   if (i < 0)
     return(False);
 
-  sprintf(comment,"IPC Service (%s)",lp_serverstring());
+  sprintf(comment,"IPC Service (%s)", Globals.szServerString );
 
   string_set(&iSERVICE(i).szPath,tmpdir());
   string_set(&iSERVICE(i).szUsername,"");
index 5494e42d6aa3a89c5529890c5d5485cd9f16c8dc..4a129c5e508263a70992d0dbe46cb0e1abefc207 100644 (file)
@@ -2214,8 +2214,16 @@ int find_service(char *service)
    /* just possibly it's a default service? */
    if (iService < 0) 
      {
-       char *defservice = lp_defaultservice();
-       if (defservice && *defservice && !strequal(defservice,service)) {
+       char *pdefservice = lp_defaultservice();
+       if (pdefservice && *pdefservice && !strequal(pdefservice,service)) {
+         /*
+          * We need to do a local copy here as lp_defaultservice() 
+          * returns one of the rotating lp_string buffers that
+          * could get overwritten by the recursive find_service() call
+          * below. Fix from Josef Hinteregger <joehtg@joehtg.co.at>.
+          */
+         pstring defservice;
+         pstrcpy(defservice, pdefservice);
         iService = find_service(defservice);
         if (iService >= 0) {
           string_sub(service,"_","/");