[SCM] Samba Shared Repository - branch v4-10-test updated

Karolin Seeger kseeger at samba.org
Mon Mar 11 11:51:03 UTC 2019


The branch, v4-10-test has been updated
       via  5c2a243d3e7 CI: don't use swap
       via  7bd135d25d6 s4/scripting/bin: open unicode files with utf8 encoding and write unicode string
       via  5d0e2bf8190 libcli/security: fix handling of deny type ACEs in access_check_max_allowed()
       via  cc7629a20e9 s4:torture: Add test_deny1().
       via  c9b6b7ed4be s4:torture: Add test_owner_rights_deny1().
       via  1dc2e296f17 libcli/security: correct access check and maximum access calculation for Owner Rights ACEs
       via  3026c1a36c3 s4:torture: Add test_owner_rights_deny().
       via  63f0db77204 s4:torture: Fix the test_owner_rights() test to show permissions are additive.
       via  7e95499d39a libcli/security: add "Owner Rights" calculation to access_check_max_allowed()
       via  ac08949dcdf s4:torture: add a Maximum Access check with an Owner Rights ACE
       via  3b52cba505a s4:libcli: remember return code from maximum access
       via  49bac77e789 autobuild: Add -py2 tests for new split backup/restore testenvs
       via  9f85efa76d3 autobuild: Split backup/restore testenvs out into separate job
       via  ea33a7b0911 sambaundoguididx: use the right escaped oder unescaped sam ldb files
       via  2f4d8214601 s4-server: Open and close a transaction on sam.ldb at startup
      from  0e80b245bf4 WHATSNEW: mention new vfs_glusterfs_fuse module

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


- Log -----------------------------------------------------------------
commit 5c2a243d3e74c2c7c82e2ae63010f59f77757aea
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 3 22:09:26 2019 +0100

    CI: don't use swap
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Mon Mar  4 13:59:42 UTC 2019 on sn-devel-144
    
    (adapted from from commit 7798bc14fbdae3461eb30421923d53978b3f781d
    by Andrew Bartlett)
    
    Autobuild-User(v4-10-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-10-test): Mon Mar 11 11:50:37 UTC 2019 on sn-devel-144

commit 7bd135d25d67c96b92f732bee1d4acad67db241c
Author: Joe Guo <joeg at catalyst.net.nz>
Date:   Wed Jan 30 15:52:08 2019 +1300

    s4/scripting/bin: open unicode files with utf8 encoding and write unicode string
    
    In files like `libcli/util/werror_err_table.txt` and `libcli/util/ntstatus_err_table.txt`,
    there were unicode quote symbols at line 6:
    
        ...(“this documentation”)...
    
    In `libcli/util/wscript_build`, it will run `gen_werror.py` and `gen_ntstatus.py`
    to `open` above files, read content from them and write to other files.
    
    When encoding not specified, `open` in both python 2/3 will guess encoding from locale.
    
    When locale is not set, it defaults to POSIX or C, and then python will use
    encoding `ANSI_X3.4-1968`.
    
    So, on a system locale is not set, `make` will fail with encoding error
    for both python 2 and 3:
    
        File "/home/ubuntu/samba/source4/scripting/bin/gen_werror.py", line 139, in main
            errors = parseErrorDescriptions(input_file, True, transformErrorName)
          File "/home/ubuntu/samba/source4/scripting/bin/gen_error_common.py", line 52, in parseErrorDescriptions
            for line in file_contents:
          File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
            return codecs.ascii_decode(input, self.errors)[0]
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 318: ordinal not in range(128)
    
    In this case, we have to use `io.open` with `encoding='utf8'`.
    However, then we got unicode strs and try to write them with other strs
    into new file, which means the new file must also open with utf-8 and
    all other strs have to be unicode, too.
    
    Instead of prefix `u` to all strs, a more easier/elegant way is to enable
    unicode literals for the python scripts, which we normally didn't do in samba.
    
    Since both `gen_werror.py` and `gen_ntstatus.py` are bin scripts and no
    other modules import them, it should be ok for this case.
    
    Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
    
    Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
    Autobuild-Date(master): Fri Feb  8 06:34:47 CET 2019 on sn-devel-144
    
    (cherry picked from commit 87149445af26b8577566dfe5e311b32e3650c6e6)

commit 5d0e2bf81901013f4052094bca180717a5213f16
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Mar 1 18:57:23 2019 +0100

    libcli/security: fix handling of deny type ACEs in access_check_max_allowed()
    
    Deny ACEs must always be evaluated against explicitly granted rights
    from previous ACEs.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 8d355dd9769e8990ce998b4c9f28977669b43616)

commit cc7629a20e93408f79a8522f2c482c7258afc18c
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 3 08:33:51 2019 +0100

    s4:torture: Add test_deny1().
    
    Creates a 2-element ALLOW + DENY ACE showing that when calculating
    effective permissions and maximum access already seen allow bits are not
    removed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b205d695d769e910a91bec87451dec189ec33740)

commit c9b6b7ed4be46d7b63947a6bbcef1ab72b6bdd68
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 28 14:59:01 2019 -0800

    s4:torture: Add test_owner_rights_deny1().
    
    Creates a 3-element ALLOW + ALLOW + DENY ACE showing that when
    calculating maximum access already seen allow bits are not removed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 0ebd8c99aed28a0ba43a22c429837f66f7e94409)

commit 1dc2e296f1749c3efff8b2e779b0c5e0f50cef34
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Mar 1 18:20:35 2019 +0100

    libcli/security: correct access check and maximum access calculation for Owner Rights ACEs
    
    We basically must process the Owner Rights ACEs as any other ACE wrt to the
    order of adding granted permissions and checking denied permissions. According
    to MS-DTYP 2.5.3.2 Owner Rights ACEs must be evaluated in the main loop over
    the ACEs in an ACL and the corresponding access_mask must be directly applied
    to bits_remaining. We currently defer this to after the loop over the ACEs in
    ACL, this is wrong.
    
    We just have to do some initial magic to determine if an ACL contains and
    Owner Rights ACEs, and in case it doesn't we grant SEC_STD_WRITE_DAC |
    SEC_STD_READ_CONTROL at the *beginning*. MS-DTYP:
    
    -- the owner of an object is always granted READ_CONTROL and WRITE_DAC.
    CALL SidInToken(Token, SecurityDescriptor.Owner, PrincipalSelfSubst)
    IF SidInToken returns True THEN
       IF DACL does not contain ACEs from object owner THEN
           Remove READ_CONTROL and WRITE_DAC from RemainingAccess
           Set GrantedAccess to GrantedAccess or READ_CONTROL or WRITE_OWNER
       END IF
    END IF
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9722f75757c0e38c7f42c7cc310d56aa6eaf6392)

commit 3026c1a36c310ab9759a9700fb023e439dd6b335
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 28 14:37:09 2019 -0800

    s4:torture: Add test_owner_rights_deny().
    
    Shows that owner and SID_OWNER_RIGHTS ACE
    entries interact in max permissions requests.
    
    Tested against Windows.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit fadc4c1bc5fcc3b2d9daea44ef8daf8a8ae0fbe2)

commit 63f0db772044862f3fe4fec08de6b888f4865501
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 28 13:55:31 2019 -0800

    s4:torture: Fix the test_owner_rights() test to show permissions are additive.
    
    Tested against Windows.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 2e181e34c48c879235c5dc64bd7ab2b59781810c)

commit 7e95499d39a5ed69bb9cea6bbf61897eb11c71c1
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Feb 27 18:07:03 2019 +0100

    libcli/security: add "Owner Rights" calculation to access_check_max_allowed()
    
    This was missing in 44590c1b70c0a24f853c02d5fcdb3c609401e2ca.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Thu Feb 28 19:18:16 UTC 2019 on sn-devel-144
    
    (cherry picked from commit 5cf0764bc4b65dbc59d8626760dbe946a2234833)

commit ac08949dcdf37645fdb736e17179a20f04c41a39
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 28 14:48:02 2019 +0100

    s4:torture: add a Maximum Access check with an Owner Rights ACE
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit 3ca38d2cd1189a5040e13ddab016063280be2b4d)

commit 3b52cba505ac494f64a6b17f7e98abfeca717a80
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 28 14:47:18 2019 +0100

    s4:libcli: remember return code from maximum access
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13812
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit 9f4ee05295827c9a607e1f63694a17906f777176)

commit 49bac77e78988bf23c21fe54fe311c92180e4a72
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Mar 11 14:20:55 2019 +1300

    autobuild: Add -py2 tests for new split backup/restore testenvs
    
    This ensures Python2 coverage for this code while it remains supported.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13780
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 9f85efa76d3bb781fccd72f59c273c6800396206
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Tue Feb 5 15:17:03 2019 +1300

    autobuild: Split backup/restore testenvs out into separate job
    
    The samba-ad-dc-2 job was reaching its limits with the number of
    testenvs and what the resource-limited CI machines can handle.
    Samba processes were getting swapped out of memory, causing CI runs
    to fail.
    
    This patch splits the backup/restore testenv targets into a separate
    autobuild job: samba-ad-dc-backup.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13780
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Tue Feb  5 12:23:31 CET 2019 on sn-devel-144
    
    (cherry picked from commit 95b2c9d7751ae1e5a00e1fb096f045dd73c03d72)

commit ea33a7b091132f0cf9b1e21464728d2dc1dab99b
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Jan 23 14:01:26 2019 +0100

    sambaundoguididx: use the right escaped oder unescaped sam ldb files
    
    the correct filename is taken from the partition database before, we should not
    unescape that because this can result in a new unescaped ldb file being created
    and the script not to work at all.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13759
    
    Signed-off-by: Bjoern Jacke <bjacke at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit cd1ac3668cd164bd5f7cadf7b59df9541aaef83e)

commit 2f4d82146018a6bed6ea447e023fe1949208bbe2
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Mar 5 01:38:41 2019 +0000

    s4-server: Open and close a transaction on sam.ldb at startup
    
    This fixes upgrading from 4.7 and earlier releases, and makes the DB
    reindexing more transparent. It should also make it easier to handle
    future normalisation rule changes, e.g. if we change the pack-format
    of integer indexes in a future release.
    
    Without this change, the  should have still handled reindexing the
    database. We don't know why exactly this wasn't happening correctly,
    but opening a transaction early in the samba process startup should
    now guarantee that the DB is correctly reindexed by the time the main
    samba code runs.
    
    An alternative fix would have been to open a transaction in the the
    DSDB module stack every time we connect to the database. However, this
    would add an extra write lock every time we open the DB, whereas
    starting samba happens much more infrequently.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13760
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Mar  7 04:58:42 UTC 2019 on sn-devel-144
    
    (cherry picked from commit 8b18da27cf261b0283fe66d2b827cab542488ac7)

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

Summary of changes:
 .gitlab-ci.yml                         |  17 +-
 libcli/security/access_check.c         | 127 +++++---
 script/autobuild.py                    |  13 +
 source4/libcli/raw/interfaces.h        |   1 +
 source4/libcli/smb2/create.c           |   4 +-
 source4/scripting/bin/gen_ntstatus.py  |  11 +-
 source4/scripting/bin/gen_werror.py    |  11 +-
 source4/scripting/bin/sambaundoguididx |   3 +-
 source4/smbd/server.c                  |  42 +++
 source4/torture/smb2/acls.c            | 558 +++++++++++++++++++++++++++++++++
 10 files changed, 720 insertions(+), 67 deletions(-)


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 04d57cb0491..4249f5296b3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,12 +7,7 @@ variables:
   GIT_DEPTH: "3"
 
 before_script:
-  - echo "Build starting (preparing swap)..."
-  - if [ $(df -m / --output=avail | tail -n1) -gt 10240 ]; then
-      sudo dd if=/dev/zero of=/samba-swap bs=1M count=6144;
-      sudo mkswap /samba-swap;
-      sudo swapon /samba-swap;
-    fi
+  - echo "Build starting..."
 
 after_script:
   - tar -xf logs.tar.gz system-info.txt -O
@@ -61,6 +56,16 @@ build_samba_ad_dc_2:
     # this one takes about 1 hours to finish
     - script/autobuild.py samba-ad-dc-2     --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase
 
+build_samba_ad_dc_backup:
+  <<: *shared_template
+  script:
+    - script/autobuild.py samba-ad-dc-backup    --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase
+
+build_samba_ad_dc_backup_py2:
+  <<: *shared_template
+  script:
+    - script/autobuild.py samba-ad-dc-backup-py2    --verbose --nocleanup --keeplogs --tail --testbase /tmp/samba-testbase
+
 build_samba_ad_dc_2_py2:
   <<: *shared_template
   script:
diff --git a/libcli/security/access_check.c b/libcli/security/access_check.c
index 03a7dca4adf..322f4fdb0c6 100644
--- a/libcli/security/access_check.c
+++ b/libcli/security/access_check.c
@@ -109,24 +109,61 @@ static uint32_t access_check_max_allowed(const struct security_descriptor *sd,
 					const struct security_token *token)
 {
 	uint32_t denied = 0, granted = 0;
+	bool am_owner = false;
+	bool have_owner_rights_ace = false;
 	unsigned i;
 
+	if (sd->dacl == NULL) {
+		if (security_token_has_sid(token, sd->owner_sid)) {
+			granted |= SEC_STD_WRITE_DAC | SEC_STD_READ_CONTROL;
+		}
+		return granted;
+	}
+
 	if (security_token_has_sid(token, sd->owner_sid)) {
-		granted |= SEC_STD_WRITE_DAC | SEC_STD_READ_CONTROL;
+		/*
+		 * Check for explicit owner rights: if there are none, we remove
+		 * the default owner right SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL
+		 * from remaining_access. Otherwise we just process the
+		 * explicitly granted rights when processing the ACEs.
+		 */
+		am_owner = true;
+
+		for (i=0; i < sd->dacl->num_aces; i++) {
+			struct security_ace *ace = &sd->dacl->aces[i];
+
+			if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
+				continue;
+			}
+
+			have_owner_rights_ace = dom_sid_equal(
+				&ace->trustee, &global_sid_Owner_Rights);
+			if (have_owner_rights_ace) {
+				break;
+			}
+		}
 	}
 
-	if (sd->dacl == NULL) {
-		return granted & ~denied;
+	if (am_owner && !have_owner_rights_ace) {
+		granted |= SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL;
 	}
 
 	for (i = 0;i<sd->dacl->num_aces; i++) {
 		struct security_ace *ace = &sd->dacl->aces[i];
+		bool is_owner_rights_ace = false;
 
 		if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
 			continue;
 		}
 
-		if (!security_token_has_sid(token, &ace->trustee)) {
+		if (am_owner) {
+			is_owner_rights_ace = dom_sid_equal(
+				&ace->trustee, &global_sid_Owner_Rights);
+		}
+
+		if (!is_owner_rights_ace &&
+		    !security_token_has_sid(token, &ace->trustee))
+		{
 			continue;
 		}
 
@@ -136,7 +173,7 @@ static uint32_t access_check_max_allowed(const struct security_descriptor *sd,
 			break;
 		case SEC_ACE_TYPE_ACCESS_DENIED:
 		case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
-			denied |= ace->access_mask;
+			denied |= ~granted & ace->access_mask;
 			break;
 		default:	/* Other ACE types not handled/supported */
 			break;
@@ -159,16 +196,8 @@ NTSTATUS se_access_check(const struct security_descriptor *sd,
 	uint32_t i;
 	uint32_t bits_remaining;
 	uint32_t explicitly_denied_bits = 0;
-	/*
-	 * Up until Windows Server 2008, owner always had these rights. Now
-	 * we have to use Owner Rights perms if they are on the file.
-	 *
-	 * In addition we have to accumulate these bits and apply them
-	 * correctly. See bug #8795
-	 */
-	uint32_t owner_rights_allowed = 0;
-	uint32_t owner_rights_denied = 0;
-	bool owner_rights_default = true;
+	bool am_owner = false;
+	bool have_owner_rights_ace = false;
 
 	*access_granted = access_desired;
 	bits_remaining = access_desired;
@@ -198,35 +227,50 @@ NTSTATUS se_access_check(const struct security_descriptor *sd,
 		goto done;
 	}
 
+	if (security_token_has_sid(token, sd->owner_sid)) {
+		/*
+		 * Check for explicit owner rights: if there are none, we remove
+		 * the default owner right SEC_STD_WRITE_DAC|SEC_STD_READ_CONTROL
+		 * from remaining_access. Otherwise we just process the
+		 * explicitly granted rights when processing the ACEs.
+		 */
+		am_owner = true;
+
+		for (i=0; i < sd->dacl->num_aces; i++) {
+			struct security_ace *ace = &sd->dacl->aces[i];
+
+			if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
+				continue;
+			}
+
+			have_owner_rights_ace = dom_sid_equal(
+				&ace->trustee, &global_sid_Owner_Rights);
+			if (have_owner_rights_ace) {
+				break;
+			}
+		}
+	}
+	if (am_owner && !have_owner_rights_ace) {
+		bits_remaining &= ~(SEC_STD_WRITE_DAC | SEC_STD_READ_CONTROL);
+	}
+
 	/* check each ace in turn. */
 	for (i=0; bits_remaining && i < sd->dacl->num_aces; i++) {
 		struct security_ace *ace = &sd->dacl->aces[i];
+		bool is_owner_rights_ace = false;
 
 		if (ace->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
 			continue;
 		}
 
-		/*
-		 * We need the Owner Rights permissions to ensure we
-		 * give or deny the correct permissions to the owner. Replace
-		 * owner_rights with the perms here if it is present.
-		 *
-		 * We don't care if we are not the owner because that is taken
-		 * care of below when we check if our token has the owner SID.
-		 *
-		 */
-		if (dom_sid_equal(&ace->trustee, &global_sid_Owner_Rights)) {
-			if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED) {
-				owner_rights_allowed |= ace->access_mask;
-				owner_rights_default = false;
-			} else if (ace->type == SEC_ACE_TYPE_ACCESS_DENIED) {
-				owner_rights_denied |= (bits_remaining & ace->access_mask);
-				owner_rights_default = false;
-			}
-			continue;
+		if (am_owner) {
+			is_owner_rights_ace = dom_sid_equal(
+				&ace->trustee, &global_sid_Owner_Rights);
 		}
 
-		if (!security_token_has_sid(token, &ace->trustee)) {
+		if (!is_owner_rights_ace &&
+		    !security_token_has_sid(token, &ace->trustee))
+		{
 			continue;
 		}
 
@@ -246,21 +290,6 @@ NTSTATUS se_access_check(const struct security_descriptor *sd,
 	/* Explicitly denied bits always override */
 	bits_remaining |= explicitly_denied_bits;
 
-	/* The owner always gets owner rights as defined above. */
-	if (security_token_has_sid(token, sd->owner_sid)) {
-		if (owner_rights_default) {
-			/*
-			 * Just remove them, no need to check if they are
-			 * there.
-			 */
-			bits_remaining &= ~(SEC_STD_WRITE_DAC |
-						SEC_STD_READ_CONTROL);
-		} else {
-			bits_remaining &= ~owner_rights_allowed;
-			bits_remaining |= owner_rights_denied;
-		}
-	}
-
 	/*
 	 * We check privileges here because they override even DENY entries.
 	 */
diff --git a/script/autobuild.py b/script/autobuild.py
index 2ea9e55b932..67c18a1aa35 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -51,6 +51,8 @@ builddirs = {
     "samba-ad-dc-py2": ".",
     "samba-ad-dc-2": ".",
     "samba-ad-dc-2-py2": ".",
+    "samba-ad-dc-backup": ".",
+    "samba-ad-dc-backup-py2": ".",
     "samba-systemkrb5": ".",
     "samba-nopython": ".",
     "samba-buildpy2-only": ".",
@@ -166,6 +168,17 @@ tasks = {
                          "--include-env=vampire_2000_dc "
                          "--include-env=fl2000dc "
                          "--include-env=ad_dc_no_nss "
+                         "'",
+                         "text/plain"),
+                        ("check-clean-tree", "script/clean-source-tree.sh", "text/plain")],
+
+    # run the backup/restore testenvs separately as they're fairly standalone
+    # (and CI seems to max out at ~8 different DCs running at once)
+    "samba-ad-dc-backup": [("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
+                        ("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"),
+                        ("make", "make -j", "text/plain"),
+                        ("test", "make test FAIL_IMMEDIATELY=1 "
+                         "TESTS='${PY3_ONLY}"
                          "--include-env=backupfromdc "
                          "--include-env=restoredc "
                          "--include-env=renamedc "
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 732ba1512dc..43a53f834df 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -1779,6 +1779,7 @@ union smb_open {
 			/* uint32_t blob_size; */
 
 			/* optional return values matching tagged values in the call */
+			uint32_t maximal_access_status;
 			uint32_t maximal_access;
 			uint8_t on_disk_id[32];
 			struct smb2_lease lease_response;
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index 550069a6cea..eb0f6a421cd 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -360,12 +360,12 @@ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct
 	/* pull out the parsed blobs */
 	for (i=0;i<io->out.blobs.num_blobs;i++) {
 		if (strcmp(io->out.blobs.blobs[i].tag, SMB2_CREATE_TAG_MXAC) == 0) {
-			/* TODO: this also contains a status field in
-			   first 4 bytes */
 			if (io->out.blobs.blobs[i].data.length != 8) {
 				smb2_request_destroy(req);
 				return NT_STATUS_INVALID_NETWORK_RESPONSE;
 			}
+			io->out.maximal_access_status =
+				IVAL(io->out.blobs.blobs[i].data.data, 0);
 			io->out.maximal_access = IVAL(io->out.blobs.blobs[i].data.data, 4);
 		}
 		if (strcmp(io->out.blobs.blobs[i].tag, SMB2_CREATE_TAG_QFID) == 0) {
diff --git a/source4/scripting/bin/gen_ntstatus.py b/source4/scripting/bin/gen_ntstatus.py
index e0d4fe3b7a1..7691e7bc5d1 100755
--- a/source4/scripting/bin/gen_ntstatus.py
+++ b/source4/scripting/bin/gen_ntstatus.py
@@ -20,6 +20,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+from __future__ import unicode_literals
+# this file is a bin script and was not imported by any other modules
+# so it should be fine to enable unicode string for python2
 
 import sys, os.path, io, string
 from gen_error_common import parseErrorDescriptions, ErrorDef
@@ -134,20 +137,20 @@ def main ():
         sys.exit()
 
     # read in the data
-    file_contents = open(input_file, "r")
+    file_contents = io.open(input_file, "rt", encoding='utf8')
 
     errors = parseErrorDescriptions(file_contents, False, transformErrorName)
 
     print("writing new header file: %s" % gen_headerfile_name)
-    out_file = open(gen_headerfile_name, "w")
+    out_file = io.open(gen_headerfile_name, "wt", encoding='utf8')
     generateHeaderFile(out_file, errors)
     out_file.close()
     print("writing new source file: %s" % gen_sourcefile_name)
-    out_file = open(gen_sourcefile_name, "w")
+    out_file = io.open(gen_sourcefile_name, "wt", encoding='utf8')
     generateSourceFile(out_file, errors)
     out_file.close()
     print("writing new python file: %s" % gen_pythonfile_name)
-    out_file = open(gen_pythonfile_name, "w")
+    out_file = io.open(gen_pythonfile_name, "wt", encoding='utf8')
     generatePythonFile(out_file, errors)
     out_file.close()
 
diff --git a/source4/scripting/bin/gen_werror.py b/source4/scripting/bin/gen_werror.py
index 700ccaf1400..6280d2d3883 100755
--- a/source4/scripting/bin/gen_werror.py
+++ b/source4/scripting/bin/gen_werror.py
@@ -20,6 +20,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+from __future__ import unicode_literals
+# this file is a bin script and was not imported by any other modules
+# so it should be fine to enable unicode string for python2
 
 import sys, os.path, io, string
 from gen_error_common import parseErrorDescriptions, ErrorDef
@@ -135,20 +138,20 @@ def main():
         print("usage: %s winerrorfile headerfile sourcefile pythonfile" % sys.argv[0])
         sys.exit()
 
-    input_file = open(input_file_name, "r")
+    input_file = io.open(input_file_name, "rt", encoding='utf8')
     errors = parseErrorDescriptions(input_file, True, transformErrorName)
     input_file.close()
 
     print("writing new header file: %s" % gen_headerfile_name)
-    out_file = open(gen_headerfile_name, "w")
+    out_file = io.open(gen_headerfile_name, "wt", encoding='utf8')
     generateHeaderFile(out_file, errors)
     out_file.close()
     print("writing new source file: %s" % gen_sourcefile_name)
-    out_file = open(gen_sourcefile_name, "w")
+    out_file = io.open(gen_sourcefile_name, "wt", encoding='utf8')
     generateSourceFile(out_file, errors)
     out_file.close()
     print("writing new python file: %s" % gen_pythonfile_name)
-    out_file = open(gen_pythonfile_name, "w")
+    out_file = io.open(gen_pythonfile_name, "wt", encoding='utf8')
     generatePythonFile(out_file, errors)
     out_file.close()
 
diff --git a/source4/scripting/bin/sambaundoguididx b/source4/scripting/bin/sambaundoguididx
index 008e79805ff..20a84c34618 100755
--- a/source4/scripting/bin/sambaundoguididx
+++ b/source4/scripting/bin/sambaundoguididx
@@ -57,8 +57,7 @@ privatedir = os.path.dirname(url)
 
 dbs = []
 for part in partitions[0]['partition']:
-    file_quoted = part.split(":")[1]
-    tdbname = urllib.unquote(file_quoted)
+    tdbname = part.split(":")[1]
     tdbpath = os.path.join(privatedir, tdbname)
 
     db = ldb.Ldb(url=tdbpath, options=["modules:"])
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index eeb46ffee6a..297da1dac8b 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -230,6 +230,41 @@ _NORETURN_ static void max_runtime_handler(struct tevent_context *ev,
 	exit(0);
 }
 
+/*
+ * When doing an in-place upgrade of Samba, the database format may have
+ * changed between versions. E.g. between 4.7 and 4.8 the DB changed from
+ * DN-based indexes to GUID-based indexes, so we have to re-index the DB after
+ * upgrading.
+ * This function handles migrating an older samba DB to a new Samba release.
+ * Note that we have to maintain DB compatibility between *all* older versions
+ * of Samba, not just the ones still under maintenance support.
+ */
+static int handle_inplace_db_upgrade(struct ldb_context *ldb_ctx)
+{
+	int ret;
+
+	/*
+	 * The DSDB stack will handle reindexing the DB (if needed) upon the first
+	 * DB write. Open and close a transaction on the DB now to trigger a
+	 * reindex if required, rather than waiting for the first write.
+	 * We do this here to guarantee that the DB will have been re-indexed by
+	 * the time the main samba code runs.
+	 * Refer to dsdb_schema_set_indices_and_attributes() for the actual reindexing
+	 * code, called from
+	 * source4/dsdb/samdb/ldb_modules/schema_load.c:schema_load_start_transaction()
+	 */
+	ret = ldb_transaction_start(ldb_ctx);
+	if (ret != LDB_SUCCESS) {
+		return ret;
+	}
+
+	ret = ldb_transaction_commit(ldb_ctx);
+	if (ret != LDB_SUCCESS) {
+		return ret;
+	}
+	return LDB_SUCCESS;
+}
+
 /*
   pre-open the key databases. This saves a lot of time in child
   processes
@@ -262,6 +297,13 @@ static int prime_ldb_databases(struct tevent_context *event_ctx, bool *am_backup
 		talloc_free(db_context);
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
+
+	ret = handle_inplace_db_upgrade(ldb_ctx);
+	if (ret != LDB_SUCCESS) {
+		talloc_free(db_context);
+		return ret;
+	}
+
 	pdb = privilege_connect(db_context, cmdline_lp_ctx);
 	if (pdb == NULL) {
 		talloc_free(db_context);
diff --git a/source4/torture/smb2/acls.c b/source4/torture/smb2/acls.c
index 6178e211034..7bccce803f0 100644
--- a/source4/torture/smb2/acls.c
+++ b/source4/torture/smb2/acls.c
@@ -2363,6 +2363,557 @@ done:
 	return ret;
 }
 
+/*
+ * test Owner Rights, S-1-3-4
+ */
+static bool test_owner_rights(struct torture_context *tctx,
+			      struct smb2_tree *tree)
+{
+	const char *fname = BASEDIR "\\owner_right.txt";
+	struct smb2_create cr;
+	struct smb2_handle handle = {{0}};
+	union smb_fileinfo gi;
+	union smb_setfileinfo si;
+	struct security_descriptor *sd_orig = NULL;
+	struct security_descriptor *sd = NULL;
+	const char *owner_sid = NULL;
+	NTSTATUS mxac_status;
+	NTSTATUS status;
+	bool ret = true;
+
+	smb2_deltree(tree, BASEDIR);
+
+	ret = smb2_util_setup_dir(tctx, tree, BASEDIR);
+	torture_assert_goto(tctx, ret, ret, done,
+			    "smb2_util_setup_dir failed\n");
+
+	torture_comment(tctx, "TESTING OWNER RIGHTS\n");
+
+	cr = (struct smb2_create) {
+		.in.desired_access = SEC_STD_READ_CONTROL |
+			SEC_STD_WRITE_DAC |SEC_STD_WRITE_OWNER,
+		.in.file_attributes = FILE_ATTRIBUTE_NORMAL,
+		.in.share_access = NTCREATEX_SHARE_ACCESS_MASK,
+		.in.create_disposition = NTCREATEX_DISP_OPEN_IF,
+		.in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS,
+		.in.fname = fname,
+	};
+
+	status = smb2_create(tree, tctx, &cr);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+	handle = cr.out.file.handle;
+
+	torture_comment(tctx, "get the original sd\n");
+
+	gi = (union smb_fileinfo) {
+		.query_secdesc.level = RAW_FILEINFO_SEC_DESC,
+		.query_secdesc.in.file.handle = handle,
+		.query_secdesc.in.secinfo_flags = SECINFO_DACL|SECINFO_OWNER,
+	};
+
+	status = smb2_getinfo_file(tree, tctx, &gi);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_getinfo_file failed\n");
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list