[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Jul 3 11:25:02 UTC 2018


The branch, master has been updated
       via  3287bfe build: bundle and reduce huge number of EA function tests
       via  417fe47 drs_utils: Add infrastructure to support 'clone with rename'
       via  00d2212 tests: Add a sub-set of tests to show the restored DC is sound
       via  ccba77a selftest: Add testenv for testing backup/restore
       via  70b73f3 tests: Add tests for the domain backup online/restore commands
       via  7844074 netcmd: domain backup restore command
       via  e0301df netcmd: domain backup online command
      from  c242259 join: Remove unnecessary clone_only flag

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


- Log -----------------------------------------------------------------
commit 3287bfe2b4ab0676b40666594b00b64ab027e04d
Author: Björn Jacke <bjacke at samba.org>
Date:   Mon Mar 12 18:44:38 2018 +0100

    build: bundle and reduce huge number of EA function tests
    
    It's sufficient to check for one basic function of an EA implementation and a
    use a single ifdef for each group of EA functions. This makes more sense than
    checking for each EA function on each platform.
    
    Signed-off-by: Bjoern Jacke <bjacke at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Jul  3 13:24:51 CEST 2018 on sn-devel-144

commit 417fe47a910f2b8aa3c5e1121a55d8ebace0012b
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Wed Jun 6 10:04:29 2018 +1200

    drs_utils: Add infrastructure to support 'clone with rename'
    
    Our end goal is to create a backup clone of a DB, but rename the
    domain/realm so we can startup the backup DC without interferring with
    the existing Samba network. The basic strategy to do this is to leverage
    DRS replication - by renaming the first object in the partition, all
    subsequent objects will automatically be renamed.
    
    This patch adds the infrastructure to do this. I've used object
    inheritance to handle the special case of renaming the partition
    objects. This means the domain-rename special case doesn't really
    pollute the existing DRS replication code. All it needs is a small
    refactor to create a new 'process_chunk()' function that the new
    sub-class can then override.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 00d22122e5c0eb0c4e45c40b6a292628ab023f2d
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Thu Jun 21 15:04:00 2018 +1200

    tests: Add a sub-set of tests to show the restored DC is sound
    
    + Add a new ldapcmp_restoredc.sh test that asserts that the original DC
    backed up (backupfromdc) matches the new restored DC.
    + Add a new join_ldapcmp.sh test that asserts we can join a given DC,
    and that the resulting DB matches the joined DC
    + Add a new login_basics.py test that sanity-checks Kerberos and NTLM
    user login works. (This reuses the password_lockout base code, without
    taking as long as the password_lockout tests do). Basic LDAP and SAMR
    connections are also tested as a side-effect.
    + run the netlogonsvc test against the restored DC to prove we can
    establish a netlogon connection.
    + run the same subset of rpc.echo tests that we do for RODC
    + run dbcheck over the new testenvs at the end of the test run
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit ccba77a9d8ead63acee11b15e1ca5f70afe168ad
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Tue May 29 16:05:02 2018 +1200

    selftest: Add testenv for testing backup/restore
    
    This adds a new testenv for testing that a DC created using the
    samba-tool backup/restore can actually be started up. This actually
    requires 2 new testenvs:
    
    1. A 'backupfromdc' that solely exists to make a online backup of.
    2. A 'restoredc' which takes the backup, and then uses the backup file
    to do a restore, which we then start the DC based on.
    
    The backupfromdc is just a plain vanilla AD DC. We use a separate test
    env purely for this purpose, because the restoredc will use the same
    domain (and so using an existing testenv would potentially interfere
    with existing test cases).
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 70b73f3ca6c3dc5425d224a826135dae6b536b11
Author: Aaron Haslett <aaronhaslett at catalyst.net.nz>
Date:   Mon Jun 11 19:13:35 2018 +1200

    tests: Add tests for the domain backup online/restore commands
    
    Signed-off-by: Aaron Haslett <aaronhaslett at catalyst.net.nz>
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit 7844074621348b778ee0f8b73652f035cc5ec9ad
Author: Aaron Haslett <aaronhaslett at catalyst.net.nz>
Date:   Tue May 1 11:11:01 2018 +1200

    netcmd: domain backup restore command
    
    Add a command option that restores a backup file. This is only intended
    for recovering from a catastrophic failure of the domain. The old domain
    DCs are removed from the DB and a new DC is added.
    
    Signed-off-by: Aaron Haslett <aaronhaslett at catalyst.net.nz>
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

commit e0301df111c5adbaa77299bb5d43c180cdd9df2c
Author: Aaron Haslett <aaronhaslett at catalyst.net.nz>
Date:   Tue May 1 11:10:11 2018 +1200

    netcmd: domain backup online command
    
    This adds a samba-tool command that can be run against a remote DC to
    produce a backup-file for the current domain. The backup stores similar
    info to what a new DC would get if it joined the network.
    
    Signed-off-by: Aaron Haslett <aaronhaslett at catalyst.net.nz>
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>

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

Summary of changes:
 docs-xml/manpages/samba-tool.8.xml        |  15 ++
 lib/replace/system/filesys.h              |  27 +-
 lib/replace/wscript                       |  47 ++--
 lib/replace/xattr.c                       |  74 +++---
 python/samba/drs_utils.py                 |  74 +++++-
 python/samba/join.py                      |  39 ++-
 python/samba/netcmd/domain.py             |   2 +
 python/samba/netcmd/domain_backup.py      | 412 ++++++++++++++++++++++++++++++
 python/samba/tests/domain_backup.py       | 307 ++++++++++++++++++++++
 selftest/target/Samba.pm                  |   2 +
 selftest/target/Samba4.pm                 | 212 +++++++++++++++
 source4/dsdb/tests/python/login_basics.py | 184 +++++++++++++
 source4/selftest/tests.py                 |  31 ++-
 testprogs/blackbox/join_ldapcmp.sh        |  41 +++
 testprogs/blackbox/ldapcmp_restoredc.sh   |  65 +++++
 15 files changed, 1419 insertions(+), 113 deletions(-)
 create mode 100644 python/samba/netcmd/domain_backup.py
 create mode 100644 python/samba/tests/domain_backup.py
 create mode 100755 source4/dsdb/tests/python/login_basics.py
 create mode 100755 testprogs/blackbox/join_ldapcmp.sh
 create mode 100755 testprogs/blackbox/ldapcmp_restoredc.sh


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/samba-tool.8.xml b/docs-xml/manpages/samba-tool.8.xml
index f785e53..b8038bc 100644
--- a/docs-xml/manpages/samba-tool.8.xml
+++ b/docs-xml/manpages/samba-tool.8.xml
@@ -292,6 +292,21 @@
 </refsect2>
 
 <refsect3>
+	<title>domain backup</title>
+	<para>Create or restore a backup of the domain.</para>
+</refsect3>
+
+<refsect3>
+	<title>domain backup online</title>
+	<para>Copy a running DC's current DB into a backup tar file.</para>
+</refsect3>
+
+<refsect3>
+	<title>domain backup restore</title>
+	<para>Restore the domain's DB from a backup-file.</para>
+</refsect3>
+
+<refsect3>
 	<title>domain classicupgrade [options] <replaceable>classic_smb_conf</replaceable></title>
 	<para>Upgrade from Samba classic (NT4-like) database to Samba AD DC
 	database.</para>
diff --git a/lib/replace/system/filesys.h b/lib/replace/system/filesys.h
index bd6e6a0..faa94c7 100644
--- a/lib/replace/system/filesys.h
+++ b/lib/replace/system/filesys.h
@@ -218,52 +218,33 @@
 #endif
 
 
-#if !defined(HAVE_GETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+#if !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
+
 ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size);
 #define getxattr(path, name, value, size) rep_getxattr(path, name, value, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FGETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size);
 #define fgetxattr(filedes, name, value, size) rep_fgetxattr(filedes, name, value, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_LISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 ssize_t rep_listxattr (const char *path, char *list, size_t size);
 #define listxattr(path, list, size) rep_listxattr(path, list, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FLISTXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 ssize_t rep_flistxattr (int filedes, char *list, size_t size);
 #define flistxattr(filedes, value, size) rep_flistxattr(filedes, value, size)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_REMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_removexattr (const char *path, const char *name);
 #define removexattr(path, name) rep_removexattr(path, name)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FREMOVEXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_fremovexattr (int filedes, const char *name);
 #define fremovexattr(filedes, name) rep_fremovexattr(filedes, name)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_SETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
 #define setxattr(path, name, value, size, flags) rep_setxattr(path, name, value, size, flags)
 /* define is in "replace.h" */
-#endif
-
-#if !defined(HAVE_FSETXATTR) || defined(XATTR_ADDITIONAL_OPTIONS)
 int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
 #define fsetxattr(filedes, name, value, size, flags) rep_fsetxattr(filedes, name, value, size, flags)
 /* define is in "replace.h" */
-#endif
+
+#endif /* !defined(HAVE_XATTR_XATTR) || defined(XATTR_ADDITIONAL_OPTIONS) */
 
 #endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 3df86b1..66694f7 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -393,35 +393,24 @@ def configure(conf):
 
     xattr_headers='sys/attributes.h attr/xattr.h sys/xattr.h'
 
-    conf.CHECK_FUNCS_IN('''
-fgetxattr flistea flistxattr
-fremovexattr fsetxattr getxattr
-listxattr removexattr setxattr
-''', 'attr', checklibc=True, headers=xattr_headers)
-
-    # We need to check for linux xattrs first, as we do not wish to link to -lattr
-    # (the XFS compat API) on Linux systems with the native xattr API
-    if not conf.CONFIG_SET('HAVE_GETXATTR'):
-        conf.CHECK_FUNCS_IN('''
-attr_get attr_getf attr_list attr_listf attropen attr_remove
-attr_removef attr_set attr_setf extattr_delete_fd extattr_delete_file
-extattr_get_fd extattr_get_file extattr_list_fd extattr_list_file
-extattr_set_fd extattr_set_file fgetea
-fremoveea fsetea getea listea
-removeea setea
-''', 'attr', checklibc=True, headers=xattr_headers)
-
-    if (conf.CONFIG_SET('HAVE_ATTR_LISTF') or
-        conf.CONFIG_SET('HAVE_EXTATTR_LIST_FD') or
-        conf.CONFIG_SET('HAVE_FLISTEA') or
-        conf.CONFIG_SET('HAVE_FLISTXATTR')):
-            conf.DEFINE('HAVE_XATTR_SUPPORT', 1)
-
-    # Darwin has extra options to xattr-family functions
-    conf.CHECK_CODE('getxattr(NULL, NULL, NULL, 0, 0, 0)',
-                    headers=xattr_headers, local_include=False,
-                    define='XATTR_ADDITIONAL_OPTIONS',
-                    msg="Checking whether xattr interface takes additional options")
+    # default to 1, we set it to 0 if we don't find any EA implementation below:
+    conf.DEFINE('HAVE_XATTR_SUPPORT', 1)
+    if conf.CHECK_FUNCS_IN('getxattr', 'attr', checklibc=True, headers=xattr_headers):
+        conf.DEFINE('HAVE_XATTR_XATTR', 1)
+        # Darwin has extra options to xattr-family functions
+        conf.CHECK_CODE('getxattr(NULL, NULL, NULL, 0, 0, 0)',
+                        headers=xattr_headers, local_include=False,
+                        define='XATTR_ADDITIONAL_OPTIONS',
+                        msg="Checking whether xattr interface takes additional options")
+    elif conf.CHECK_FUNCS_IN('attr_listf', 'attr', checklibc=True, headers=xattr_headers):
+        conf.DEFINE('HAVE_XATTR_ATTR', 1)
+    elif conf.CHECK_FUNCS('extattr_list_fd'):
+        conf.DEFINE('HAVE_XATTR_EXTATTR', 1)
+    elif conf.CHECK_FUNCS('flistea'):
+        conf.DEFINE('HAVE_XATTR_EA', 1)
+    elif not conf.CHECK_FUNCS('attropen'):
+            conf.DEFINE('HAVE_XATTR_SUPPORT', 0)
+
 
     conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl',
                         checklibc=True, headers='dlfcn.h dl.h')
diff --git a/lib/replace/xattr.c b/lib/replace/xattr.c
index 2479c21..2420ee1 100644
--- a/lib/replace/xattr.c
+++ b/lib/replace/xattr.c
@@ -48,7 +48,7 @@ static int solaris_openat(int fildes, const char *path, int oflag, mode_t mode);
 
 ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size)
 {
-#if defined(HAVE_GETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return getxattr(path, name, value, size);
 #else
@@ -58,9 +58,9 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
 	int options = 0;
 	return getxattr(path, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_GETEA)
+#elif defined(HAVE_XATTR_EA)
 	return getea(path, name, value, size);
-#elif defined(HAVE_EXTATTR_GET_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
 	ssize_t retval;
 	int attrnamespace;
 	const char *attrname;
@@ -93,7 +93,7 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
 	}
 
 	return -1;
-#elif defined(HAVE_ATTR_GET)
+#elif defined(HAVE_XATTR_ATTR)
 	int retval, flags = 0;
 	int valuelength = (int)size;
 	char *attrname = strchr(name,'.') + 1;
@@ -122,7 +122,7 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
 
 ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
 {
-#if defined(HAVE_FGETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return fgetxattr(filedes, name, value, size);
 #else
@@ -132,9 +132,9 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
 	int options = 0;
 	return fgetxattr(filedes, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_FGETEA)
+#elif defined(HAVE_XATTR_EA)
 	return fgetea(filedes, name, value, size);
-#elif defined(HAVE_EXTATTR_GET_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
 	ssize_t retval;
 	int attrnamespace;
 	const char *attrname;
@@ -162,7 +162,7 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
 	}
 
 	return -1;
-#elif defined(HAVE_ATTR_GETF)
+#elif defined(HAVE_XATTR_ATTR)
 	int retval, flags = 0;
 	int valuelength = (int)size;
 	char *attrname = strchr(name,'.') + 1;
@@ -188,7 +188,7 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
 #endif
 }
 
-#if defined(HAVE_EXTATTR_LIST_FILE)
+#if defined(HAVE_XATTR_EXTATTR)
 
 #define EXTATTR_PREFIX(s)	(s), (sizeof((s))-1)
 
@@ -219,21 +219,15 @@ static ssize_t bsd_attr_list (int type, extattr_arg arg, char *list, size_t size
 			continue;
 		}
 		switch(type) {
-#if defined(HAVE_EXTATTR_LIST_FILE)
 			case 0:
 				list_size = extattr_list_file(arg.path, extattr[t].space, list, size);
 				break;
-#endif
-#if defined(HAVE_EXTATTR_LIST_LINK)
 			case 1:
 				list_size = extattr_list_link(arg.path, extattr[t].space, list, size);
 				break;
-#endif
-#if defined(HAVE_EXTATTR_LIST_FD)
 			case 2:
 				list_size = extattr_list_fd(arg.filedes, extattr[t].space, list, size);
 				break;
-#endif
 			default:
 				errno = ENOSYS;
 				return -1;
@@ -285,7 +279,7 @@ static ssize_t bsd_attr_list (int type, extattr_arg arg, char *list, size_t size
 
 #endif
 
-#if defined(HAVE_ATTR_LIST) && (defined(HAVE_SYS_ATTRIBUTES_H) || defined(HAVE_ATTR_ATTRIBUTES_H))
+#if defined(HAVE_XATTR_ATTR) && (defined(HAVE_SYS_ATTRIBUTES_H) || defined(HAVE_ATTR_ATTRIBUTES_H))
 static char attr_buffer[ATTR_MAX_VALUELEN];
 
 static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t size, int flags)
@@ -355,7 +349,7 @@ static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t
 
 ssize_t rep_listxattr (const char *path, char *list, size_t size)
 {
-#if defined(HAVE_LISTXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return listxattr(path, list, size);
 #else
@@ -364,13 +358,13 @@ ssize_t rep_listxattr (const char *path, char *list, size_t size)
 	int options = 0;
 	return listxattr(path, list, size, options);
 #endif
-#elif defined(HAVE_LISTEA)
+#elif defined(HAVE_XATTR_EA)
 	return listea(path, list, size);
-#elif defined(HAVE_EXTATTR_LIST_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
 	extattr_arg arg;
 	arg.path = path;
 	return bsd_attr_list(0, arg, list, size);
-#elif defined(HAVE_ATTR_LIST) && defined(HAVE_SYS_ATTRIBUTES_H)
+#elif defined(HAVE_XATTR_ATTR) && defined(HAVE_SYS_ATTRIBUTES_H)
 	return irix_attr_list(path, 0, list, size, 0);
 #elif defined(HAVE_ATTROPEN)
 	ssize_t ret = -1;
@@ -388,7 +382,7 @@ ssize_t rep_listxattr (const char *path, char *list, size_t size)
 
 ssize_t rep_flistxattr (int filedes, char *list, size_t size)
 {
-#if defined(HAVE_FLISTXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return flistxattr(filedes, list, size);
 #else
@@ -397,13 +391,13 @@ ssize_t rep_flistxattr (int filedes, char *list, size_t size)
 	int options = 0;
 	return flistxattr(filedes, list, size, options);
 #endif
-#elif defined(HAVE_FLISTEA)
+#elif defined(HAVE_XATTR_EA)
 	return flistea(filedes, list, size);
-#elif defined(HAVE_EXTATTR_LIST_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
 	extattr_arg arg;
 	arg.filedes = filedes;
 	return bsd_attr_list(2, arg, list, size);
-#elif defined(HAVE_ATTR_LISTF)
+#elif defined(HAVE_XATTR_ATTR)
 	return irix_attr_list(NULL, filedes, list, size, 0);
 #elif defined(HAVE_ATTROPEN)
 	ssize_t ret = -1;
@@ -421,7 +415,7 @@ ssize_t rep_flistxattr (int filedes, char *list, size_t size)
 
 int rep_removexattr (const char *path, const char *name)
 {
-#if defined(HAVE_REMOVEXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return removexattr(path, name);
 #else
@@ -430,9 +424,9 @@ int rep_removexattr (const char *path, const char *name)
 	int options = 0;
 	return removexattr(path, name, options);
 #endif
-#elif defined(HAVE_REMOVEEA)
+#elif defined(HAVE_XATTR_EA)
 	return removeea(path, name);
-#elif defined(HAVE_EXTATTR_DELETE_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
 	int attrnamespace;
 	const char *attrname;
 
@@ -448,7 +442,7 @@ int rep_removexattr (const char *path, const char *name)
 	}
 
 	return extattr_delete_file(path, attrnamespace, attrname);
-#elif defined(HAVE_ATTR_REMOVE)
+#elif defined(HAVE_XATTR_ATTR)
 	int flags = 0;
 	char *attrname = strchr(name,'.') + 1;
 
@@ -471,7 +465,7 @@ int rep_removexattr (const char *path, const char *name)
 
 int rep_fremovexattr (int filedes, const char *name)
 {
-#if defined(HAVE_FREMOVEXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return fremovexattr(filedes, name);
 #else
@@ -480,9 +474,9 @@ int rep_fremovexattr (int filedes, const char *name)
 	int options = 0;
 	return fremovexattr(filedes, name, options);
 #endif
-#elif defined(HAVE_FREMOVEEA)
+#elif defined(HAVE_XATTR_EA)
 	return fremoveea(filedes, name);
-#elif defined(HAVE_EXTATTR_DELETE_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
 	int attrnamespace;
 	const char *attrname;
 
@@ -498,7 +492,7 @@ int rep_fremovexattr (int filedes, const char *name)
 	}
 
 	return extattr_delete_fd(filedes, attrnamespace, attrname);
-#elif defined(HAVE_ATTR_REMOVEF)
+#elif defined(HAVE_XATTR_ATTR)
 	int flags = 0;
 	char *attrname = strchr(name,'.') + 1;
 
@@ -521,7 +515,7 @@ int rep_fremovexattr (int filedes, const char *name)
 
 int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags)
 {
-#if defined(HAVE_SETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return setxattr(path, name, value, size, flags);
 #else
@@ -530,9 +524,9 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
 	int options = 0;
 	return setxattr(path, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_SETEA)
+#elif defined(HAVE_XATTR_EA)
 	return setea(path, name, value, size, flags);
-#elif defined(HAVE_EXTATTR_SET_FILE)
+#elif defined(HAVE_XATTR_EXTATTR)
 	int retval = 0;
 	int attrnamespace;
 	const char *attrname;
@@ -569,7 +563,7 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
 	}
 	retval = extattr_set_file(path, attrnamespace, attrname, value, size);
 	return (retval < 0) ? -1 : 0;
-#elif defined(HAVE_ATTR_SET)
+#elif defined(HAVE_XATTR_ATTR)
 	int myflags = 0;
 	char *attrname = strchr(name,'.') + 1;
 
@@ -598,7 +592,7 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
 
 int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags)
 {
-#if defined(HAVE_FSETXATTR)
+#if defined(HAVE_XATTR_XATTR)
 #ifndef XATTR_ADDITIONAL_OPTIONS
 	return fsetxattr(filedes, name, value, size, flags);
 #else
@@ -607,9 +601,9 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
 	int options = 0;
 	return fsetxattr(filedes, name, value, size, 0, options);
 #endif
-#elif defined(HAVE_FSETEA)
+#elif defined(HAVE_XATTR_EA)
 	return fsetea(filedes, name, value, size, flags);
-#elif defined(HAVE_EXTATTR_SET_FD)
+#elif defined(HAVE_XATTR_EXTATTR)
 	int retval = 0;
 	int attrnamespace;
 	const char *attrname;
@@ -646,7 +640,7 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
 	}
 	retval = extattr_set_fd(filedes, attrnamespace, attrname, value, size);
 	return (retval < 0) ? -1 : 0;
-#elif defined(HAVE_ATTR_SETF)
+#elif defined(HAVE_XATTR_ATTR)
 	int myflags = 0;
 	char *attrname = strchr(name,'.') + 1;
 
diff --git a/python/samba/drs_utils.py b/python/samba/drs_utils.py
index aa4605e..db83267 100644
--- a/python/samba/drs_utils.py
+++ b/python/samba/drs_utils.py
@@ -24,7 +24,8 @@ from samba import dsdb
 from samba import werror
 from samba import WERRORError
 import samba, ldb
-
+from samba.dcerpc.drsuapi import DRSUAPI_ATTID_name
+import re
 
 class drsException(Exception):
     """Base element for drs errors"""
@@ -213,6 +214,12 @@ class drs_Replicate(object):
                 (req.more_flags & drsuapi.DRSUAPI_DRS_GET_TGT) == 0 and
                 self.supported_extensions & drsuapi.DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10)
 
+    def process_chunk(self, level, ctr, schema, req_level, req, first_chunk):
+        '''Processes a single chunk of received replication data'''
+        # pass the replication into the py_net.c python bindings for processing
+        self.net.replicate_chunk(self.replication_state, level, ctr,
+                                 schema=schema, req_level=req_level, req=req)
+
     def replicate(self, dn, source_dsa_invocation_id, destination_dsa_guid,
                   schema=False, exop=drsuapi.DRSUAPI_EXOP_NONE, rodc=False,
                   replica_flags=None, full_sync=True, sync_forced=False, more_flags=0):
@@ -309,14 +316,15 @@ class drs_Replicate(object):
 
         num_objects = 0
         num_links = 0
+        first_chunk = True
+
         while True:
             (level, ctr) = self.drs.DsGetNCChanges(self.drs_handle, req_level, req)
             if ctr.first_object is None and ctr.object_count != 0:
                 raise RuntimeError("DsGetNCChanges: NULL first_object with object_count=%u" % (ctr.object_count))
 
             try:
-                self.net.replicate_chunk(self.replication_state, level, ctr,
-                    schema=schema, req_level=req_level, req=req)
+                self.process_chunk(level, ctr, schema, req_level, req, first_chunk)
             except WERRORError as e:
                 # Check if retrying with the GET_TGT flag set might resolve this error
                 if self._should_retry_with_get_tgt(e.args[0], req):
@@ -324,11 +332,14 @@ class drs_Replicate(object):
                     print("Missing target object - retrying with DRS_GET_TGT")
                     req.more_flags |= drsuapi.DRSUAPI_DRS_GET_TGT
 
-                    # try sending the request again
+                    # try sending the request again (this has the side-effect
+                    # of causing the DC to restart the replication from scratch)
+                    first_chunk = True
                     continue
                 else:
                     raise e
 
+            first_chunk = False
             num_objects += ctr.object_count
 
             # Cope with servers that do not return level 6, so do not return any links
@@ -342,3 +353,58 @@ class drs_Replicate(object):
             req.highwatermark = ctr.new_highwatermark
 
         return (num_objects, num_links)
+
+
+# Handles the special case of creating a new clone of a DB, while also renaming
+# the entire DB's objects on the way through
+class drs_ReplicateRenamer(drs_Replicate):
+    '''Uses DRS replication to rename the entire DB'''
+
+    def __init__(self, binding_string, lp, creds, samdb, invocation_id,
+                 old_base_dn, new_base_dn):
+        super(drs_ReplicateRenamer, self).__init__(binding_string, lp, creds,
+                                                   samdb, invocation_id)
+        self.old_base_dn = old_base_dn
+        self.new_base_dn = new_base_dn
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list