]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
13 months agos3:param: Check return value of strlower_m() (CID 1598446)
Jo Sutton [Tue, 11 Jun 2024 03:10:02 +0000 (15:10 +1200)] 
s3:param: Check return value of strlower_m() (CID 1598446)

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agotests/krb5: Simplify code using dict.get()
Jo Sutton [Tue, 2 Jul 2024 02:55:45 +0000 (14:55 +1200)] 
tests/krb5: Simplify code using dict.get()

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agotests/krb5: Fix type errors by giving ‘pwd_last_set’ an appropriate type
Jo Sutton [Thu, 16 May 2024 02:41:17 +0000 (14:41 +1200)] 
tests/krb5: Fix type errors by giving ‘pwd_last_set’ an appropriate type

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agoFix starvation of pending writes in CTDB queues
Xavi Hernandez [Thu, 27 Jun 2024 13:41:19 +0000 (15:41 +0200)] 
Fix starvation of pending writes in CTDB queues

CTDB uses a queue to receive requests and send answers. It works
asynchronously using the tevent framework. However there was an issue
that gave priority to the receiving side so, when a request was
processed and the answer posted to the queue, if another incoming
request arrived, it was served before sending the previous answer.

This scenario could repeat for long periods of time if the frequency of
incoming requests was high enough.

Eventually, a small time gap between incoming request gave a chance to
process the pending output queue, sending many answers in a burst.

This patch makes sure that both queues (input and output) are processed
if the event contains the appropriate flag.

Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jul  1 09:17:43 UTC 2024 on atb-devel-224

13 months agos4:torture: Initialize param arrays
Andreas Schneider [Fri, 21 Jun 2024 11:36:23 +0000 (13:36 +0200)] 
s4:torture: Initialize param arrays

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/gentest.c:2690: var_decl: Declaring variable ""parm"" without initializer.
samba-4.20.0rc2/source4/torture/gentest.c:2711: uninit_use: Using uninitialized value ""parm[0]"". Field ""parm[0].out"" is uninitialized.
 2709|    }
 2710|
 2711|->  GEN_COPY_PARM;
 2712|    GEN_SET_FNUM_SMB2(in.file.handle);
 2713|    GEN_CALL_SMB2(smb2_lock(tree, &parm[i]));"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Jul  1 00:23:08 UTC 2024 on atb-devel-224

13 months agos4:torture: Remove trailing spaces from gentest.c
Andreas Schneider [Fri, 21 Jun 2024 11:37:46 +0000 (13:37 +0200)] 
s4:torture: Remove trailing spaces from gentest.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:winbind: Fix integer type of len
Andreas Schneider [Fri, 21 Jun 2024 08:57:32 +0000 (10:57 +0200)] 
s3:winbind: Fix integer type of len

"Error: INTEGER_OVERFLOW (CWE-190):
samba-4.20.0rc2/source3/winbindd/winbindd_cache.c:849: cast_overflow: Truncation due to cast operation on ""len"" from 32 to 8 bits.
samba-4.20.0rc2/source3/winbindd/winbindd_cache.c:851: overflow_sink: ""len"", which might have overflowed, is passed to ""memcpy(centry->data + centry->ofs, s, len)"". [Note: The source code implementation of the function has been overridden by a builtin model.]
  849|    centry_put_uint8(centry, len);
  850|    centry_expand(centry, len);
  851|->  memcpy(centry->data + centry->ofs, s, len);
  852|    centry->ofs += len;
  853|   }"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:smbd: Make sure struct security_ace is initialized
Andreas Schneider [Fri, 21 Jun 2024 08:49:53 +0000 (10:49 +0200)] 
s3:smbd: Make sure struct security_ace is initialized

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/smbd/posix_acls.c:4706: var_decl: Declaring variable ""aces"" without initializer.
samba-4.20.0rc2/source3/smbd/posix_acls.c:4748: uninit_use_in_call: Using uninitialized value ""*aces"". Field ""aces->object"" is uninitialized when calling ""make_sec_acl"".
 4746|    idx++;
 4747|
 4748|->  new_dacl = make_sec_acl(ctx,
 4749|    NT4_ACL_REVISION,
 4750|    idx,"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:libsmb: Check if we have a valid file descriptor
Andreas Schneider [Fri, 21 Jun 2024 08:48:01 +0000 (10:48 +0200)] 
s3:libsmb: Check if we have a valid file descriptor

"Error: REVERSE_NEGATIVE (CWE-191):
samba-4.20.0rc2/source3/libsmb/pylibsmb.c:215: negative_sink_in_call: Passing ""t->shutdown_pipe[1]"" to a parameter that cannot be negative.
samba-4.20.0rc2/source3/libsmb/pylibsmb.c:230: check_after_sink: You might be using variable ""t->shutdown_pipe[1]"" before verifying that it is >= 0.
  228|    t->shutdown_pipe[0] = -1;
  229|    }
  230|->  if (t->shutdown_pipe[1] != -1) {
  231|    close(t->shutdown_pipe[1]);
  232|    t->shutdown_pipe[1] = -1;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:torture: Initialize pointers
Andreas Schneider [Fri, 21 Jun 2024 08:45:23 +0000 (10:45 +0200)] 
s4:torture: Initialize pointers

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/durable_open.c:1518: var_decl: Declaring variable ""tree2"" without initializer.
samba-4.20.0rc2/source4/torture/smb2/durable_open.c:1584: uninit_use_in_call: Using uninitialized value ""tree2"" when calling ""smb2_util_close"".
 1582|    if (tree != NULL) {
 1583|    if (h != NULL) {
 1584|->  smb2_util_close(tree2, *h);
 1585|    }
 1586|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:torture: Initialize struct smb2_handle
Andreas Schneider [Thu, 20 Jun 2024 12:48:29 +0000 (14:48 +0200)] 
s4:torture: Initialize struct smb2_handle

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/lease.c:452: var_decl: Declaring variable ""h"" without initializer.
samba-4.20.0rc2/source4/torture/smb2/lease.c:516: uninit_use_in_call: Using uninitialized value ""h"" when calling ""smb2_util_close"".
  514|
  515|    done:
  516|->  smb2_util_close(tree, h);
  517|    smb2_util_close(tree, hnew);
  518|    smb2_util_close(tree, h2);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:torture: Initialize struct netr_LogonSamLogonEx
Andreas Schneider [Thu, 20 Jun 2024 12:44:33 +0000 (14:44 +0200)] 
s4:torture: Initialize struct netr_LogonSamLogonEx

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/rpc/schannel.c:250: var_decl: Declaring variable ""r"" without initializer.
samba-4.20.0rc2/source4/torture/rpc/schannel.c:357: uninit_use_in_call: Using uninitialized value ""r.in.validation_level"" when calling ""torture_comment"".
  355|    ""LogonSamLogonEx failed"");
  356|    } else {
  357|->  torture_comment(tctx,
  358|    ""Skip auth_level[%u] Testing LogonSamLogonEx with name %s using %s and validation_level: %d\n"",
  359|    auth_level, ninfo.identity_info.account_name.string, crypto_alg,"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:rpc_client: Initialize struct security_ace
Andreas Schneider [Thu, 20 Jun 2024 12:42:54 +0000 (14:42 +0200)] 
s3:rpc_client: Initialize struct security_ace

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/rpc_client/init_spoolss.c:348: var_decl: Declaring variable ""ace"" without initializer.
samba-4.20.0rc2/source3/rpc_client/init_spoolss.c:415: uninit_use_in_call: Using uninitialized value ""*ace"". Field ""ace->object"" is uninitialized when calling ""make_sec_acl"".
  413|       NT5 machine. */
  414|
  415|->  if ((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, i, ace)) != NULL) {
  416|    psd = make_sec_desc(mem_ctx,
  417|        SD_REVISION,"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:torture: Make sure struct smb2_handle is initialized
Andreas Schneider [Thu, 20 Jun 2024 07:24:12 +0000 (09:24 +0200)] 
s4:torture: Make sure struct smb2_handle is initialized

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/lease.c:1223: var_decl: Declaring variable ""h2"" without initializer.
samba-4.20.0rc2/source4/torture/smb2/lease.c:1328: uninit_use_in_call: Using uninitialized value ""h2"" when calling ""smb2_util_close"".
 1326|    done:
 1327|    smb2_util_close(tree, h);
 1328|->  smb2_util_close(tree, h2);
 1329|
 1330|    smb2_util_unlink(tree, fname);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:smbd: Make sure struct security_ace is initialized
Andreas Schneider [Thu, 20 Jun 2024 07:14:45 +0000 (09:14 +0200)] 
s3:smbd: Make sure struct security_ace is initialized

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/smbd/posix_acls.c:4778: var_decl: Declaring variable ""aces"" without initializer.
samba-4.20.0rc2/source3/smbd/posix_acls.c:4799: uninit_use_in_call: Using uninitialized value ""*aces"". Field ""aces->object"" is uninitialized when calling ""make_sec_acl"".
 4797|    idx++;
 4798|
 4799|->  new_dacl = make_sec_acl(ctx,
 4800|    NT4_ACL_REVISION,
 4801|    idx,"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:smbd: Remove trailing spaces in posix_acls.c
Andreas Schneider [Thu, 20 Jun 2024 07:14:20 +0000 (09:14 +0200)] 
s3:smbd: Remove trailing spaces in posix_acls.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agoexamples: Make sure the array is probably initialized
Andreas Schneider [Thu, 20 Jun 2024 07:12:22 +0000 (09:12 +0200)] 
examples: Make sure the array is probably initialized

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/examples/libsmbclient/testacl2.c:27: var_decl: Declaring variable ""value"" without initializer.
samba-4.20.0rc2/examples/libsmbclient/testacl2.c:48: uninit_use_in_call: Using uninitialized value ""*value"" as argument to ""%s"" when calling ""printf"". [Note: The source code implementation of the function has been overridden by a builtin model.]
   46|    }
   47|
   48|->  printf(""Attributes for [%s] are:\n%s\n"", argv[1], value);
   49|
   50|    flags = 0;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agowinexe: Make sure specificError is initialized
Andreas Schneider [Thu, 20 Jun 2024 07:08:48 +0000 (09:08 +0200)] 
winexe: Make sure specificError is initialized

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/examples/winexe/winexesvc.c:684: var_decl: Declaring variable ""specificError"" without initializer.
samba-4.20.0rc2/examples/winexe/winexesvc.c:711: uninit_use: Using uninitialized value ""specificError"".
  709|    winexesvcStatus.dwWaitHint = 0;
  710|    winexesvcStatus.dwWin32ExitCode = status;
  711|->  winexesvcStatus.dwServiceSpecificExitCode = specificError;
  712|
  713|    SetServiceStatus(winexesvcStatusHandle, &winexesvcStatus);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
13 months agosmbd: Fix cached dos attributes
Volker Lendecke [Mon, 24 Jun 2024 14:50:57 +0000 (16:50 +0200)] 
smbd: Fix cached dos attributes

The callers of fset_dos_mode must set the cached attributes
themselves, which I did not see. I tried, but I did not find a clean
way to fix this behind SMB_VFS_FSET_DOS_ATTRIBUTES, with a smb_fname
and smb_fname->fsp->fsp_name we might have two copies of the cached
dos attributes around and if we only update fsp->fsp_name, we might
miss the outer one.

Not doing a test, this is really fresh code, and in the future we must
reorganize setting and caching dos attributes anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jun 28 14:32:27 UTC 2024 on atb-devel-224

13 months agolibrpc: Make NDR_PRINT_DEBUG call just one DEBUG
Volker Lendecke [Mon, 17 Jun 2024 12:42:30 +0000 (14:42 +0200)] 
librpc: Make NDR_PRINT_DEBUG call just one DEBUG

Give debug.c the chance to use just one write call (right now it
doesn't yet)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify smbd_do_qfsinfo with direct struct initialization
Volker Lendecke [Thu, 27 Jun 2024 10:50:50 +0000 (12:50 +0200)] 
smbd: Simplify smbd_do_qfsinfo with direct struct initialization

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify reopen_from_fsp
Volker Lendecke [Wed, 26 Jun 2024 13:30:50 +0000 (15:30 +0200)] 
smbd: Simplify reopen_from_fsp

In a variable declaration the (struct ...) is not needed

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Remove some unused code
Volker Lendecke [Wed, 26 Jun 2024 06:57:26 +0000 (08:57 +0200)] 
smbd: Remove some unused code

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Avoid a cast
Volker Lendecke [Tue, 25 Jun 2024 14:11:16 +0000 (16:11 +0200)] 
smbd: Avoid a cast

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Print reparse_point in dos_mode_debug_print
Volker Lendecke [Tue, 25 Jun 2024 14:10:28 +0000 (16:10 +0200)] 
smbd: Print reparse_point in dos_mode_debug_print

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify dos_mode_from_sbuf
Volker Lendecke [Tue, 25 Jun 2024 14:07:58 +0000 (16:07 +0200)] 
smbd: Simplify dos_mode_from_sbuf

We don't need that else branch, this could be a switch as well

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify fdos_mode
Volker Lendecke [Tue, 25 Jun 2024 14:04:53 +0000 (16:04 +0200)] 
smbd: Simplify fdos_mode

We don't need the outer !NT_STATUS_IS_OK and the comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify filename_convert_dirfsp_nosymlink
Volker Lendecke [Tue, 25 Jun 2024 13:49:23 +0000 (15:49 +0200)] 
smbd: Simplify filename_convert_dirfsp_nosymlink

Initialize the timestamps in the existing struct assignment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Remove an obsolete comment
Volker Lendecke [Tue, 25 Jun 2024 11:08:58 +0000 (13:08 +0200)] 
smbd: Remove an obsolete comment

We have a good understanding of SAMBA_UTIME_OMIT these days

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify init_smb_file_time
Volker Lendecke [Tue, 25 Jun 2024 11:06:35 +0000 (13:06 +0200)] 
smbd: Simplify init_smb_file_time

Call make_omit_timespec just once, saves a few .text bytes

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Simplify copy_stat_ex_timestamps
Volker Lendecke [Tue, 25 Jun 2024 10:39:09 +0000 (12:39 +0200)] 
smbd: Simplify copy_stat_ex_timestamps

copy_stat_ex_timestamps doesn't need the fsp, it only needs the
destination stat struct

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Modernize a DEBUG
Volker Lendecke [Tue, 25 Jun 2024 08:41:41 +0000 (10:41 +0200)] 
smbd: Modernize a DEBUG

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agovfs: Fix typos
Volker Lendecke [Tue, 25 Jun 2024 08:28:38 +0000 (10:28 +0200)] 
vfs: Fix typos

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Don't leave a pointer variable uninitialized
Volker Lendecke [Mon, 24 Jun 2024 14:52:51 +0000 (16:52 +0200)] 
smbd: Don't leave a pointer variable uninitialized

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Align an integer type
Volker Lendecke [Mon, 24 Jun 2024 14:51:08 +0000 (16:51 +0200)] 
smbd: Align an integer type

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agosmbd: Modernize a DEBUG
Volker Lendecke [Mon, 24 Jun 2024 12:06:18 +0000 (14:06 +0200)] 
smbd: Modernize a DEBUG

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agoctdb-conf: Rename config loading to not be daemon-specific
Martin Schwenke [Sat, 22 Jun 2024 01:27:22 +0000 (11:27 +1000)] 
ctdb-conf: Rename config loading to not be daemon-specific

We might end up using it elsewhere.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-conf: Move conf.[ch] to conf/ subdirectory
Martin Schwenke [Mon, 19 Aug 2019 02:17:20 +0000 (12:17 +1000)] 
ctdb-conf: Move conf.[ch] to conf/ subdirectory

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-conf: Move all conf files to new conf/ subdirectory
Martin Schwenke [Mon, 19 Aug 2019 02:06:40 +0000 (12:06 +1000)] 
ctdb-conf: Move all conf files to new conf/ subdirectory

Leave common/conf.[ch] where they are to make this commit
comprehensible.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agos4:torture: Initialize struct wrepl_wins_name
Andreas Schneider [Mon, 24 Jun 2024 13:19:20 +0000 (15:19 +0200)] 
s4:torture: Initialize struct wrepl_wins_name

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:1244: var_decl: Declaring variable ""wins_name1"" without initializer.
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:4835: assign: Assigning: ""wins_name_r1"" = ""&wins_name1"", which points to uninitialized data.
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:4905: uninit_use_in_call: Using uninitialized value ""*wins_name_r1"". Field ""wins_name_r1->is_group"" is uninitialized when calling ""test_wrepl_update_one"".
 4903|
 4904|    /* now apply R1 */
 4905|->  ret &= test_wrepl_update_one(tctx, ctx, records[i].r1.owner, wins_name_r1);
 4906|    ret &= test_wrepl_is_applied(tctx, ctx, records[i].r1.owner,
 4907|         wins_name_r1, records[i].r1.apply_expected);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jun 28 12:44:31 UTC 2024 on atb-devel-224

13 months agoexamples: Initialize char arrays
Andreas Schneider [Mon, 24 Jun 2024 13:17:13 +0000 (15:17 +0200)] 
examples: Initialize char arrays

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/examples/libsmbclient/testacl3.c:15: var_decl: Declaring variable ""value"" without initializer.
samba-4.20.0rc2/examples/libsmbclient/testacl3.c:55: uninit_use_in_call: Using uninitialized value ""*value"" as argument to ""%s"" when calling ""printf"". [Note: The source code implementation of the function has been overridden by a builtin model.]
   53|    }
   54|
   55|->  printf(""Attributes for [%s] are:\n%s\n"", path, value);
   56|    }
   57|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agoexamples: Use cp with force option
Andreas Schneider [Mon, 24 Jun 2024 13:14:43 +0000 (15:14 +0200)] 
examples: Use cp with force option

"Error: SHELLCHECK_WARNING:
/usr/share/doc/samba/printing/VampireDriversFunctions:951:15: warning[SC2216]: Piping to 'cp', a command that doesn't read stdin. Wrong command or missing xargs?
  949|    CWD2=""$( pwd )"" ;
  950|    cd ""${i}"";
  951|->  echo ""yes"" | cp ../alldriverfiles.txt . 2> /dev/null ;
  952|
  953|    cat alldriverfiles.txt \"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos4:torture: Fully initialize struct samr_OpenUser
Andreas Schneider [Mon, 24 Jun 2024 13:09:21 +0000 (15:09 +0200)] 
s4:torture: Fully initialize struct samr_OpenUser

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/rpc/samr.c:7381: var_decl: Declaring variable ""r"" without initializer.
samba-4.20.0rc2/source4/torture/rpc/samr.c:7428: uninit_use: Using uninitialized value ""r.out.result.v"".
 7426|    torture_assert_ntstatus_ok(tctx, dcerpc_samr_QueryUserInfo_r(b, tctx, &q),
 7427|    ""QueryUserInfo failed"");
 7428|->  if (!NT_STATUS_IS_OK(r.out.result)) {
 7429|    torture_result(tctx, TORTURE_FAIL, ""QueryUserInfo(%u) failed - %s\n"", r.in.rid, nt_errstr(r.out.result));
 7430|    return false;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos3:rpc_client: Check for array size instead of UINT16_MAX
Andreas Schneider [Mon, 24 Jun 2024 11:38:34 +0000 (13:38 +0200)] 
s3:rpc_client: Check for array size instead of UINT16_MAX

mdscli_ctx->mdscmd_open.share_path is an array of size 1025. The
boundary is 1025 and not UINT16_MAX.

"Error: OVERRUN (CWE-119):
samba-4.20.0rc2/source3/rpc_client/cli_mdssvc.c:127: cond_at_least: Checking ""share_path_len < 1UL"" implies that ""share_path_len"" is at least 1 on the false branch.
samba-4.20.0rc2/source3/rpc_client/cli_mdssvc.c:127: cond_between: Checking ""share_path_len > 65535UL"" implies that ""share_path_len"" is between 1 and 65535 (inclusive) on the false branch.
samba-4.20.0rc2/source3/rpc_client/cli_mdssvc.c:133: overrun-local: Overrunning array ""mdscli_ctx->mdscmd_open.share_path"" of 1025 bytes at byte offset 65534 using index ""share_path_len - 1UL"" (which evaluates to 65534).
  131|    mdscli_ctx->mdscmd_open.share_path_len = share_path_len;
  132|
  133|->  if (mdscli_ctx->mdscmd_open.share_path[share_path_len-1] == '/') {
  134|    mdscli_ctx->mdscmd_open.share_path[share_path_len-1] = '\0';
  135|    mdscli_ctx->mdscmd_open.share_path_len--;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos4:torture: Initialize struct wrepl_wins_name
Andreas Schneider [Mon, 24 Jun 2024 10:22:19 +0000 (12:22 +0200)] 
s4:torture: Initialize struct wrepl_wins_name

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:6759: var_decl: Declaring variable ""wins_name_"" without initializer.
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:6760: assign: Assigning: ""wins_name"" = ""&wins_name_"", which points to uninitialized data.
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:9455: uninit_use_in_call: Using uninitialized value ""*wins_name"". Field ""wins_name->is_group"" is uninitialized when calling ""test_wrepl_update_one"".
 9453|    wins_name->unknown = ""255.255.255.255"";
 9454|
 9455|->  ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name);
 9456|
 9457|    /*"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos3:auth: Avoid passing freed pamh pointer to funcitons using it
Andreas Schneider [Mon, 24 Jun 2024 08:20:51 +0000 (10:20 +0200)] 
s3:auth: Avoid passing freed pamh pointer to funcitons using it

"Error: USE_AFTER_FREE (CWE-416):
samba-4.20.0rc2/source3/auth/pampass.c:466: freed_arg: ""pam_end"" frees ""pamh"".
samba-4.20.0rc2/source3/auth/pampass.c:467: pass_freed_arg: Passing freed pointer ""pamh"" as an argument to ""smb_pam_error_handler"".
  465|    if( pamh != NULL ) {
  466|    pam_error = pam_end(pamh, 0);
  467|->  if(smb_pam_error_handler(pamh, pam_error, ""End Cleanup Failed"", 2) == True) {
  468|    DEBUG(4, (""smb_pam_end: PAM: PAM_END OK.\n""));
  469|    return True;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos3:auth: Remove trailing spaces in pampass.c
Andreas Schneider [Mon, 24 Jun 2024 08:21:30 +0000 (10:21 +0200)] 
s3:auth: Remove trailing spaces in pampass.c

Reviewed-by: Noel Power <npower@samba.org>
13 months agos4:torture: Initialize struct smb2_handle
Andreas Schneider [Mon, 24 Jun 2024 08:11:31 +0000 (10:11 +0200)] 
s4:torture: Initialize struct smb2_handle

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/lease.c:336: var_decl: Declaring variable ""hnew"" without initializer.
samba-4.20.0rc2/source4/torture/smb2/lease.c:377: uninit_use_in_call: Using uninitialized value ""hnew"" when calling ""smb2_util_close"".
  375|    done:
  376|    smb2_util_close(tree, h);
  377|->  smb2_util_close(tree, hnew);
  378|
  379|    smb2_util_unlink(tree, fname);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos4:torture: Initialize struct nbt_name_query
Andreas Schneider [Mon, 24 Jun 2024 08:09:43 +0000 (10:09 +0200)] 
s4:torture: Initialize struct nbt_name_query

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/nbt/query.c:53: var_decl: Declaring variable ""io"" without initializer.
samba-4.20.0rc2/source4/torture/nbt/query.c:76: uninit_use_in_call: Using uninitialized value ""io.in.retries"" when calling ""nbt_name_query_send"".
   74|    while (num_sent - (result->num_pass+result->num_fail) < 10) {
   75|    struct nbt_name_request *req;
   76|->  req = nbt_name_query_send(nbtsock, &io);
   77|    torture_assert(tctx, req != NULL, ""Failed to setup request!"");
   78|    req->async.fn = increment_handler;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agos3:torture: Remove trailing spaces in query.c
Andreas Schneider [Mon, 24 Jun 2024 08:09:24 +0000 (10:09 +0200)] 
s3:torture: Remove trailing spaces in query.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
13 months agodoc: Update codeing guidelines for struct initialisation
Noel Power [Thu, 27 Jun 2024 08:02:04 +0000 (09:02 +0100)] 
doc: Update codeing guidelines for struct initialisation

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Fri Jun 28 10:17:14 UTC 2024 on atb-devel-224

13 months agosmbd: Fix crossing automounter mount points
Volker Lendecke [Fri, 29 Dec 2023 15:54:56 +0000 (16:54 +0100)] 
smbd: Fix crossing automounter mount points

We get ENOENT on /proc/self/fd/<fdnum> when we try to turn the
mountpoint's O_PATH handle into a real one. This does not trigger a
mount attempt, you have to use name-based calls.

This is not the real fix, because if the autofs mount triggers, the
inode number will change. For directories this is not a huge problem
as we don't touch the share mode database before we open the "real"
fd. We would only violate potential share modes with other pure
READ_ATTRIBUTES (i.e. stat-) opens that came before the mount
trigger.

As I don't think share modes on directories are really relevant, I
think we can live with this "fix". Once we do directory leases this
will potentially change.

As a quick remedy we could use our defer_open() mechanism that starts
path processing from scratch. But as long as this seems not really
required, we should not add users of this really bad way of going back
to square 1.

The "real" fix would be to go back to the point where we open the last
component with openat(). In the retry round we need to do this without
O_PATH to trigger the mount and only then do the initial fstat.

Right now I don't see an easy way to properly test this
behaviour. Intercepting with vfs_error_inject is certainly possible,
but nailing the exact call would clutter the main code path. So I have
just tested this manually.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Jun 27 11:59:05 UTC 2024 on atb-devel-224

13 months agovfs_ceph: use consistent code style when setting errno
Shachar Sharon [Tue, 28 May 2024 09:36:14 +0000 (12:36 +0300)] 
vfs_ceph: use consistent code style when setting errno

When setting explicit value to 'errno' use same coding-style as used in
this entire module (spaces before and after assignment operator).

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Thu Jun 27 06:35:19 UTC 2024 on atb-devel-224

13 months agovfs_ceph: explicit cast to uint64_t upon failure of ceph_statfs
Shachar Sharon [Thu, 30 May 2024 08:02:37 +0000 (11:02 +0300)] 
vfs_ceph: explicit cast to uint64_t upon failure of ceph_statfs

When a call to 'ceph_statfs' from with 'cephwrap_disk_free' returns
non-zero status do an explicit cast to uint64_t for the negative (-1)
value returned by 'status_code'.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_ceph: adjust code-style of cephwrap_disk_free
Shachar Sharon [Mon, 27 May 2024 09:30:44 +0000 (12:30 +0300)] 
vfs_ceph: adjust code-style of cephwrap_disk_free

The common convention in 'vfs_ceph.c' module is to bailout (by return or
goto) whenever the return value from libcephfs call is not OK. Apply
this code-style to cephwrap_disk_free hook.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_ceph: replace WRAP_RETURN macro with convenience helpers
Shachar Sharon [Thu, 23 May 2024 14:15:40 +0000 (17:15 +0300)] 
vfs_ceph: replace WRAP_RETURN macro with convenience helpers

The WRAP_RETURN is a non-hygienic macro, and as such has the potential
of creating bogus code (e.g. 'return WRAP_RETURN(ret);' which existed
in the code in the past but did not yield any compiler warning). Prefer
simple convenience helper functions instead, which are also type safe.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_ceph: use talloc in realpath hook
Shachar Sharon [Wed, 22 May 2024 13:28:32 +0000 (16:28 +0300)] 
vfs_ceph: use talloc in realpath hook

Prefer talloc_asprintf over asprintf when resolving realpath.
Re-format code using 'git clang-format'.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_ceph: re-map unimplemented hooks
Shachar Sharon [Wed, 22 May 2024 13:11:57 +0000 (16:11 +0300)] 
vfs_ceph: re-map unimplemented hooks

Code cleanup: prefer standard convenience helpers for unimplemented
VFS hooks.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_ceph: align lines-length with coding standard
Shachar Sharon [Sun, 26 May 2024 13:24:06 +0000 (16:24 +0300)] 
vfs_ceph: align lines-length with coding standard

Coding standard requires following Linux kernel style guide, with an
explicit statement that "Maximum Line Width is 80 Characters". Align
vfs_ceph.c with this convention: split long lines into multiple lines
and use 'git clang-format' to do auto-formatting based on Samba project
'.clang-format' settings.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_ceph: improve readability of cephwrap_realpath
Shachar Sharon [Thu, 30 May 2024 07:27:35 +0000 (10:27 +0300)] 
vfs_ceph: improve readability of cephwrap_realpath

Minor code cleanup: use local variable to reference current-work dir.
This commit is in preparation to following code-cleanup which aligns
line-length with Samba's coding conventions.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoExtended the documentation for the "tls certfile" parameter in the smb.conf.
Oliver Mihatsch [Thu, 13 Jun 2024 10:16:05 +0000 (12:16 +0200)] 
Extended the documentation for the "tls certfile" parameter in the smb.conf.

Signed-off-by: Oliver Mihatsch <om-git@q4k.de>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Thu Jun 27 05:33:17 UTC 2024 on atb-devel-224

13 months agothird_party/heimdal: Import lorikeet-heimdal-202406270253 (commit cbd2c0b8ec604686dc7...
Jo Sutton [Thu, 27 Jun 2024 02:59:43 +0000 (14:59 +1200)] 
third_party/heimdal: Import lorikeet-heimdal-202406270253 (commit cbd2c0b8ec604686dc7b363d1dcec69bf5f7a7ec)

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
13 months agothird_party/heimdal: Import lorikeet-heimdal-202406240121 (commit 4315286377278234be2...
Jo Sutton [Wed, 12 Jun 2024 02:42:38 +0000 (14:42 +1200)] 
third_party/heimdal: Import lorikeet-heimdal-202406240121 (commit 4315286377278234be2f3b6d52225a17b6116d54)

This lets us match the Windows FAST reply when the password is expired.

Windows clients were upset by the NTSTATUS field in the edata,
apparently interpreting it to mean “insufficient resource”.

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

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
13 months agotests/krb5: Add tests for errors produced when logging in with unusable accounts
Jo Sutton [Thu, 27 Jun 2024 00:29:52 +0000 (12:29 +1200)] 
tests/krb5: Add tests for errors produced when logging in with unusable accounts

Heimdal matches Windows in the no‐FAST case, but produces NTSTATUS codes
when it shouldn’t in the FAST case.

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

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
13 months agotests/krb5: Allow creation of disabled accounts for testing
Jo Sutton [Tue, 25 Jun 2024 00:51:48 +0000 (12:51 +1200)] 
tests/krb5: Allow creation of disabled accounts for testing

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

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
13 months agoctdb-failover: Split statd_callout add-client/del-client
Martin Schwenke [Fri, 10 May 2024 01:42:26 +0000 (11:42 +1000)] 
ctdb-failover: Split statd_callout add-client/del-client

rpc.statd is single-threaded and runs its HA callout synchronously. If
it is too slow then latency accumulates and rpc.statd's backlog grows.

Running a pair of add-client/del-client events with the current code
averages ~0.030s in my test environment.  This mean that 1000 clients
reclaiming locks after failover can easily cause 10s of latency.  This
could cause rpc.statd to become unresponsive, resulting in a time out
for an rpcinfo-based health check of the status service.

Split the add-client/del-client events out to a standalone
statd_callout executable, written in C, to be used as the HA callout
for rpc.statd.  All other functions move to statd_callout_helper.
Now, running a pair of add-client/del-client events in my test
environment averages only ~0.002s.  This seems less likely to cause
latency problems.

The standalone statd_callout executable needs to read a configuration
file, which is generated by statd_callout_helper from the "startup"
event.  It also needs access to a list of currently assigned public
IPs.

For backward compatibility, during installation a symlink is created
from $CTDB_BASE/statd-callout to the new statd_callout, which is
installed in the helper directory.

Testing this as part of the eventscript unit tests starts to become
even more of a hack than it used to be.  However, the dependency on
stubs and the corresponding setup of fake state makes it hard to move
this elsewhere.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jun 25 04:24:57 UTC 2024 on atb-devel-224

13 months agoctdb-doc: Drop unnecessary, broken attempt at rpc.statd stack trace
Martin Schwenke [Mon, 4 Mar 2024 03:29:41 +0000 (14:29 +1100)] 
ctdb-doc: Drop unnecessary, broken attempt at rpc.statd stack trace

There is a typo here, since there will be no process called "status".
Instead of fixing it, drop this because rpc.statd isn't the focus of
this monitoring check and when systemd is init rpc.statd isn't
restarted with nfs-ganesha.  It stays running, so a confusing stack
trace for rpc.statd is always logged.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
13 months agoctdb-scripts: Fail monitoring after 1 x NFS-Ganesha not running
Martin Schwenke [Fri, 24 May 2024 01:55:59 +0000 (11:55 +1000)] 
ctdb-scripts: Fail monitoring after 1 x NFS-Ganesha not running

If ganesha.nfsd is gone then a node can't provide an NFS service, so
should be marked unhealthy.  A later restart may bring it back to
health.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
13 months agoctdb-doc: Add example for NFS-Ganesha RPC checking
Martin Schwenke [Mon, 4 Mar 2024 03:28:11 +0000 (14:28 +1100)] 
ctdb-doc: Add example for NFS-Ganesha RPC checking

This one does an rpcinfo check, along with statistics mitigation.  It
can be used in combination with the existing 20.nfs_ganesha.check.

The equivalent kernel NFS file only restarts every 10 failures.  This
one can be a little more proactive given that false positives are less
likely with the statistics mitigation.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
13 months agoctdb-scripts: Implement NFS statistics retrieval for NFS-Ganesha
Martin Schwenke [Mon, 4 Mar 2024 02:52:10 +0000 (13:52 +1100)] 
ctdb-scripts: Implement NFS statistics retrieval for NFS-Ganesha

Simplicity is preferred here over absolute correctness.  If the
ganesha_stats command exits with an error or times out then no output
is produced so, implicitly, the statistics do not change.  Also, the
statistics always change at startup.  However, it is likely that the
statistics change when NFS makes progress and do not change when NFS
does not make progress.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
13 months agoctdb-scripts: Add service_stats_command variable to NFS checks
Martin Schwenke [Mon, 19 Feb 2024 10:42:11 +0000 (21:42 +1100)] 
ctdb-scripts: Add service_stats_command variable to NFS checks

When monitoring an RPC service, the rpcinfo command might time out
even though the service is making progress.  In this case, it is just
slow, so counting the timeout as a failure and potentially restarting
the service will not help.  The problem is determining if a service is
making progress.

Add a new NFS checks service_stats_command.  This command is intended
to run a statistics command.  The output is naively compared using
cmp(1).  If the output changes then rpcinfo failures are converted to
successes.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
13 months agosmbd: Simplify callers of notify_filter_string
Volker Lendecke [Thu, 20 Jun 2024 18:25:24 +0000 (20:25 +0200)] 
smbd: Simplify callers of notify_filter_string

This is exactly the application talloc_tos() was made for

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Jun 24 17:27:04 UTC 2024 on atb-devel-224

13 months agosmbd: Simplify notify_filter_string
Volker Lendecke [Thu, 20 Jun 2024 18:19:52 +0000 (20:19 +0200)] 
smbd: Simplify notify_filter_string

Just a single NULL check through talloc_asprintf_addbuf

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Modernize a DEBUG
Volker Lendecke [Thu, 20 Jun 2024 18:06:44 +0000 (20:06 +0200)] 
smbd: Modernize a DEBUG

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agolib: Align an integer type
Volker Lendecke [Mon, 17 Jun 2024 10:45:32 +0000 (12:45 +0200)] 
lib: Align an integer type

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Simplify smbd_do_qfilepathinfo()
Volker Lendecke [Mon, 17 Jun 2024 13:24:57 +0000 (15:24 +0200)] 
smbd: Simplify smbd_do_qfilepathinfo()

Use fsctl_get_reparse_tag()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agolib: Avoid an includes.h
Volker Lendecke [Mon, 10 Jun 2024 12:32:27 +0000 (14:32 +0200)] 
lib: Avoid an includes.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agolib: Move 286 bytes from R/W data to R/O text segment
Volker Lendecke [Mon, 10 Jun 2024 14:08:04 +0000 (16:08 +0200)] 
lib: Move 286 bytes from R/W data to R/O text segment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotdb: Update times in tdb_transaction_commit per fd, not per name
Volker Lendecke [Fri, 14 Jun 2024 15:48:52 +0000 (17:48 +0200)] 
tdb: Update times in tdb_transaction_commit per fd, not per name

We might have a relative filename in tdb->name, so we might do the
wrong thing here. And as we have the fd, why not use it...

We call futimens in vfs_default without #ifdef and it's Posix 2018 or
before. So I don't think we need to check for it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Fix DEBUG messages
Volker Lendecke [Fri, 14 Jun 2024 16:28:10 +0000 (18:28 +0200)] 
smbd: Fix DEBUG messages

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agocredentials: Protect the cred's nt hash with talloc_keep_secret
Volker Lendecke [Fri, 24 May 2024 15:16:14 +0000 (17:16 +0200)] 
credentials: Protect the cred's nt hash with talloc_keep_secret

This avoids the need for an explict ZERO_STRUCT before TALLOC_FREE

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agospnego: Fix typos
Volker Lendecke [Thu, 30 May 2024 12:06:39 +0000 (14:06 +0200)] 
spnego: Fix typos

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agogensec: Fix whitespace
Volker Lendecke [Thu, 30 May 2024 12:04:51 +0000 (14:04 +0200)] 
gensec: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agogse: Simplify gse_errstr() with talloc_asprintf_addbuf()
Volker Lendecke [Wed, 29 May 2024 15:27:11 +0000 (17:27 +0200)] 
gse: Simplify gse_errstr() with talloc_asprintf_addbuf()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agogse: Avoid explicit ZERO_STRUCT in gse_errstr()
Volker Lendecke [Wed, 29 May 2024 15:25:54 +0000 (17:25 +0200)] 
gse: Avoid explicit ZERO_STRUCT in gse_errstr()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agolibsmb: "clang-format" for an if-condition
Volker Lendecke [Fri, 31 May 2024 09:42:45 +0000 (11:42 +0200)] 
libsmb: "clang-format" for an if-condition

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agolib: Remove pointless \ line endings
Volker Lendecke [Fri, 31 May 2024 09:41:28 +0000 (11:41 +0200)] 
lib: Remove pointless \ line endings

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotdb: Fix a typo
Volker Lendecke [Fri, 31 May 2024 06:51:45 +0000 (08:51 +0200)] 
tdb: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agoheimdal_build: Fix whitespace
Volker Lendecke [Mon, 29 Apr 2024 11:11:36 +0000 (13:11 +0200)] 
heimdal_build: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotorture4: Fix some whitespace
Volker Lendecke [Fri, 31 May 2024 19:28:50 +0000 (21:28 +0200)] 
torture4: Fix some whitespace

Review with "git show -w"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agopackaging: Add missing quotes in smbprint
Andreas Schneider [Wed, 19 Jun 2024 09:50:26 +0000 (11:50 +0200)] 
packaging: Add missing quotes in smbprint

Found by Covscan.

"Error: SHELLCHECK_WARNING (CWE-569):
/usr/bin/smbprint:49:21: warning[SC1083]: This } is literal. Check expression (missing ;/\n?) or quote it.
   47|   #   Concat this with /.config to get the config file.
   48|   #
   49|-> eval acct_file=\${$#}
   50|   spool_dir=$(dirname $acct_file)
   51|   config_file=$spool_dir/.config"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jun 24 07:14:54 UTC 2024 on atb-devel-224

13 months agos3:registry: Add missing return value checks
Andreas Schneider [Wed, 19 Jun 2024 09:47:41 +0000 (11:47 +0200)] 
s3:registry: Add missing return value checks

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:registry: Avoid possible double frees
Andreas Schneider [Wed, 19 Jun 2024 09:46:15 +0000 (11:46 +0200)] 
s3:registry: Avoid possible double frees

Found by Covscan.

"Error: USE_AFTER_FREE (CWE-416):
samba-4.20.0rc2/source3/registry/reg_perfcount.c:309: freed_arg: ""_reg_perfcount_multi_sz_from_tdb"" frees ""*retbuf"".
samba-4.20.0rc2/source3/registry/reg_perfcount.c:313: double_free: Calling ""_reg_perfcount_multi_sz_from_tdb"" frees pointer ""*retbuf"" which has already been freed.
  311|    for(i = 1; i <= base_index; i++)
  312|    {
  313|->  buffer_size = _reg_perfcount_multi_sz_from_tdb(names, i*2, retbuf, buffer_size);
  314|    }
  315|    tdb_close(names);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:registry: Remove trailing spaces in reg_perfcount.c
Andreas Schneider [Wed, 19 Jun 2024 09:45:01 +0000 (11:45 +0200)] 
s3:registry: Remove trailing spaces in reg_perfcount.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:dsdb: Avoid possible underflows with new_len
Andreas Schneider [Wed, 19 Jun 2024 09:33:00 +0000 (11:33 +0200)] 
s4:dsdb: Avoid possible underflows with new_len

Found by Covscan.

"Error: INTEGER_OVERFLOW (CWE-190):
samba-4.20.0rc2/source4/dsdb/schema/schema_query.c:403: tainted_data_argument: The check ""i < new_len"" contains the tainted expression ""i"" which causes ""new_len"" to be considered tainted.
samba-4.20.0rc2/source4/dsdb/schema/schema_query.c:407: overflow: The expression ""new_len - i"" is deemed underflowed because at least one of its arguments has underflowed.
samba-4.20.0rc2/source4/dsdb/schema/schema_query.c:407: overflow: The expression ""(new_len - i) * 8UL"" is deemed underflowed because at least one of its arguments has underflowed.
samba-4.20.0rc2/source4/dsdb/schema/schema_query.c:407: overflow_sink: ""(new_len - i) * 8UL"", which might have underflowed, is passed to ""memmove(val1, val2, (new_len - i) * 8UL)"". [Note: The source code implementation of the function has been overridden by a builtin model.]
  405|    const char **val2 = &attr_list[i];
  406|    if (ldb_attr_cmp(*val1, *val2) == 0) {
  407|->  memmove(val1, val2, (new_len - i) * sizeof( *attr_list));
  408|    attr_list[new_len-1] = NULL;
  409|    new_len--;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:dsdb: Remove trailing spaces in schema_query.c
Andreas Schneider [Wed, 19 Jun 2024 09:26:12 +0000 (11:26 +0200)] 
s4:dsdb: Remove trailing spaces in schema_query.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:torture: Initialize struct wrepl_wins_name
Andreas Schneider [Wed, 19 Jun 2024 09:21:12 +0000 (11:21 +0200)] 
s4:torture: Initialize struct wrepl_wins_name

Found by Covscan.

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:5040: var_decl: Declaring variable ""wins_name_"" without initializer.
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:5041: assign: Assigning: ""wins_name"" = ""&wins_name_"", which points to uninitialized data.
samba-4.20.0rc2/source4/torture/nbt/winsreplication.c:6680: uninit_use_in_call: Using uninitialized value ""*wins_name"". Field ""wins_name->is_group"" is uninitialized when calling ""test_wrepl_update_one"".
 6678|    wins_name->unknown = ""255.255.255.255"";
 6679|
 6680|->  ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name);
 6681|    ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, true);
 6682|    } else {"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos4:torture: Remove trailing spaces in winsreplication.c
Andreas Schneider [Wed, 19 Jun 2024 09:20:37 +0000 (11:20 +0200)] 
s4:torture: Remove trailing spaces in winsreplication.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:utils: Fix get_window_height() return value
Andreas Schneider [Wed, 19 Jun 2024 09:17:22 +0000 (11:17 +0200)] 
s3:utils: Fix get_window_height() return value

Found by Covscan.

"Error: INTEGER_OVERFLOW (CWE-190):
samba-4.20.0rc2/source3/utils/regedit_list.c:522: tainted_data_return: Called function ""get_window_height(list)"", and a possible return value may be less than zero.
samba-4.20.0rc2/source3/utils/regedit_list.c:522: cast_underflow: An assign of a possibly negative number to an unsigned type, which might trigger an underflow.
samba-4.20.0rc2/source3/utils/regedit_list.c:526: overflow: The expression ""list->cursor_row -= page"" is deemed underflowed because at least one of its arguments has underflowed.
samba-4.20.0rc2/source3/utils/regedit_list.c:529: overflow_sink: ""list->cursor_row"", which might have underflowed, is passed to ""data_get_row_n(list, list->cursor_row)"".
  527|    list->start_row -= page;
  528|    }
  529|->  tmp = data_get_row_n(list, list->cursor_row);
  530|    break;
  531|    case ML_CURSOR_PGDN:"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
13 months agos3:rpc_server: Make sure struct security_ace is initialized
Andreas Schneider [Tue, 18 Jun 2024 13:57:45 +0000 (15:57 +0200)] 
s3:rpc_server: Make sure struct security_ace is initialized

Found by Covscan.

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/rpc_server/samr/srv_samr_nt.c:235: var_decl: Declaring variable ""ace"" without initializer.
samba-4.20.0rc2/source3/rpc_server/samr/srv_samr_nt.c:269: uninit_use_in_call: Using uninitialized value ""*ace"". Field ""ace->object"" is uninitialized when calling ""make_sec_acl"".
  267|    /* create the security descriptor */
  268|
  269|->  if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL)
  270|    return NT_STATUS_NO_MEMORY;
  271|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>