The branch, v4-1-test has been updated
       via  00f6184 s3:smbd: fix file corruption using "write cache size != 0"
       via  907e64c s3: nmbd: Ensure NetBIOS names are only 15 characters 
stored.
       via  56ed600 s3: libsmbclient - smb2. MacOSX 10 SMB2 server doesn't set 
STATUS_NO_MORE_FILES when handed a non-wildcard path.
       via  5126c01 spoolss: fix handling of bad EnumJobs levels
       via  39a9211 s3-nmbd: Fix netbios name truncation.
       via  0e03a17 There are tests all over the SMB1 code to check that 
srv_send_smb fails, but it never returns false.
       via  859a84d s3: daemons - ensure nmbd and winbindd are consistent in 
command line processing by adding POPT_COMMON_DYNCONFIG.
      from  43fbaf6 vfs_glusterfs: Remove "integer fd" code and store the glfs 
pointers.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-1-test


- Log -----------------------------------------------------------------
commit 00f6184e52b7b4a044b8696e02023cd548ce87aa
Author: Stefan Metzmacher <me...@samba.org>
Date:   Fri Nov 7 15:57:40 2014 -0800

    s3:smbd: fix file corruption using "write cache size != 0"
    
    A client can:
    - open a handle (h1)
    - write some data to h1.
    - open a 2nd handle h2 (downgrades both handles to level II)
    - try to read the data on h2 (this gets old data)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10921
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    
    Autobuild-User(v4-1-test): Karolin Seeger <ksee...@samba.org>
    Autobuild-Date(v4-1-test): Sun Nov  9 22:57:54 CET 2014 on sn-devel-104

commit 907e64cc6534933d5da780444e930488ecd8aa42
Author: Jeremy Allison <j...@samba.org>
Date:   Fri Oct 31 11:01:26 2014 -0700

    s3: nmbd: Ensure NetBIOS names are only 15 characters stored.
    
    This screws up if the name is greater than MAX_NETBIOSNAME_LEN-1 in the
    unix charset, but less than or equal to MAX_NETBIOSNAME_LEN-1 in the DOS
    charset, but this is so old we have to live with that.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10920
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    
    (cherry picked from commit 7467f6e72cba214eeca75c34e9d9fba354c7ef31)
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 56ed6003219655443578bb08f24dd5c8587cc85a
Author: Jeremy Allison <j...@samba.org>
Date:   Tue Oct 21 14:41:32 2014 -0700

    s3: libsmbclient - smb2. MacOSX 10 SMB2 server doesn't set 
STATUS_NO_MORE_FILES when handed a non-wildcard path.
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Steve French <smfre...@gmail.com>
    Tested-by: Ralph Boehme <s...@samba.org>
    
    Autobuild-User(master): Steve French <sfre...@samba.org>
    Autobuild-Date(master): Thu Oct 23 20:44:31 CEST 2014 on sn-devel-104
    
    (cherry picked from commit 95bf43bc6a0b6a4a47b8a556eee3b78446ea4123)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10904
    smbclient loops doing a directory listing against Mac OS X 10 server with a
    non-wildcard path.

commit 5126c0157757d16c723d3a23f3b0218c06994f86
Author: David Disseldorp <dd...@samba.org>
Date:   Mon Oct 27 20:13:59 2014 +0100

    spoolss: fix handling of bad EnumJobs levels
    
    Currently Samba is inconsistent when returning WERR_UNKNOWN_LEVEL
    errors for spoolss EnumJobs requests - if no print jobs are present,
    then WERR_OK will be returned, regardless of whether the EnumJobs level
    is supported or not.
    This change fixes this behaviour, by catching invalid or unsupported
    levels prior to the no-jobs response fast-path.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10898
    
    Signed-off-by: David Disseldorp <dd...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Tue Oct 28 03:05:35 CET 2014 on sn-devel-104
    
    (cherry picked from commit d4f233a746d89e13aae78008b499c71b695ff882)

commit 39a9211e2c59f98b3185419c6409298c0abb77f5
Author: Jeremy Allison <j...@samba.org>
Date:   Tue Oct 28 11:55:30 2014 -0700

    s3-nmbd: Fix netbios name truncation.
    
    Try and cope with truncation more intelligently.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10896
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    (cherry picked from commit 6adcc7bffd5e1474ecba04d2328955c0b208cabc)
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 0e03a17bc70232cd07fbd1e0e8a99b3b3e10feb5
Author: Richard Sharpe <realrichardsha...@gmail.com>
Date:   Mon Jul 22 16:04:43 2013 -0700

    There are tests all over the SMB1 code to check that srv_send_smb fails, 
but it never returns false.
    
    Even if the write to the socket/fd fails, we never return false and
    will keep reading stuff off of the input buffer until it is exhausted
    and then we will exit.
    
    Signed-off-by: Richard Sharpe <rsha...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Richard Sharpe <sha...@samba.org>
    Autobuild-Date(master): Sat Aug  3 17:41:22 CEST 2013 on sn-devel-104
    
    (cherry picked from commit 852c9ac34dbef66d0b2619554c611157c2fab771)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10880
    S3: source3/smbd/process.c::srv_send_smb() returns true on the error path.

commit 859a84dec60fe87d2c6b7f8607f3d5c422ea865a
Author: Jeremy Allison <j...@samba.org>
Date:   Mon Jul 14 16:13:24 2014 -0700

    s3: daemons - ensure nmbd and winbindd are consistent in command line 
processing by adding POPT_COMMON_DYNCONFIG.
    
    Bug #10711 - nmbd fails to accept --piddir option.
    
    https://bugzilla.samba.org/show_bug.cgi?id=10711
    
    Signed-off-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 source3/lib/util_names.c                    | 10 +++-
 source3/libsmb/cli_smb2_fnum.c              | 14 ++++++
 source3/nmbd/nmbd.c                         |  3 +-
 source3/nmbd/nmbd_nameregister.c            | 76 ++++++++++++++++++++++++++---
 source3/rpc_server/spoolss/srv_spoolss_nt.c |  7 ++-
 source3/smbd/oplock.c                       |  3 ++
 source3/smbd/process.c                      |  2 +-
 source3/winbindd/winbindd.c                 |  1 +
 8 files changed, 104 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/util_names.c b/source3/lib/util_names.c
index cf54a0e..1392b48 100644
--- a/source3/lib/util_names.c
+++ b/source3/lib/util_names.c
@@ -60,7 +60,15 @@ static bool set_my_netbios_names(const char *name, int i)
 {
        SAFE_FREE(smb_my_netbios_names[i]);
 
-       smb_my_netbios_names[i] = SMB_STRDUP(name);
+       /*
+        * Don't include space for terminating '\0' in strndup,
+        * it is automatically added. This screws up if the name
+        * is greater than MAX_NETBIOSNAME_LEN-1 in the unix
+        * charset, but less than or equal to MAX_NETBIOSNAME_LEN-1
+        * in the DOS charset, but this is so old we have to live
+        * with that.
+        */
+       smb_my_netbios_names[i] = SMB_STRNDUP(name, MAX_NETBIOSNAME_LEN-1);
        if (!smb_my_netbios_names[i])
                return False;
        return strupper_m(smb_my_netbios_names[i]);
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 8eb776a..aeade88 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -501,6 +501,7 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
        bool processed_file = false;
        TALLOC_CTX *frame = talloc_stackframe();
        TALLOC_CTX *subframe = NULL;
+       bool mask_has_wild;
 
        if (smbXcli_conn_has_async_calls(cli->conn)) {
                /*
@@ -524,6 +525,8 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
                goto fail;
         }
 
+       mask_has_wild = ms_has_wild(mask);
+
        status = cli_smb2_create_fnum(cli,
                        parent_dir,
                        0,                      /* create_flags */
@@ -625,6 +628,17 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
 
                TALLOC_FREE(subframe);
 
+               if (!mask_has_wild) {
+                       /*
+                        * MacOSX 10 doesn't set STATUS_NO_MORE_FILES
+                        * when handed a non-wildcard path. Do it
+                        * for the server (with a non-wildcard path
+                        * there should only ever be one file returned.
+                        */
+                       status = STATUS_NO_MORE_FILES;
+                       break;
+               }
+
        } while (NT_STATUS_IS_OK(status));
 
        if (NT_STATUS_EQUAL(status, STATUS_NO_MORE_FILES)) {
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 9ea662c..ae84818 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -798,7 +798,8 @@ static bool open_sockets(bool isdaemon, int port)
        {"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 0, "Load a netbios hosts 
file"},
        {"port", 'p', POPT_ARG_INT, &global_nmb_port, 0, "Listen on the 
specified port" },
        POPT_COMMON_SAMBA
-       { NULL }
+       POPT_COMMON_DYNCONFIG
+       POPT_TABLEEND
        };
        TALLOC_CTX *frame;
        NTSTATUS status;
diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c
index 71c4751..8b078e6 100644
--- a/source3/nmbd/nmbd_nameregister.c
+++ b/source3/nmbd/nmbd_nameregister.c
@@ -482,17 +482,77 @@ void register_name(struct subnet_record *subrec,
 {
        struct nmb_name nmbname;
        nstring nname;
+       size_t converted_size;
 
        errno = 0;
-       push_ascii_nstring(nname, name);
-        if (errno == E2BIG) {
-               unstring tname;
-               pull_ascii_nstring(tname, sizeof(tname), nname);
-               DEBUG(0,("register_name: NetBIOS name %s is too long. 
Truncating to %s\n",
-                       name, tname));
-               make_nmb_name(&nmbname, tname, type);
-       } else {
+       converted_size = push_ascii_nstring(nname, name);
+       if (converted_size != (size_t)-1) {
+               /* Success. */
                make_nmb_name(&nmbname, name, type);
+       } else if (errno == E2BIG) {
+               /*
+                * Name converted to CH_DOS is too large.
+                * try to truncate.
+                */
+               char *converted_str_dos = NULL;
+               char *converted_str_unix = NULL;
+               bool ok;
+
+               converted_size = 0;
+
+               ok = convert_string_talloc(talloc_tos(),
+                               CH_UNIX,
+                               CH_DOS,
+                               name,
+                               strlen(name)+1,
+                               &converted_str_dos,
+                               &converted_size);
+               if (!ok) {
+                       DEBUG(0,("register_name: NetBIOS name %s cannot be "
+                               "converted. Failing to register name.\n",
+                               name));
+                       return;
+               }
+
+               /*
+                * As it's now CH_DOS codepage
+                * we truncate by writing '\0' at
+                * MAX_NETBIOSNAME_LEN-1 and then
+                * convert back to CH_UNIX which we
+                * need for the make_nmb_name() call.
+                */
+               if (converted_size >= MAX_NETBIOSNAME_LEN) {
+                       converted_str_dos[MAX_NETBIOSNAME_LEN-1] = '\0';
+               }
+
+               ok = convert_string_talloc(talloc_tos(),
+                               CH_DOS,
+                               CH_UNIX,
+                               converted_str_dos,
+                               strlen(converted_str_dos)+1,
+                               &converted_str_unix,
+                               &converted_size);
+               if (!ok) {
+                       DEBUG(0,("register_name: NetBIOS name %s cannot be "
+                               "converted back to CH_UNIX. "
+                               "Failing to register name.\n",
+                               converted_str_dos));
+                       TALLOC_FREE(converted_str_dos);
+                       return;
+               }
+
+               make_nmb_name(&nmbname, converted_str_unix, type);
+
+               TALLOC_FREE(converted_str_dos);
+               TALLOC_FREE(converted_str_unix);
+       } else {
+               /*
+                * Generic conversion error. Fail to register.
+                */
+               DEBUG(0,("register_name: NetBIOS name %s cannot be "
+                       "converted (%s). Failing to register name.\n",
+                       name, strerror(errno)));
+               return;
        }
 
        /* Always set the NB_ACTIVE flag on the name we are
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c 
b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 335647b..c247173 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -7333,6 +7333,11 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p,
                return WERR_INVALID_PARAM;
        }
 
+       if ((r->in.level != 1) && (r->in.level != 2) && (r->in.level != 3)) {
+               DEBUG(4, ("EnumJobs level %d not supported\n", r->in.level));
+               return WERR_UNKNOWN_LEVEL;
+       }
+
        DEBUG(4,("_spoolss_EnumJobs\n"));
 
        *r->out.needed = 0;
@@ -7378,7 +7383,7 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p,
                                         pinfo2, r->out.info, r->out.count);
                break;
        default:
-               result = WERR_UNKNOWN_LEVEL;
+               SMB_ASSERT(false);      /* level checked on entry */
                break;
        }
 
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index f2d39b8..ed4de13 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -151,6 +151,9 @@ static void downgrade_file_oplock(files_struct *fsp)
        sconn->oplocks.level_II_open++;
        fsp->sent_oplock_break = NO_BREAK_SENT;
 
+       flush_write_cache(fsp, OPLOCK_RELEASE_FLUSH);
+       delete_write_cache(fsp);
+
        TALLOC_FREE(fsp->oplock_timeout);
 }
 
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 45bde2f..d01bf39 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -201,7 +201,7 @@ out:
        SMB_PERFCOUNT_END(pcd);
 
        smbd_unlock_socket(sconn);
-       return true;
+       return (ret > 0);
 }
 
 /*******************************************************************
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index f101e52..27c43dc 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1364,6 +1364,7 @@ int main(int argc, char **argv, char **envp)
                { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive 
mode" },
                { "no-caching", 'n', POPT_ARG_NONE, NULL, 'n', "Disable 
caching" },
                POPT_COMMON_SAMBA
+               POPT_COMMON_DYNCONFIG
                POPT_TABLEEND
        };
        poptContext pc;


-- 
Samba Shared Repository

Reply via email to