[PATCH]: Fix a delete on close divergence from windows and the associated torture test

Thomas Bork tombork at web.de
Sat Dec 27 03:02:04 GMT 2008


Jeremy Allison wrote:

>>> Could you please split the first patch into two (one for the torture
>>> test and one for smbd). Then it's easier to backport the smbd fixes to
>>> the v3-x-* branches.
>> You can find the split version here:
>> http://git.samba.org/?p=tprouty/samba.git;a=shortlog;h=refs/heads/delete_on_close_bug_split
> This patch looks *great* !
> Can you push into master and 3.3 please ?
> I'll wait until 3.2.6 ships and then back
> port to that also (too close to release to
> make this change now).

Is this the right fix for 3.0?

diff -Nurp samba-3.0.33.orig/source/include/smb.h 
samba-3.0.33/source/include/smb.h
--- samba-3.0.33.orig/source/include/smb.h      Fri Dec  5 00:35:07 2008
+++ samba-3.0.33/source/include/smb.h   Wed Dec 10 10:40:46 2008
@@ -764,7 +764,6 @@ struct pending_message_list {
  };

  #define SHARE_MODE_FLAG_POSIX_OPEN     0x1
-#define SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE      0x2

  /* struct returned by get_share_modes */
  struct share_mode_entry {
diff -Nurp samba-3.0.33.orig/source/locking/locking.c 
samba-3.0.33/source/locking/locking.c
--- samba-3.0.33.orig/source/locking/locking.c  Fri Dec  5 00:35:07 2008
+++ samba-3.0.33/source/locking/locking.c       Wed Dec 10 10:40:12 2008
@@ -1017,13 +1017,10 @@ static void add_share_mode_entry(struct
  }

  void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
-                       uid_t uid, uint16 mid, uint16 op_type, BOOL 
initial_delete_on_close_allowed)
+                       uid_t uid, uint16 mid, uint16 op_type)
  {
         struct share_mode_entry entry;
         fill_share_mode_entry(&entry, fsp, uid, mid, op_type);
-       if (initial_delete_on_close_allowed) {
-               entry.flags |= SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE;
-       }
         add_share_mode_entry(lck, &entry);
  }

@@ -1223,22 +1220,6 @@ NTSTATUS can_set_delete_on_close(files_s
         return NT_STATUS_OK;
  }

-/****************************************************************************
- Do we have an open file handle that created this entry ?
-****************************************************************************/
-
-BOOL can_set_initial_delete_on_close(const struct share_mode_lock *lck)
-{
-       int i;
-
-       for (i=0; i<lck->num_share_modes; i++) {
-               if (lck->share_modes[i].flags & 
SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE) {
-                       return True;
-               }
-       }
-       return False;
-}
-
  /*************************************************************************
   Return a talloced copy of a UNIX_USER_TOKEN. NULL on fail.
   (Should this be in locking.c.... ?).
@@ -1336,31 +1317,6 @@ BOOL set_delete_on_close(files_struct *f
         }

         TALLOC_FREE(lck);
-       return True;
-}
-
-/****************************************************************************
- Sets the allow initial delete on close flag for this share mode.
-****************************************************************************/
-
-BOOL set_allow_initial_delete_on_close(struct share_mode_lock *lck, 
files_struct *fsp, BOOL delete_on_close)
-{
-       struct share_mode_entry entry, *e;
-
-       /* Don't care about the pid owner being correct here - just a 
search. */
-       fill_share_mode_entry(&entry, fsp, (uid_t)-1, 0, NO_OPLOCK);
-
-       e = find_share_mode_entry(lck, &entry);
-       if (e == NULL) {
-               return False;
-       }
-
-       if (delete_on_close) {
-               e->flags |= SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE;
-       } else {
-               e->flags &= ~SHARE_MODE_ALLOW_INITIAL_DELETE_ON_CLOSE;
-       }
-       lck->modified = True;
         return True;
  }

diff -Nurp samba-3.0.33.orig/source/smbd/open.c 
samba-3.0.33/source/smbd/open.c
--- samba-3.0.33.orig/source/smbd/open.c        Fri Dec  5 00:35:07 2008
+++ samba-3.0.33/source/smbd/open.c     Wed Dec 10 10:36:21 2008
@@ -1794,10 +1794,10 @@ NTSTATUS open_file_ntcreate(connection_s
                 new_file_created = True;
         }

-       set_share_mode(lck, fsp, current_user.ut.uid, 0, 
fsp->oplock_type, new_file_created);
+       set_share_mode(lck, fsp, current_user.ut.uid, 0, fsp->oplock_type);

         /* Handle strange delete on close create semantics. */
-       if ((create_options & FILE_DELETE_ON_CLOSE) && 
can_set_initial_delete_on_close(lck)) {
+       if (create_options & FILE_DELETE_ON_CLOSE) {
                 status = can_set_delete_on_close(fsp, True, 
new_dos_attributes);

                 if (!NT_STATUS_IS_OK(status)) {
@@ -2187,7 +2187,7 @@ NTSTATUS open_directory(connection_struc
                 return status;
         }

-       set_share_mode(lck, fsp, current_user.ut.uid, 0, NO_OPLOCK, True);
+       set_share_mode(lck, fsp, current_user.ut.uid, 0, NO_OPLOCK);

         /* For directories the delete on close bit at open time seems
            always to be honored on close... See test 19 in Samba4 
BASE-DELETE. */
diff -Nurp samba-3.0.33.orig/source/smbd/reply.c 
samba-3.0.33/source/smbd/reply.c
--- samba-3.0.33.orig/source/smbd/reply.c       Fri Dec  5 00:35:07 2008
+++ samba-3.0.33/source/smbd/reply.c    Wed Dec 10 10:33:29 2008
@@ -4346,8 +4346,6 @@ NTSTATUS rename_internals_fsp(connection
                  * depends on these semantics. JRA.
                  */

-               set_allow_initial_delete_on_close(lck, fsp, True);
-
                 if (create_options & FILE_DELETE_ON_CLOSE) {
                         status = can_set_delete_on_close(fsp, True, 0);



Don't know, if there is something to change in files, which are created 
from make proto.


der tom


More information about the samba-technical mailing list