]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
11 months agos4:drs:tests: repeat getncchanges test with zero reserved_usn
Douglas Bagnall [Wed, 14 Aug 2024 01:26:37 +0000 (13:26 +1200)] 
s4:drs:tests: repeat getncchanges test with zero reserved_usn

This emulates the behaviour of Azure AD.

As this is quite slow we will later reduce the test load in this case,
but for now we want to run all the getncchanges tests this way.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <josutton@catalyst.net.nz>
11 months agos4:drs:tests: add hook for changing highwatermark
Douglas Bagnall [Thu, 8 Aug 2024 22:16:29 +0000 (10:16 +1200)] 
s4:drs:tests: add hook for changing highwatermark

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <josutton@catalyst.net.nz>
11 months agos4:drs:test:getncchanges: add a timeout failure
Douglas Bagnall [Thu, 8 Aug 2024 23:20:38 +0000 (11:20 +1200)] 
s4:drs:test:getncchanges: add a timeout failure

In the next commit we are going to add tests in which the client
modifies the highwatermark in a way that resets replication (on Samba
only). After that we'll fix it.

If we leave the test in an eternal loop, the commit history will not
be bisectable, so we are temporarily going to turn long waits into
failures.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <josutton@catalyst.net.nz>
11 months agolibcli:auth: Remove unreachable code (CID 1272968)
Joseph Sutton [Thu, 5 Oct 2023 23:36:13 +0000 (12:36 +1300)] 
libcli:auth: Remove unreachable code (CID 1272968)

For us to reach the statement ‘if (0 < len1)’, ‘len1’ must be equal to
‘len2’, and they must not both be equal to zero. That cannot be the case
if ‘len1’ is equal to zero, and therefore the ‘else’ branch cannot be
reached.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
11 months agoutil:charset: Remove unreachable code (CID 1272948)
Joseph Sutton [Thu, 5 Oct 2023 21:54:57 +0000 (10:54 +1300)] 
util:charset: Remove unreachable code (CID 1272948)

Suppose that ‘slen’ is equal to (size_t)-1. A few lines up, we had:

    if (lastp != 0) goto slow_path;

Therefore, ‘lastp’ must evaluate to false.

Now suppose that ‘slen’ is not equal to (size_t)-1. In that case, we
would have executed:

    if (slen != 0) goto slow_path;

Therefore, ‘slen’ must evaluate to false.

Consequently, this code can be seen to be unreachable.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
11 months agolibrpc: Speed up GUID_buf_string()
Jo Sutton [Wed, 1 Mar 2023 01:54:14 +0000 (14:54 +1300)] 
librpc: Speed up GUID_buf_string()

This is faster than calling snprintf().

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
11 months agolib/util: Speed up slow data-blob-to-hex functions
Jo Sutton [Wed, 1 Mar 2023 01:50:45 +0000 (14:50 +1300)] 
lib/util: Speed up slow data-blob-to-hex functions

This is much faster than calling sprintf() for every byte of data, and
improves the performance of functions outputting binary DNs.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
11 months agobootstrap: Migrate to Rocky8
David Mulder [Tue, 27 Aug 2024 15:32:43 +0000 (09:32 -0600)] 
bootstrap: Migrate to Rocky8

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Aug 28 00:24:35 UTC 2024 on atb-devel-224

11 months agoidl: dnsp.h references NTTIME
Volker Lendecke [Sun, 25 Aug 2024 17:50:34 +0000 (19:50 +0200)] 
idl: dnsp.h references NTTIME

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Aug 27 08:36:11 UTC 2024 on atb-devel-224

11 months agoidl: misc.idl references DATA_BLOB
Volker Lendecke [Sun, 25 Aug 2024 17:51:00 +0000 (19:51 +0200)] 
idl: misc.idl references DATA_BLOB

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agopidl: Add headerhelper idl property
Volker Lendecke [Fri, 23 Aug 2024 14:39:58 +0000 (16:39 +0200)] 
pidl: Add headerhelper idl property

Add includes to for example misc.h if needed, so that misc.h can be
directly included without prerequisites

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agolib: Make a few functions static
Volker Lendecke [Sun, 25 Aug 2024 17:29:24 +0000 (19:29 +0200)] 
lib: Make a few functions static

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agolibsmb: Simplify pdb_sethexpwd with hex_byte()
Volker Lendecke [Sun, 25 Aug 2024 10:08:49 +0000 (12:08 +0200)] 
libsmb: Simplify pdb_sethexpwd with hex_byte()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agopidl:Samba4/Header: only include ntstatus.h if required
Stefan Metzmacher [Fri, 23 Aug 2024 15:25:34 +0000 (17:25 +0200)] 
pidl:Samba4/Header: only include ntstatus.h if required

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agopidl: add scalarTypeUsed() helper to find if a type was actually used...
Stefan Metzmacher [Fri, 23 Aug 2024 15:24:19 +0000 (17:24 +0200)] 
pidl: add scalarTypeUsed() helper to find if a type was actually used...

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agolib: Add libcli/util/ntstatus.h in a few headers where it's needed
Volker Lendecke [Fri, 23 Aug 2024 13:53:51 +0000 (15:53 +0200)] 
lib: Add libcli/util/ntstatus.h in a few headers where it's needed

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agoidl: Remove unused KRB5_EDATA_NTSTATUS
Volker Lendecke [Fri, 23 Aug 2024 13:39:30 +0000 (15:39 +0200)] 
idl: Remove unused KRB5_EDATA_NTSTATUS

I think the last user went away with e2028837b95 in 2017

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agosmbd: Inline set_sticky_write_time_path into set_sticky_write_time_fsp
Volker Lendecke [Thu, 25 Jul 2024 11:23:21 +0000 (13:23 +0200)] 
smbd: Inline set_sticky_write_time_path into set_sticky_write_time_fsp

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agosmbd: Modernize a few DEBUGs
Volker Lendecke [Mon, 5 Aug 2024 11:45:07 +0000 (13:45 +0200)] 
smbd: Modernize a few DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agosmbd: Introduce "ace" helper variable
Volker Lendecke [Mon, 5 Aug 2024 11:42:09 +0000 (13:42 +0200)] 
smbd: Introduce "ace" helper variable

Use "psd->dacl->aces[0]" once instead of 3 times

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agoidl: security.idl compiles with only secace.h
Volker Lendecke [Thu, 22 Aug 2024 16:00:12 +0000 (18:00 +0200)] 
idl: security.idl compiles with only secace.h

It does not need all of security.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agopidl: replace.h is sufficient in ndr_*.c
Volker Lendecke [Thu, 22 Aug 2024 15:20:07 +0000 (17:20 +0200)] 
pidl: replace.h is sufficient in ndr_*.c

Avoid a few uses of includes.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agolib: Add a few explicit includes
Volker Lendecke [Thu, 22 Aug 2024 16:25:06 +0000 (18:25 +0200)] 
lib: Add a few explicit includes

Required to trim down includes from gen_ndr/*security*

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agolibndr: Use _talloc_array() to benefit from overflow protection
Volker Lendecke [Wed, 21 Aug 2024 12:03:22 +0000 (14:03 +0200)] 
libndr: Use _talloc_array() to benefit from overflow protection

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agolibndr: Remove 368 bytes from R/W data into R/O text segment
Volker Lendecke [Wed, 21 Aug 2024 11:46:20 +0000 (13:46 +0200)] 
libndr: Remove 368 bytes from R/W data into R/O text segment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agosmbd: Modernize a few DEBUGs
Volker Lendecke [Wed, 21 Aug 2024 09:14:45 +0000 (11:14 +0200)] 
smbd: Modernize a few DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agoctdb: Add a NULL check to convert_node_map_to_list()
Volker Lendecke [Tue, 20 Aug 2024 10:48:20 +0000 (12:48 +0200)] 
ctdb: Add a NULL check to convert_node_map_to_list()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
11 months agosource3/wscript: Introduce auto mode to build ceph vfs modules
Anoop C S [Mon, 5 Aug 2024 13:21:49 +0000 (18:51 +0530)] 
source3/wscript: Introduce auto mode to build ceph vfs modules

Use 'auto' mode as the default for building ceph vfs modules so that an
explicit --enable-cephfs can reliably fail in the absence of required
dependencies.

ref: https://lists.samba.org/archive/samba/2024-August/249569.html

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Aug 27 06:18:51 UTC 2024 on atb-devel-224

11 months agos3:smbd: fix NULL dereference in case of readlink failure
Shachar Sharon [Thu, 22 Aug 2024 11:44:28 +0000 (14:44 +0300)] 
s3:smbd: fix NULL dereference in case of readlink failure

When VFS readlinkat hook returns with error the following sequence
yields NULL-pointer dereference (SIGSEGV):

  symlink_target_below_conn (source3/smbd/open.c)
    char *target = NULL;
    ...
    readlink_talloc (source3/smbd/files.c)
      SMB_VFS_READLINKAT
        smb_vfs_call_readlinkat (source3/smbd/vfs.c)
          handle->fns->readlinkat_fn --> returns error

  status = safe_symlink_target_path(.., target /* NULL */ ..)
    safe_symlink_target_path (source3/smbd/filename.c)
      if (target[0] == '/') { /* NULL pointer dereference */

A failure in VFS module's readlinkat hook may happen due to run-time
error (e.g., network failure which cases libcephfs to disconnect from
MDS).

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15700
Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Aug 23 09:27:06 UTC 2024 on atb-devel-224

11 months agos3:tests: Fix spelling error
Martin Schwenke [Tue, 13 Aug 2024 11:55:34 +0000 (21:55 +1000)] 
s3:tests: Fix spelling error

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Aug 22 10:38:09 UTC 2024 on atb-devel-224

11 months agocodespell: Ignore CTDB bin/
Martin Schwenke [Tue, 13 Aug 2024 11:43:48 +0000 (21:43 +1000)] 
codespell: Ignore CTDB bin/

This might be hanging around if standalone CTDB builds have been done.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
11 months agovfs_ceph_new: add missing newline in debug-logging
Shachar Sharon [Tue, 20 Aug 2024 09:06:40 +0000 (12:06 +0300)] 
vfs_ceph_new: add missing newline in debug-logging

Commit d00f20f3 ("vfs_ceph_new: debug-log upon libcephfs low-level
calls") introduced debug-logging before each call to libcephfs low-level
APIs. Unfortunately, one of the logging messages missed the terminating
newline ('\n') character.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Wed Aug 21 14:18:07 UTC 2024 on atb-devel-224

11 months agolibsmb: Remove cli_state->rap_error
Volker Lendecke [Tue, 20 Aug 2024 13:13:52 +0000 (15:13 +0200)] 
libsmb: Remove cli_state->rap_error

I could not find any caller which uses rap_error outside of the
routine implementing the rap client call itself.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Aug 21 12:49:45 UTC 2024 on atb-devel-224

11 months agolibsmb: Remove unused cli_NetWkstaUserLogoff()
Volker Lendecke [Mon, 19 Aug 2024 12:17:42 +0000 (14:17 +0200)] 
libsmb: Remove unused cli_NetWkstaUserLogoff()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
11 months agolibsmb: Remove unused cli_ns_check_server_type()
Volker Lendecke [Mon, 19 Aug 2024 12:16:40 +0000 (14:16 +0200)] 
libsmb: Remove unused cli_ns_check_server_type()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
11 months agoWHATSNEW: add 'vfs mkdir use tmp name' option
Stefan Metzmacher [Mon, 12 Aug 2024 12:41:47 +0000 (14:41 +0200)] 
WHATSNEW: add 'vfs mkdir use tmp name' option

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Aug 21 09:18:00 UTC 2024 on atb-devel-224

11 months agos3:smbd: let mkdir_internal() try VFS_RENAME_HOW_NO_REPLACE first
Stefan Metzmacher [Wed, 7 Aug 2024 15:01:53 +0000 (17:01 +0200)] 
s3:smbd: let mkdir_internal() try VFS_RENAME_HOW_NO_REPLACE first

With renameat2(RENAME_NOREPLACE) being available
it's even better, as we don't even have the short
window where the incomplete directory is visible
to others.

The flow will be this:

tmp_name = ".::TMPNAME:D:$PID:client_name"
mkdirat(tmp_name, mode=client_mode);
prepare_acls(tmp_name);
renameat2(tmp_name, client_name, NOREPLACE);
if (EEXIST) {
   unlinkat(tmp_name);
   return EEXIST;
}
if (EINVAL) {
   /* fallback if NOREPLACE is not supported */
   mkdirat(client_name, mode=0);
   if (EEXIST) {
      unlinkat(tmp_name);
      return EEXIST;
   }
   renameat(tmp_name, client_name);
}

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:vfs_default: implement VFS_RENAME_HOW_NO_REPLACE in vfswrap_renameat()
Stefan Metzmacher [Wed, 7 Aug 2024 11:14:23 +0000 (13:14 +0200)] 
s3:vfs_default: implement VFS_RENAME_HOW_NO_REPLACE in vfswrap_renameat()

We can use renameat2() without ifdef as libreplace always provides it.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:vfs: add VFS_RENAME_HOW_NO_REPLACE
Stefan Metzmacher [Wed, 7 Aug 2024 11:05:07 +0000 (13:05 +0200)] 
s3:vfs: add VFS_RENAME_HOW_NO_REPLACE

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:vfs: add vfs_rename_how to SMB_VFS_RENAMEAT()
Stefan Metzmacher [Tue, 6 Aug 2024 11:21:34 +0000 (13:21 +0200)] 
s3:vfs: add vfs_rename_how to SMB_VFS_RENAMEAT()

This will support renameat2-like operations in future.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/replace: add renameat2() replacement
Stefan Metzmacher [Wed, 7 Aug 2024 11:01:48 +0000 (13:01 +0200)] 
lib/replace: add renameat2() replacement

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:smbd: let mkdir_internal() work more atomically using a temporary name
Stefan Metzmacher [Thu, 1 Aug 2024 12:37:55 +0000 (14:37 +0200)] 
s3:smbd: let mkdir_internal() work more atomically using a temporary name

Currently we do this in mkdir_internal():

mkdirat(client_name);
if (EEXIST) {
   return EEXIST;
}
prepare_acls(client_name);

Note 'prepare_acls()' is a placeholder for the complex steps
it is doing to prepare the directory. During these steps
we have the problem that other clients already see
the directory and are able to create files or subdirectories
in it and these may not inherit the correct acls as
the their parent directory is not created completely.

I think I found a good strategie even without relying on
renameat2(RENAME_NOREPLACE).

We would do this instead:

tmp_name = ".::TMPNAME:D:$PID:client_name"
mkdirat(tmp_name, mode=client_mode);
prepare_acls(tmp_name);
mkdirat(client_name, mode=0);
if (EEXIST) {
   unlinkat(tmp_name);
   return EEXIST;
}
renameat(tmp_name, client_name);

So instead of having a long windows during prepare_acls,
we just have a short window between mkdirat(client_name, mode=0)
and renameat(tmp_name, client_name);
And in that short window the directory with the client_name
has a mode of 0, so it's not possible for other clients
to create files or subdirs in it.

As the mkdirat(client_name, mode=0) still catches
EEXIST the race where two clients try to create
the same client_name is closed as before,
so we don't need any other protection.

Following patches will make use of renameat2(RENAME_NOREPLACE),
but this already a very good improvement.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agodocs-xml: add 'vfs mkdir use tmp name' option
Stefan Metzmacher [Fri, 9 Aug 2024 09:08:17 +0000 (11:08 +0200)] 
docs-xml: add 'vfs mkdir use tmp name' option

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:smbd: improve DEBUG messages in mkdir_internal()
Stefan Metzmacher [Thu, 1 Aug 2024 12:37:55 +0000 (14:37 +0200)] 
s3:smbd: improve DEBUG messages in mkdir_internal()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:smbd: let mkdir_internal() use a talloc_stackframe()
Stefan Metzmacher [Thu, 1 Aug 2024 12:37:55 +0000 (14:37 +0200)] 
s3:smbd: let mkdir_internal() use a talloc_stackframe()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:smbd: call apply_new_nt_acl() already in mkdir_internals()
Stefan Metzmacher [Fri, 9 Aug 2024 15:52:25 +0000 (17:52 +0200)] 
s3:smbd: call apply_new_nt_acl() already in mkdir_internals()

We should have preparation steps as close as possible together.

We could move it for files as well, but that's a task for another
day...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos3:smbd: split out apply_new_nt_acl() helper
Stefan Metzmacher [Fri, 9 Aug 2024 15:52:25 +0000 (17:52 +0200)] 
s3:smbd: split out apply_new_nt_acl() helper

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/util: let server_id_str_buf_unique() use server_id_buf
Stefan Metzmacher [Fri, 2 Aug 2024 06:25:16 +0000 (08:25 +0200)] 
lib/util: let server_id_str_buf_unique() use server_id_buf

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/util: split out server_id_from_string_ex allow the unique delimiter to be passed in
Stefan Metzmacher [Fri, 2 Aug 2024 06:25:16 +0000 (08:25 +0200)] 
lib/util: split out server_id_from_string_ex allow the unique delimiter to be passed in

In future it also allows to specifiy another delemiter than '/'
in order to use the resulting buffer as part of a file/directory
name.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/util: add server_id_str_buf_unique_ex() and allow the delimiter to be passed in
Stefan Metzmacher [Fri, 2 Aug 2024 06:25:16 +0000 (08:25 +0200)] 
lib/util: add server_id_str_buf_unique_ex() and allow the delimiter to be passed in

This way the server_id_str_buf() can just be a tiny wrapper using
'\0' as delemiter.

In future it also allows to specifiy another delemiter than '/'
in order to use the resulting buffer as part of a file/directory
name.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/util: let server_id_str_buf() use PRIu32 and PRIu64
Stefan Metzmacher [Fri, 2 Aug 2024 06:25:16 +0000 (08:25 +0200)] 
lib/util: let server_id_str_buf() use PRIu32 and PRIu64

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/util: add a comment to struct server_id_buf
Stefan Metzmacher [Fri, 2 Aug 2024 06:25:16 +0000 (08:25 +0200)] 
lib/util: add a comment to struct server_id_buf

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos4:torture/smb2: add smb2.create.mkdir-visible
Stefan Metzmacher [Fri, 9 Aug 2024 09:06:00 +0000 (11:06 +0200)] 
s4:torture/smb2: add smb2.create.mkdir-visible

This reproduces a race where one client creates
a directory and other clients see it before
the directory is fully setup including the correct
permissions and similar things.

We have a DENY ACE for SEC_DIR_ADD_FILE, which means
that files can't be created. This is set on
a base directory 'mkdir_visible'.

Then we have a lot of async loops trying to create
a file called 'mkdir_visible\dir\file_NR'. These loop
as fast as possible expecting OBJECT_PATH_NOT_FOUND,
because 'mkdir_visible\dir' is not there.

Then we send a create for 'mkdir_visible\dir' and
expect that to work.

This should turn the 'mkdir_visible\dir\file_NR' loop
into getting ACCESS_DENIED, because the
DENY ACE for SEC_DIR_ADD_FILE should be inherited
before 'mkdir_visible\dir' is visible to other clients.

Because of the complex steps in mkdir_internal(),
smbd allows the creation 'mkdir_visible\dir\file_NR',
as 'mkdir_visible\dir' is already visible after the
mkdirat(), before the DENY ACE is inherited.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agolib/param: Don't treat a missing include file as an error in handle_include().
Pavel Filipenský [Tue, 20 Aug 2024 15:15:46 +0000 (17:15 +0200)] 
lib/param: Don't treat a missing include file as an error in handle_include().

Same fix as in commit 09d7690

'samba-tool domain provision -d10' fails if the included file does not
exist:

lpcfg_load: refreshing parameters from /etc/samba/smb.conf
Processing section "[global]"
Can't find include file /etc/samba/usershares.conf
pm_process() returned No
ERROR: Unable to load default file
  File "/usr/lib64/python3.12/site-packages/samba/netcmd/domain/provision.py", line 183, in run
    lp = sambaopts.get_loadparm()
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/samba/getopt.py", line 282, in get_loadparm
    self._lp.load_default()

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Aug 21 00:04:19 UTC 2024 on atb-devel-224

11 months agoctdb-scripts: Avoid flapping NFS services at startup
Martin Schwenke [Sat, 29 Jun 2024 02:25:59 +0000 (12:25 +1000)] 
ctdb-scripts: Avoid flapping NFS services at startup

If an NFS service check is set to, say, unhealthy_after=2 then it will
always switch from the (default startup) unhealthy state to healthy,
even if there is a fatal problem.  If all services/scripts appear OK
then the node will become healthy.  When the counter hits the limit it
will return to unhealthy.  This is misleading.

Instead, never use the counter at startup, until the service becomes
healthy.  This stops services flapping unhealthy-healthy-unhealthy.

A side-effect is that a service that starts in a broken state will
never be restarted to try to fix the problem.  This makes sense.  The
counting and restarting really exist to deal with problems that might
occur under load.  The first monitor events occur before public IPs
are hosted, so there can be no load.  If a service doesn't start
reliably the first time then the admin probably wants to know about
it.

nfs_iterate_test() is updated to run an initial monitor event to mark
the services as healthy.  This initialises the counter so it can be
used for the important part of the test.  Passing the -i option avoids
running the extra monitor event, so the first iteration will be the
initial monitor event.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-scripts: Make initial statistics output empty
Martin Schwenke [Sat, 29 Jun 2024 09:24:25 +0000 (19:24 +1000)] 
ctdb-scripts: Make initial statistics output empty

This makes initial failure to retrieve statistics less likely to
result in a statistics change.  To help with this, statistics
retrieval stderr now goes to the log - only stdout goes to the file.

This means that the test code for checking statistics changes needs to
be redone to actually run the statistics command and check.  As with
rpcinfo output, this output needs to behave as deterministically in
the test code as it done in the event script.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-scripts: Only consider statistics on timeout
Martin Schwenke [Sun, 30 Jun 2024 00:35:09 +0000 (10:35 +1000)] 
ctdb-scripts: Only consider statistics on timeout

Checking statistics is only really relevant to timeouts.  That is, if
an rpcinfo times out it is worth checking if the service making
progress.  If the RPC service is not registered then the statistics
don't need to be checked because they shouldn't be changing.

The 2 previously added tests added to check statistics progress now
behave identically and fail on all iterations.  To support testing
with "timeouts", an optional TIMEOUT flag can now be added to the RPC
service passed to nfs_iterate_test().  2 new tests are added to
exercise the new behaviour.

The 2 new "if" statements in nfs_iterate_test() could be combined.
However, a subsequent commit would split them and would be more
difficult to read.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Make _rpc_service_up() and _rpc_services_down() internal
Martin Schwenke [Fri, 5 Jul 2024 01:28:34 +0000 (11:28 +1000)] 
ctdb-tests: Make _rpc_service_up() and _rpc_services_down() internal

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Make NFS RPC monitoring tests consistent
Martin Schwenke [Thu, 4 Jul 2024 01:10:59 +0000 (11:10 +1000)] 
ctdb-tests: Make NFS RPC monitoring tests consistent

Update the remaining RPC monitoring tests to use nfs_iterate_test(),
depending on it to set results.  This makes all RPC monitoring tests
consistent, so they will all benefit from future improvements.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Drop unnecessarily "else"
Martin Schwenke [Fri, 5 Jul 2024 01:01:45 +0000 (11:01 +1000)] 
ctdb-tests: Drop unnecessarily "else"

Doing this in a previous commit would have made it more difficult to
read that commit.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Replace implicit healthy behaviour with early exits
Martin Schwenke [Thu, 4 Jul 2024 05:17:25 +0000 (15:17 +1000)] 
ctdb-tests: Replace implicit healthy behaviour with early exits

The early exits from the sub-shell make the obvious successes much
more obvious, and slightly simplify the code that follows.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Simplify handling of statistics change
Martin Schwenke [Fri, 5 Jul 2024 00:46:30 +0000 (10:46 +1000)] 
ctdb-tests: Simplify handling of statistics change

Handling this across two different functions led to insanity, so
simplify.

The handling of unhealthy_after when $_numfails = 0 implicitly causes
the node to be healthy.  This is how the "rpcinfo succeeds" case
works.  Doing it this way for statistics makes this patch easier to
read.  The implicit behaviour will go away in the next patch.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Move result check to rpc_set_service_failure_response()
Martin Schwenke [Thu, 4 Jul 2024 02:04:15 +0000 (12:04 +1000)] 
ctdb-tests: Move result check to rpc_set_service_failure_response()

The current structure here is wrong and repetitive.  Checking rpcinfo
result and determining output should be in the same place.

Failure counting is now contained in
rpc_set_service_failure_response(), but needs a file to survive the
sub-shell.

Don't attempt to combine and simplify code yet.  That would make this
commit harder to review.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Initialise return code file
Martin Schwenke [Fri, 5 Jul 2024 01:47:56 +0000 (11:47 +1000)] 
ctdb-tests: Initialise return code file

The output file is initialised, so doesn't need to be created on
success.  Treat the return code file the same way.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Add function rpc_failure() to log failures and warnings
Martin Schwenke [Thu, 4 Jul 2024 23:23:27 +0000 (09:23 +1000)] 
ctdb-tests: Add function rpc_failure() to log failures and warnings

Improves readability, makes future changes easier.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: Argument 3 to nfs_iterate_test() is up iteration
Martin Schwenke [Thu, 4 Jul 2024 00:44:18 +0000 (10:44 +1000)] 
ctdb-tests: Argument 3 to nfs_iterate_test() is up iteration

Nothing more complex is ever done, so we might as well simplify and
reduce coupling.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tests: nfs_iterate_test() marks RPC service down
Martin Schwenke [Thu, 4 Jul 2024 00:55:07 +0000 (10:55 +1000)] 
ctdb-tests: nfs_iterate_test() marks RPC service down

If an RPC service is given, it is automatically marked down.  This
avoids repetition in test cases and loosens coupling.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
11 months agoctdb-tcp: Remove a use of ctdb_addr_to_str()
Martin Schwenke [Sun, 18 Aug 2024 22:48:43 +0000 (08:48 +1000)] 
ctdb-tcp: Remove a use of ctdb_addr_to_str()

This one is in a rarely used error path, so call a function that
talloc()s the string instead.

Again, this will also print the port, which might be useful if we ever
add the ability to also specify ports in the nodes list.

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 Aug 20 14:24:14 UTC 2024 on atb-devel-224

11 months agoctdb-tcp: Consolidate failure code
Martin Schwenke [Sun, 18 Aug 2024 22:45:43 +0000 (08:45 +1000)] 
ctdb-tcp: Consolidate failure code

Same thing several times, so change to common failure code.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agoctdb-tcp: Use already constructed node name
Martin Schwenke [Sun, 18 Aug 2024 10:49:30 +0000 (20:49 +1000)] 
ctdb-tcp: Use already constructed node name

Node has been found, so use the pre-constructed name instead of
calling ctdb_addr_to_str().

This will also print the port, which might be useful if we ever add
the ability to also specify ports in the nodes list.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agoctdb-tcp: Use path_rundir_append() to construct lock_path
Martin Schwenke [Fri, 9 Aug 2024 01:20:06 +0000 (11:20 +1000)] 
ctdb-tcp: Use path_rundir_append() to construct lock_path

The current constant value doesn't respect CTDB_TEST_MODE/CTDB_BASE.
Instead use the path module to allow automatic listening in test mode
with local daemons.

A single node can be tested with local daemons, using something like:

  $ tests/local_daemons.sh foo setup -n 1 -C "node address"
  $ grep "node address" foo/node.0/ctdb.conf
      # node address = 127.0.0.1
  $ tests/local_daemons.sh foo start all
  $ tests/local_daemons.sh foo print-log 0 | grep -i chose
  ... node.0 ctdbd[24546]: ctdb chose network address 127.0.0.1:4379

The trick is that commenting out the node address in ctdb.conf means
the chosen node address is the first one from the nodes file that
allows bind/listen.  In this case it is the only line.

The following ensures that automatic listening works for a node that
isn't the first:

  $ cat >mynodes
  192.168.1.1
  127.0.0.1
  $ tests/local_daemons.sh foo setup -n 2 -N mynodes -C "node address"
  $ grep "node address" foo/node.1/ctdb.conf
      # node address = 127.0.0.1
  $ tests/local_daemons.sh foo start 1
  $ tests/local_daemons.sh foo print-log 1 | grep -i chose
  [...] node.1 ctdbd[22787]: ctdb chose network address 127.0.0.1:4379

Note that the first address isn't local on this host, so will always
fail.

So, doing the above and starting both nodes yields...

  ...
  $ tests/local_daemons.sh foo start 1
  $ sleep 3; tests/local_daemons.sh foo start 0
  $ tests/local_daemons.sh foo print-log all | grep -i 'chose\|bind'
  [...] node.1 ctdbd[26351]: ctdb chose network address 127.0.0.1:4379
  [...] node.0 ctdbd[26438]: ctdb_tcp_listen_addr: Failed to bind() to socket - Address already in use (98)
  [...] node.0 ctdbd[26438]: Unable to bind to any node address - giving up

... as expected.

It would be nice to add tests for this, but we don't really have
infrastructure for that.  At least manual testing shows, for the
obvious cases, the previous commits didn't break anything.  :-)

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agoctdb-ib: Remove a use of ctdb_set_error()
Martin Schwenke [Fri, 26 Jul 2024 00:45:36 +0000 (10:45 +1000)] 
ctdb-ib: Remove a use of ctdb_set_error()

Now the transport code is free of ctdb_set_error().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agoctdb-tcp: Factor out listening code to avoid repetition
Martin Schwenke [Fri, 5 Jul 2024 05:51:25 +0000 (15:51 +1000)] 
ctdb-tcp: Factor out listening code to avoid repetition

Modernise debug and comments while here.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agoctdb-tcp: Use talloc_strdup() instead of repeating logic
Martin Schwenke [Fri, 5 Jul 2024 05:52:51 +0000 (15:52 +1000)] 
ctdb-tcp: Use talloc_strdup() instead of repeating logic

The node name is already constructed when the nodes file is loaded, so
just copy the node name.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agoctdb-daemon: Remove a use of ctdb_errstr()
Martin Schwenke [Fri, 26 Jul 2024 00:49:16 +0000 (10:49 +1000)] 
ctdb-daemon: Remove a use of ctdb_errstr()

Code to setup the transport is about to be cleaned up, including
removing uses of ctdb_set_error(), so avoid logging a NULL pointer or
some other old error.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
11 months agolibsmb: Remove cli_state->raw_status
Volker Lendecke [Mon, 19 Aug 2024 09:36:02 +0000 (11:36 +0200)] 
libsmb: Remove cli_state->raw_status

All callers which looked at this are gone

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Aug 20 10:57:12 UTC 2024 on atb-devel-224

11 months agolibsmb: Remove unused cli_is_error()
Volker Lendecke [Mon, 19 Aug 2024 09:25:52 +0000 (11:25 +0200)] 
libsmb: Remove unused cli_is_error()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Remove a call to cli_is_error()
Volker Lendecke [Mon, 19 Aug 2024 09:24:24 +0000 (11:24 +0200)] 
libsmb: Remove a call to cli_is_error()

We are already in the !NT_STATUS_IS_OK if-branch, so this call was
redundant

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Remove unused cli_errno()
Volker Lendecke [Mon, 19 Aug 2024 07:30:42 +0000 (09:30 +0200)] 
libsmb: Remove unused cli_errno()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Don't set errno in cli_NetServerEnum()
Volker Lendecke [Mon, 19 Aug 2024 07:28:45 +0000 (09:28 +0200)] 
libsmb: Don't set errno in cli_NetServerEnum()

No caller looks at it, and if someone should ever want to return a
more informative error, we now have NTSTATUS

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Convert cli_NetServerEnum() to return NTSTATUS
Volker Lendecke [Mon, 19 Aug 2024 07:26:51 +0000 (09:26 +0200)] 
libsmb: Convert cli_NetServerEnum() to return NTSTATUS

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Remove a reference to cli_errno()
Volker Lendecke [Mon, 19 Aug 2024 07:10:03 +0000 (09:10 +0200)] 
libsmb: Remove a reference to cli_errno()

If I see it correctly, this case was already covered by checking the
return code of cli_trans() a few lines above.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Remove unused cli_nt_error()
Volker Lendecke [Sun, 18 Aug 2024 19:47:01 +0000 (21:47 +0200)] 
libsmb: Remove unused cli_nt_error()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Make cli_api() static to clirap2.c
Volker Lendecke [Sun, 18 Aug 2024 19:45:58 +0000 (21:45 +0200)] 
libsmb: Make cli_api() static to clirap2.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agotorture3: Convert run_randomipc() away from cli_api()
Volker Lendecke [Sun, 18 Aug 2024 19:40:29 +0000 (21:40 +0200)] 
torture3: Convert run_randomipc() away from cli_api()

Not that it matters much, but I want to make cli_api() static in
clirap2.c.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Convert cli_NetServerEnum() away from cli_api()
Volker Lendecke [Sun, 18 Aug 2024 19:30:24 +0000 (21:30 +0200)] 
libsmb: Convert cli_NetServerEnum() away from cli_api()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Convert cli_RNetShareEnum() to NTSTATUS
Volker Lendecke [Sun, 18 Aug 2024 18:48:48 +0000 (20:48 +0200)] 
libsmb: Convert cli_RNetShareEnum() to NTSTATUS

Avoid a call to cli_nt_error()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Convert cli_RNetShareEnum() away from cli_api()
Volker Lendecke [Sun, 18 Aug 2024 18:36:45 +0000 (20:36 +0200)] 
libsmb: Convert cli_RNetShareEnum() away from cli_api()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Reduce indentation in cli_RNetShareEnum()
Volker Lendecke [Sun, 18 Aug 2024 18:19:56 +0000 (20:19 +0200)] 
libsmb: Reduce indentation in cli_RNetShareEnum()

Use a "goto done", review with "git show -b"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Convert cli_oem_change_password() to NTSTATUS
Volker Lendecke [Sun, 18 Aug 2024 10:55:34 +0000 (12:55 +0200)] 
libsmb: Convert cli_oem_change_password() to NTSTATUS

Remove a few calls to cli_nt_error()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Simplify smb1cli_trans_recv()
Volker Lendecke [Sun, 18 Aug 2024 09:29:46 +0000 (11:29 +0200)] 
libsmb: Simplify smb1cli_trans_recv()

tevent_req_received() called below takes care of this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Remove a pointless variable
Volker Lendecke [Sun, 18 Aug 2024 09:22:13 +0000 (11:22 +0200)] 
libsmb: Remove a pointless variable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agoutils: Fix "net rap password" return code
Volker Lendecke [Sun, 18 Aug 2024 10:40:29 +0000 (12:40 +0200)] 
utils: Fix "net rap password" return code

cli_oem_change_password() returns a bool, net_rap_password must return
0 for success

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Fix cli_oem_change_password()
Volker Lendecke [Sun, 18 Aug 2024 10:37:13 +0000 (12:37 +0200)] 
libsmb: Fix cli_oem_change_password()

"(rdrcnt < 2)" was wrong, we don't look at rdata but at rparam. Use
"min_rparam" to cli_trans and the fact that if that succeeds "rparam"
is not NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Convert cli_oem_change_password() away from cli_api()
Volker Lendecke [Sun, 18 Aug 2024 07:37:13 +0000 (09:37 +0200)] 
libsmb: Convert cli_oem_change_password() away from cli_api()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agosamr: Avoid a "ret == false" for a bool
Volker Lendecke [Sun, 18 Aug 2024 10:07:51 +0000 (12:07 +0200)] 
samr: Avoid a "ret == false" for a bool

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agobuild: Fix LIBCLI_SAMR dependencies
Volker Lendecke [Tue, 6 Aug 2024 07:05:15 +0000 (09:05 +0200)] 
build: Fix LIBCLI_SAMR dependencies

cli_samr.c calls init_Lsa_String

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Remove a pointless variable assignment
Volker Lendecke [Mon, 5 Aug 2024 15:31:15 +0000 (17:31 +0200)] 
libsmb: Remove a pointless variable assignment

We right away overwrite this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Avoid an "else", we return in the "true" branch
Volker Lendecke [Mon, 5 Aug 2024 15:29:46 +0000 (17:29 +0200)] 
libsmb: Avoid an "else", we return in the "true" branch

Reduce indentation

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
11 months agolibsmb: Swap if/else branches in remote_password_change
Volker Lendecke [Mon, 5 Aug 2024 15:28:02 +0000 (17:28 +0200)] 
libsmb: Swap if/else branches in remote_password_change

bail out with an early return next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>