[SCM] Samba Shared Repository - branch v4-12-stable updated

Karolin Seeger kseeger at samba.org
Tue May 19 10:18:19 UTC 2020


The branch, v4-12-stable has been updated
       via  659c8c3d733 VERSION: Disable GIT_SNAPSHOT for the 4.12.3 release.
       via  53d94505055 WHATSNEW: Add release notes for Samba 4.12.3.
       via  f1c602ea9c9 docs-xml: Fix usernames in pam_winbind manpages
       via  8d8549f571d libsmb: Protect cli_oem_change_password() from rprcnt<2
       via  054e7de5b4b libsmb: Protect cli_RNetServerEnum against rprcnt<6
       via  8dc3d1e4fb7 libsmb: Protect cli_RNetShareEnum() against rprcnt<6
       via  848a1ad7c15 libsmb: Fix indentation in cli_RNetShareEnum()
       via  136a83c5a9f s3/locking: prime flags in a fresh sharemode data object
       via  6b650659ef6 smbd: fix for bug 14375
       via  2b1525ca030 smbd: make conflicting_access available to other functions
       via  5c76c6f2d60 s4/torture: reproducer for bug 14375
       via  31f91b59365 selftest: split a knownfail entry
       via  20d61b9c543 s3: RPC: Don't crash on trying to talloc_free(-1) if smb_iconv_open_ex() fails.
       via  43bc61b1c79 vfs_io_uring: retry after a short writes in vfs_io_uring_pwrite_completion()
       via  0baa1036c6f vfs_io_uring: retry after a short read in vfs_io_uring_pread_completion()
       via  8ed9668cefb vfs_io_uring: protect vfs_io_uring_fsync_completion() against invalid results
       via  9b1281a7062 vfs_io_uring: protect vfs_io_uring_pwrite_completion() against invalid results
       via  dadb1698693 vfs_io_uring: protect vfs_io_uring_pread_completion() against invalid results
       via  0c3523d83cf vfs_io_uring: split out a vfs_io_uring_pwrite_submit() function
       via  bd41e956fcd vfs_io_uring: split out a vfs_io_uring_pread_submit() function
       via  adac9ae7017 vfs_io_uring: split out a vfs_io_uring_request_submit() function
       via  2ab5eaebc4c vfs_io_uring: avoid stack recursion of vfs_io_uring_queue_run()
       via  efdcf63d939 vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pwrite_send()
       via  49847bada15 vfs_io_uring: make use of sys_valid_io_range() in vfs_io_uring_pread_send()
       via  2588cf0d711 vfs_io_uring: move error handling out of vfs_io_uring_fsync_recv()
       via  d9e2acf9445 vfs_io_uring: move error handling out of vfs_io_uring_pwrite_recv()
       via  3dc60c54090 vfs_io_uring: move error handling out of vfs_io_uring_pread_recv()
       via  a15861f6dd3 vfs_io_uring: introduce vfs_io_uring_request->completion_fn()
       via  5acc7ee7681 vfs_io_uring: replace vfs_io_uring_request->state with _tevent_req_data()
       via  7130e37d8f2 vfs_io_uring: fix the prefix for parametric options from 'vfs_io_uring' to 'io_uring'
       via  6b347a406de s3: VFS: default. Change pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE_SEND() to protect against short writes.
       via  00e0cf4241b s3: VFS: default. Change pread() -> sys_pread_full() in SMB_VFS_PREAD_SEND() to protect against short reads.
       via  838a52fa25e s3: VFS: default. Change sys_pwrite() -> sys_pwrite_full() in SMB_VFS_PWRITE() to protect against short writes.
       via  aff82c00a05 s3: VFS: default. Change sys_pread() -> sys_pread_full() in SMB_VFS_PREAD() to protect against short reads.
       via  b60d60bd505 s3: VFS: aio_fork: Change sys_pwrite() -> sys_pwrite_full() to protect against short writes.
       via  f6baeeece8f s3: VFS: aio_fork: Change sys_pread() -> sys_pread_full() to protect against short reads.
       via  0d29e442b15 smbd: add vfs_valid_{pread,pwrite}_range() checks where needed
       via  3197bd27b35 s3:smbd: add vfs_valid_{pread,pwrite}_range() helper functions
       via  9b0aba40e83 s3:smbd: handle 0 length writes as no-op.
       via  f3114c72a3f smb2_server: fix smbd_smb2_request_verify_sizes() for SMB2_OP_WRITE
       via  6c51b56282b lib: util: Add sys_pwrite_full().
       via  442fa5a9782 lib: util: Add sys_pread_full().
       via  b171d8161d2 lib: util: Add sys_valid_io_range()
       via  b50874309d2 s4:torture: add tests to test the SMB2 read/write offset/length boundaries
       via  392863d3d51 vfs_shadow_copy2: implement case canonicalisation in shadow_copy2_get_real_filename()
       via  105ed96add2 s3/lib: add is_gmt_token()
       via  6bf40566d88 smbd: make get_real_filename_full_scan() public
       via  3cedb9c9594 CI: add two tests for shadow_copy2 VFS module
       via  f9f03c0a6f5 ldb: Bump version to 2.1.3
       via  39742f3ffe8 lib ldb: lmdb init var before calling mdb_reader_check
       via  d294eb47296 lib ldb: lmdb clear stale readers on write txn start
       via  2b8faefabb4 ldb tests: Confirm lmdb free list handling
       via  f6468de046e lib:util: Fix smbclient -l basename dir
       via  6bc407b2860 Add a test for smbclient -l basename
       via  21cf1419c54 s3: pass DCE RPC handle type to create_policy_hnd
       via  d2e0eafa92b dbwrap_watch: Set rec->value_valid while returning nested share_mode_do_locked()
       via  d3eb8ef981e libsmb: Don't try to find posix stat info in SMBC_getatr()
       via  af4d2a38fcb VERSION: Bump version up to 4.12.3.
       via  11620a07a89 Merge tag 'samba-4.12.2' into v4-12-test
       via  21f64af155b ctdb: Fix a memleak
       via  790bf2ab198 s3: VFS: Add cmocka test for vfs_full_audit to make sure all arrays are correct.
       via  5ecac7b6dd5 s3: VFS: full_audit. Add missing fcntl entry in vfs_op_names[] array.
       via  8c537c8a402 s3/librpc/crypto: Fix double free with unresolved credential cache
       via  8e3484c163c mit-kdc: Explicitly reject S4U requests
       via  8bdcac936ea selftest: Set KRB5RCACHETYPE to none for selftest
       via  95880710984 Sign and verify PAC with ticket principal instead of canon principal
       via  25fefdb75f5 Fix uxsuccess test with new MIT krb5 library 1.18
       via  6e3fd37ab24 Adapt sign_authdata in our KDB module for krb5 v1.18
       via  d0ca4d173cd testprogs: Add 'net ads join createupn' test also verifying the keytab
       via  dacbd35a11b s3:libads: Fix ads_get_upn()
       via  d6d93329b4c smbd: let delayed update handler also update on-disk timestamps
       via  6d3279d01d9 smbd: let mark_file_modified() always call trigger_write_time_update()
       via  f09cb423ec6 torture/smb2: delayed timestamp updates test: more then one write
       via  92b0555fcd7 torture/smb2: delayed timestamp update test: single write
       via  bd89299d2f7 smbd: remove stat call from mark_file_modified()
       via  58723f78af0 s3: tests: Add samba3.blackbox.force-close-share
       via  a108dece4fb smbd: enforce AIO requests draining
       via  680157b5338 s3: smbd: Remove file_close_pid().
       via  824bc7f7f5b s3: smbd: Remove old synchronous SMB1 reply_exit().
       via  2b32fdde692 s3: smbd: Add async internals of reply_exit().
       via  83b4482828b s3: smbd: Remove old synchronous SMB1 reply_ulogoffX().
       via  aa58b41b8b9 s3: smbd: reply_ulogoffX() Update to modern coding standards.
       via  b619e2042a4 s3: smbd: In reply_ulogoffX(), replace req -> smb1req.
       via  f6bb69d9215 s3: smbd: Add async internals of reply_ulogoffX.
       via  999a14c5cb7 s3: smbd: Remove old synchronous SMB1 reply_tdis().
       via  c613e113dbe s3: smbd: reply_tdis() Update to modern coding standards.
       via  01450dece21 s3: smbd: In reply_tdis(), replace req -> smb1req.
       via  83eace543fa s3: smbd: Add async internals of reply_tdis().
       via  b22e8c8c411 s3: smbd: Replace synchronous conn_force_tdis() with the async version.
       via  97e136880ef s3: smbd: Add async internals of conn_force_tdis().
       via  044cf379e54 s3: smbd: Don't allow force disconnect of a connection already being disconnected.
       via  efc902b29ee s3: smbd: Every place we check fsp->deferred_close, also check for fsp->closing.
       via  49d50bedb8f s3: smbd: In async SMB1 reply_close() set fsp->closing = true, as we already do in SMB2 async close.
       via  1ad202440c5 s3: smbd: Now we free fsp->aio_requests when it gets zero entries, talloc in chunks of 10 instead of 1.
       via  8a6dc998ec6 s3: smbd: In aio_del_req_from_fsp() talloc_free(fsp->aio_requests[]) when fsp->num_aio_requests reaches zero.
       via  bb646d6b5b8 s3: VFS: vfs_aio_pthread: Make aio opens safe against connection teardown.
       via  ef91325978d s3: VFS: vfs_aio_pthread: Add a talloc context parameter to create_private_open_data().
       via  35583c7b80c s3: VFS: vfs_aio_pthread. Move xconn into state struct (opd).
       via  addd33f6880 s3: VFS: vfs_aio_pthread: Replace state destructor with explicitly called teardown function.
       via  7c6a0354736 s3: VFS: vfs_aio_pthread. Fix leak of state struct on error.
       via  24ab1b46af3 smbd: avoid double chdir() in chdir_current_service()
       via  8935fe7e034 torture/smb2: Windows 2019 15 ms timestamp resolution
       via  f6497e769ac smbd: flush pending writetime update when setting timestamps file
       via  a8b94620302 smbd: flush pending writetime update when flushing file
       via  8d05e789320 smbd: always flush pending write time update when setting filesize
       via  f79e39158db torture/smb2: add a test verifying a setinfo(basicinfo) flushes a pending writetime update
       via  6c7b69c7f2b torture/smb2: add a test verifying a flush flushes a pending writetime update
       via  2d21f3c4b38 torture/smb2: mtime update logic with 2 handles: write io on handle 1, then set mtime on handle 2
       via  be695ae6e0e s4/torture: fix a timestamps test to work on ext filesystem
       via  a3157b958bf VERSION: Bump version up to 4.12.2...
      from  ee9600d8a8f VERSION: Disable GIT_SNAPSHOT for the 4.12.2 release.

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


- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 VERSION                                            |   2 +-
 WHATSNEW.txt                                       |  95 ++-
 ctdb/server/ctdb_recoverd.c                        |   1 +
 docs-xml/manpages/pam_winbind.8.xml                |   4 +-
 docs-xml/manpages/pam_winbind.conf.5.xml           |   4 +-
 lib/ldb/ABI/{ldb-2.0.5.sigs => ldb-2.1.3.sigs}     |   0
 ...pyldb-util-2.1.0.sigs => pyldb-util-2.1.3.sigs} |   0
 lib/ldb/ldb_mdb/ldb_mdb.c                          |  17 +
 lib/ldb/tests/ldb_lmdb_free_list_test.c            | 661 ++++++++++++++++++
 lib/ldb/wscript                                    |  10 +-
 lib/util/debug.c                                   |   8 +-
 lib/util/sys_rw.c                                  | 121 ++++
 lib/util/sys_rw.h                                  |   3 +
 selftest/knownfail                                 |   3 +-
 selftest/knownfail.d/rw-invalid                    |   1 +
 .../kinit_mit => knownfail_mit_krb5_pre_1_18}      |   0
 selftest/selftest.pl                               |   1 +
 selftest/skip                                      |   2 +
 selftest/wscript                                   |   3 +
 source3/include/libsmb_internal.h                  |   1 -
 source3/include/proto.h                            |   1 +
 source3/lib/dbwrap/dbwrap_watch.c                  |   1 +
 source3/lib/filename_util.c                        |  19 +
 source3/libads/ldap.c                              |   1 +
 source3/librpc/crypto/gse.c                        |   4 -
 source3/libsmb/clirap.c                            | 151 ++--
 source3/libsmb/libsmb_file.c                       |  20 -
 source3/libsmb/libsmb_server.c                     |   9 -
 source3/locking/share_mode_lock.c                  |   3 +
 source3/modules/offload_token.c                    |  10 +
 .../test_vfs_full_audit.c}                         |  42 +-
 source3/modules/vfs_aio_fork.c                     |   4 +-
 source3/modules/vfs_aio_pthread.c                  | 109 ++-
 source3/modules/vfs_default.c                      |  27 +-
 source3/modules/vfs_full_audit.c                   |   1 +
 source3/modules/vfs_io_uring.c                     | 377 ++++++++--
 source3/modules/vfs_shadow_copy2.c                 |  91 ++-
 source3/modules/wscript_build                      |   5 +
 source3/rpc_server/epmapper/srv_epmapper.c         |   7 +-
 source3/rpc_server/eventlog/srv_eventlog_nt.c      |   2 +-
 source3/rpc_server/lsa/srv_lsa_nt.c                |   2 +-
 source3/rpc_server/mdssvc/mdssvc.c                 |  11 +-
 source3/rpc_server/mdssvc/srv_mdssvc_nt.c          |   2 +-
 source3/rpc_server/rpc_handles.c                   |  30 +-
 source3/rpc_server/rpc_pipes.h                     |  19 +-
 source3/rpc_server/samr/srv_samr_nt.c              |  84 ++-
 source3/rpc_server/spoolss/srv_spoolss_nt.c        |   2 +-
 source3/rpc_server/svcctl/srv_svcctl_nt.c          |   2 +-
 source3/rpc_server/winreg/srv_winreg_nt.c          |   6 +-
 source3/script/tests/test_force_close_share.sh     | 100 +++
 source3/script/tests/test_shadow_copy.sh           |  12 +
 .../script/tests/test_smbclient_log_basename.sh    |  36 +
 source3/selftest/tests.py                          |  16 +
 source3/smbd/aio.c                                 |  37 +-
 source3/smbd/close.c                               |  80 +--
 source3/smbd/conn_idle.c                           | 179 ++++-
 source3/smbd/fileio.c                              |  35 +-
 source3/smbd/filename.c                            |  10 +-
 source3/smbd/files.c                               |  31 +-
 source3/smbd/open.c                                |  22 +-
 source3/smbd/proto.h                               |  10 +-
 source3/smbd/reply.c                               | 650 +++++++++++++++--
 source3/smbd/service.c                             |  67 +-
 source3/smbd/smb2_flush.c                          |   7 +
 source3/smbd/smb2_server.c                         |  10 +-
 source3/smbd/trans2.c                              |  32 +-
 source3/smbd/vfs.c                                 |  66 +-
 source4/kdc/mit-kdb/kdb_samba.c                    |   2 +-
 source4/kdc/mit-kdb/kdb_samba.h                    |  21 +
 source4/kdc/mit-kdb/kdb_samba_policies.c           |  40 +-
 source4/torture/smb2/read_write.c                  | 189 +++++
 source4/torture/smb2/sharemode.c                   | 114 +++
 source4/torture/smb2/smb2.c                        |   1 +
 source4/torture/smb2/timestamps.c                  | 775 ++++++++++++++++++++-
 testprogs/blackbox/test_kinit_mit.sh               |   4 -
 testprogs/blackbox/test_net_ads.sh                 |  17 +
 wscript_configure_system_mitkrb5                   |   3 +
 77 files changed, 4016 insertions(+), 529 deletions(-)
 copy lib/ldb/ABI/{ldb-2.0.5.sigs => ldb-2.1.3.sigs} (100%)
 copy lib/ldb/ABI/{pyldb-util-2.1.0.sigs => pyldb-util-2.1.3.sigs} (100%)
 create mode 100644 lib/ldb/tests/ldb_lmdb_free_list_test.c
 create mode 100644 selftest/knownfail.d/rw-invalid
 rename selftest/{knownfail.d/kinit_mit => knownfail_mit_krb5_pre_1_18} (100%)
 copy source3/{rpc_server/rpc_contexts.c => modules/test_vfs_full_audit.c} (52%)
 create mode 100755 source3/script/tests/test_force_close_share.sh
 create mode 100755 source3/script/tests/test_smbclient_log_basename.sh


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index a8cdfb7be6b..d0d38128b21 100644
--- a/VERSION
+++ b/VERSION
@@ -25,7 +25,7 @@
 ########################################################
 SAMBA_VERSION_MAJOR=4
 SAMBA_VERSION_MINOR=12
-SAMBA_VERSION_RELEASE=2
+SAMBA_VERSION_RELEASE=3
 
 ########################################################
 # If a official release has a serious bug              #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 57498cdc8ed..389bab85d38 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,3 +1,88 @@
+                   ==============================
+                   Release Notes for Samba 4.12.3
+                            May 19, 2020
+		   ==============================
+
+
+This is the latest stable release of the Samba 4.12 release series.
+
+
+Changes since 4.12.2
+--------------------
+
+o  Jeremy Allison <jra at samba.org>
+   * BUG 14301: Fix smbd panic on force-close share during async io.
+   * BUG 14343: s3: vfs_full_audit: Add missing fcntl entry in vfs_op_names[]
+     array.
+   * BUG 14361: vfs_io_uring: Fix data corruption with Windows clients.
+   * BUG 14372: Fix smbd crashes when MacOS Catalina connects if iconv
+     initialization fails.
+
+o  Ralph Boehme <slow at samba.org>
+   * BUG 14150: Exporting from macOS Adobe Illustrator creates multiple copies.
+   * BUG 14256: smbd does a chdir() twice per request.
+   * BUG 14320: smbd mistakenly updates a file's write-time on close.
+   * BUG 14350: vfs_shadow_copy2: implement case canonicalisation in
+     shadow_copy2_get_real_filename().
+   * BUG 14375: Fix Windows 7 clients problem after upgrading samba file server.
+
+o  Alexander Bokovoy <ab at samba.org>
+   * BUG 14359: s3: Pass DCE RPC handle type to create_policy_hnd.
+
+o  Isaac Boukris <iboukris at gmail.com>
+   * BUG 14155: Fix uxsuccess test with new MIT krb5 library 1.18.
+   * BUG 14342: mit-kdc: Explicitly reject S4U requests.
+
+o  Anoop C S <anoopcs at redhat.com>
+   * BUG 14352: dbwrap_watch: Set rec->value_valid while returning nested
+     share_mode_do_locked().
+
+o  Amit Kumar <amitkuma at redhat.com>
+   * BUG 14345: lib:util: Fix smbclient -l basename dir.
+
+o  Volker Lendecke <vl at samba.org>
+   * BUG 14336: s3:libads: Fix ads_get_upn().
+   * BUG 14348: ctdb: Fix a memleak.
+   * BUG 14366: Malicous SMB1 server can crash libsmbclient.
+
+o  Gary Lockyer <gary at catalyst.net.nz>
+   * BUG 14330: ldb: Bump version to 2.1.3, LMDB databases can grow without
+     bounds
+
+o  Stefan Metzmacher <metze at samba.org>
+   * BUG 14361: vfs_io_uring: Fix data corruption with Windows clients.
+
+o  Noel Power <noel.power at suse.com>
+   * BUG 14344: s3/librpc/crypto: Fix double free with unresolved credential
+     cache.
+
+o  Andreas Schneider <asn at samba.org>
+   * BUG 14358: docs-xml: Fix usernames in pam_winbind manpages.
+
+
+#######################################
+Reporting bugs & Development Discussion
+#######################################
+
+Please discuss this release on the samba-technical mailing list or by
+joining the #samba-technical IRC channel on irc.freenode.net.
+
+If you do report problems then please try to send high quality
+feedback. If you don't provide vital information to help us track down
+the problem then you will probably be ignored.  All bug reports should
+be filed under the Samba 4.1 and newer product in the project's Bugzilla
+database (https://bugzilla.samba.org/).
+
+
+======================================================================
+== Our Code, Our Bugs, Our Responsibility.
+== The Samba Team
+======================================================================
+
+
+Release notes for older releases follow:
+----------------------------------------
+
                    ==============================
                    Release Notes for Samba 4.12.2
                            April 28, 2020
@@ -56,8 +141,8 @@ database (https://bugzilla.samba.org/).
 ======================================================================
 
 
-Release notes for older releases follow:
-----------------------------------------
+----------------------------------------------------------------------
+
 
                    ==============================
                    Release Notes for Samba 4.12.1
@@ -89,7 +174,7 @@ o  Ralph Boehme <slow at samba.org>
 
 o  Günther Deschner <gd at samba.org>
    * BUG 14313: librpc: Fix IDL for svcctl_ChangeServiceConfigW.
-   * BUG 14327: nsswitch: Fix use-after-free causing segfault in 
+   * BUG 14327: nsswitch: Fix use-after-free causing segfault in
      _pam_delete_cred.
 
 o  Art M. Gallagher <repos at artmg.net>
@@ -100,7 +185,7 @@ o  Amitay Isaacs <amitay at gmail.com>
      node banning.
 
 o  Noel Power <noel.power at suse.com>
-   * BUG 14332: s3/utils: Fix double free error with smbtree. 
+   * BUG 14332: s3/utils: Fix double free error with smbtree.
 
 o  Martin Schwenke <martin at meltin.net>
    * BUG 14294: CTDB recovery corner cases can cause record resurrection and
@@ -418,7 +503,7 @@ o  Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    * BUG 14284: pidl/wscript: configure should insist on Parse::Yapp::Driver.
 
 o  Andrew Bartlett <abartlet at samba.org>
-   * BUG 14270: ldb: Fix search with scope ONE and small result sets. 
+   * BUG 14270: ldb: Fix search with scope ONE and small result sets.
    * BUG 14284: build: Do not check if system perl modules should be bundled.
 
 o  Volker Lendecke <vl at samba.org>
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index ee083e92fb1..3f5d43c1e87 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -2078,6 +2078,7 @@ static int verify_local_ip_allocation(struct ctdb_context *ctdb,
 	/* Return early if disabled... */
 	if (ctdb_config.failover_disabled ||
 	    ctdb_op_is_disabled(rec->takeover_run)) {
+		talloc_free(mem_ctx);
 		return  0;
 	}
 
diff --git a/docs-xml/manpages/pam_winbind.8.xml b/docs-xml/manpages/pam_winbind.8.xml
index 003020d8b7c..622e9e188d9 100644
--- a/docs-xml/manpages/pam_winbind.8.xml
+++ b/docs-xml/manpages/pam_winbind.8.xml
@@ -83,8 +83,8 @@
 		<listitem><para>
 		If this option is set, pam_winbind will only succeed if the user is a member of the given SID or NAME. A SID
 		can be either a group-SID, an alias-SID or even an user-SID. It is also possible to give a NAME instead of the
-		SID. That name must have the form: <parameter>MYDOMAIN\\mygroup</parameter> or
-		<parameter>MYDOMAIN\\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
+		SID. That name must have the form: <parameter>MYDOMAIN\mygroup</parameter> or
+		<parameter>MYDOMAIN\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
 		NAME may not contain any spaces. It is thus recommended to only use SIDs. You can verify the list of SIDs a
 		user is a member of with <command>wbinfo --user-sids=SID</command>.
 		</para>
diff --git a/docs-xml/manpages/pam_winbind.conf.5.xml b/docs-xml/manpages/pam_winbind.conf.5.xml
index 918450c4643..c4a7771fb31 100644
--- a/docs-xml/manpages/pam_winbind.conf.5.xml
+++ b/docs-xml/manpages/pam_winbind.conf.5.xml
@@ -68,8 +68,8 @@
 		<listitem><para>
 		If this option is set, pam_winbind will only succeed if the user is a member of the given SID or NAME. A SID
 		can be either a group-SID, an alias-SID or even an user-SID. It is also possible to give a NAME instead of the
-		SID. That name must have the form: <parameter>MYDOMAIN\\mygroup</parameter> or
-		<parameter>MYDOMAIN\\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
+		SID. That name must have the form: <parameter>MYDOMAIN\mygroup</parameter> or
+		<parameter>MYDOMAIN\myuser</parameter>.  pam_winbind will, in that case, lookup the SID internally. Note that
 		NAME may not contain any spaces. It is thus recommended to only use SIDs. You can verify the list of SIDs a
 		user is a member of with <command>wbinfo --user-sids=SID</command>. This setting is empty by default.
 		</para>
diff --git a/lib/ldb/ABI/ldb-2.0.5.sigs b/lib/ldb/ABI/ldb-2.1.3.sigs
similarity index 100%
copy from lib/ldb/ABI/ldb-2.0.5.sigs
copy to lib/ldb/ABI/ldb-2.1.3.sigs
diff --git a/lib/ldb/ABI/pyldb-util-2.1.0.sigs b/lib/ldb/ABI/pyldb-util-2.1.3.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-2.1.0.sigs
copy to lib/ldb/ABI/pyldb-util-2.1.3.sigs
diff --git a/lib/ldb/ldb_mdb/ldb_mdb.c b/lib/ldb/ldb_mdb/ldb_mdb.c
index 6c679c214b8..f0a418d07ee 100644
--- a/lib/ldb/ldb_mdb/ldb_mdb.c
+++ b/lib/ldb/ldb_mdb/ldb_mdb.c
@@ -641,6 +641,23 @@ static int lmdb_transaction_start(struct ldb_kv_private *ldb_kv)
 		return LDB_ERR_PROTOCOL_ERROR;
 	}
 
+	/*
+	 * Clear out any stale readers
+	 */
+	{
+		int stale = 0;
+		mdb_reader_check(lmdb->env, &stale);
+		if (stale > 0) {
+			ldb_debug(
+				lmdb->ldb,
+				LDB_DEBUG_ERROR,
+				"LMDB Stale readers, deleted (%d)",
+				stale);
+		}
+	}
+
+
+
 	ltx_head = lmdb_private_trans_head(lmdb);
 
 	tx_parent = lmdb_trans_get_tx(ltx_head);
diff --git a/lib/ldb/tests/ldb_lmdb_free_list_test.c b/lib/ldb/tests/ldb_lmdb_free_list_test.c
new file mode 100644
index 00000000000..9b295460730
--- /dev/null
+++ b/lib/ldb/tests/ldb_lmdb_free_list_test.c
@@ -0,0 +1,661 @@
+/*
+ * Copyright (C) Catalyst.Net Ltd 2020
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/*
+ * Tests confirming lmdb's handling of the free space list in the presence
+ * of active and stale readers.  A stale reader is a process that opens a
+ * read lock and then exits without releasing the lock.
+ *
+ * lmdb uses MVCC to maintain databased consistency, new copies of updated
+ * records are written to the database. The old entries are only
+ * reused when they are no longer referenced in a read transaction.
+ *
+ * The tests all update a single record multiple times
+ *
+ * If there is a read transaction or a stale reader lmdb will report
+ * out of space.
+ *
+ * If no read transaction and no stale reader, lmdb reclaims space from the
+ * free list.
+ */
+
+/*
+ * from cmocka.c:
+ * These headers or their equivalents should be included prior to
+ * including
+ * this header file.
+ *
+ * #include <stdarg.h>
+ * #include <stddef.h>
+ * #include <setjmp.h>
+ *
+ * This allows test applications to use custom definitions of C standard
+ * library functions and types.
+ *
+ */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <talloc.h>
+#include <tevent.h>
+#include <ldb.h>
+#include <ldb_module.h>
+#include <ldb_private.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <sys/wait.h>
+
+#include "ldb_tdb/ldb_tdb.h"
+#include "ldb_key_value/ldb_kv.h"
+
+#define DEFAULT_BE "mdb"
+
+#ifndef TEST_BE
+#define TEST_BE DEFAULT_BE
+#endif /* TEST_BE */
+
+const int RECORD_SIZE = 6144;
+const int ITERATIONS = 3;
+
+struct test_ctx {
+	struct tevent_context *ev;
+	struct ldb_context *ldb;
+
+	const char *dbfile;
+	const char *lockfile; /* lockfile is separate */
+
+	const char *dbpath;
+};
+
+static void unlink_old_db(struct test_ctx *test_ctx)
+{
+	int ret;
+
+	errno = 0;
+	ret = unlink(test_ctx->lockfile);
+	if (ret == -1 && errno != ENOENT) {
+		fail();
+	}
+
+	errno = 0;
+	ret = unlink(test_ctx->dbfile);
+	if (ret == -1 && errno != ENOENT) {
+		fail();
+	}
+}
+
+static int noconn_setup(void **state)
+{
+	struct test_ctx *test_ctx;
+
+	test_ctx = talloc_zero(NULL, struct test_ctx);
+	assert_non_null(test_ctx);
+
+	test_ctx->ev = tevent_context_init(test_ctx);
+	assert_non_null(test_ctx->ev);
+
+	test_ctx->ldb = ldb_init(test_ctx, test_ctx->ev);
+	assert_non_null(test_ctx->ldb);
+
+	test_ctx->dbfile = talloc_strdup(test_ctx, "lmdb_free_list_test.ldb");
+	assert_non_null(test_ctx->dbfile);
+
+	test_ctx->lockfile =
+	    talloc_asprintf(test_ctx, "%s-lock", test_ctx->dbfile);
+	assert_non_null(test_ctx->lockfile);
+
+	test_ctx->dbpath =
+	    talloc_asprintf(test_ctx, TEST_BE "://%s", test_ctx->dbfile);
+	assert_non_null(test_ctx->dbpath);
+
+	unlink_old_db(test_ctx);
+	*state = test_ctx;
+	return 0;
+}
+
+static int noconn_teardown(void **state)
+{
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+
+	unlink_old_db(test_ctx);
+	talloc_free(test_ctx);
+	return 0;
+}
+
+static int setup(void **state)
+{
+	struct test_ctx *test_ctx;
+	int ret;
+	struct ldb_ldif *ldif;
+	const char *index_ldif = "dn: @INDEXLIST\n"
+				 "@IDXGUID: objectUUID\n"
+				 "@IDX_DN_GUID: GUID\n"
+				 "\n";
+	/*
+	 * Use a 64KiB DB for this test
+	 */
+	const char *options[] = {"lmdb_env_size:65536", NULL};
+
+	noconn_setup((void **)&test_ctx);
+
+	ret = ldb_connect(test_ctx->ldb, test_ctx->dbpath, 0, options);
+	assert_int_equal(ret, 0);
+
+	while ((ldif = ldb_ldif_read_string(test_ctx->ldb, &index_ldif))) {
+		ret = ldb_add(test_ctx->ldb, ldif->msg);
+		assert_int_equal(ret, LDB_SUCCESS);
+	}
+	*state = test_ctx;
+	return 0;
+}
+
+static int teardown(void **state)
+{
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+	noconn_teardown((void **)&test_ctx);
+	return 0;
+}
+
+static struct ldb_kv_private *get_ldb_kv(struct ldb_context *ldb)
+{
+	void *data = NULL;
+	struct ldb_kv_private *ldb_kv = NULL;
+
+	data = ldb_module_get_private(ldb->modules);
+	assert_non_null(data);
+
+	ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+	assert_non_null(ldb_kv);
+
+	return ldb_kv;
+}
+
+static int parse(struct ldb_val key, struct ldb_val data, void *private_data)
+{
+	struct ldb_val *read = private_data;
+
+	/* Yes, we leak this.  That is OK */
+	read->data = talloc_size(NULL, data.length);
+	assert_non_null(read->data);
+
+	memcpy(read->data, data.data, data.length);
+	read->length = data.length;
+	return LDB_SUCCESS;
+}
+
+/*
+ * This test has the same structure as the test_free_list_read_lock
+ * except the parent process does not keep the read lock open while the
+ * child process is performing an update.
+ */
+static void test_free_list_no_read_lock(void **state)
+{
+	int ret;
+	struct test_ctx *test_ctx =
+	    talloc_get_type_abort(*state, struct test_ctx);
+	struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb);
+	struct ldb_val key;
+	struct ldb_val val;
+
+	const char *KEY1 = "KEY01";
+
+	/*
+	 * Pipes etc to co-ordinate the processes
+	 */
+	int to_child[2];
+	int to_parent[2];
+	char buf[2];
+	pid_t pid;
+	size_t i;
+
+	TALLOC_CTX *tmp_ctx;
+	tmp_ctx = talloc_new(test_ctx);
+	assert_non_null(tmp_ctx);
+
+	ret = pipe(to_child);
+	assert_int_equal(ret, 0);
+	ret = pipe(to_parent);
+	assert_int_equal(ret, 0);
+	/*
+	 * Now fork a new process
+	 */
+
+	pid = fork();
+	if (pid == 0) {
+		/*
+		 * Child process
+		 */
+
+		struct ldb_context *ldb = NULL;
+		close(to_child[1]);
+		close(to_parent[0]);
+
+		/*
+		 * Wait for the parent to get ready.
+		 */
+		ret = read(to_child[0], buf, 2);
+		assert_int_equal(ret, 2);
+
+		ldb = ldb_init(test_ctx, test_ctx->ev);
+		assert_non_null(ldb);
+
+		ret = ldb_connect(ldb, test_ctx->dbpath, 0, NULL);
+		assert_int_equal(ret, LDB_SUCCESS);
+
+		ldb_kv = get_ldb_kv(ldb);
+		assert_non_null(ldb_kv);
+		/*
+		 * Add a record to the database


-- 
Samba Shared Repository



More information about the samba-cvs mailing list