]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
3 years agoselftest: remove unused import
Rob van der Linde [Wed, 22 Feb 2023 22:54:16 +0000 (11:54 +1300)] 
selftest: remove unused import

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agoselftest: pep8: too many blank lines
Rob van der Linde [Wed, 22 Feb 2023 22:53:30 +0000 (11:53 +1300)] 
selftest: pep8: too many blank lines

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agoselftest: Fix some typos in selftest tests.py
Rob van der Linde [Tue, 21 Feb 2023 00:11:13 +0000 (13:11 +1300)] 
selftest: Fix some typos in selftest tests.py

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agoselftests: Make sure print queue is empty before printing_var_exp test ends
Samuel Cabrero [Fri, 17 Feb 2023 16:22:39 +0000 (17:22 +0100)] 
selftests: Make sure print queue is empty before printing_var_exp test ends

Although "lpq cache time" is 0 in the test environment the
"print_queue_length()" function can still return cached results. This is
because the print_queue_length() function calls print_queue_update(),
which just sends MSG_PRINTER_UPDATE to the samba-bgqd daemon and returns
without waiting for the daemon to update it.

This behavior causes problems in the selftests between
samba3.blackbox.printing_var_exp and samba3.rpc.spoolss.printserver
because when the later enumerates the printers at different levels and
compares the results the number of jobs can differ depending if samba-bgqd
updates the cache in between print_queue_update() and
get_queue_status() in the print_queue_length() function:

  test: samba3.rpc.spoolss.printserver.printserver.enum_printers(nt4_dc)
  time: 2023-02-17 13:07:34.043842Z
  Testing EnumPrinters level 0
  Testing EnumPrinters level 1
  Testing EnumPrinters level 2
  Checking EnumPrinters level 0 printer print_var_exp (ref print_var_exp)
  time: 2023-02-17 13:07:34.285992Z
  failure: samba3.rpc.spoolss.printserver.printserver.enum_printers(nt4_dc) [
  Exception: Exception: ../../source4/torture/rpc/spoolss.c:1132: cur->info0.cjobs was 1 (0x1), expected 0 (0x0): invalid value

To fix it, make sure the queue is empty before printing_var_exp test
ends.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Feb 20 22:58:44 UTC 2023 on atb-devel-224

3 years agoSkip running a C program during cross compilation
Helmut Grohne [Sun, 5 Feb 2023 21:18:13 +0000 (21:18 +0000)] 
Skip running a C program during cross compilation

When passing --cross-compile, one has to specify a --cross-answers file
and this test cannot be performed anyway, so skip it already.

Signed-off-by: Helmut Grohne <helmut@subdivi.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Make sure we delete the OU for movetest
Andreas Schneider [Wed, 8 Feb 2023 14:44:43 +0000 (15:44 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Add missing result checks for samba_tool.gpo tests
Andreas Schneider [Thu, 9 Feb 2023 17:32:59 +0000 (18:32 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Tell dns.resolver to not read /etc/resolv.conf
Andreas Schneider [Wed, 8 Feb 2023 11:21:10 +0000 (12:21 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Fix domain_backup test with Python 3.11
Andreas Schneider [Wed, 8 Feb 2023 10:16:12 +0000 (11:16 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Make sure we do not run into issues with already existing users
Andreas Schneider [Wed, 8 Feb 2023 09:17:05 +0000 (10:17 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Use a random machine name for computer_edit.sh test
Andreas Schneider [Wed, 8 Feb 2023 20:40:25 +0000 (21:40 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Correctly escape $ in computer_edit.sh
Andreas Schneider [Wed, 8 Feb 2023 20:37:06 +0000 (21:37 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Use a random username for contact_edit.sh test
Andreas Schneider [Wed, 8 Feb 2023 17:41:18 +0000 (18:41 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Correctly escape $ in contact_edit.sh
Andreas Schneider [Wed, 8 Feb 2023 17:40:04 +0000 (18:40 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Use a random username for user_edit.sh tests
Andreas Schneider [Wed, 8 Feb 2023 09:20:21 +0000 (10:20 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopython:tests: Correctly escape $ in user_edit.sh
Andreas Schneider [Wed, 8 Feb 2023 14:33:00 +0000 (15:33 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotestprogs: Use random user names for kpasswd tests
Andreas Schneider [Wed, 8 Feb 2023 07:30:56 +0000 (08:30 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotestprogs: Use random usernames for export keytab tests
Andreas Schneider [Wed, 8 Feb 2023 07:30:38 +0000 (08:30 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotestprogs: Use random usernames for kinit tests
Andreas Schneider [Wed, 8 Feb 2023 07:29:33 +0000 (08:29 +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@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotalloc: remove Python 2 #if clauses
Douglas Bagnall [Fri, 10 Feb 2023 02:53:10 +0000 (15:53 +1300)] 
talloc: remove Python 2 #if clauses

Also fix an obsolete related comment.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Feb 17 14:52:26 UTC 2023 on atb-devel-224

3 years agos4/wmi: begone
Douglas Bagnall [Fri, 10 Feb 2023 02:40:15 +0000 (15:40 +1300)] 
s4/wmi: begone

We don't use this and will never use this.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agolib:util: File descriptor being closed repeatedly.
baixiangcpp [Fri, 10 Feb 2023 03:01:47 +0000 (11:01 +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@gmail.com
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Feb 16 12:13:05 UTC 2023 on atb-devel-224

3 years agolib:ldb: Print a debug message in case we have a corrupted MDB
Andreas Schneider [Tue, 14 Feb 2023 15:31:18 +0000 (16:31 +0100)] 
lib:ldb: Print a debug message in case we have a corrupted MDB

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Feb 15 09:05:56 UTC 2023 on atb-devel-224

3 years agolib:ldb: Add the location to ldb_kv_parse_data_unpack() debug output
Andreas Schneider [Tue, 14 Feb 2023 15:30:36 +0000 (16:30 +0100)] 
lib:ldb: Add the location to ldb_kv_parse_data_unpack() debug output

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoctdb-scripts: Avoid using testparm to process its own output
Martin Schwenke [Mon, 13 Feb 2023 03:59:18 +0000 (14:59 +1100)] 
ctdb-scripts: Avoid using testparm to process its own output

When testparm processes the output of "testparm -v" (which includes
default values) it appears to do global checks (or some other sort of
initialisation logic) for all specified values.  This includes a DNS
lookup for the node's hostname, as a side-effect of a libldap
ldap_set_option() call when processing "ldap debug level".  If DNS
servers are down then this can induce timeouts, possibly resulting in
monitor timeouts.

Avoid this by using sed to extract configuration values from the
testparm cache file.

This is already shown to work when retrieving share paths, where
testparm is basically used as cat.  Update the sed pattern to avoid
matching empty values on the right-hand side of the equals ('=') -
this avoids the default empty path value (and "smb ports" never has an
empty value).

Corresponding test changes:

* 50.samba.monitor.111.sh no longer expects a failure from being
  unable to set smb ports, since testparm is no longer used in that
  code path.

* smb ports needs to be set in fake smb.conf so it is in the default
  output and can be extracted using sed.

* Although testparm --parameter-name is no longer used in
  50.samba.script, update the stub implementation (in case it is ever
  used again) to extract from fake smb.conf, since "smb ports" is now
  set there.  The change from $parameter to $param allows a long line
  to stay below 80 columns.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Feb 14 08:43:53 UTC 2023 on atb-devel-224

3 years agoctdb-scripts: Do not replace commas with spaces in "smb ports" list
Martin Schwenke [Tue, 14 Feb 2023 01:36:11 +0000 (12:36 +1100)] 
ctdb-scripts: Do not replace commas with spaces in "smb ports" list

The list changed back to space-separated in commit
93448f4be92d4e018aaf2f9705f0351360b2ed0f, so simplify the code a
little.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 years agoctdb-scripts: Reformat script with "shfmt -w -p -i 0 -fn"
Martin Schwenke [Mon, 13 Feb 2023 02:02:52 +0000 (13:02 +1100)] 
ctdb-scripts: Reformat script with "shfmt -w -p -i 0 -fn"

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 years agovfs: Fix whitespace in vfs_aixacl_util.c
Volker Lendecke [Tue, 7 Feb 2023 08:49:54 +0000 (09:49 +0100)] 
vfs: Fix whitespace in vfs_aixacl_util.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Feb 13 21:23:43 UTC 2023 on atb-devel-224

3 years agosmbd: Remove dptr_struct->expect_close
Volker Lendecke [Mon, 6 Feb 2023 20:40:38 +0000 (21:40 +0100)] 
smbd: Remove dptr_struct->expect_close

This was only set but never read

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Remove dptr_struct->spid
Volker Lendecke [Mon, 6 Feb 2023 20:36:51 +0000 (21:36 +0100)] 
smbd: Remove dptr_struct->spid

This was only set but never read

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Simplify SeekDir() with an early return
Volker Lendecke [Thu, 2 Feb 2023 16:01:16 +0000 (17:01 +0100)] 
smbd: Simplify SeekDir() with an early return

Review with git show -w

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Simplify struct dptr_struct
Volker Lendecke [Thu, 2 Feb 2023 11:52:32 +0000 (12:52 +0100)] 
smbd: Simplify struct dptr_struct

We can access the file name via "dir_hnd"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolib: Fix a typo
Volker Lendecke [Thu, 2 Feb 2023 11:28:56 +0000 (12:28 +0100)] 
lib: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolib: Simplify ms_has_wild() with strpbrk()
Volker Lendecke [Thu, 2 Feb 2023 11:25:05 +0000 (12:25 +0100)] 
lib: Simplify ms_has_wild() with strpbrk()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Use ISDOT() in dptr_create()
Volker Lendecke [Thu, 2 Feb 2023 11:19:46 +0000 (12:19 +0100)] 
smbd: Use ISDOT() in dptr_create()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agovfs_ceph: use fsp_get_pathref_fd in ceph fstatat and close vfs calls
John Mulligan [Fri, 3 Feb 2023 18:09:18 +0000 (13:09 -0500)] 
vfs_ceph: use fsp_get_pathref_fd in ceph fstatat and close vfs calls

Replace fsp_get_io_fd with fsp_get_pathref_fd as these calls do use
pathref fsps. fsp_get_io_fd asserts that the fsp is not pathref and
asserts (on a debug build) or returns -1 (non debug build).

Prior to these changes running ls on the root of the share failed.
Logging from the failure case:
```
openat_pathref_fsp: smb_fname [.]
openat_pathref_fullname: smb_fname [.]
fsp_new: allocated files structure (1 used)
file_name_hash: //. hash 0x3dfcc1c2
check_reduced_name: check_reduced_name [.] [/]
cephwrap_realpath: [CEPH] realpath(0x55604da9a030, .) = //.
check_reduced_name realpath [.] -> [//.]
check_reduced_name: . reduced to //.
cephwrap_openat: [CEPH] openat(0x55604da9a030, ., 0x55604da81f00, 133120, 0)
cephwrap_openat: [CEPH] open(...) = 10
cephwrap_fstat: fsp_get_io_fd: fsp [.] is a path referencing fsp
[CEPH] fstat(0x55604da9a030, -1)
fsp_get_io_fd: fsp [.] is a path referencing fsp
cephwrap_fstat: [CEPH] fstat(...) = -9
fd_openat: name ., flags = 04000 mode = 00, fd = 10.  NT_STATUS_INVALID_HANDLE
openat_pathref_fullname: Opening pathref for [.] failed: NT_STATUS_INVALID_HANDLE
```

This change also seems to match the recommendations in the `When to use
fsp_get_io_fd() or fsp_get_pathref_fd()` section of The_New_VFS.txt
document.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15307

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Gunther Deschner <gdeschne@redhat.com>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Feb 13 20:04:38 UTC 2023 on atb-devel-224

3 years agoAdd gitleaks configuration file to avoid false positives
Pavel Filipenský [Fri, 3 Feb 2023 10:29:37 +0000 (11:29 +0100)] 
Add gitleaks configuration file to avoid false positives

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Mon Feb 13 18:45:21 UTC 2023 on atb-devel-224

3 years agosmbd: Remove smbXsrv_open_global0->db_rec
Volker Lendecke [Wed, 11 Jan 2023 10:02:11 +0000 (11:02 +0100)] 
smbd: Remove smbXsrv_open_global0->db_rec

The only user by now was net serverid wipedbs, and there it was easy to replace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Feb 13 10:49:43 UTC 2023 on atb-devel-224

3 years agosmbd: Use dbwrap_do_locked() in smb2srv_open_recreate()
Volker Lendecke [Wed, 11 Jan 2023 09:54:37 +0000 (10:54 +0100)] 
smbd: Use dbwrap_do_locked() in smb2srv_open_recreate()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: rename 'op' into 'global' in smbXsrv_open_cleanup_fn()
Stefan Metzmacher [Tue, 31 Jan 2023 11:39:06 +0000 (12:39 +0100)] 
smbd: rename 'op' into 'global' in smbXsrv_open_cleanup_fn()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 years agosmbd: let smbXsrv_open_cleanup() delete broken records
Volker Lendecke [Tue, 10 Jan 2023 11:29:18 +0000 (12:29 +0100)] 
smbd: let smbXsrv_open_cleanup() delete broken records

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Use dbwrap_do_locked() in smbXsrv_open_cleanup()
Volker Lendecke [Tue, 10 Jan 2023 11:29:18 +0000 (12:29 +0100)] 
smbd: Use dbwrap_do_locked() in smbXsrv_open_cleanup()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Use dbwrap_do_locked() in smbXsrv_open_close()
Volker Lendecke [Tue, 10 Jan 2023 10:59:07 +0000 (11:59 +0100)] 
smbd: Use dbwrap_do_locked() in smbXsrv_open_close()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Use dbwrap_do_locked() in smbXsrv_open_update()
Volker Lendecke [Sun, 8 Jan 2023 20:04:25 +0000 (21:04 +0100)] 
smbd: Use dbwrap_do_locked() in smbXsrv_open_update()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Use dbwrap_do_locked() in smbXsrv_open_global_allocate()
Volker Lendecke [Thu, 26 Jan 2023 08:08:27 +0000 (09:08 +0100)] 
smbd: Use dbwrap_do_locked() in smbXsrv_open_global_allocate()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Make smbXsrv_open_global_allocate() store the record
Volker Lendecke [Fri, 6 Jan 2023 16:12:23 +0000 (17:12 +0100)] 
smbd: Make smbXsrv_open_global_allocate() store the record

Micro-step towards using dbwrap_do_locked()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Simplify smbXsrv_open_global_store()
Volker Lendecke [Thu, 5 Jan 2023 15:18:37 +0000 (16:18 +0100)] 
smbd: Simplify smbXsrv_open_global_store()

Avoid the dependency on global->db_rec. This makes the callers more
verbose, but it makes the data dependencies much more obvious. This
will enable removing smbXsrv_open_global0->db_rec at some point.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Move smbXsrv_open_global_verify_record() down in smbXsrv_open.c
Volker Lendecke [Thu, 26 Jan 2023 07:46:31 +0000 (08:46 +0100)] 
smbd: Move smbXsrv_open_global_verify_record() down in smbXsrv_open.c

Avoid prototypes

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Use generate_nonce_buffer() in smbXsrv_open_global_allocate()
Volker Lendecke [Fri, 6 Jan 2023 15:46:11 +0000 (16:46 +0100)] 
smbd: Use generate_nonce_buffer() in smbXsrv_open_global_allocate()

We don't need anything cryptographic for persistent file handle ids

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agos3: smbd: Fix log spam. Change a normal error message from DBG_ERR (level 0) to DBG_I...
Jeremy Allison [Wed, 8 Feb 2023 01:51:10 +0000 (17:51 -0800)] 
s3: smbd: Fix log spam. Change a normal error message from DBG_ERR (level 0) to DBG_INFO (level 5).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15302

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sat Feb 11 08:48:05 UTC 2023 on atb-devel-224

3 years agogp: gp_sudoers_ext warn w/out visudo installed
David Mulder [Thu, 9 Feb 2023 17:43:42 +0000 (10:43 -0700)] 
gp: gp_sudoers_ext warn w/out visudo installed

Rather than print an ugly error message from
Popen, display a warning to the user if visudo
is missing.

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): David Mulder <dmulder@samba.org>
Autobuild-Date(master): Fri Feb 10 20:31:37 UTC 2023 on atb-devel-224

3 years agogp: Log ext failure with file and line number
David Mulder [Thu, 9 Feb 2023 17:34:24 +0000 (10:34 -0700)] 
gp: Log ext failure with file and line number

Rather than dumping a traceback when there is a
failure, simply log the file name, line number
and the error message instead. This is much
cleaner.

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agos4-auth: Free user_info_dc in KDC caller to authsam_update_user_info_dc()
Andrew Bartlett [Tue, 7 Feb 2023 21:59:56 +0000 (10:59 +1300)] 
s4-auth: Free user_info_dc in KDC caller to authsam_update_user_info_dc()

It is up to the caller to choose if it wants to clean up the user_info_dc
memory early, we do so only in the KDC as was allocated on a context
provided to samba_kdc_update_pac_blob(), whereas auth_winbind uses
a locally managed tevent state as the memory context.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Feb  8 01:05:47 UTC 2023 on atb-devel-224

3 years agoauth: Free empty SID arrays
Joseph Sutton [Wed, 21 Dec 2022 23:50:26 +0000 (12:50 +1300)] 
auth: Free empty SID arrays

In the unlikely event that these arrays are empty, they can be freed
early.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Use consistent ordering for etypes
Joseph Sutton [Mon, 19 Dec 2022 00:43:08 +0000 (13:43 +1300)] 
tests/krb5: Use consistent ordering for etypes

The 'etype' field in a Kerberos request is ordered. Make this fact
clearer by using a tuple or an array to represent etypes rather than a
set.

get_default_enctypes() now returns encryption types in order of
strength. As a consequence, the encryption type chosen by the MIT KDC
matches up with that chosen by Windows, and more tests begin to pass.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Discard non-base SIDs when creating SamInfo2
Joseph Sutton [Thu, 15 Dec 2022 01:07:06 +0000 (14:07 +1300)] 
auth: Discard non-base SIDs when creating SamInfo2

Our SamLogon tests are now all passing.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Test groups returned by SamLogon
Joseph Sutton [Thu, 15 Dec 2022 01:06:59 +0000 (14:06 +1300)] 
tests/krb5: Test groups returned by SamLogon

Levels NetlogonValidationSamInfo2 and NetlogonValidationSamInfo4 behave
as might be expected, so we pass those tests. NetlogonValidationSamInfo
returns no resource groups and doesn't set the NETLOGON_EXTRA_SIDS flag,
and we fail its test.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Return validation structure from _test_samlogon()
Joseph Sutton [Wed, 14 Dec 2022 23:32:02 +0000 (12:32 +1300)] 
tests/krb5: Return validation structure from _test_samlogon()

This lets us check the groups that are returned.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Allow tests to set SamLogon validation level
Joseph Sutton [Wed, 14 Dec 2022 23:17:13 +0000 (12:17 +1300)] 
tests/krb5: Allow tests to set SamLogon validation level

We'll want to test various levels to ensure they all behave as expected.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Move _test_samlogon() to base class
Joseph Sutton [Wed, 14 Dec 2022 23:16:00 +0000 (12:16 +1300)] 
tests/krb5: Move _test_samlogon() to base class

We'll want to make use of it in the group tests.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4/dsdb/samldb: Disallow setting a domain-local group as a primary group
Joseph Sutton [Thu, 22 Dec 2022 02:54:14 +0000 (15:54 +1300)] 
s4/dsdb/samldb: Disallow setting a domain-local group as a primary group

Windows also disallows this. Note that changing a primary group to a
domain-local group is allowed by both Windows and Samba.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoselftest: Expect setting domain-local group as primary group to fail
Joseph Sutton [Thu, 22 Dec 2022 18:29:58 +0000 (07:29 +1300)] 
selftest: Expect setting domain-local group as primary group to fail

This will no longer be allowed.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Correct primary group handling
Joseph Sutton [Mon, 12 Dec 2022 20:04:47 +0000 (09:04 +1300)] 
auth: Correct primary group handling

Heretofore we have treated the primary group SID specially, storing it
in a fixed position as the second element of the user_info_dc->sids
array, and filtering out other copies in the PAC_LOGON_INFO base
structure. This filtering has made it difficult to distinguish between
the case where the primary group is a universal or global group, located
in the base RIDs, and the case where it is a domain-local group, missing
from the base RIDs; especially since the attributes of a domain-local
primary group are lost by being stored in the PAC. Domain-local primary
groups are normally disallowed by Windows, but are allowed by Samba, and
so it is reasonable to support them with at least some measure of
consistency.

The second element of user_info_dc->sids is still reserved for the
primary group's SID, but we no longer filter out any other copies in the
array. The first two elements are no more than the SIDs of the user and
the primary group respectively; and the remaining SIDs are as if taken
without modification from arrays of SIDs in the PAC. user_info_dc->sids
should therefore become a more faithful representation of the SIDs in
the PAC. After adding resource SIDs to it with
dsdb_expand_resource_groups(), we should have a result that more closely
and in more cases matches that of Windows.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4-dsdb: Use correct primary group SID in token group test
Joseph Sutton [Thu, 15 Dec 2022 23:41:50 +0000 (12:41 +1300)] 
s4-dsdb: Use correct primary group SID in token group test

This test will thereby continue to pass when we correct the handling of
primary groups.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:torture: Remove assertion that primary group is not duplicated in user_info_dc
Joseph Sutton [Thu, 15 Dec 2022 23:47:02 +0000 (12:47 +1300)] 
s4:torture: Remove assertion that primary group is not duplicated in user_info_dc

This assertion is one we will be breaking shortly.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Add tests for the primary group
Joseph Sutton [Thu, 15 Dec 2022 23:47:41 +0000 (12:47 +1300)] 
tests/krb5: Add tests for the primary group

Primary groups are handled differently from normal groups of which a
user is simply a member. Of particular note is the case where a
domain-local group is made a primary group; a case normally disallowed
by Windows, but not by Samba. Therefore we want tests for it.

Our testing framework must be able to set the user's primary group, and
to clean up afterwards; to set the primary group RID of a PAC; and to
check that the primary group RID is as expected in the PAC returned to
us.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Align integer types
Joseph Sutton [Thu, 15 Dec 2022 23:52:51 +0000 (12:52 +1300)] 
auth: Align integer types

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4-dsdb: Simplify search expression
Joseph Sutton [Thu, 15 Dec 2022 23:45:29 +0000 (12:45 +1300)] 
s4-dsdb: Simplify search expression

We want to find objects for which the groupType attribute has at least
one of GROUP_TYPE_ACCOUNT_GROUP and GROUP_TYPE_UNIVERSAL_GROUP set. For
this the OR comparator is perfectly suited. It produces a true result if
at least one set bit is shared between both operands.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoldap: Make use of LDB_OID_COMPARATOR constants
Joseph Sutton [Fri, 16 Dec 2022 01:24:18 +0000 (14:24 +1300)] 
ldap: Make use of LDB_OID_COMPARATOR constants

These constants allow one to tell at a glance what search operation is
being performed.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoldap: Cut down on string substitution
Joseph Sutton [Thu, 15 Dec 2022 23:41:03 +0000 (12:41 +1300)] 
ldap: Cut down on string substitution

Constant strings can be inserted directly into format strings, reducing
the amount of string substitution to be performed.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Make more liberal use of SID index constants
Joseph Sutton [Thu, 15 Dec 2022 23:08:41 +0000 (12:08 +1300)] 
auth: Make more liberal use of SID index constants

Arrays of SIDs are handled not fully consistently throughout the
codebase. Sometimes SIDs in the first and second positions represent a
user and a primary group respectively; other times they don't mean
anything in particular. Using these index constants in situations of the
former sort can help to clarify our intent.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Shorten long SID flags combinations
Joseph Sutton [Wed, 14 Dec 2022 22:58:11 +0000 (11:58 +1300)] 
auth: Shorten long SID flags combinations

The combination MANDATORY | ENABLED_BY_DEFAULT | ENABLED is very
commonly used, and introducing a shorter alias for it makes the code
clearer.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:kdc: Add resource SID compression
Joseph Sutton [Thu, 1 Dec 2022 21:49:20 +0000 (10:49 +1300)] 
s4:kdc: Add resource SID compression

The domain-local groups that are added to the PAC of a service ticket
are now, if the service doesn't disclaim support for SID compression,
placed into the resource groups structure in PAC_LOGON_INFO.

In a TGS exchange directed to a KDC, rather than to a service, the
resource groups structure is simply copied into the updated PAC without
any processing being done.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Pass through entire PAC flags value in auth_user_info
Joseph Sutton [Sun, 11 Dec 2022 21:50:01 +0000 (10:50 +1300)] 
auth: Pass through entire PAC flags value in auth_user_info

Besides the NETLOGON_GUEST bit indicating whether the user has been
authenticated, we now carry all of the other bits as well. This lets us
match Windows' behaviour of simply passing these bits through to an
updated PAC when processing a TGS-REQ.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agonamed_pipe_auth: Bump info5 to info6
Joseph Sutton [Thu, 22 Dec 2022 04:48:26 +0000 (17:48 +1300)] 
named_pipe_auth: Bump info5 to info6

In the next commit, we shall replace the 'authenticated' field of
named_pipe_auth_req_info.info5.session_info.session_info.info with a
more general 'user_flags' field.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:torture: Make use of torture_assert_sid_equal()
Joseph Sutton [Sun, 11 Dec 2022 21:28:45 +0000 (10:28 +1300)] 
s4:torture: Make use of torture_assert_sid_equal()

This macro produces a slightly more useful message if the assertion
fails.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Add tests of NETLOGON_RESOURCE_GROUPS flag handling
Joseph Sutton [Sun, 11 Dec 2022 22:20:18 +0000 (11:20 +1300)] 
tests/krb5: Add tests of NETLOGON_RESOURCE_GROUPS flag handling

This lets us test what happens in TGS-REQ exchanges to the KDC, when the
flags and resource groups are simply passed through into the new PAC,
regardless of what value the flags hold.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Allow setting or resetting PAC flags
Joseph Sutton [Sun, 11 Dec 2022 22:08:28 +0000 (11:08 +1300)] 
tests/krb5: Allow setting or resetting PAC flags

This lets us test what happens when the flags in the PAC, such as
NETLOGON_RESOURCE_GROUPS, are given "interesting" values.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Add group tests simulating PACs from a trusted domain
Joseph Sutton [Sun, 11 Dec 2022 22:20:53 +0000 (11:20 +1300)] 
tests/krb5: Add group tests simulating PACs from a trusted domain

Crucially, in these tests the user's domain and its SID are different
from our domain and its SID. These tests will assert that in such a case
resource groups are added to the PAC and handled correctly.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Allow changing the SID of a user's PAC
Joseph Sutton [Sun, 11 Dec 2022 22:05:05 +0000 (11:05 +1300)] 
tests/krb5: Allow changing the SID of a user's PAC

This lets us simulate a ticket of a user from another domain.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Add some more test cases for PAC group handling
Joseph Sutton [Sun, 11 Dec 2022 22:17:19 +0000 (11:17 +1300)] 
tests/krb5: Add some more test cases for PAC group handling

Change some of the attributes in TGS-REQ PACs to ensure they are handled
correctly.

Add a test of a PAC containing resource SIDs for a service without
resource SID compression support, ensuring the SIDs are correctly
removed.

Add a Samba 4.17 compatibility test for a service with resource SID
compression support.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Improve assertion failure message
Joseph Sutton [Sun, 11 Dec 2022 22:02:29 +0000 (11:02 +1300)] 
tests/krb5: Improve assertion failure message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Remove tests of KDCs without resource SID compression support
Joseph Sutton [Sun, 11 Dec 2022 21:57:42 +0000 (10:57 +1300)] 
tests/krb5: Remove tests of KDCs without resource SID compression support

As part of mitigations of CVE-2022-37966, we no longer regard the
msDS-SupportedEncryptionTypes attribute of the KDC when determining its
supported encryption types. Thus, these tests that try to disable SID
compression support by setting this attribute run to no purpose.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4: Add 'const' to some parameters
Joseph Sutton [Mon, 7 Nov 2022 01:14:18 +0000 (14:14 +1300)] 
s4: Add 'const' to some parameters

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4-dsdb: Make sid_list_match() static
Joseph Sutton [Mon, 7 Nov 2022 01:23:26 +0000 (14:23 +1300)] 
s4-dsdb: Make sid_list_match() static

It's not used anywhere other than this file.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4-dsdb: Check for talloc failure in dsdb_expand_nested_groups()
Joseph Sutton [Mon, 7 Nov 2022 01:32:23 +0000 (14:32 +1300)] 
s4-dsdb: Check for talloc failure in dsdb_expand_nested_groups()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Only process resource groups if NETLOGON_RESOURCE_GROUPS flag is set
Joseph Sutton [Mon, 7 Nov 2022 06:27:24 +0000 (19:27 +1300)] 
auth: Only process resource groups if NETLOGON_RESOURCE_GROUPS flag is set

MS-PAC section 2.5 states that if the resource_groups member is
non-NULL, or resource_groups.groups.count is not zero, the
NETLOGON_RESOURCE_GROUPS flag MUST be set. Thus, there's no need to
process resource groups if the flag is not set.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Remove early return from make_user_info_dc_pac()
Joseph Sutton [Mon, 7 Nov 2022 06:37:12 +0000 (19:37 +1300)] 
auth: Remove early return from make_user_info_dc_pac()

'rg' is never NULL, so this codepath is never taken. But if it were, we
would return early and entirely neglect filling in the UPN_DNS_INFO from
the 'pac_upn_dns_info' parameter. So remove the early return.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Exclude resource groups from a TGT
Joseph Sutton [Tue, 27 Sep 2022 01:51:54 +0000 (14:51 +1300)] 
auth: Exclude resource groups from a TGT

Resource group SIDs should only be placed into a service ticket, but we
were including them in all tickets. Now that we have access to the group
attributes, we'll filter out any groups with SE_GROUP_RESOURCE set if
we're creating a TGT.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:torture: Assert that group attributes match
Joseph Sutton [Tue, 8 Nov 2022 00:34:14 +0000 (13:34 +1300)] 
s4:torture: Assert that group attributes match

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth: Store group attributes in auth_user_info_dc
Joseph Sutton [Tue, 27 Sep 2022 02:13:12 +0000 (15:13 +1300)] 
auth: Store group attributes in auth_user_info_dc

Group expansion, performed in dsdb_expand_nested_groups(), now
incorporates a check of the type of each group. Those that are resource
groups receive the SE_GROUP_RESOURCE bit in the attributes which are now
carried alongside each group SID.

Whereas before, in auth_convert_user_info_dc_sambaseinfo() and
auth_convert_user_info_dc_saminfo6(), we invariantly used the flag
combination SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT |
SE_GROUP_ENABLED to set attributes in the PAC, we now take the correct
attributes from user_info_dc.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4-dsdb: Add samdb_result_dom_sid_attrs()
Joseph Sutton [Mon, 7 Nov 2022 01:28:21 +0000 (14:28 +1300)] 
s4-dsdb: Add samdb_result_dom_sid_attrs()

This function is modelled on samdb_result_dom_sid(). It allocates,
rather than a dom_sid, an auth_SidAttr object, which we can pass to
other functions accepting an auth_SidAttr.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agolibcli/security: Add auth_SidAttr utility functions
Joseph Sutton [Tue, 27 Sep 2022 02:12:52 +0000 (15:12 +1300)] 
libcli/security: Add auth_SidAttr utility functions

These functions are modelled on add_sid_to_array() and
add_sid_to_array_unique(). They differ in that they operate not on an
array of dom_sid, but of auth_SidAttr, and take an additional 'attrs'
parameter of type uint32_t.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoauth.idl: Add auth_SidAttr type
Joseph Sutton [Tue, 27 Sep 2022 02:12:19 +0000 (15:12 +1300)] 
auth.idl: Add auth_SidAttr type

This type incorporates, alongside a SID, a group attributes member,
through which attributes from a PAC or the AD database can be conveyed
into the completed PAC. A useful benefit this provides is the ability to
distinguish and exclude domain-local groups, which only belong in
service tickets, from the PAC of a TGT.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:torture: Skip over asserted identity SIDs when comparing groups
Joseph Sutton [Tue, 8 Nov 2022 00:34:07 +0000 (13:34 +1300)] 
s4:torture: Skip over asserted identity SIDs when comparing groups

We've already tested for the existence of these SIDs, and the assumption
that they are always the last element in a PAC is false. We must check
all the SIDs in each array, skipping over ones that were found to be
asserted identity SIDS.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:torture: Zero-initialise netr_NetworkInfo structure
Joseph Sutton [Tue, 8 Nov 2022 00:33:25 +0000 (13:33 +1300)] 
s4:torture: Zero-initialise netr_NetworkInfo structure

This ensures that no members contain garbage data.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Declare supported encryption types of service account
Joseph Sutton [Sun, 11 Dec 2022 22:01:20 +0000 (11:01 +1300)] 
tests/krb5: Declare supported encryption types of service account

If SID compression support is disabled for a created account,
msDS-SupportedEncryptionTypes will be set to a value that includes the
RESOURCE_SID_COMPRESSION_DISABLED bit, but no actual encryption type
bits. Since stricter encryption type handling was introduced to address
CVE-2022-37966, this combination has been interpreted as an expression
of no encryption type support, and trying to make a Kerberos request to
a service with such a combination of bits will fail with
ERR_ETYPE_NOSUPP.

To allow us to make Kerberos requests to test service accounts again, we
must set some actual encryption type bits.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agowaf: Add support for MemorySanitizer
Andreas Schneider [Fri, 3 Feb 2023 12:43:16 +0000 (13:43 +0100)] 
waf: Add support for MemorySanitizer

This currently only works with binaries. As there is no shared library for
MSAN it only is statically linked against binaries. This means if we have e.g.
a python script trying to load ldb, it will fail with undefined symbols.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Feb  6 23:49:04 UTC 2023 on atb-devel-224

3 years agos3:torture: Remove unused variable
Andreas Schneider [Fri, 3 Feb 2023 19:37:58 +0000 (20:37 +0100)] 
s3:torture: Remove unused variable

source3/torture/test_smb1_dfs.c:3264:11: error: variable 'accessmode' set but
not used [-Werror,-Wunused-but-set-variable]
        uint16_t accessmode = 0;
                 ^

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agos3:utils: Remove unused variable
Andreas Schneider [Fri, 3 Feb 2023 19:35:20 +0000 (20:35 +0100)] 
s3:utils: Remove unused variable

source3/utils/log2pcaphex.c:138:13: error: variable 'i' set but not used
[-Werror,-Wunused-but-set-variable]
        static int i = 0;
                   ^

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>