prs_give_memory in wrong place, also poss. was losing mem.
authorLuke Leighton <lkcl@samba.org>
Sat, 27 May 2000 09:19:57 +0000 (09:19 +0000)
committerLuke Leighton <lkcl@samba.org>
Sat, 27 May 2000 09:19:57 +0000 (09:19 +0000)
(This used to be commit 9805e17cd0ce427c329a8b5a8318d5f75227e283)

source3/lib/util_unixsd.c
source3/smbd/nttrans.c
source3/smbd/process.c

index 1bfc56a2dacabc4107eaf2b33569e99c66055890..bee9f6964142292843f1f3e8b3ef548c5fdc4805 100644 (file)
@@ -136,7 +136,7 @@ size_t convertperms_unix_to_sd(const SMB_STRUCT_STAT * sbuf,
 
        (*ppdesc) = NULL;
 
-       if (!lp_nt_acl_support())
+       if (!lp_nt_acl_support() || sbuf == NULL)
        {
                sid_copy(&owner_sid, global_sid_everyone);
                sid_copy(&group_sid, global_sid_everyone);
@@ -302,7 +302,7 @@ size_t convertperms_unix_to_sd(const SMB_STRUCT_STAT * sbuf,
 
        sec_desc_size = make_sec_desc((*ppdesc), 1,
                                      SEC_DESC_SELF_RELATIVE |
-                                     SEC_DESC_DACL_PRESENT,
+                                     (sbuf?SEC_DESC_DACL_PRESENT:0),
                                      sid_dup(&owner_sid),
                                      sid_dup(&group_sid), NULL, psa);
 
index a14937411482fe17ff6ce7588df94e734ce24bfc..bb0436aab3b2798d67e73d8e6188c6298eaa7884 100644 (file)
@@ -1924,7 +1924,13 @@ static int call_nt_transact_query_security_desc(connection_struct *conn,
    * Init the parse struct we will marshall into.
    */
 
-  prs_init(&pd, sec_desc_size, 4, MARSHALL);
+  prs_init(&pd, 0, 4, MARSHALL);
+
+  /*
+   * copy the data out of the marshalled structure
+   */
+
+  prs_give_memory( &pd, data, (uint32)sec_desc_size, False);
 
   /*
    * Finally, linearize into the outgoing buffer.
@@ -1943,12 +1949,6 @@ security descriptor.\n"));
     return(UNIXERROR(ERRDOS,ERRnoaccess));
   }
 
-  /*
-   * copy the data out of the marshalled structure
-   */
-
-  prs_give_memory( &pd, data, (uint32)sec_desc_size, False);
-
   /*
    * Now we can delete the security descriptor.
    */
index 9e5b7b14778c04f704bcf995bc9c68c689a6b5aa..74ec3b64db34173a78af3456f5a0a8054b081008 100644 (file)
@@ -408,6 +408,29 @@ struct smb_message_struct
    {SMBgetmac,"SMBgetmac",NULL,AS_GUEST}
  };
 
+/*******************************************************************
+dump a prs to a file
+ ********************************************************************/
+static void smb_dump(char *name, int type, char *data, ssize_t len)
+{
+       int fd, i;
+       pstring fname;
+       if (DEBUGLEVEL < 50) return;
+
+       if (len < 4) len = smb_buflen(data);
+       for (i=1;i<100;i++) {
+               slprintf(fname,sizeof(fname), "/tmp/%s.%d.%s", name, i,
+                               type ? "req" : "resp");
+               fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);
+               if (fd != -1 || errno != EEXIST) break;
+       }
+       if (fd != -1) {
+               write(fd, data, len);
+               close(fd);
+               DEBUG(0,("created %s len %d\n", fname, len));
+       }
+}
+
 
 /****************************************************************************
 do a switch on the message type, and return the response size
@@ -445,12 +468,14 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
   if (match == num_smb_messages)
   {
     DEBUG(0,("Unknown message type %d!\n",type));
+    smb_dump("Unknown", 1, inbuf, size);
     outsize = reply_unknown(inbuf,outbuf);
   }
   else
   {
     DEBUG(3,("switch message %s (pid %d)\n",smb_messages[match].name,(int)pid));
 
+    smb_dump(smb_messages[match].name, 1, inbuf, size);
     if(global_oplock_break)
     {
       int flags = smb_messages[match].flags;
@@ -548,6 +573,8 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
     }
   }
 
+  smb_dump(smb_messages[match].name, 0, outbuf, outsize);
+
   return(outsize);
 }