The branch, master has been updated
       via  084978f s3: Slightly simplify fd_open_atomic
       via  d95d326 s3: Put a comment into the right place
       via  d0df12f s3: Fix a typo
       via  63279e3 s3: Factor out disposition_to_open_flags
       via  f67a6c4 s3: Factor out calculation of clear_ads
       via  0d86932 s3: Slightly simplify open_file_ntcreate
       via  25bdc36 s3: Fix a comment
       via  93e10db s3: Make "open_match_attributes" static
       via  1c9b1e0 s3: Fix some nonempty blank lines
       via  2fe08c8 s3: Fix memleaks in pylibsmb.c
      from  2172a14 s3: in sys_popen(), add a debug message for failed fork

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 084978f3d0306b7800c3ce64bf99ba30e6ac2fb1
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Sep 3 12:57:18 2012 +0200

    s3: Slightly simplify fd_open_atomic
    
    Replace an if-statement by a direct assignment
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Wed Sep  5 01:56:46 CEST 2012 on sn-devel-104

commit d95d32606b5f90e865c3c8eef95f14be938b3bbe
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Sep 2 12:42:59 2012 +0200

    s3: Put a comment into the right place
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit d0df12f3ea6d3ad9bc83d9628ab68da9b4cc44d4
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Aug 29 17:19:04 2012 +0200

    s3: Fix a typo
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 63279e374a26e4b855b5089b8d616f199609d8fe
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Sep 2 20:47:46 2012 +0200

    s3: Factor out disposition_to_open_flags
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit f67a6c463cbe14dfaaeb8a6255cfb587eea1b5a2
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Sep 2 13:06:22 2012 +0200

    s3: Factor out calculation of clear_ads
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 0d869327edaede4f573cd607a14538d92160a286
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Sep 2 12:53:04 2012 +0200

    s3: Slightly simplify open_file_ntcreate
    
    We have not set flags2 before, so do direct assignment and not |=
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 25bdc3641890cc0fc5f4587e011c968d4b4f6a6b
Author: Volker Lendecke <v...@samba.org>
Date:   Sun Sep 2 07:35:43 2012 +0200

    s3: Fix a comment
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 93e10db3dde3616ab61bf28e0b9c44378d445ab5
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Aug 31 14:52:21 2012 +0200

    s3: Make "open_match_attributes" static
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 1c9b1e07662dca308c8432890d3d5055639b675a
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Aug 31 14:41:44 2012 +0200

    s3: Fix some nonempty blank lines
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 2fe08c886ae60c0affae0166ce1cdab1593bab3e
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Aug 20 13:43:41 2012 +0200

    s3: Fix memleaks in pylibsmb.c
    
    Cut&Paste errors from the read&x routine
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/dbwrap/dbwrap_watch.h |    2 +-
 source3/libsmb/pylibsmb.c         |    4 +-
 source3/locking/share_mode_lock.c |    2 +-
 source3/passdb/lookup_sid.c       |    6 +-
 source3/smbd/open.c               |  139 ++++++++++++++++++++++++-------------
 source3/smbd/proto.h              |    6 --
 6 files changed, 99 insertions(+), 60 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap/dbwrap_watch.h 
b/source3/lib/dbwrap/dbwrap_watch.h
index 66fef32..3362e45 100644
--- a/source3/lib/dbwrap/dbwrap_watch.h
+++ b/source3/lib/dbwrap/dbwrap_watch.h
@@ -43,4 +43,4 @@ void dbwrap_watchers_traverse_read(
 void dbwrap_watchers_wakeall(struct messaging_context *msg);
 
 
-#endif /* __DBWRAP_H__ */
+#endif /* __DBWRAP_WATCH_H__ */
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index be04e5b..d8e64b3 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -577,9 +577,9 @@ static PyObject *py_cli_ftruncate(struct py_cli_state 
*self, PyObject *args,
                return NULL;
        }
        status = cli_ftruncate_recv(req);
+       TALLOC_FREE(req);
 
        if (!NT_STATUS_IS_OK(status)) {
-               TALLOC_FREE(req);
                PyErr_SetNTSTATUS(status);
                return NULL;
        }
@@ -609,9 +609,9 @@ static PyObject *py_cli_delete_on_close(struct py_cli_state 
*self,
                return NULL;
        }
        status = cli_nt_delete_on_close_recv(req);
+       TALLOC_FREE(req);
 
        if (!NT_STATUS_IS_OK(status)) {
-               TALLOC_FREE(req);
                PyErr_SetNTSTATUS(status);
                return NULL;
        }
diff --git a/source3/locking/share_mode_lock.c 
b/source3/locking/share_mode_lock.c
index 171c72f..a82c44e 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -346,7 +346,7 @@ static int the_lock_destructor(struct share_mode_lock *l)
 }
 
 /*******************************************************************
- Get a share_mode_lock, Reference counted to allow nexted calls.
+ Get a share_mode_lock, Reference counted to allow nested calls.
 ********************************************************************/
 
 struct share_mode_lock *get_share_mode_lock(
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index 76a454c..e48420d 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1085,15 +1085,15 @@ static bool legacy_sid_to_unixid(const struct dom_sid 
*psid, struct unixid *id)
 {
        GROUP_MAP *map;
        bool ret;
-       
+
        become_root();
        ret = pdb_sid_to_id(psid, id);
        unbecome_root();
-       
+
        if (ret) {
                goto done;
        }
-       
+
        if ((sid_check_is_in_builtin(psid) ||
             sid_check_is_in_wellknown_domain(psid))) {
                map = talloc_zero(NULL, GROUP_MAP);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 381f3b5..6378521 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -563,14 +563,13 @@ static NTSTATUS fd_open_atomic(struct connection_struct 
*conn,
                 * Fail if already exists, just pass through.
                 */
                status = fd_open(conn, fsp, flags, mode);
-               if (NT_STATUS_IS_OK(status)) {
-                       /*
-                        * Here we've opened with O_CREAT|O_EXCL
-                        * and got success. We *know* we created
-                        * this file.
-                        */
-                       *file_created = true;
-               }
+
+               /*
+                * Here we've opened with O_CREAT|O_EXCL. If that went
+                * NT_STATUS_OK, we *know* we created this file.
+                */
+               *file_created = NT_STATUS_IS_OK(status);
+
                return status;
        }
 
@@ -1480,12 +1479,12 @@ static void defer_open(struct share_mode_lock *lck,
  On overwrite open ensure that the attributes match.
 ****************************************************************************/
 
-bool open_match_attributes(connection_struct *conn,
-                          uint32 old_dos_attr,
-                          uint32 new_dos_attr,
-                          mode_t existing_unx_mode,
-                          mode_t new_unx_mode,
-                          mode_t *returned_unx_mode)
+static bool open_match_attributes(connection_struct *conn,
+                                 uint32 old_dos_attr,
+                                 uint32 new_dos_attr,
+                                 mode_t existing_unx_mode,
+                                 mode_t new_unx_mode,
+                                 mode_t *returned_unx_mode)
 {
        uint32 noarch_old_dos_attr, noarch_new_dos_attr;
 
@@ -1778,6 +1777,75 @@ bool is_deferred_open_async(const void *ptr)
        return state->async_open;
 }
 
+static bool clear_ads(uint32_t create_disposition)
+{
+       bool ret = false;
+
+       switch (create_disposition) {
+       case FILE_SUPERSEDE:
+       case FILE_OVERWRITE_IF:
+       case FILE_OVERWRITE:
+               ret = true;
+               break;
+       default:
+               break;
+       }
+       return ret;
+}
+
+static int disposition_to_open_flags(uint32_t create_disposition)
+{
+       int ret = 0;
+
+       /*
+        * Currently we're using FILE_SUPERSEDE as the same as
+        * FILE_OVERWRITE_IF but they really are
+        * different. FILE_SUPERSEDE deletes an existing file
+        * (requiring delete access) then recreates it.
+        */
+
+       switch (create_disposition) {
+       case FILE_SUPERSEDE:
+       case FILE_OVERWRITE_IF:
+               /*
+                * If file exists replace/overwrite. If file doesn't
+                * exist create.
+                */
+               ret = O_CREAT|O_TRUNC;
+               break;
+
+       case FILE_OPEN:
+               /*
+                * If file exists open. If file doesn't exist error.
+                */
+               ret = 0;
+               break;
+
+       case FILE_OVERWRITE:
+               /*
+                * If file exists overwrite. If file doesn't exist
+                * error.
+                */
+               ret = O_TRUNC;
+               break;
+
+       case FILE_CREATE:
+               /*
+                * If file exists error. If file doesn't exist create.
+                */
+               ret = O_CREAT|O_EXCL;
+               break;
+
+       case FILE_OPEN_IF:
+               /*
+                * If file exists open. If file doesn't exist create.
+                */
+               ret = O_CREAT;
+               break;
+       }
+       return ret;
+}
+
 /****************************************************************************
  Open a file with a share mode. Passed in an already created files_struct *.
 ****************************************************************************/
@@ -1802,7 +1870,6 @@ static NTSTATUS open_file_ntcreate(connection_struct 
*conn,
        bool def_acl = False;
        bool posix_open = False;
        bool new_file_created = False;
-       bool clear_ads = false;
        NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED;
        mode_t new_unx_mode = (mode_t)0;
        mode_t unx_mode = (mode_t)0;
@@ -1933,26 +2000,6 @@ static NTSTATUS open_file_ntcreate(connection_struct 
*conn,
        }
 
        switch( create_disposition ) {
-               /*
-                * Currently we're using FILE_SUPERSEDE as the same as
-                * FILE_OVERWRITE_IF but they really are
-                * different. FILE_SUPERSEDE deletes an existing file
-                * (requiring delete access) then recreates it.
-                */
-               case FILE_SUPERSEDE:
-                       /* If file exists replace/overwrite. If file doesn't
-                        * exist create. */
-                       flags2 |= (O_CREAT | O_TRUNC);
-                       clear_ads = true;
-                       break;
-
-               case FILE_OVERWRITE_IF:
-                       /* If file exists replace/overwrite. If file doesn't
-                        * exist create. */
-                       flags2 |= (O_CREAT | O_TRUNC);
-                       clear_ads = true;
-                       break;
-
                case FILE_OPEN:
                        /* If file exists open. If file doesn't exist error. */
                        if (!file_existed) {
@@ -1976,8 +2023,6 @@ static NTSTATUS open_file_ntcreate(connection_struct 
*conn,
                                errno = ENOENT;
                                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
                        }
-                       flags2 |= O_TRUNC;
-                       clear_ads = true;
                        break;
 
                case FILE_CREATE:
@@ -1995,19 +2040,18 @@ static NTSTATUS open_file_ntcreate(connection_struct 
*conn,
                                }
                                return map_nt_error_from_unix(errno);
                        }
-                       flags2 |= (O_CREAT|O_EXCL);
                        break;
 
+               case FILE_SUPERSEDE:
+               case FILE_OVERWRITE_IF:
                case FILE_OPEN_IF:
-                       /* If file exists open. If file doesn't exist
-                        * create. */
-                       flags2 |= O_CREAT;
                        break;
-
                default:
                        return NT_STATUS_INVALID_PARAMETER;
        }
 
+       flags2 = disposition_to_open_flags(create_disposition);
+
        /* We only care about matching attributes on file exists and
         * overwrite. */
 
@@ -2494,7 +2538,7 @@ static NTSTATUS open_file_ntcreate(connection_struct 
*conn,
        SMB_ASSERT(lck != NULL);
 
        /* Delete streams if create_disposition requires it */
-       if (!new_file_created && clear_ads &&
+       if (!new_file_created && clear_ads(create_disposition) &&
            !is_ntfs_stream_smb_fname(smb_fname)) {
                status = delete_all_streams(conn, smb_fname->base_name);
                if (!NT_STATUS_IS_OK(status)) {
@@ -3639,11 +3683,12 @@ static NTSTATUS create_file_unixpath(connection_struct 
*conn,
                        goto fail;
                }
 
-               /*
-                * We're opening the stream element of a base_fsp
-                * we already opened. Set up the base_fsp pointer.
-                */
                if (base_fsp) {
+                       /*
+                        * We're opening the stream element of a
+                        * base_fsp we already opened. Set up the
+                        * base_fsp pointer.
+                        */
                        fsp->base_fsp = base_fsp;
                }
 
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 5f4947e..b7bab6e 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -608,12 +608,6 @@ NTSTATUS change_dir_owner_to_parent(connection_struct 
*conn,
                                    const char *fname,
                                    SMB_STRUCT_STAT *psbuf);
 bool is_stat_open(uint32 access_mask);
-bool open_match_attributes(connection_struct *conn,
-                          uint32 old_dos_attr,
-                          uint32 new_dos_attr,
-                          mode_t existing_unx_mode,
-                          mode_t new_unx_mode,
-                          mode_t *returned_unx_mode);
 void remove_deferred_open_entry(struct file_id id, uint64_t mid,
                                struct server_id pid);
 bool is_deferred_open_async(const void *ptr);


-- 
Samba Shared Repository

Reply via email to