[SCM] Samba Shared Repository - branch v4-18-test updated
Jule Anger
janger at samba.org
Fri Feb 24 09:51:01 UTC 2023
The branch, v4-18-test has been updated
via b8299405352 lib:util: File descriptor being closed repeatedly.
via 6191dbda193 python:tests: Make sure we delete the OU for movetest
via b925ac8094f python:tests: Add missing result checks for samba_tool.gpo tests
via b7b61025b65 python:tests: Tell dns.resolver to not read /etc/resolv.conf
via 8739c9c72dd python:tests: Fix domain_backup test with Python 3.11
via 9e8cc236bd3 python:tests: Make sure we do not run into issues with already existing users
via bebf313dcb0 python:tests: Use a random machine name for computer_edit.sh test
via 5ce320a06e0 python:tests: Correctly escape $ in computer_edit.sh
via 889839858fe python:tests: Use a random username for contact_edit.sh test
via 074e0c2783a python:tests: Correctly escape $ in contact_edit.sh
via 359095e8ddd python:tests: Use a random username for user_edit.sh tests
via d45706e2653 python:tests: Correctly escape $ in user_edit.sh
via 820970ab5ec testprogs: Use random user names for kpasswd tests
via f15a1413571 testprogs: Use random usernames for export keytab tests
via 67639f6d9ad testprogs: Use random usernames for kinit tests
from b2d0a834149 VERSION: Bump version up to Samba 4.18.0rc4...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-18-test
- Log -----------------------------------------------------------------
commit b829940535215f0608bc927829544cfa8a80e934
Author: baixiangcpp <baixiangcpp at gmail.com>
Date: Fri Feb 10 11:01:47 2023 +0800
lib:util: File descriptor being closed repeatedly.
In file_load()/file_lines_load(), the file's fd is obtained using
open(), and in fd_load() the fd is converted to a FILE* using
fdopen(). However, after fclose(), the fd is closed again using
close().
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15311
Signed-off-by: baixiangcpp baixiangcpp at gmail.com
Reviewed-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Autobuild-User(master): Volker Lendecke <vl at samba.org>
Autobuild-Date(master): Thu Feb 16 12:13:05 UTC 2023 on atb-devel-224
(cherry picked from commit 206dcf7d426e9e85c896c54839008e194d9a2824)
Autobuild-User(v4-18-test): Jule Anger <janger at samba.org>
Autobuild-Date(v4-18-test): Fri Feb 24 09:50:59 UTC 2023 on atb-devel-224
commit 6191dbda1932d8eab59a593ce5ef979143ce3a46
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 15:44:43 2023 +0100
python:tests: Make sure we delete the OU for movetest
UNEXPECTED(failure): samba.tests.samba_tool.group.samba.tests.samba_tool.group.GroupCmdTestCase.test_move(ad_dc_default:local)
REASON: Exception: Exception: Traceback (most recent call last):
File "python/samba/tests/samba_tool/group.py", line 341, in test_move
self.assertCmdSuccess(result, out, err)
File "python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess
self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n"))
AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to
add ou "OU=movetest,DC=addom,DC=samba,DC=example,DC=com" - Entry
OU=movetest,DC=addom,DC=samba,DC=example,DC=com already exists
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit a4307072d6ea5ddef5b37aa361e9e9f16f7254e7)
commit b925ac8094fb62a6247d066bc17b374d24abcd5b
Author: Andreas Schneider <asn at samba.org>
Date: Thu Feb 9 18:32:59 2023 +0100
python:tests: Add missing result checks for samba_tool.gpo tests
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit 69442ae1072eb6dc4c9903122d613c1756ca57c7)
commit b7b61025b65164327f5d375de38e92f0b6ddc4cf
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 12:21:10 2023 +0100
python:tests: Tell dns.resolver to not read /etc/resolv.conf
We explicitly set the nameserver in the next line. Also the file
/etc/resolv.conf might not exist on the system (e.g in Fedora mockbuild).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit c4dba61e3691a1fd15eb63ee69224457102bf961)
commit 8739c9c72ddb346642e4adf98b1fb8f4440cf288
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 11:16:12 2023 +0100
python:tests: Fix domain_backup test with Python 3.11
Traceback (most recent call last):
File "bin/python/samba/tests/domain_backup.py", line 615, in test_backup_restore_with_conf
self._test_backup_restore_with_conf()
File "bin/python/samba/tests/domain_backup.py", line 244, in _test_backup_restore_with_conf
self.restore_backup(backup_file, ["--configfile=" + smbconf])
File "bin/python/samba/tests/domain_backup.py", line 421, in restore_backup
self.run_cmd(args)
File "bin/python/samba/tests/domain_backup.py", line 384, in run_cmd
self.cleanup_tempdir()
File "bin/python/samba/tests/domain_backup.py", line 370, in cleanup_tempdir
shutil.rmtree(filepath)
File "/usr/lib64/python3.11/shutil.py", line 732, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib64/python3.11/shutil.py", line 635, in _rmtree_safe_fd
onerror(os.scandir, path, sys.exc_info())
File "/usr/lib64/python3.11/shutil.py", line 631, in _rmtree_safe_fd
with os.scandir(topfd) as scandir_it:
^^^^^^^^^^^^^^^^^
NotADirectoryError: [Errno 20] Not a directory:
'st/tmp/tmp7usvex3t/samba-backup-2023-02-08T10-13-18.461113.tar.bz2'
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit 804fb07259b87e80993b1916935b626906e04580)
commit 9e8cc236bd3111b81289fe35187e6d8e5d843ea8
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 10:17:05 2023 +0100
python:tests: Make sure we do not run into issues with already existing users
UNEXPECTED(failure): samba.tests.samba_tool.user.samba.tests.samba_tool.user.UserCmdTestCase.test_getpwent(ad_dc_ntvfs:local)
REASON: Exception: Exception: Traceback (most recent call last):
File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/user.py", line 1044, in test_getpwent
self.assertCmdSuccess(result, out, err)
File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess
self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n"))
AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to
add user 'mockbuild': - LDAP error 68 LDAP_ENTRY_ALREADY_EXISTS - <00002071:
samldb: samAccountName 'mockbuild' already in use!> <>
]:
UNEXPECTED(failure): samba.tests.samba_tool.user.samba.tests.samba_tool.user.UserCmdTestCase.test_list(ad_dc_ntvfs:local)
REASON: Exception: Exception: Traceback (most recent call last):
File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/user.py", line 69, in setUp
self.assertCmdSuccess(result, out, err)
File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess
self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n"))
AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to
add user 'sambatool1': - LDAP error 68 LDAP_ENTRY_ALREADY_EXISTS - <00002071:
samldb: samAccountNa me 'sambatool1' already in use!> <>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit af27b1d37573d165983933d3789a18b12fad0272)
commit bebf313dcb05af6ba7dbc75ea64ad8270562ba1b
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 21:40:25 2023 +0100
python:tests: Use a random machine name for computer_edit.sh test
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit ae315397a653ec2249b89e246eb46589d4542f75)
commit 5ce320a06e049a6dc7e407e34f3563fafb272db0
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 21:37:06 2023 +0100
python:tests: Correctly escape $ in computer_edit.sh
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit 8ff1ccc6d6d8804be55f5549910aa11c6a9a7664)
commit 889839858fe50337bfbea0b52fb52f3816616713
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 18:41:18 2023 +0100
python:tests: Use a random username for contact_edit.sh test
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit e846a9df60323a77e8222f27be8d31b326ce8d6a)
commit 074e0c2783aae1e220f4e195b325374b440e3a8d
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 18:40:04 2023 +0100
python:tests: Correctly escape $ in contact_edit.sh
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit af1324e3be28773e0b8cc827c669812e4c257989)
commit 359095e8ddda1db6c04f1edc32c13bf2c452c12f
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 10:20:21 2023 +0100
python:tests: Use a random username for user_edit.sh tests
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit 0bcdba952ec887139517841b8882bd6e10c00267)
commit d45706e26538b689be7d565c185f87f47735f801
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 15:33:00 2023 +0100
python:tests: Correctly escape $ in user_edit.sh
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit a78c38e1f114858bd72738c752d27ef4b4358488)
commit 820970ab5ec1e70af751cfefeea609230a52a058
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 08:30:56 2023 +0100
testprogs: Use random user names for kpasswd tests
This avoids that subsequent tests because users already exist and cleanup didn't
work.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit a3b80b656f16049772005bd7b00451aaa5df2dd6)
commit f15a1413571861eafb7c6a84c70fd684732a1823
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 08:30:38 2023 +0100
testprogs: Use random usernames for export keytab tests
This avoids that subsequent tests because users already exist and cleanup didn't
work.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit 5595765d4e5918abe8d68423a8036f99675e64e7)
commit 67639f6d9ad481c4c15555d6202db8aa0132c0de
Author: Andreas Schneider <asn at samba.org>
Date: Wed Feb 8 08:29:33 2023 +0100
testprogs: Use random usernames for kinit tests
This avoids that subsequent tests because users already exist and cleanup didn't
work.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
(cherry picked from commit 93c7bbf4d2db73116e5de564b428d6d30504bd5c)
-----------------------------------------------------------------------
Summary of changes:
lib/util/util_file.c | 9 ++++-
python/samba/tests/blackbox/netads_dns.py | 4 ++-
python/samba/tests/domain_backup.py | 5 ++-
python/samba/tests/samba_tool/computer_edit.sh | 30 ++++++++--------
python/samba/tests/samba_tool/contact_edit.sh | 28 ++++++++-------
python/samba/tests/samba_tool/gpo.py | 15 ++++++++
python/samba/tests/samba_tool/group.py | 8 ++---
python/samba/tests/samba_tool/user.py | 21 ++++++++---
python/samba/tests/samba_tool/user_edit.sh | 30 ++++++++--------
testprogs/blackbox/test_export_keytab_heimdal.sh | 17 ++++-----
testprogs/blackbox/test_export_keytab_mit.sh | 4 +--
testprogs/blackbox/test_kinit_heimdal.sh | 46 ++++++++++++------------
testprogs/blackbox/test_kinit_mit.sh | 38 ++++++++++----------
testprogs/blackbox/test_kpasswd_mit.sh | 2 +-
14 files changed, 152 insertions(+), 105 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/util_file.c b/lib/util/util_file.c
index af90e4a7621..fa5abadedec 100644
--- a/lib/util/util_file.c
+++ b/lib/util/util_file.c
@@ -175,13 +175,20 @@ _PUBLIC_ char *fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ct
size_t size = 0;
size_t chunk = 1024;
int err;
+ int fd_dup;
if (maxsize == 0) {
maxsize = SIZE_MAX;
}
- file = fdopen(fd, "r");
+ fd_dup = dup(fd);
+ if (fd_dup == -1) {
+ return NULL;
+ }
+
+ file = fdopen(fd_dup, "r");
if (file == NULL) {
+ close(fd_dup);
return NULL;
}
diff --git a/python/samba/tests/blackbox/netads_dns.py b/python/samba/tests/blackbox/netads_dns.py
index 0a491504537..e9f945eaef9 100644
--- a/python/samba/tests/blackbox/netads_dns.py
+++ b/python/samba/tests/blackbox/netads_dns.py
@@ -30,7 +30,9 @@ class NetAdsDnsTests(BlackboxTestCase):
def setUp(self):
super(NetAdsDnsTests, self).setUp()
nameserver = os.environ["DC_SERVER_IP"]
- self.resolver = dns.resolver.Resolver()
+ # filename=None will disable reading /etc/resolv.conf. The file might
+ # not exist e.g. on build or CI systems.
+ self.resolver = dns.resolver.Resolver(filename=None)
self.resolver.nameservers = [nameserver]
def parse_output(self, output):
diff --git a/python/samba/tests/domain_backup.py b/python/samba/tests/domain_backup.py
index b890a1030b7..2feef28bcb4 100644
--- a/python/samba/tests/domain_backup.py
+++ b/python/samba/tests/domain_backup.py
@@ -367,7 +367,10 @@ class DomainBackupBase(BlackboxTestCase):
def cleanup_tempdir(self):
for filename in os.listdir(self.tempdir):
filepath = os.path.join(self.tempdir, filename)
- shutil.rmtree(filepath)
+ if os.path.isfile(filepath):
+ os.remove(filepath)
+ elif os.path.isdir(filepath):
+ shutil.rmtree(filepath)
def run_cmd(self, args):
"""Executes a samba-tool backup/restore command"""
diff --git a/python/samba/tests/samba_tool/computer_edit.sh b/python/samba/tests/samba_tool/computer_edit.sh
index 500a00d9a34..da32760de35 100755
--- a/python/samba/tests/samba_tool/computer_edit.sh
+++ b/python/samba/tests/samba_tool/computer_edit.sh
@@ -29,10 +29,12 @@ display_name_con_b64="dGVzdCAHIHN0cmluZwo="
tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
+TEST_MACHINE="$(mktemp -u testmachineXXXXXX)"
+
create_test_computer()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- computer create testmachine1 \
+ computer create ${TEST_MACHINE} \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -48,7 +50,7 @@ $SED -i -e 's/userAccountControl: 4098/userAccountControl: 4096/' $computer_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- computer edit testmachine1 --editor=$tmpeditor \
+ computer edit ${TEST_MACHINE} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -60,20 +62,20 @@ add_attribute_base64()
#!/usr/bin/env bash
computer_ldif="\$1"
-grep -v '^$' \$computer_ldif > \${computer_ldif}.tmp
+grep -v '^\$' \$computer_ldif > \${computer_ldif}.tmp
echo "displayName:: $display_name_b64" >> \${computer_ldif}.tmp
mv \${computer_ldif}.tmp \$computer_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \
- testmachine1 --editor=$tmpeditor \
+ ${TEST_MACHINE} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_attribute_base64()
{
- ${ldbsearch} '(sAMAccountName=testmachine1$)' displayName \
+ ${ldbsearch} "(sAMAccountName=${TEST_MACHINE}\$)" displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -88,7 +90,7 @@ grep -v '^displayName' \$computer_ldif >> \${computer_ldif}.tmp
mv \${computer_ldif}.tmp \$computer_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \
- testmachine1 --editor=$tmpeditor \
+ ${TEST_MACHINE} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -100,20 +102,20 @@ add_attribute_base64_control()
#!/usr/bin/env bash
computer_ldif="\$1"
-grep -v '^$' \$computer_ldif > \${computer_ldif}.tmp
+grep -v '^\$' \$computer_ldif > \${computer_ldif}.tmp
echo "displayName:: $display_name_con_b64" >> \${computer_ldif}.tmp
mv \${computer_ldif}.tmp \$computer_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \
- testmachine1 --editor=$tmpeditor \
+ ${TEST_MACHINE} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_attribute_base64_control()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \
- testmachine1 --attributes=displayName \
+ ${TEST_MACHINE} --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -121,7 +123,7 @@ get_attribute_force_no_base64()
{
# LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \
- testmachine1 --attributes=displayName \
+ ${TEST_MACHINE} --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -137,7 +139,7 @@ sed -i -e 's/displayName:: $display_name_con_b64/displayName: $display_name/' \
\$computer_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \
- testmachine1 --editor=$tmpeditor \
+ ${TEST_MACHINE} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -156,21 +158,21 @@ sed -i -e 's/displayName: $display_name/displayName: $display_name_new/' \
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \
- testmachine1 --editor=$tmpeditor \
+ ${TEST_MACHINE} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_changed_attribute_force_no_base64()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \
- testmachine1 --attributes=displayName \
+ ${TEST_MACHINE} --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
delete_computer()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- computer delete testmachine1 \
+ computer delete ${TEST_MACHINE} \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
diff --git a/python/samba/tests/samba_tool/contact_edit.sh b/python/samba/tests/samba_tool/contact_edit.sh
index 3c14ac8de26..d31413dbcd6 100755
--- a/python/samba/tests/samba_tool/contact_edit.sh
+++ b/python/samba/tests/samba_tool/contact_edit.sh
@@ -28,13 +28,15 @@ display_name_new="Renamed Bjoern"
# echo -e "test \a string" | base64
display_name_con_b64="dGVzdCAHIHN0cmluZwo="
+TEST_USER="$(mktemp -u testcontactXXXXXX)"
+
tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
create_test_contact()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- contact create testcontact1 \
+ contact create ${TEST_USER} \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -46,20 +48,20 @@ add_attribute_base64()
#!/usr/bin/env bash
contact_ldif="\$1"
-grep -v '^$' \$contact_ldif > \${contact_ldif}.tmp
+grep -v '^\$' \$contact_ldif > \${contact_ldif}.tmp
echo "displayName:: $display_name_b64" >> \${contact_ldif}.tmp
mv \${contact_ldif}.tmp \$contact_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \
- testcontact1 --editor=$tmpeditor \
+ ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_attribute_base64()
{
- $samba_ldbsearch '(&(objectClass=contact)(name=testcontact1))' \
+ $samba_ldbsearch "(&(objectClass=contact)(name=${TEST_USER}))" \
displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -75,7 +77,7 @@ grep -v '^displayName' \$contact_ldif >> \${contact_ldif}.tmp
mv \${contact_ldif}.tmp \$contact_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \
- testcontact1 --editor=$tmpeditor \
+ ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -87,20 +89,20 @@ add_attribute_base64_control()
#!/usr/bin/env bash
contact_ldif="\$1"
-grep -v '^$' \$contact_ldif > \${contact_ldif}.tmp
+grep -v '^\$' \$contact_ldif > \${contact_ldif}.tmp
echo "displayName:: $display_name_con_b64" >> \${contact_ldif}.tmp
mv \${contact_ldif}.tmp \$contact_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \
- testcontact1 --editor=$tmpeditor \
+ ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_attribute_base64_control()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
- testcontact1 --attributes=displayName \
+ ${TEST_USER} --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -108,7 +110,7 @@ get_attribute_force_no_base64()
{
# LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
- testcontact1 --attributes=displayName \
+ ${TEST_USER} --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -124,7 +126,7 @@ sed -i -e 's/displayName:: $display_name_con_b64/displayName: $display_name/' \
\$contact_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \
- testcontact1 --editor=$tmpeditor \
+ ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -143,21 +145,21 @@ sed -i -e 's/displayName: $display_name/displayName: $display_name_new/' \
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \
- testcontact1 --editor=$tmpeditor \
+ ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_changed_attribute_force_no_base64()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \
- testcontact1 --attributes=displayName \
+ ${TEST_USER} --attributes=displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
delete_contact()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- contact delete testcontact1 \
+ contact delete ${TEST_USER} \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py
index 78ed5d493af..723c8f055cd 100644
--- a/python/samba/tests/samba_tool/gpo.py
+++ b/python/samba/tests/samba_tool/gpo.py
@@ -183,6 +183,9 @@ class GpoCmdTestCase(SambaToolCmdTest):
os.environ["PASSWORD"]),
"--restore-metadata")
+ self.assertCmdSuccess(result, out, err,
+ "Ensure gpo restore successful")
+
gpo_guid = "{%s}" % out.split("{")[1].split("}")[0]
(result, out, err) = self.runsubcmd("gpo", "backup", gpo_guid,
@@ -237,6 +240,9 @@ class GpoCmdTestCase(SambaToolCmdTest):
os.environ["PASSWORD"]),
"--restore-metadata")
+ self.assertCmdSuccess(result, out, err,
+ "Ensure gpo restore successful")
+
gpo_guid = "{%s}" % out.split("{")[1].split("}")[0]
gpo_guid1 = gpo_guid
@@ -259,6 +265,9 @@ class GpoCmdTestCase(SambaToolCmdTest):
os.environ["PASSWORD"]),
"--restore-metadata")
+ self.assertCmdSuccess(result, out, err,
+ "Ensure gpo restore successful")
+
gpo_guid = "{%s}" % out.split("{")[1].split("}")[0]
gpo_guid2 = gpo_guid
@@ -322,6 +331,9 @@ class GpoCmdTestCase(SambaToolCmdTest):
os.environ["PASSWORD"]),
"--restore-metadata")
+ self.assertCmdSuccess(result, out, err,
+ "Ensure gpo restore successful")
+
gpo_guid = "{%s}" % out.split("{")[1].split("}")[0]
gpo_guid1 = gpo_guid
@@ -342,6 +354,9 @@ class GpoCmdTestCase(SambaToolCmdTest):
os.environ["PASSWORD"]),
"--restore-metadata")
+ self.assertCmdSuccess(result, out, err,
+ "Ensure gpo restore successful")
+
gpo_guid = "{%s}" % out.split("{")[1].split("}")[0]
gpo_guid2 = gpo_guid
diff --git a/python/samba/tests/samba_tool/group.py b/python/samba/tests/samba_tool/group.py
index 2542411d74a..3019b7596d2 100644
--- a/python/samba/tests/samba_tool/group.py
+++ b/python/samba/tests/samba_tool/group.py
@@ -336,7 +336,9 @@ class GroupCmdTestCase(SambaToolCmdTest):
def test_move(self):
- full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest"))
+ full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest_grp"))
+ self.addCleanup(self.samdb.delete, full_ou_dn, ["tree_delete:1"])
+
(result, out, err) = self.runsubcmd("ou", "add", full_ou_dn)
self.assertCmdSuccess(result, out, err)
self.assertEqual(err, "", "There shouldn't be any error message")
@@ -363,10 +365,6 @@ class GroupCmdTestCase(SambaToolCmdTest):
self.assertIn('Moved group "%s" into "%s"' %
(group["name"], new_dn), out)
- (result, out, err) = self.runsubcmd("ou", "delete", full_ou_dn)
- self.assertCmdSuccess(result, out, err,
- "Failed to delete ou '%s'" % full_ou_dn)
-
def test_show(self):
"""Assert that we can show a group correctly."""
(result, out, err) = self.runsubcmd("group", "show", "Domain Users",
diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py
index 700cb89c968..9b6d19b11cb 100644
--- a/python/samba/tests/samba_tool/user.py
+++ b/python/samba/tests/samba_tool/user.py
@@ -62,6 +62,11 @@ class UserCmdTestCase(SambaToolCmdTest):
self.users.append(self._randomUnixUser({"name": "unixuser3"}))
self.users.append(self._randomUnixUser({"name": "unixuser4"}))
+ # Make sure users don't exist
+ for user in self.users:
+ if self._find_user(user["name"]):
+ self.runsubcmd("user", "delete", user["name"])
+
# setup the 12 users and ensure they are correct
for user in self.users:
(result, out, err) = user["createUserFn"](user)
@@ -703,7 +708,9 @@ sAMAccountName: %s
self.assertGreater(pwd_expires_time, pwd_last_set_time)
def test_move(self):
- full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest"))
+ full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest_usr"))
+ self.addCleanup(self.samdb.delete, full_ou_dn, ["tree_delete:1"])
+
(result, out, err) = self.runsubcmd("ou", "add", full_ou_dn)
self.assertCmdSuccess(result, out, err)
self.assertEqual(err, "", "There shouldn't be any error message")
@@ -730,10 +737,6 @@ sAMAccountName: %s
self.assertIn('Moved user "%s" into "%s"' %
(user["name"], new_dn), out)
- (result, out, err) = self.runsubcmd("ou", "delete", full_ou_dn)
- self.assertCmdSuccess(result, out, err,
- "Failed to delete ou '%s'" % full_ou_dn)
-
def test_rename_surname_initials_givenname(self):
"""rename the existing surname and given name and add missing
initials, then remove them, for all users"""
@@ -999,6 +1002,10 @@ sAMAccountName: %s
"gecos": gecos,
"loginShell": u[6],
})
+
+ # Remove user if it already exists
+ if self._find_user(u[0]):
+ self.runsubcmd("user", "delete", u[0])
# check if --rfc2307-from-nss sets the same values as we got from pwd.getpwuid()
(result, out, err) = self.runsubcmd("user", "create", user["name"], user["password"],
"--surname=%s" % user["surname"],
@@ -1023,6 +1030,10 @@ sAMAccountName: %s
#
# get a user with all random posix attributes
user = self._randomPosixUser({"name": u[0]})
+
+ # Remove user if it already exists
+ if self._find_user(u[0]):
+ self.runsubcmd("user", "delete", u[0])
# create a user with posix attributes from nss but override all of them with the
# random ones just obtained
(result, out, err) = self.runsubcmd("user", "create", user["name"], user["password"],
diff --git a/python/samba/tests/samba_tool/user_edit.sh b/python/samba/tests/samba_tool/user_edit.sh
index 81a62bb269c..342899f3f0f 100755
--- a/python/samba/tests/samba_tool/user_edit.sh
+++ b/python/samba/tests/samba_tool/user_edit.sh
@@ -31,10 +31,12 @@ display_name_con_b64="dGVzdCAHIHN0cmluZwo="
tmpeditor=$(mktemp --suffix .sh -p ${SELFTEST_TMPDIR} samba-tool-editor-XXXXXXXX)
chmod +x $tmpeditor
+TEST_USER="$(mktemp -u sambatoolXXXXXX)"
+
create_test_user()
{
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- user create sambatool1 --random-password \
+ user create ${TEST_USER} --random-password \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -49,7 +51,7 @@ $SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool \
- user edit sambatool1 --editor=$tmpeditor \
+ user edit ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -61,20 +63,20 @@ add_attribute_base64()
#!/usr/bin/env bash
user_ldif="\$1"
-grep -v '^$' \$user_ldif > \${user_ldif}.tmp
+grep -v '^\$' \$user_ldif > \${user_ldif}.tmp
echo "displayName:: $display_name_b64" >> \${user_ldif}.tmp
mv \${user_ldif}.tmp \$user_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
- sambatool1 --editor=$tmpeditor \
+ ${TEST_USER} --editor=$tmpeditor \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
get_attribute_base64()
{
- $samba_ldbsearch '(sAMAccountName=sambatool1)' displayName \
+ $samba_ldbsearch "(sAMAccountName=${TEST_USER})" displayName \
-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
}
@@ -89,7 +91,7 @@ grep -v '^displayName' \$user_ldif >> \${user_ldif}.tmp
mv \${user_ldif}.tmp \$user_ldif
EOF
$PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
--
Samba Shared Repository
More information about the samba-cvs
mailing list