]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
12 months agovfs_ceph_new: use low-level APIs for xattr ops
Shachar Sharon [Sun, 23 Jun 2024 11:57:10 +0000 (14:57 +0300)] 
vfs_ceph_new: use low-level APIs for xattr ops

Implement extended-attributes operations using libcephfs' low-level
APIs. Whenever possible, use the open file-handle from fsp-extension to
resolve inode-reference and user-permissions. Otherwise, resolve both
on-the-fly.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for mknodat
Shachar Sharon [Sun, 23 Jun 2024 10:08:25 +0000 (13:08 +0300)] 
vfs_ceph_new: use low-level APIs for mknodat

Implement mknodat operations using libcephfs' low-level APIs. Requires
parent directory to have valid inode-ref associated with its fsp
extension.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for renameat
Shachar Sharon [Sun, 23 Jun 2024 09:47:19 +0000 (12:47 +0300)] 
vfs_ceph_new: use low-level APIs for renameat

Implement renameat operations using libcephfs' low-level APIs. Requires
both directories to have valid inode-ref associated with their fsp
extension.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for linkat
Shachar Sharon [Thu, 20 Jun 2024 19:46:52 +0000 (22:46 +0300)] 
vfs_ceph_new: use low-level APIs for linkat

Implement link operations using libcephfs' low-level APIs. Requires two
phase operation: resolve (by-lookup) reference to inode and then do the
actual (hard) link operation using parent dir-inode reference to the
locally-cached inode.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for ftruncate/fallocate
Shachar Sharon [Thu, 20 Jun 2024 11:58:34 +0000 (14:58 +0300)] 
vfs_ceph_new: use low-level APIs for ftruncate/fallocate

Implement ftruncate/fallocate operations using libcephfs' low-level
APIs. Requires open ceph Fh* associated with fsp (extension).

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for fsync
Shachar Sharon [Thu, 20 Jun 2024 09:43:39 +0000 (12:43 +0300)] 
vfs_ceph_new: use low-level APIs for fsync

Implement fsync operation using libcephfs' low-level APIs. Requires
open ceph Fh* associated with fsp (extension).

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for lseek
Shachar Sharon [Thu, 20 Jun 2024 09:23:03 +0000 (12:23 +0300)] 
vfs_ceph_new: use low-level APIs for lseek

Implement lseek operation using libcephfs' low-level APIs. Requires
open ceph Fh* associated with fsp (extension).

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for read/write
Shachar Sharon [Wed, 19 Jun 2024 14:52:45 +0000 (17:52 +0300)] 
vfs_ceph_new: use low-level APIs for read/write

Implement read/write IO operations using libcephfs' low-level APIs.
Requires open ceph Fh* associated with fsp (extension) to complete both
pread/pwrite as well as async I/O operations.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for symlink/readlink
Shachar Sharon [Wed, 26 Jun 2024 10:46:54 +0000 (13:46 +0300)] 
vfs_ceph_new: use low-level APIs for symlink/readlink

Implement unlinkat using libcephfs low-level APIs. For readlink
operation need to resolve child inode by-lookup and then used the inode
reference for the actual low-level readlink.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for unlinkat
Shachar Sharon [Wed, 19 Jun 2024 11:27:24 +0000 (14:27 +0300)] 
vfs_ceph_new: use low-level APIs for unlinkat

Implement unlinkat using libcephfs low-level APIs. Operate using parent
directory's open file-handle. When flags has AT_REMOVEDIR bit set call
low-level rmdir; otherwise, do normal unlink.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for fntimes
Shachar Sharon [Wed, 19 Jun 2024 10:59:53 +0000 (13:59 +0300)] 
vfs_ceph_new: use low-level APIs for fntimes

Implement fntimes hook using libcephfs' low-level APIs. Convert
smb_file_time to ceph_statx plus proper field mask on-the-fly upon
issuing low-level call to libcephfs.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for fchown/fchmod
Shachar Sharon [Wed, 19 Jun 2024 09:48:14 +0000 (12:48 +0300)] 
vfs_ceph_new: use low-level APIs for fchown/fchmod

Use libcephfs' low-level APIs to implement 'fchown' and 'fchmod' using
open file-handle. If fsp does not have an open cephfs Fh reference,
set errno to EBADF and return -1 to VFS.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: proper error handling to readdir
Shachar Sharon [Wed, 17 Jul 2024 08:41:13 +0000 (11:41 +0300)] 
vfs_ceph_new: proper error handling to readdir

Error handling in the case of 'ceph_readdir' is done by setting 'errno'
deep within libcephfs code. In case of error, emit proper debug message
and re-update errno to avoid possible over-write by logging mechanism.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for readdir ops
Shachar Sharon [Mon, 24 Jun 2024 10:33:05 +0000 (13:33 +0300)] 
vfs_ceph_new: use low-level APIs for readdir ops

Implement readdir and rewinddir operations using libcephfs' low-level
APIs. Casts the opaque DIR pointer into struct vfs_ceph_dirp (the first
member of struct vfs_ceph_fh) to resolve the ceph_dir_result pointer
which libcephfs expects for readdir operations.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for mkdirat
Shachar Sharon [Wed, 19 Jun 2024 08:55:27 +0000 (11:55 +0300)] 
vfs_ceph_new: use low-level APIs for mkdirat

Implement 'mkdirat' hook using libcephfs' low-level APIs, via the open
file-handle reference to parent directory.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for fdopendir
Shachar Sharon [Tue, 18 Jun 2024 14:20:59 +0000 (17:20 +0300)] 
vfs_ceph_new: use low-level APIs for fdopendir

Implement fdopendir using libcephfs low-level API and cached (via fsp)
open file-handle. Embed the result within cached vfs_ceph_fh so it may
be used properly by closedir.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for fstatat
Shachar Sharon [Wed, 19 Jun 2024 09:35:11 +0000 (12:35 +0300)] 
vfs_ceph_new: use low-level APIs for fstatat

Use libcephfs' low-level APIs to do lookup-by-name via parent's open
reference followed by getattr on the inode itself.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for fstat
Shachar Sharon [Mon, 24 Jun 2024 08:39:43 +0000 (11:39 +0300)] 
vfs_ceph_new: use low-level APIs for fstat

Use libcephfs' low-level APIs and apply the same logic as stat, but
via explicit inode-reference.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for open/close
Shachar Sharon [Tue, 18 Jun 2024 12:02:52 +0000 (15:02 +0300)] 
vfs_ceph_new: use low-level APIs for open/close

Implement openat, close and closedir and hooks using libcephfs'
low-level APIs. Cache the open Fh* from libcephfs and its related
meta-data using VFS fsp-extension mechanism.

Upon open-create of new vfs_ceph_fh store the caller credentials
(ceph's UserPerm*) within the same context object for subsequent calls.
In addition, provide a "pseudo" fd numbering which is reported back to
VFS layer and used as debugging hints.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: ref cephmount_cached entry in handle->data
Shachar Sharon [Tue, 18 Jun 2024 09:58:52 +0000 (12:58 +0300)] 
vfs_ceph_new: ref cephmount_cached entry in handle->data

Allow direct access to ceph-mount cached-entry via 'handle->data'
private pointer. Required in order to allow more complex cached-state
with each cephfs mount. Users should now use the local-helper function
'cmount_of' to access the underlying ceph_mount_info.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for lchown
Shachar Sharon [Mon, 17 Jun 2024 13:59:05 +0000 (16:59 +0300)] 
vfs_ceph_new: use low-level APIs for lchown

Use libcephfs' low-level API ceph_ll_setattr to implement VFS lchown_fn
hook. Use to standard pattern of iget/iput to allow operation by Inode
reference.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for statfs
Shachar Sharon [Mon, 17 Jun 2024 15:02:07 +0000 (18:02 +0300)] 
vfs_ceph_new: use low-level APIs for statfs

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for lstat
Shachar Sharon [Mon, 17 Jun 2024 12:57:42 +0000 (15:57 +0300)] 
vfs_ceph_new: use low-level APIs for lstat

Use libcephfs' low-level APIs and apply the same logic as stat, but
using AT_SYMLINK_NOFOLLOW flags.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for stat
Shachar Sharon [Mon, 17 Jun 2024 09:11:18 +0000 (12:11 +0300)] 
vfs_ceph_new: use low-level APIs for stat

Start migrating to libcephfs' low-level APIs, using explicit Inode*
reference. Implement the VFS 'stat' hook using a ceph_ll_getattr
function, encapsulated with a pair of iget/iput to hold a
pinned-to-cache Inode* instance.

Upon calling to libcephfs this new code crates and destroys on-the-fly
a Ceph UserPerm instance based on the uig, gid and groups from
'handle->conn->session_info->unix_token'. This logic ensures that the
correct caller-credentials are passed-on to cephfs (instead of those
set upon connection-creation in legacy 'vfs_ceph.c').

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: use low-level APIs for disk_free
Shachar Sharon [Sun, 16 Jun 2024 11:50:08 +0000 (14:50 +0300)] 
vfs_ceph_new: use low-level APIs for disk_free

Start using libcephfs low-level APIs: get reference to root inode and
use it to query statfs. Requires an explicit put-inode to avoid resource
leakage by libcephfs.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agovfs_ceph_new: next iteration of samba-to-cephfs bridge
Shachar Sharon [Thu, 13 Jun 2024 12:54:48 +0000 (15:54 +0300)] 
vfs_ceph_new: next iteration of samba-to-cephfs bridge

Defined new module 'vfs_ceph_new.c' which serves as a place holder for
the next development phase of the bridge between samba's VFS layer and
libcephfs. Begin with a module which is almost identical to existing
'vfs_ceph.c', except for hooks-names prefix which is 'vfs_ceph_' in
order to make clear distinction from existing code base. Following
commits will also switch to low-level APIs.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
12 months agoldb: change the version to 2.11.0 for Samba 4.22
Jule Anger [Mon, 29 Jul 2024 08:42:07 +0000 (10:42 +0200)] 
ldb: change the version to 2.11.0 for Samba 4.22

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Jule Anger <janger@samba.org>
Autobuild-Date(master): Mon Jul 29 10:06:23 UTC 2024 on atb-devel-224

12 months agoWHATSNEW: Start release notes for Samba 4.22.0pre1.
Jule Anger [Mon, 29 Jul 2024 08:54:41 +0000 (10:54 +0200)] 
WHATSNEW: Start release notes for Samba 4.22.0pre1.

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
12 months agoVERSION: Bump version up to 4.22.0pre1...
Jule Anger [Mon, 29 Jul 2024 08:34:32 +0000 (10:34 +0200)] 
VERSION: Bump version up to 4.22.0pre1...

and re-enable GIT_SNAPSHOT.

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
12 months agoVERSION: Disable GIT_SNAPSHOT for the Samba 4.21.0rc1 release. samba-4.21.0rc1
Jule Anger [Mon, 29 Jul 2024 08:33:05 +0000 (10:33 +0200)] 
VERSION: Disable GIT_SNAPSHOT for the Samba 4.21.0rc1 release.

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
12 months agoWHATSNEW: Up to Samba 4.21.0rc1.
Jule Anger [Mon, 29 Jul 2024 08:31:38 +0000 (10:31 +0200)] 
WHATSNEW: Up to Samba 4.21.0rc1.

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
12 months agotdb: version 1.4.11 tdb-1.4.11
Jule Anger [Mon, 29 Jul 2024 08:11:55 +0000 (10:11 +0200)] 
tdb: version 1.4.11

* Add tdbdump -x option to output all data as hex values
* Add missing overflow check for num_values in pytdb.c
* Remove Py2 related tests
* Update times in tdb_transaction_commit per fd, not per name
* Fix compilation with TDB_TRACE=1
* Allow tracing of internal tdb

Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
12 months agoldb:kv_index: use subtransaction_cancel in transaction_cancel
Douglas Bagnall [Sun, 21 Jul 2024 06:04:49 +0000 (18:04 +1200)] 
ldb:kv_index: use subtransaction_cancel in transaction_cancel

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Sat Jul 27 23:51:44 UTC 2024 on atb-devel-224

12 months agoldb:kv_index: subtransaction_cancel: check for nested tdb
Douglas Bagnall [Sun, 21 Jul 2024 06:07:56 +0000 (18:07 +1200)] 
ldb:kv_index: subtransaction_cancel: check for nested tdb

Just in case, but also so ldb_kv_index_transaction_cancel() can use
this and retain the same logic.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agoldb:kv_index: don't recalculate a length
Douglas Bagnall [Sun, 21 Jul 2024 06:06:18 +0000 (18:06 +1200)] 
ldb:kv_index: don't recalculate a length

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agoldb:kv_index: realloc away old dn list
Douglas Bagnall [Mon, 22 Jul 2024 10:22:15 +0000 (22:22 +1200)] 
ldb:kv_index: realloc away old dn list

We can't just free it, because has the GUID index list as a child, and
these are shared by the new dn list (from the subtransaction we are
committing). But if the dn list is long and the main transaction is
long-lived, we can save a lot of memory by turning this dn list into
an almost empty node in the talloc tree. This returns us to roughly
the situation we had prior to the last commit.

For example, with the repro.sh script on bug 15590 in indexes mode
with 10000 rules, The last 3 commits use this much memory at the end
of an unusually large transaction:

full talloc report on 'struct ldb_context' (total 4012222 bytes in 90058 blocks)
full talloc report on 'struct ldb_context' (total 2405482219 bytes in 90058 blocks)
full talloc report on 'struct ldb_context' (total 4282195 bytes in 90058 blocks)

That is, the last commit increased usage 500 fold, and this commit
brings it back to normal.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agoldb_kv_index: dn_list load sub transaction can re-use keys
Douglas Bagnall [Tue, 25 Jun 2024 23:05:49 +0000 (11:05 +1200)] 
ldb_kv_index: dn_list load sub transaction can re-use keys

We don't want to modify the original list, but we can reuse the keys
if we treat them as immutable and don't free them. That makes it a lot
quicker if there are many keys (i.e. where an index is useful) and may
sub-transactions. In particular, it avoids O(n²) talloc_memdups.

A removed comment that says "We have to free the top level index
memory otherwise we would leak", and this will be addressed in the
next commit.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agoldb:ldb_kv_dn_list_find_val: check for int overflow
Douglas Bagnall [Tue, 9 Jul 2024 23:52:39 +0000 (11:52 +1200)] 
ldb:ldb_kv_dn_list_find_val: check for int overflow

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agoldb_kv_cache: always initialise dn_list.strict
Douglas Bagnall [Tue, 9 Jul 2024 02:47:25 +0000 (14:47 +1200)] 
ldb_kv_cache: always initialise dn_list.strict

The strict flag is only read in list intersection, so most of the time
it doesn't matter whether it is set because that path is not used.
Nevertheless seeing it set to all kinds of values is distracting.

The undefined behaviour has likely been hidden from static analysis
because the structure is passed through the in-memory tdb before use.

Incorrect true values will have disabled an optimisation but not
caused the wrong result.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agotdb: allow tracing of internal tdb
Douglas Bagnall [Wed, 10 Jul 2024 04:04:27 +0000 (16:04 +1200)] 
tdb: allow tracing of internal tdb

This will trace internal databases to files like this:

tdb_0x5da896b51870.trace.267290

We avoid strlen(name) because name could be NULL in this case (which
works fine with glibc but feels bad).

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agotdb: fix compilation with TDB_TRACE=1
Douglas Bagnall [Wed, 10 Jul 2024 02:35:28 +0000 (14:35 +1200)] 
tdb: fix compilation with TDB_TRACE=1

../../lib/tdb/common/tdb.c: In function ‘tdb_trace_record’:
../../lib/tdb/common/tdb.c:1224:22: error: ‘snprintf’ output truncated before the last format character [-Werror=format-truncation=]
 1224 |                 p += snprintf(p, 2, %02x, rec.dptr[i]);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/tdb/common/tdb.c:1224:22: note: ‘snprintf’ output 3 bytes into a destination of size 2
cc1: all warnings being treated as errors

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoWHATSNEW: Automatic keytab update after machine password changes
Pavel Filipenský [Mon, 12 Feb 2024 09:25:06 +0000 (10:25 +0100)] 
WHATSNEW: Automatic keytab update after machine password changes

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Fri Jul 26 18:16:15 UTC 2024 on atb-devel-224

13 months agoselftest: Add tests for keytab update in clustered samba
Pavel Filipenský [Mon, 15 Jul 2024 15:07:59 +0000 (17:07 +0200)] 
selftest: Add tests for keytab update in clustered samba

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoselftest: setup clusteredmember with kerberos, change dependency to "ad_dc"
Pavel Filipenský [Mon, 15 Jul 2024 15:07:59 +0000 (17:07 +0200)] 
selftest: setup clusteredmember with kerberos, change dependency to "ad_dc"

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoselftest: Rename nt4_dc_vars -> dcvars in setup_clusteredmember
Pavel Filipenský [Mon, 15 Jul 2024 15:01:09 +0000 (17:01 +0200)] 
selftest: Rename nt4_dc_vars -> dcvars in setup_clusteredmember

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoscript: clustered samba: Build samba-ctdb with ad-dc support
Pavel Filipenský [Fri, 12 Jul 2024 20:09:43 +0000 (22:09 +0200)] 
script: clustered samba: Build samba-ctdb with ad-dc support

samba-tool requires addc support

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:script: clustered samba: Add script updatekeytab.sh
Pavel Filipenský [Tue, 9 Apr 2024 06:39:40 +0000 (08:39 +0200)] 
s3:script: clustered samba: Add script updatekeytab.sh

Admin should use this script in smb.conf parameter 'sync machine
password script' in clustered samba

TODO: onnode will update the keytab on all connected nodes, so the
update will happen on the triggering node twice. This can be improved in
the future.

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoctdb:events: Add 46.update-keytabs.script for 'recovered' event
Pavel Filipenský [Mon, 8 Apr 2024 12:47:21 +0000 (14:47 +0200)] 
ctdb:events: Add 46.update-keytabs.script for 'recovered' event

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:libads: Call 'sync machine password script' when machine password is updated
Pavel Filipenský [Wed, 28 Feb 2024 12:30:30 +0000 (13:30 +0100)] 
s3:libads: Call 'sync machine password script' when machine password is updated

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:utils: Remove from "net ads keytab": "add", "delete" and "add_update_ads"
Pavel Filipenský [Thu, 15 Feb 2024 09:58:13 +0000 (10:58 +0100)] 
s3:utils: Remove from "net ads keytab": "add", "delete" and "add_update_ads"

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:libads: Remove ads_keytab_create_default & friends
Pavel Filipenský [Mon, 12 Feb 2024 11:19:14 +0000 (12:19 +0100)] 
s3:libads: Remove ads_keytab_create_default & friends

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agotestprogs: Remove alias test from test_net_ads.sh
Pavel Filipenský [Thu, 15 Feb 2024 09:14:28 +0000 (10:14 +0100)] 
testprogs: Remove alias test from test_net_ads.sh

"net ads keytab create" no longer reads msDS-AdditionalDnsHostName from AD

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agotestprogs: Remove dnshostname related test from test_net_ads.sh
Pavel Filipenský [Thu, 15 Feb 2024 09:14:01 +0000 (10:14 +0100)] 
testprogs: Remove dnshostname related test from test_net_ads.sh

"net ads keytab create" no longer reads dNSHostName from AD

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agotestprogs: Use "HOST' instead of 'host' in test_net_ads.sh
Pavel Filipenský [Thu, 15 Feb 2024 09:13:15 +0000 (10:13 +0100)] 
testprogs: Use "HOST' instead of 'host' in test_net_ads.sh

"net ads keytab create" will uses the same value as in AD,
modifications to lower case are no longer done

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agotestprogs: Remove upn related test from test_net_ads.sh
Pavel Filipenský [Thu, 15 Feb 2024 08:47:34 +0000 (09:47 +0100)] 
testprogs: Remove upn related test from test_net_ads.sh

"net ads keytab create" will no longer read "userPrincipalName" from AD

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agotestprogs: Remove "keytab add", "keytab delete" and "keytab add_apdate_ads" related...
Pavel Filipenský [Thu, 15 Feb 2024 08:15:03 +0000 (09:15 +0100)] 
testprogs: Remove "keytab add", "keytab delete" and "keytab add_apdate_ads" related tests from test_net_ads.sh

"net ads" will no longer support "keytab add", "keytab delete" and "keytab add_apdate_ads"

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoselftest: Add tests for keytab update
Pavel Filipenský [Fri, 3 Sep 2021 17:10:01 +0000 (19:10 +0200)] 
selftest: Add tests for keytab update

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

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoselftest: Add "sync machine password to keytab" to env. ad_member_idmap_nss
Pavel Filipenský [Fri, 3 Sep 2021 17:07:48 +0000 (19:07 +0200)] 
selftest: Add "sync machine password to keytab" to env. ad_member_idmap_nss

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

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:utils: Change net_ads_keytab_create() to call sync_pw2keytabs()
Pavel Filipenský [Thu, 15 Feb 2024 10:10:06 +0000 (11:10 +0100)] 
s3:utils: Change net_ads_keytab_create() to call sync_pw2keytabs()

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:libnet: Sync keytab during libnet_join_create_keytab()
Pavel Filipenský [Tue, 13 Feb 2024 12:43:50 +0000 (13:43 +0100)] 
s3:libnet: Sync keytab during libnet_join_create_keytab()

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3: Sync machine account password in secrets_{prepare,finish}_password_change
Pavel Filipenský [Thu, 21 Dec 2023 12:57:38 +0000 (13:57 +0100)] 
s3: Sync machine account password in secrets_{prepare,finish}_password_change

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:ads: Remove 'kerberos method' warning for 'net ads keytab' functions
Pavel Filipenský [Fri, 26 Jul 2024 11:15:03 +0000 (13:15 +0200)] 
s3:ads: Remove 'kerberos method' warning for 'net ads keytab' functions

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:ads: Do not update system keytab from "net ads changetrustpw"
Pavel Filipenský [Thu, 21 Dec 2023 12:57:38 +0000 (13:57 +0100)] 
s3:ads: Do not update system keytab from "net ads changetrustpw"

It will be done in secrets_{prepare,finish}_password_change

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:lib: Sync machine password to keytab: helper functions
Pavel Filipenský [Mon, 6 Sep 2021 14:58:17 +0000 (16:58 +0200)] 
s3:lib: Sync machine password to keytab: helper functions

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

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:libads: Request "msDS-KeyVersionNumber" from ads_find_machine_acct()
Pavel Filipenský [Tue, 23 Jan 2024 16:19:30 +0000 (17:19 +0100)] 
s3:libads: Request "msDS-KeyVersionNumber" from ads_find_machine_acct()

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:libads: Use the TRACE SUPPORT for keys operations
Pavel Filipenský [Thu, 7 Dec 2023 16:49:07 +0000 (17:49 +0100)] 
s3:libads: Use the TRACE SUPPORT for keys operations

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agokrb5_wrap: Add TRACE SUPPORT for keys operations
Pavel Filipenský [Wed, 7 Jul 2021 18:06:48 +0000 (20:06 +0200)] 
krb5_wrap: Add TRACE SUPPORT for keys operations

The trace looks like below. Useful is the last filed - hex dump of the
data - allows to search for all manipulations.

KEYTAB_TRACE sync_pw2keytabs_process_keytab:622 add ADMEMKEYTAB$@ADDOM.SAMBA.EXAMPLE.COM 14 17 C66D244CB26005C7D6FF9FC00FCBBE4A

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

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:testparm: Add check for "sync machine password to keytab" to testparm
Pavel Filipenský [Sun, 17 Dec 2023 15:15:00 +0000 (16:15 +0100)] 
s3:testparm: Add check for "sync machine password to keytab" to testparm

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agodocs:smbdotconf: Add parameter 'sync machine password script'
Pavel Filipenský [Wed, 28 Feb 2024 12:30:55 +0000 (13:30 +0100)] 
docs:smbdotconf: Add parameter 'sync machine password script'

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

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agodocs:smbdotconf: Add parameter 'sync machine password to keytab'
Pavel Filipenský [Fri, 3 Sep 2021 17:07:01 +0000 (19:07 +0200)] 
docs:smbdotconf: Add parameter 'sync machine password to keytab'

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

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3:lib: Merge library trusts_util into library ads
Pavel Filipenský [Wed, 2 Jun 2021 13:20:46 +0000 (15:20 +0200)] 
s3:lib: Merge library trusts_util into library ads

Function trust_pw_change() originally from library trustis_util was updated
to call functionality from ads library. This would introduce circular
dependency between the two libraries. To avoid it, trusts_util is merged
into ads.

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

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoWHATSNEW.txt: document "veto files" and "hide files"
Ralph Boehme [Fri, 2 Feb 2024 14:14:27 +0000 (15:14 +0100)] 
WHATSNEW.txt: document "veto files" and "hide files"

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jul 26 11:10:42 UTC 2024 on atb-devel-224

13 months agos3/lib: return error from set_namearray()
Ralph Boehme [Wed, 7 Feb 2024 10:40:29 +0000 (11:40 +0100)] 
s3/lib: return error from set_namearray()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agosmbd: return errors from token_contains_name()
Ralph Boehme [Fri, 2 Feb 2024 07:10:54 +0000 (08:10 +0100)] 
smbd: return errors from token_contains_name()

Invalid names in "valid users", "invalid users", "read list", "write list",
"veto files" and "hide files" are logged and ignored, but a failure to contact
winbind or a DC from winbind, or a memory allocation failure, now all trigger a
failure of the tree connect.

Manually tested with smbclient with the following hack in winbindd:

---8<---
  $ git di
   source3/winbindd/winbindd_cache.c | 7 +++++++
   1 file changed, 7 insertions(+)

  diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
  index c889489dbbbc..8ccf0a28e11a 100644
  --- a/source3/winbindd/winbindd_cache.c
  +++ b/source3/winbindd/winbindd_cache.c
  @@ -1821,6 +1821,13 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
          ZERO_STRUCTP(sid);
          *type = SID_NAME_UNKNOWN;

  +       if (strequal(name, "unknown")) {
  +               return NT_STATUS_OK;
  +       }
  +       if (strequal(name, "iotimeout")) {
  +               return NT_STATUS_IO_TIMEOUT;
  +       }
  +
          status = wcache_name_to_sid(domain, domain_name, name, sid, type);
          if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
                  return status;
---8<---

  veto files = ../unknown/file1/../slow/file2

  $ bin/smbclient -U slow%x //localhost/test -c quit
  $

In the log:

  [2024/03/04 15:21:33.659356,  1, pid=977167, effective(0, 0), real(0, 0)] ../../source3/lib/util_namearray.c:128(token_contains_name)
    token_contains_name: lookup_name 'unknown' failed

  veto files = ../iotimeout/file1/../slow/file2

  $ bin/smbclient -U slow%x //localhost/test -c quit
  tree connect failed: NT_STATUS_LOGON_FAILURE
  $

  [2024/03/04 15:22:15.655811,  0, pid=977177, effective(0, 0), real(0, 0)] ../../source3/lib/util_namearray.c:131(token_contains_name)
    token_contains_name: lookup_name 'iotimeout' failed NT_STATUS_NO_SUCH_DOMAIN
  [2024/03/04 15:22:15.655846,  1, pid=977177, effective(0, 0), real(0, 0)] ../../source3/smbd/uid.c:381(change_to_user_impersonate)
    change_to_user_impersonate: SMB user slow (unix user slow) not permitted access to share test.
  [2024/03/04 15:22:15.655855,  0, pid=977177, effective(0, 0), real(0, 0)] ../../source3/smbd/smb2_service.c:689(make_connection_snum)
    make_connection_snum: Can't become connected user!

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/lib: use lookup_name_smbconf_ex() in token_contains_name()
Ralph Boehme [Fri, 9 Feb 2024 14:24:27 +0000 (15:24 +0100)] 
s3/lib: use lookup_name_smbconf_ex() in token_contains_name()

No change in behaviour as we still ignore lookup erros as well as a not-found
result.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/passdb: add lookup_name_smbconf_ex() using lookup_name_internal()
Ralph Boehme [Fri, 9 Feb 2024 08:40:23 +0000 (09:40 +0100)] 
s3/passdb: add lookup_name_smbconf_ex() using lookup_name_internal()

Returns NTSTATUS instead of bool. lookup_name_smbconf() becomes a thin
wrapper around lookup_name_smbconf_ex().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/passdb: factor out lookup_name_internal()
Ralph Boehme [Fri, 9 Feb 2024 09:53:35 +0000 (10:53 +0100)] 
s3/passdb: factor out lookup_name_internal()

lookup_name() becomes a thin wrapper around lookup_name_internal(). Prepares for
adding more callers to lookup_name_internal() that are interested in the
NTSTATUS return value to distinguish between NAME_NOT_FOUND lookup results and
real errors.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/passdb: use winbind_lookup_name_ex() in lookup_name() instead of winbind_lookup_name()
Ralph Boehme [Thu, 8 Feb 2024 17:20:15 +0000 (18:20 +0100)] 
s3/passdb: use winbind_lookup_name_ex() in lookup_name() instead of winbind_lookup_name()

No change in behaviour, prepares for returning NTSTATUS instead of bool from
lookup_name().

Review-with: git show -w

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/passdb: add winbind_lookup_name_ex()
Ralph Boehme [Thu, 8 Feb 2024 17:20:15 +0000 (18:20 +0100)] 
s3/passdb: add winbind_lookup_name_ex()

Differs from winbind_lookup_name() by

- returning NTSTATUS instead of bool, so callers can distinguish between
STATUS_NAME_NOT_FOUND lookup results and real errors.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3-errormap: add WBC_ERR_NOT_MAPPED -> NT_STATUS_NONE_MAPPED
Ralph Boehme [Fri, 16 Feb 2024 16:16:57 +0000 (17:16 +0100)] 
s3-errormap: add WBC_ERR_NOT_MAPPED -> NT_STATUS_NONE_MAPPED

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3-errormap: move map_nt_error_from_wbcErr() back into errormap.c
Ralph Boehme [Thu, 8 Feb 2024 11:09:33 +0000 (12:09 +0100)] 
s3-errormap: move map_nt_error_from_wbcErr() back into errormap.c

This basically reverts commit 313db81ad3de6cf7759d6a0fc21ee32419b2e62b.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/rpc_client: fix handling of NT_STATUS_SOME_NOT_MAPPED
Ralph Boehme [Wed, 6 Mar 2024 13:23:45 +0000 (14:23 +0100)] 
s3/rpc_client: fix handling of NT_STATUS_SOME_NOT_MAPPED

In this case names that couldn't be resolved will be have a NULL sid pointer
which would trigger a crash in sid_copy().

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
13 months agowinbindd: let LookupNames return NT_STATUS_OK and SID_NAME_UNKNOWN for unmapped names
Ralph Boehme [Fri, 16 Feb 2024 15:44:57 +0000 (16:44 +0100)] 
winbindd: let LookupNames return NT_STATUS_OK and SID_NAME_UNKNOWN for unmapped names

Previously LookupNames would fail if a name could not be translated, so winbindd
clients like libwbclient couldn't differentiate between not being able to talk
to a DC and just an unkown name.

As a visible change this alters

  $ bin/wbinfo -n Idontexist
  failed to call wbcLookupName: WBC_ERR_DOMAIN_NOT_FOUND
  Could not lookup name Idontexist

to

  $ bin/wbinfo -n Idontexist
  failed to call wbcLookupName: WBC_ERR_SOME_NOT_MAPPED
  Could not lookup name Idontexist

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agolibwbclient: prepare wbcCtxLookupName() for dealing with WBC_SID_NAME_UNKNOWN
Ralph Boehme [Fri, 16 Feb 2024 15:38:11 +0000 (16:38 +0100)] 
libwbclient: prepare wbcCtxLookupName() for dealing with WBC_SID_NAME_UNKNOWN

This changes the wbcErr from WBC_ERR_DOMAIN_NOT_FOUND to WBC_ERR_NOT_MAPPED.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agolibwbclient: add error WBC_ERR_NOT_MAPPED
Ralph Boehme [Fri, 16 Feb 2024 15:33:57 +0000 (16:33 +0100)] 
libwbclient: add error WBC_ERR_NOT_MAPPED

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agowinbindd: properly initialize sid and type in wb_cache_name_to_sid()
Ralph Boehme [Fri, 16 Feb 2024 15:42:59 +0000 (16:42 +0100)] 
winbindd: properly initialize sid and type in wb_cache_name_to_sid()

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agowinbindd: collapse two if expressions
Ralph Boehme [Fri, 16 Feb 2024 15:19:34 +0000 (16:19 +0100)] 
winbindd: collapse two if expressions

No change in behaviour.

After calling set_domain_offline() domain->offline will be set to false, iow
everytime

  if (!domain->internal && was_online)

is true,

  if (!domain->internal &&
      !domain->online &&
      was_online)

will also true, so we can drop the second if expression.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agowinbindd: reformatting
Ralph Boehme [Fri, 16 Feb 2024 15:17:33 +0000 (16:17 +0100)] 
winbindd: reformatting

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agowinbindd: rename variable old_status to was_online in wb_cache_name_to_sid()
Ralph Boehme [Fri, 16 Feb 2024 15:12:43 +0000 (16:12 +0100)] 
winbindd: rename variable old_status to was_online in wb_cache_name_to_sid()

A lot easier to make sense of the complex logic when using this name.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoCI: add a test for per-user (and per-group) veto files
Ralph Boehme [Thu, 25 Jan 2024 14:03:10 +0000 (15:03 +0100)] 
CI: add a test for per-user (and per-group) veto files

Not adding a specific test for per-user hide files as that uses the exact same
mechanism as the per-user veto files.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoCI: fix test file cleanup
Ralph Boehme [Thu, 25 Jan 2024 15:26:42 +0000 (16:26 +0100)] 
CI: fix test file cleanup

Test files are stored beneath "$SHAREPATH/dir1", not "$SHAREPATH/dir_1".

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/lib: add per-user support to set_namearray()
Ralph Boehme [Fri, 2 Feb 2024 11:04:10 +0000 (12:04 +0100)] 
s3/lib: add per-user support to set_namearray()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agosmbd: move token_contains_name() to util_namearray.c and make it public
Ralph Boehme [Wed, 7 Feb 2024 07:46:43 +0000 (08:46 +0100)] 
smbd: move token_contains_name() to util_namearray.c and make it public

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agoselftest: add groups "group1" and "group2" to Samba3
Ralph Boehme [Thu, 25 Jan 2024 07:07:49 +0000 (08:07 +0100)] 
selftest: add groups "group1" and "group2" to Samba3

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/lib: move set_namearray() to util_namearray.c
Ralph Boehme [Wed, 7 Feb 2024 09:21:33 +0000 (10:21 +0100)] 
s3/lib: move set_namearray() to util_namearray.c

Needed to fix circular dependencies between samba-passdb, secrets3 and
samba3util (iirc).

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agosmbd: maintain veto_list and hide_list in the vuid cache
Ralph Boehme [Wed, 7 Feb 2024 09:18:13 +0000 (10:18 +0100)] 
smbd: maintain veto_list and hide_list in the vuid cache

Prepares for adding per-user support to both options. I don't think it makes
sense also adding per-user support to "veto oplock files" and "aio write behind"
so I'm ignoring those.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agosmbd: prepare free_conn_session_info_if_unused() for more cleanup logic
Ralph Boehme [Tue, 23 Jan 2024 14:29:17 +0000 (15:29 +0100)] 
smbd: prepare free_conn_session_info_if_unused() for more cleanup logic

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agosmbd: move target code out of loop body
Ralph Boehme [Tue, 23 Jan 2024 14:19:12 +0000 (15:19 +0100)] 
smbd: move target code out of loop body

Reduces indentation of the code code that is run in this function and prepares
for adding more of it.

Review with: git show -w

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/lib: modernize set_namearray()
Ralph Boehme [Sat, 20 Jan 2024 11:58:52 +0000 (12:58 +0100)] 
s3/lib: modernize set_namearray()

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agos3/lib: move path_to_strv() to util_path.c
Ralph Boehme [Tue, 23 Jan 2024 11:29:36 +0000 (12:29 +0100)] 
s3/lib: move path_to_strv() to util_path.c

More callers are coming.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>