]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
2 years agos3-librpc: merge two PIDL lists
Günther Deschner [Thu, 14 Mar 2024 14:22:25 +0000 (15:22 +0100)] 
s3-librpc: merge two PIDL lists

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb_dn: make LDB_FREE, TALLOC_FREE
Douglas Bagnall [Fri, 15 Mar 2024 10:29:34 +0000 (23:29 +1300)] 
ldb_dn: make LDB_FREE, TALLOC_FREE

This LDB_FREE() seems to predate TALLOC_FREE(), and was identical
until TALLOC_FREE was optimised to avoid calling talloc_free(NULL) in
b9fcfc6399eab750880ee0b9806311dd351a8ff6.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopyldb: ldb_msg_richcmp: avoid one intransitive compare
Douglas Bagnall [Fri, 15 Mar 2024 02:47:55 +0000 (15:47 +1300)] 
pyldb: ldb_msg_richcmp: avoid one intransitive compare

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb:ldb_dn: use safe transitive comparison in ldb_dn_compare()
Douglas Bagnall [Fri, 15 Mar 2024 02:03:44 +0000 (15:03 +1300)] 
ldb:ldb_dn: use safe transitive comparison in ldb_dn_compare()

The comparison we make is unconventional, and makes no difference in
normal usage, where we just want to know whether two DNs are the same
or not. But with over 100 callers, it is possible that something
somewhere is attempting a sort.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopyldb: add a FIXME for a non-transitive compare
Douglas Bagnall [Thu, 14 Mar 2024 03:36:07 +0000 (16:36 +1300)] 
pyldb: add a FIXME for a non-transitive compare

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopyldb_utils: pyldb_Object_AsDn() sets TypeError more often
Douglas Bagnall [Thu, 14 Mar 2024 23:12:26 +0000 (12:12 +1300)] 
pyldb_utils: pyldb_Object_AsDn() sets TypeError more often

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb:pyldb.h: include some headers that are used
Douglas Bagnall [Thu, 7 Mar 2024 09:29:10 +0000 (22:29 +1300)] 
ldb:pyldb.h: include some headers that are used

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib/ldb: don't allow repeated connections
Douglas Bagnall [Tue, 19 Mar 2024 23:18:12 +0000 (12:18 +1300)] 
lib/ldb: don't allow repeated connections

In the best case, this would have leaked.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb:pytests: test duplicate connections fail
Douglas Bagnall [Wed, 6 Mar 2024 22:09:39 +0000 (11:09 +1300)] 
ldb:pytests: test duplicate connections fail

(they don't yet).

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb-samba:ldb_wrap: don't crash if "ldb_url" opaque is unset
Douglas Bagnall [Wed, 6 Mar 2024 22:07:20 +0000 (11:07 +1300)] 
ldb-samba:ldb_wrap: don't crash if "ldb_url" opaque is unset

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopyldb: py_ldb_init() uses py_ldb_connect() for connecting
Douglas Bagnall [Tue, 5 Mar 2024 23:57:15 +0000 (23:57 +0000)] 
pyldb: py_ldb_init() uses py_ldb_connect() for connecting

To avoid all the same logic, subtly different.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopyldb: catch errors in ldb_db_get_casefold
Douglas Bagnall [Thu, 7 Mar 2024 22:02:23 +0000 (11:02 +1300)] 
pyldb: catch errors in ldb_db_get_casefold

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest:segfault: do not assume PLEASE_NO_GDB_BACKTRACE var is unset
Douglas Bagnall [Thu, 14 Mar 2024 01:48:23 +0000 (14:48 +1300)] 
pytest:segfault: do not assume PLEASE_NO_GDB_BACKTRACE var is unset

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest:segfault: prevent @no_gdb_backtrace smearing on exception
Douglas Bagnall [Wed, 6 Mar 2024 22:05:55 +0000 (11:05 +1300)] 
pytest:segfault: prevent @no_gdb_backtrace smearing on exception

It is OK for one of these tests to raise an exception -- that is often
the only reasonable thing to do when you'd otherwise crash -- but the
@no_gdb_backtrace decorator would not clean up in that case, leading to
no gdb backtraces for all subsequent tests.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoselftest: Run samba.tests.segfault with TALLOC_FREE_FILL
Andrew Bartlett [Sun, 3 Dec 2023 21:34:57 +0000 (10:34 +1300)] 
selftest: Run samba.tests.segfault with TALLOC_FREE_FILL

This helps make use-after-free testing reliable.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2 years agopy:samdb: make SamDB.__str__ show the URL and ID
Douglas Bagnall [Thu, 14 Mar 2024 01:15:47 +0000 (14:15 +1300)] 
py:samdb: make SamDB.__str__ show the URL and ID

Getting the right samdb is going to matter more, so it is useful for
debugging to see which is which.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoselftest/gdb_backtrace: print `info threads` and some signpost headers
Douglas Bagnall [Tue, 12 Mar 2024 23:25:40 +0000 (12:25 +1300)] 
selftest/gdb_backtrace: print `info threads` and some signpost headers

Search for '###'.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoselftest/gdb_backtrace: avoid printing backtrace twice with 1 thread
Douglas Bagnall [Thu, 7 Mar 2024 10:13:56 +0000 (23:13 +1300)] 
selftest/gdb_backtrace: avoid printing backtrace twice with 1 thread

We call 'thread apply all bt full' in case there are interesting
things going on in other threads, but often there are no other threads
and it only serves to repeat the original trace (and very slowly, for
some reason).

The $_inferior_thread_count convenience variable is new in gdb 13.1
(2022-ish) so we init-if-undefined it to default to the old behaviour.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoselftest/gdb_backtrace: print python traceback if available
Douglas Bagnall [Thu, 7 Mar 2024 09:30:24 +0000 (22:30 +1300)] 
selftest/gdb_backtrace: print python traceback if available

If a program happens to have 'PyList_New' defined but is not a python
script, gdb will print

> Undefined command: "py-bt".  Try "help".

and probably stop. This happens after the C backtraces have been
printed, so nothing is lost.

The traceback is printed twice -- once in conventional Python style
for clarity, and once with extra "full" information.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests: gmsa blackbox tests
Rob van der Linde [Thu, 29 Feb 2024 22:22:03 +0000 (11:22 +1300)] 
tests: gmsa blackbox tests

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Mar 20 04:53:57 UTC 2024 on atb-devel-224

2 years agotests: models: test additional Computer constructor cases
Rob van der Linde [Wed, 6 Mar 2024 03:52:53 +0000 (16:52 +1300)] 
tests: models: test additional Computer constructor cases

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests: models: fix username should be account_name
Rob van der Linde [Wed, 6 Mar 2024 03:49:21 +0000 (16:49 +1300)] 
tests: models: fix username should be account_name

The reason this didn't fail, is because it doesn't save the Computers.

This gets fixed in the next commit.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests: user: create gmsa with models
Rob van der Linde [Tue, 5 Mar 2024 03:39:33 +0000 (16:39 +1300)] 
tests: user: create gmsa with models

It was fetching the GMSA with the models straight after creating it anyway.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests: user: fix PEP8 spacing around operator
Rob van der Linde [Tue, 5 Mar 2024 03:20:52 +0000 (16:20 +1300)] 
tests: user: fix PEP8 spacing around operator

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests: user: gmsa dNSHostName is a required field
Rob van der Linde [Mon, 4 Mar 2024 23:14:06 +0000 (12:14 +1300)] 
tests: user: gmsa dNSHostName is a required field

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests: samdb: Make use of the domain_sid property
Rob van der Linde [Wed, 28 Feb 2024 04:00:24 +0000 (17:00 +1300)] 
tests: samdb: Make use of the domain_sid property

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: fix json encoder should handle Exception
Rob van der Linde [Tue, 19 Mar 2024 20:50:49 +0000 (09:50 +1300)] 
python: fix json encoder should handle Exception

This happens if --json is used and a CommandError is raised, so will affect other commands too where --json is used.

This happens in the print_json_status method.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: models: add Container model
Rob van der Linde [Wed, 13 Mar 2024 10:07:52 +0000 (23:07 +1300)] 
python: models: add Container model

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: models: add kwargs to __json__ and as_dict methods
Rob van der Linde [Wed, 13 Mar 2024 09:20:39 +0000 (22:20 +1300)] 
python: models: add kwargs to __json__ and as_dict methods

Allows passing arguments through

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: pep8: fix import sorting after move
Rob van der Linde [Wed, 13 Mar 2024 07:59:27 +0000 (20:59 +1300)] 
python: pep8: fix import sorting after move

Only touch files where samba.domain.models import was moved

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: move models out of the netcmd package
Rob van der Linde [Tue, 12 Mar 2024 03:47:58 +0000 (16:47 +1300)] 
python: move models out of the netcmd package

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: create domain module to move models into
Rob van der Linde [Tue, 12 Mar 2024 03:28:07 +0000 (16:28 +1300)] 
python: create domain module to move models into

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: gmsa: show viewers also works if SID is not found
Rob van der Linde [Tue, 12 Mar 2024 00:06:31 +0000 (13:06 +1300)] 
netcmd: gmsa: show viewers also works if SID is not found

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: gmsa: add and remove don't fetch trustee if it is a SID
Rob van der Linde [Mon, 11 Mar 2024 23:40:12 +0000 (12:40 +1300)] 
netcmd: gmsa: add and remove don't fetch trustee if it is a SID

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: gmsa: add_trustee and remove_trustee change argument to sid
Rob van der Linde [Mon, 11 Mar 2024 23:38:13 +0000 (12:38 +1300)] 
netcmd: gmsa: add_trustee and remove_trustee change argument to sid

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: gmsa: fix typo if trustee is not found
Rob van der Linde [Mon, 11 Mar 2024 23:33:30 +0000 (12:33 +1300)] 
netcmd: gmsa: fix typo if trustee is not found

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: gmsa: create should allow custom SDDL
Rob van der Linde [Mon, 4 Mar 2024 23:04:49 +0000 (12:04 +1300)] 
netcmd: gmsa: create should allow custom SDDL

gMSA update already supported it but not create

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: models: improve Computer constructor adding "$" handling
Rob van der Linde [Wed, 6 Mar 2024 03:47:29 +0000 (16:47 +1300)] 
netcmd: models: improve Computer constructor adding "$" handling

In some cases the previous code would end up creating computers where the account name ended on double "$"

Rewrote constructor to handle more cases, for example only an account name is provided, only a name is provided, or both.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: models: allow scope to be overridden in query
Rob van der Linde [Mon, 11 Mar 2024 23:13:09 +0000 (12:13 +1300)] 
netcmd: models: allow scope to be overridden in query

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: models: add User.get_sid_for_principal helper
Rob van der Linde [Mon, 11 Mar 2024 23:23:36 +0000 (12:23 +1300)] 
netcmd: models: add User.get_sid_for_principal helper

Unlike User.find, this will not fetch the User if an SID is provided.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonetcmd: models: User.find also tries object_sid
Rob van der Linde [Tue, 5 Mar 2024 02:30:47 +0000 (15:30 +1300)] 
netcmd: models: User.find also tries object_sid

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: samdb: Make connecting_user_sid a property
Rob van der Linde [Wed, 28 Feb 2024 03:59:06 +0000 (16:59 +1300)] 
python: samdb: Make connecting_user_sid a property

This is following the same design as other similar properties like samdb.domain_sid, only it doesn't need a setter.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: samdb: Move get_connecting_user_sid to samdb
Rob van der Linde [Wed, 28 Feb 2024 03:57:40 +0000 (16:57 +1300)] 
python: samdb: Move get_connecting_user_sid to samdb

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: check again for NULL values
Douglas Bagnall [Sun, 17 Mar 2024 10:08:23 +0000 (23:08 +1300)] 
libcli/security: check again for NULL values

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Mar 18 02:51:08 UTC 2024 on atb-devel-224

2 years agolibcli/security: claims_conversions: check for NULL in claims array
Douglas Bagnall [Sun, 17 Mar 2024 10:07:17 +0000 (23:07 +1300)] 
libcli/security: claims_conversions: check for NULL in claims array

If by mistake we end up with a NULL in our array of claims pointers,
it is better to return an error than crash.

There can be NULLs in the array if a resource attribute ACE has a
claim that uses 0 as a relative data pointer. Samba assumes this means
a NULL pointer, rather than a zero offset.

Credit to OSS-Fuzz.

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66777
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15606

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4-auth/kerberos: Report errors observed during smb_krb5_remove_obsolete_keytab_entries()
Andrew Bartlett [Thu, 14 Mar 2024 03:55:19 +0000 (16:55 +1300)] 
s4-auth/kerberos: Report errors observed during smb_krb5_remove_obsolete_keytab_entries()

Previously any errors noticed during the main loop would be ignored.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Mar 14 23:16:16 UTC 2024 on atb-devel-224

2 years agosamba-tool domain exportkeytab: Refuse to overwrite an existing file in full-db export
Andrew Bartlett [Thu, 7 Mar 2024 01:53:53 +0000 (14:53 +1300)] 
samba-tool domain exportkeytab: Refuse to overwrite an existing file in full-db export

Since 87f67d336919172845f53067c67d1eab8e7ef18a samba-tool domain exportkeytab has
silently unlinked the given target file.  Instead, the administrator now needs
to specify a file that does not exist.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-libnet: Prepare for a "rolling update" keytab export
Andrew Bartlett [Wed, 6 Mar 2024 04:48:09 +0000 (17:48 +1300)] 
s4-libnet: Prepare for a "rolling update" keytab export

This mode will allow keytabs to be exported with all current keys added
to historical keys, which will be useful in a domain with many gMSA
servers that require wireshark decryption.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-auth/kerberos: Do not add true duplicates to exported keytab
Andrew Bartlett [Wed, 6 Mar 2024 04:43:47 +0000 (17:43 +1300)] 
s4-auth/kerberos: Do not add true duplicates to exported keytab

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoselftest: Add tests of samba-tool domain export-keytab --keep-stale-entries behaviour
Andrew Bartlett [Fri, 8 Mar 2024 03:23:01 +0000 (16:23 +1300)] 
selftest: Add tests of samba-tool domain export-keytab --keep-stale-entries behaviour

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoselftest: Add tests for "samba-tool domain exportkeytab" with existing files"
Andrew Bartlett [Thu, 7 Mar 2024 03:12:56 +0000 (16:12 +1300)] 
selftest: Add tests for "samba-tool domain exportkeytab" with existing files"

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agosamba-tool domain exportkeytab: Raise a proper CommandError
Andrew Bartlett [Sun, 10 Mar 2024 22:14:17 +0000 (11:14 +1300)] 
samba-tool domain exportkeytab: Raise a proper CommandError

This avoids giving just a backtrace for things like exporting a keytab
to an existing file.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-libnet: Raise NTSTATUSError not RuntimeError in keytab export
Andrew Bartlett [Thu, 7 Mar 2024 02:34:37 +0000 (15:34 +1300)] 
s4-libnet: Raise NTSTATUSError not RuntimeError in keytab export

We should never raise RuntimeError if we have a better option.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agosamba-tool: Add option --keep-stale-entries to "samba-tool domain exportkeytab"
Andrew Bartlett [Wed, 6 Mar 2024 22:59:21 +0000 (11:59 +1300)] 
samba-tool: Add option --keep-stale-entries to "samba-tool domain exportkeytab"

This will keep stale keys in the keytab, which may be useful for wireshark
but is not correct if the keytab is used for accepting Kerberos tickets,
as tickets encrypted with old passwords would still be accepted.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agolib/krb5_wrap: Pull already_hashed case out of smb_krb5_kt_add_entry()
Andrew Bartlett [Wed, 6 Mar 2024 04:42:01 +0000 (17:42 +1300)] 
lib/krb5_wrap: Pull already_hashed case out of smb_krb5_kt_add_entry()

The two callers of this function want two very different things, the
common point was wanting to call smb_krb5_kt_seek_and_delete_old_entries()
however this is now done earlier in sdb_kt_copy() with
smb_krb5_remove_obsolete_keytab_entries() or an unlink() in
libnet_export_keytab().

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agolib/krb5_wrap: Rename confusing add_salt parameter to smb_krb5_kt_add_entry()
Andrew Bartlett [Wed, 6 Mar 2024 02:30:53 +0000 (15:30 +1300)] 
lib/krb5_wrap: Rename confusing add_salt parameter to smb_krb5_kt_add_entry()

This just adds the key directly, it is not related to if salting is used or not.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agopython/tests: Add test that gMSA keytab export works and matches direct keytab export
Andrew Bartlett [Thu, 22 Feb 2024 04:29:07 +0000 (17:29 +1300)] 
python/tests: Add test that gMSA keytab export works and matches direct keytab export

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-auth/kerberos: Note the good possability that the msDS-KeyVersionNumber is wrong
Andrew Bartlett [Fri, 2 Feb 2024 01:41:52 +0000 (14:41 +1300)] 
s4-auth/kerberos: Note the good possability that the msDS-KeyVersionNumber is wrong

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Cope with GMSA 5min password preview in cli_credentials_set_gmsa_pa...
Andrew Bartlett [Fri, 2 Feb 2024 01:40:24 +0000 (14:40 +1300)] 
auth/credentials: Cope with GMSA 5min password preview in cli_credentials_set_gmsa_passwords()

This is unused in Samba currently, but is a subtle race that will be difficult
to debug if this is ever used, so this makes things easier for some future
developer.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-libnet: Add export of gMSA keys to "samba-tool domain exportkeytab"
Andrew Bartlett [Wed, 20 Dec 2023 05:10:45 +0000 (18:10 +1300)] 
s4-libnet: Add export of gMSA keys to "samba-tool domain exportkeytab"

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-kdc: Prepare for gMSA support by recording it on the entry
Andrew Bartlett [Thu, 21 Dec 2023 23:09:45 +0000 (12:09 +1300)] 
s4-kdc: Prepare for gMSA support by recording it on the entry

This will allow the "samba-tool domain exportkeytab" code to do special gMSA
processing and in the future will allow the KDC to know it needs to check
if the keys in the DB need refreshing.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Allow generation of old Kerberos keys also
Andrew Bartlett [Thu, 21 Dec 2023 01:04:23 +0000 (14:04 +1300)] 
auth/credentials: Allow generation of old Kerberos keys also

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Make cli_credentials_get_aes256_key into generic key access
Andrew Bartlett [Thu, 21 Dec 2023 09:25:25 +0000 (22:25 +1300)] 
auth/credentials: Make cli_credentials_get_aes256_key into generic key access

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Add hook to set credentials from msDS-ManagedPassword blob
Andrew Bartlett [Thu, 21 Dec 2023 01:06:26 +0000 (14:06 +1300)] 
auth/credentials: Add hook to set credentials from msDS-ManagedPassword blob

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-libnet: Pass the full struct smb_krb5_context to sdb_kt_copy()
Andrew Bartlett [Wed, 20 Dec 2023 20:01:36 +0000 (09:01 +1300)] 
s4-libnet: Pass the full struct smb_krb5_context to sdb_kt_copy()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Dynamically calculate the salt principal (unless speccified)
Andrew Bartlett [Wed, 20 Dec 2023 23:00:46 +0000 (12:00 +1300)] 
auth/credentials: Dynamically calculate the salt principal (unless speccified)

This helps pull the salt principal calculation into a single spot.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Use salt on credentials object for Creds.get_aes256_key()
Andrew Bartlett [Wed, 20 Dec 2023 09:55:07 +0000 (22:55 +1300)] 
auth/credentials: Use salt on credentials object for Creds.get_aes256_key()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoauth/credentials: Add bindings for getting and setting the salt principal
Andrew Bartlett [Thu, 21 Dec 2023 09:04:17 +0000 (22:04 +1300)] 
auth/credentials: Add bindings for getting and setting the salt principal

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-libnet: Provide hint for "samba-tool domain exportkeytab" if used over LDAP withou...
Andrew Bartlett [Tue, 19 Dec 2023 22:53:06 +0000 (11:53 +1300)] 
s4-libnet: Provide hint for "samba-tool domain exportkeytab" if used over LDAP without gMSA

Only gMSA accounts, and only for authoriszed users, can export be exported without
local sam.ldb access.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agoMake "samba-tool domain exportkeytab" prune old keys
Andrew Bartlett [Tue, 19 Dec 2023 22:18:13 +0000 (11:18 +1300)] 
Make "samba-tool domain exportkeytab" prune old keys

This slowly prepares this to be an update tool, not just a one-off export tool

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-auth/kerberos: Rename create_keytab() to smb_krb5_fill_keytab()
Andrew Bartlett [Tue, 19 Dec 2023 22:08:57 +0000 (11:08 +1300)] 
s4-auth/kerberos: Rename create_keytab() to smb_krb5_fill_keytab()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-auth/kerberos: Add define ENC_STRONG_SALTED_TYPES
Andrew Bartlett [Tue, 19 Dec 2023 21:58:01 +0000 (10:58 +1300)] 
s4-auth/kerberos: Add define ENC_STRONG_SALTED_TYPES

This allows us to mask out RC4 and insist on the modern AES types
where that makes sense.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agos4-auth/kerberos: Remove unused paremters to create_keytab()
Andrew Bartlett [Tue, 19 Dec 2023 21:40:07 +0000 (10:40 +1300)] 
s4-auth/kerberos: Remove unused paremters to create_keytab()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agosamba-tool domain exportkeytab: Add support for -H to point to a different sam.ldb
Andrew Bartlett [Tue, 19 Dec 2023 04:04:35 +0000 (17:04 +1300)] 
samba-tool domain exportkeytab: Add support for -H to point to a different sam.ldb

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agolibnet: Prepare to allow "samba-tool domain exportkeytab to support -H
Andrew Bartlett [Tue, 19 Dec 2023 02:58:49 +0000 (15:58 +1300)] 
libnet: Prepare to allow "samba-tool domain exportkeytab to support -H

We need to allow a samdb to be passed from the python to support
using a specific DB or remote server for gMSA passwords.

The gMSA passwords will not use this code, but we need to be
consistant.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agopython: Explain strange enable_net_export_keytab() behaviour is no longer due Heimdal
Andrew Bartlett [Mon, 18 Dec 2023 04:57:56 +0000 (17:57 +1300)] 
python: Explain strange enable_net_export_keytab() behaviour is no longer due Heimdal

This code is now common between Heimdal and MIT Kerberos, but can still be missing
for builds of "samba-tool" that do not include the whole AD DC.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agopackaging: Provide a systemd service file for samba-bgqd
Andreas Schneider [Mon, 4 Mar 2024 09:58:23 +0000 (10:58 +0100)] 
packaging: Provide a systemd service file for samba-bgqd

There might be scenarios where the background queue daemon should be
running all the time instead of being started on demand. This makes
especially sense for bigger printing servers with a lot of printers. It
takes ~1 sec to get a printer from cups, so a print server with 100
printers needs 100 seconds to update the printer_list.tdb. The service
will be killed because of idle in the meantime.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Thu Mar 14 12:19:56 UTC 2024 on atb-devel-224

2 years agos3/smbd: If we fail to close file_handle ensure we should reset the fd
Noel Power [Tue, 20 Feb 2024 09:26:29 +0000 (09:26 +0000)] 
s3/smbd: If we fail to close file_handle ensure we should reset the fd

if fsp_flags.fstat_before_close == true then close_file_smb will call
vfs_stat which can fail. If it does fail then the fd associated
with the file handle will still be set (and we will hit an assert
is the file handle destructor) when calling file_free.
We need to set fd to -1 to avoid that. To achieve that we capture and
return the vfs_stat_fsp failure status while still processing the rest
of the fd_close logic.

[2024/02/20 09:23:48.454671,  0, pid=9744] ../../source3/smbd/smb2_close.c:226(smbd_smb2_close)
  smbd_smb2_close: close_file[]: NT_STATUS_ACCESS_DENIED
[2024/02/20 09:23:48.454757,  0, pid=9744] ../../source3/smbd/fd_handle.c:40(fd_handle_destructor)
  PANIC: assert failed at ../../source3/smbd/fd_handle.c(40): (fh->fd == -1) || (fh->fd == AT_FDCWD)
[2024/02/20 09:23:48.454781,  0, pid=9744] ../../lib/util/fault.c:178(smb_panic_log)
  ===============================================================
[2024/02/20 09:23:48.454804,  0, pid=9744] ../../lib/util/fault.c:185(smb_panic_log)
  INTERNAL ERROR: assert failed: (fh->fd == -1) || (fh->fd == AT_FDCWD) in smbd (smbd[192.168.10) (client [192.168.100.15]) pid 9744 (4.21.0pre1-DEVELOPERBUILD)
[2024/02/20 09:23:48.454844,  0, pid=9744] ../../lib/util/fault.c:190(smb_panic_log)
  If you are running a recent Samba version, and if you think this problem is not yet fixed in the latest versions, please consider reporting this bug, see https://wiki.samba.org/index.php/Bug_Reporting
[2024/02/20 09:23:48.454869,  0, pid=9744] ../../lib/util/fault.c:191(smb_panic_log)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15527
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed Mar 13 10:34:45 UTC 2024 on atb-devel-224

2 years agosmbd: simplify handling of failing fstat() after unlinking file
Ralph Boehme [Mon, 5 Feb 2024 14:03:48 +0000 (15:03 +0100)] 
smbd: simplify handling of failing fstat() after unlinking file

close_remove_share_mode() already called vfs_stat_fsp(), so we can skip the
fstat() triggered in fd_close() by fsp->fsp_flags.fstat_before_close being true.

This avoids getting an EACCESS error when doing an fstat() on the removed file
which seems to happen with some FUSE filesystems.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agoctdb: Remove an unnecessary cast
Volker Lendecke [Thu, 29 Feb 2024 14:33:56 +0000 (15:33 +0100)] 
ctdb: Remove an unnecessary cast

nl->srvid is uint64_t, as is the srvid parameter of ctdb_daemon_send_message()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Mar 13 08:43:16 UTC 2024 on atb-devel-224

2 years agosmbd: Fix a DBG message
Volker Lendecke [Tue, 20 Feb 2024 11:50:36 +0000 (12:50 +0100)] 
smbd: Fix a DBG message

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2 years agosmbd: Avoid a ZERO_STRUCT() with direct struct initialization
Volker Lendecke [Mon, 19 Feb 2024 08:57:16 +0000 (09:57 +0100)] 
smbd: Avoid a ZERO_STRUCT() with direct struct initialization

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Mar 12 14:33:14 UTC 2024 on atb-devel-224

2 years agotools: Fix whitespace
Volker Lendecke [Thu, 8 Feb 2024 10:02:15 +0000 (11:02 +0100)] 
tools: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Fix a typo
Volker Lendecke [Thu, 8 Feb 2024 09:28:02 +0000 (10:28 +0100)] 
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Fix and modernize a few DBG statements
Volker Lendecke [Thu, 8 Feb 2024 09:24:56 +0000 (10:24 +0100)] 
smbd: Fix and modernize a few DBG statements

There were still a few function names in DBGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Give smbXsrv_session.c its own header file
Volker Lendecke [Thu, 8 Feb 2024 09:04:32 +0000 (10:04 +0100)] 
smbd: Give smbXsrv_session.c its own header file

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agovfs: Fix a typo
Volker Lendecke [Sun, 4 Feb 2024 09:09:07 +0000 (10:09 +0100)] 
vfs: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoauth: Simplify smb_krb5_send_to_kdc_state_destructor()
Volker Lendecke [Mon, 12 Feb 2024 12:35:19 +0000 (13:35 +0100)] 
auth: Simplify smb_krb5_send_to_kdc_state_destructor()

Replace a call to dbwrap_fetch_locked() with the higherlevel
dbwrap_delete().

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Fix a comment
Volker Lendecke [Sun, 11 Feb 2024 11:44:10 +0000 (12:44 +0100)] 
smbd: Fix a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbXsrv_version: Use a struct assignment
Volker Lendecke [Sat, 10 Feb 2024 09:40:46 +0000 (10:40 +0100)] 
smbXsrv_version: Use a struct assignment

Make sure everything is initialized

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbXsrv_version: Remove unused smbXsrv_version_global0->db_rec
Volker Lendecke [Sat, 10 Feb 2024 09:37:42 +0000 (10:37 +0100)] 
smbXsrv_version: Remove unused smbXsrv_version_global0->db_rec

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbXsrv_version: Use a struct assignment instead of ZERO_STRUCT
Volker Lendecke [Sat, 10 Feb 2024 09:36:51 +0000 (10:36 +0100)] 
smbXsrv_version: Use a struct assignment instead of ZERO_STRUCT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbXsrv_version: Modernize DEBUG statements
Volker Lendecke [Sat, 10 Feb 2024 09:29:35 +0000 (10:29 +0100)] 
smbXsrv_version: Modernize DEBUG statements

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib: Simplify _hexcharval
Volker Lendecke [Mon, 19 Feb 2024 12:15:55 +0000 (13:15 +0100)] 
lib: Simplify _hexcharval

Saves a few bytes and conditional jumps

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Add parentheses for easier readability
Volker Lendecke [Wed, 31 Jan 2024 16:16:04 +0000 (17:16 +0100)] 
smbd: Add parentheses for easier readability

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotorture: Fix an error message
Volker Lendecke [Wed, 31 Jan 2024 13:06:58 +0000 (14:06 +0100)] 
torture: Fix an error message

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib: Simplify copy_unix_token()
Volker Lendecke [Fri, 2 Feb 2024 14:14:33 +0000 (15:14 +0100)] 
lib: Simplify copy_unix_token()

Avoid an else with implicit NULL initialization

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibsmb: Simplify an if-condition
Volker Lendecke [Fri, 2 Feb 2024 14:06:06 +0000 (15:06 +0100)] 
libsmb: Simplify an if-condition

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib: Make GUID_to_ndr_buf() return void
Volker Lendecke [Fri, 9 Feb 2024 18:09:35 +0000 (19:09 +0100)] 
lib: Make GUID_to_ndr_buf() return void

The whole point of struct GUID_ndr_buf is that this never fails.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Remove get_Protocol()
Volker Lendecke [Tue, 13 Feb 2024 12:13:26 +0000 (13:13 +0100)] 
smbd: Remove get_Protocol()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>