]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
13 months agos3:modules: Make nread a size_t and check for possible overflow
Andreas Schneider [Mon, 8 Jul 2024 09:25:32 +0000 (11:25 +0200)] 
s3:modules: Make nread a size_t and check for possible overflow

"Error: INTEGER_OVERFLOW (CWE-190):
samba-4.20.0rc2/source3/modules/vfs_preopen.c:215: tainted_data_return: Called function ""read(sock_fd, namebuf + nread, talloc_get_size(namebuf) - nread)"", and a possible return value may be less than zero.
samba-4.20.0rc2/source3/modules/vfs_preopen.c:215: assign: Assigning: ""thistime"" = ""read(sock_fd, namebuf + nread, talloc_get_size(namebuf) - nread)"".
samba-4.20.0rc2/source3/modules/vfs_preopen.c:221: overflow: The expression ""nread"" is considered to have possibly overflowed.
samba-4.20.0rc2/source3/modules/vfs_preopen.c:215: overflow: The expression ""talloc_get_size(namebuf) - nread"" is deemed overflowed because at least one of its arguments has overflowed.
samba-4.20.0rc2/source3/modules/vfs_preopen.c:215: overflow_sink: ""talloc_get_size(namebuf) - nread"", which might have underflowed, is passed to ""read(sock_fd, namebuf + nread, talloc_get_size(namebuf) - nread)"". [Note: The source code implementation of the function has been overridden by a builtin model.]
  213|    ssize_t thistime;
  214|
  215|->  thistime = read(sock_fd, namebuf + nread,
  216|    talloc_get_size(namebuf) - nread);
  217|    if (thistime <= 0) {"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos3:modules: Move chunk out of the loop
Andreas Schneider [Mon, 8 Jul 2024 09:24:34 +0000 (11:24 +0200)] 
s3:modules: Move chunk out of the loop

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos3:modules: Rename thistime to chunk
Andreas Schneider [Mon, 8 Jul 2024 09:23:39 +0000 (11:23 +0200)] 
s3:modules: Rename thistime to chunk

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agolibgpo: Initialize struct security_ace array
Andreas Schneider [Mon, 8 Jul 2024 09:13:35 +0000 (11:13 +0200)] 
libgpo: Initialize struct security_ace array

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/libgpo/gpo_reg.c:708: var_decl: Declaring variable ""ace"" without initializer.
samba-4.20.0rc2/libgpo/gpo_reg.c:755: uninit_use_in_call: Using uninitialized value ""*ace"". Field ""ace->object"" is uninitialized when calling ""make_sec_acl"".
  753|         mask, inherit_flags);
  754|
  755|->  theacl = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 6, ace);
  756|    W_ERROR_HAVE_NO_MEMORY(theacl);
  757|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos4:torture: Initialize struct smb_nttrans
Andreas Schneider [Mon, 8 Jul 2024 09:12:02 +0000 (11:12 +0200)] 
s4:torture: Initialize struct smb_nttrans

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/basic/scanner.c:368: var_decl: Declaring variable ""parms"" without initializer.
samba-4.20.0rc2/source4/torture/basic/scanner.c:388: uninit_use_in_call: Using uninitialized value ""parms.in.setup"" when calling ""smb_raw_nttrans"".
  386|    parms.in.data = ntdata_blob;
  387|
  388|->  status = smb_raw_nttrans(cli->tree, mem_ctx, &parms);
  389|
  390|    if (NT_STATUS_IS_ERR(status)) {"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos4:torture: Remove tailing spaces in scanner.c
Andreas Schneider [Mon, 8 Jul 2024 09:11:26 +0000 (11:11 +0200)] 
s4:torture: Remove tailing spaces in scanner.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos4:torture: Initialize struct smb2_create
Andreas Schneider [Mon, 8 Jul 2024 09:05:45 +0000 (11:05 +0200)] 
s4:torture: Initialize struct smb2_create

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/sharemode.c:639: var_decl: Declaring variable ""cr3"" without initializer.
samba-4.20.0rc2/source4/torture/smb2/sharemode.c:736: uninit_use_in_call: Using uninitialized value ""cr3.out.file.handle"" when calling ""smb2_util_close"".
  734|    smb2_util_close(tree, cr1.out.file.handle);
  735|    smb2_util_close(tree, cr2.out.file.handle);
  736|->  smb2_util_close(tree, cr3.out.file.handle);
  737|    smb2_util_unlink(tree, fname);
  738|    return ret;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agolib:util: Move open() of /dev/null into the if-clause
Andreas Schneider [Mon, 8 Jul 2024 08:14:39 +0000 (10:14 +0200)] 
lib:util: Move open() of /dev/null into the if-clause

"Error: RESOURCE_LEAK (CWE-772):
samba-4.20.0rc2/lib/util/close_low_fd.c:40: open_fn: Returning handle opened by ""open"". [Note: The source code implementation of the function has been overridden by a user model.]
samba-4.20.0rc2/lib/util/close_low_fd.c:40: var_assign: Assigning: ""dev_null"" = handle returned from ""open(""/dev/null"", 2, 0)"".
samba-4.20.0rc2/lib/util/close_low_fd.c:52: overwrite_var: Overwriting handle ""dev_null"" in ""dev_null = open(""/dev/null"", 2, 0)"" leaks the handle.
   50|    }
   51|
   52|->  dev_null = open(""/dev/null"", O_RDWR, 0);
   53|    if (dev_null == -1) {
   54|    dev_null = open(""/dev/null"", O_WRONLY, 0);"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agolibcli:nbt: Initialize struct nbt_name_register
Andreas Schneider [Fri, 5 Jul 2024 12:00:11 +0000 (14:00 +0200)] 
libcli:nbt: Initialize struct nbt_name_register

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/libcli/nbt/pynbt.c:277: var_decl: Declaring variable ""io"" without initializer.
samba-4.20.0rc2/libcli/nbt/pynbt.c:305: uninit_use_in_call: Using uninitialized value ""io.in.nb_flags"" when calling ""nbt_name_register"".
  303|    return NULL;
  304|
  305|->  status = nbt_name_register(node->socket, NULL, &io);
  306|
  307|    if (NT_STATUS_IS_ERR(status)) {"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos4:torture: Initialize union smb_open
Andreas Schneider [Fri, 5 Jul 2024 11:58:53 +0000 (13:58 +0200)] 
s4:torture: Initialize union smb_open

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/raw/open.c:1136: var_decl: Declaring variable ""io1"" without initializer.
samba-4.20.0rc2/source4/torture/raw/open.c:1198: uninit_use_in_call: Using uninitialized value ""io1.ntcreatex.out.file.fnum"" when calling ""smbcli_close"".
 1196|    done:
 1197|    smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
 1198|->  smbcli_close(cli->tree, io1.ntcreatex.out.file.fnum);
 1199|    smbcli_deltree(cli->tree, BASEDIR);
 1200|    return ret;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agos4:torture: Initialize struct netr_IdentityInfo
Andreas Schneider [Fri, 5 Jul 2024 11:37:30 +0000 (13:37 +0200)] 
s4:torture: Initialize struct netr_IdentityInfo

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/rpc/samr.c:3601: var_decl: Declaring variable ""identity"" without initializer.
samba-4.20.0rc2/source4/torture/rpc/samr.c:3650: uninit_use: Using uninitialized value ""identity"". Field ""identity.domain_name.length"" is uninitialized.
 3648|    }
 3649|
 3650|->  pinfo.identity_info = identity;
 3651|    logon.password = &pinfo;
 3652|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
13 months agopython:tests: pass bytes.decode() instead of str(bytes) to assertMultiLineEqual(...
Stefan Metzmacher [Mon, 15 Jul 2024 18:14:46 +0000 (20:14 +0200)] 
python:tests: pass bytes.decode() instead of str(bytes) to assertMultiLineEqual() to get better failure output

When not equal a diff of the two strings highlighting the differences
will be included this way.

This is a flapping test.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jul 16 07:40:41 UTC 2024 on atb-devel-224

13 months agopython:tests: Use assertMultiLineEqual() to get better failure output
Andreas Schneider [Mon, 15 Jul 2024 08:25:50 +0000 (10:25 +0200)] 
python:tests: Use assertMultiLineEqual() to get better failure output

When not equal a diff of the two strings highlighting the differences
will be included this way.

This is a flapping test.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jul 15 13:51:03 UTC 2024 on atb-devel-224

13 months agosmbd: Show blk and chr devices as nfs reparse points
Volker Lendecke [Mon, 8 Jul 2024 09:23:14 +0000 (11:23 +0200)] 
smbd: Show blk and chr devices as nfs reparse points

Can't test these in selftest, we can't create devices and I don't want
us to depend on /dev to exist. Tested manually on a system where
/dev/null exists:

Try "help" to get a list of possible commands.
smb: \> allinfo null
altname: null
create_time:    Fri Jun 21 02:45:59 PM 2024 CEST
access_time:    Fri Jun 21 02:45:59 PM 2024 CEST
write_time:     Fri Jun 21 02:45:59 PM 2024 CEST
change_time:    Fri Jun 21 02:45:59 PM 2024 CEST
attributes:  (480)
stream: [::$DATA], 0 bytes
0x80000014 (IO_REPARSE_TAG_NFS)
 0x524843 (NFS_SPECFILE_CHR)
 1/3
smb: \>

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): Fri Jul 12 21:36:16 UTC 2024 on atb-devel-224

13 months agosmbd: Report sockets as NFS style reparse points
Volker Lendecke [Sun, 7 Jul 2024 18:39:30 +0000 (20:39 +0200)] 
smbd: Report sockets as NFS style reparse points

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Factor out fsctl_get_reparse_point_int
Volker Lendecke [Sun, 7 Jul 2024 18:37:49 +0000 (20:37 +0200)] 
smbd: Factor out fsctl_get_reparse_point_int

We'll use it for the other special files as well

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Show sockets as reparse points in fdos_mode
Volker Lendecke [Mon, 8 Jul 2024 08:25:05 +0000 (10:25 +0200)] 
smbd: Show sockets as reparse points in fdos_mode

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotests: Sockets should be shown as NFS reparse points
Volker Lendecke [Sun, 7 Jul 2024 18:28:59 +0000 (20:28 +0200)] 
tests: Sockets should be shown as NFS reparse points

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotests: Factor out do_test_nfs_reparse
Volker Lendecke [Sun, 7 Jul 2024 18:21:12 +0000 (20:21 +0200)] 
tests: Factor out do_test_nfs_reparse

Will be used for sockets next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Report FIFOs as NFS style reparse points
Volker Lendecke [Fri, 5 Jul 2024 15:58:55 +0000 (17:58 +0200)] 
smbd: Report FIFOs as NFS style reparse points

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Turn an if-statement getting reparse points into a switch
Volker Lendecke [Fri, 5 Jul 2024 15:31:19 +0000 (17:31 +0200)] 
smbd: Turn an if-statement getting reparse points into a switch

There will be more cases soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Show fifos as reparse points in fdos_mode
Volker Lendecke [Fri, 5 Jul 2024 15:57:44 +0000 (17:57 +0200)] 
smbd: Show fifos as reparse points in fdos_mode

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Turn file type handling in fdos_mode into a switch
Volker Lendecke [Fri, 5 Jul 2024 15:56:40 +0000 (17:56 +0200)] 
smbd: Turn file type handling in fdos_mode into a switch

There will be more cases soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agosmbd: Add DBG to return tag for SMB_FILE_ATTRIBUTE_TAG_INFORMATION
Volker Lendecke [Fri, 5 Jul 2024 15:30:49 +0000 (17:30 +0200)] 
smbd: Add DBG to return tag for SMB_FILE_ATTRIBUTE_TAG_INFORMATION

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotests: FIFOs should be shown as NFS reparse points
Volker Lendecke [Mon, 17 Jun 2024 10:45:18 +0000 (12:45 +0200)] 
tests: FIFOs should be shown as NFS reparse points

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotests: Run reparsepoint tests in fileserver_smb1
Volker Lendecke [Fri, 5 Jul 2024 16:03:10 +0000 (18:03 +0200)] 
tests: Run reparsepoint tests in fileserver_smb1

We'll need posix extensions soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agovfs: xattr calls give EBADF for sockets
Volker Lendecke [Mon, 8 Jul 2024 17:37:01 +0000 (19:37 +0200)] 
vfs: xattr calls give EBADF for sockets

This is required for make test with disabled O_PATH

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agopidl: Wireshark: Another C99 type conversion
John Thacker [Wed, 3 Jul 2024 12:03:41 +0000 (08:03 -0400)] 
pidl: Wireshark: Another C99 type conversion

Pick up change from Wireshark:

    commit bdb719f846f9d8f7800b9f50dadfde5e7f7a89e1
    Author: John Thacker <johnthacker@gmail.com>
    Date:   Sun Jun 23 08:15:45 2024 -0400

        pidl: Another C99 type conversion

        Change an automated sizeof() call in the pidl dissector generation from
        prefixing a "g" to getting the actual C type.

        Ping #19116

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jul 12 11:08:03 UTC 2024 on atb-devel-224

13 months agopidl: Wireshark: Don't assign hash undef, assign it an empty array
John Thacker [Wed, 3 Jul 2024 12:00:59 +0000 (08:00 -0400)] 
pidl: Wireshark: Don't assign hash undef, assign it an empty array

Pick up change from Wireshark:

    commit ade6577f109e2bf741909226254b758e79a816f1
    Author: John Thacker <johnthacker@gmail.com>
    Date:   Fri Jun 21 20:27:51 2024 -0400

        pidl: Don't assign hash undef, assign it an empty array

        Perl works, but complains if warnings are on, if a hash is
        initialized to undef instead of to empty. Upstream Samba turned on
        warnings in the next commit to catch things like this.

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Wireshark: Remove init of proto variables
John Thacker [Wed, 3 Jul 2024 11:58:04 +0000 (07:58 -0400)] 
pidl: Wireshark: Remove init of proto variables

Pick up change from Wireshark:

    commit 10b046cbdd110dbae8f4cab048e5954bf6955402
    Author: John Thacker <johnthacker@gmail.com>
    Date:   Sat Jun 22 20:31:40 2024 -0400

        pidl: Remove init of proto variables

        Remove initialization of proto variables from pidl generated dissectors
        and regenerate.
        Follow up to 2a9bc63325c99653c5da873c273430add3b5e9dd

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Wireshark: Convert the pidl dissector generation code to C99 types
John Thacker [Wed, 3 Jul 2024 11:56:42 +0000 (07:56 -0400)] 
pidl: Wireshark: Convert the pidl dissector generation code to C99 types

Pick up change from Wireshark:

    commit 4df8d2884ddfe72a03d0b322c10ae515a8366ea4
    Author: John Thacker <johnthacker@gmail.com>
    Date:   Sat Jun 22 11:21:47 2024 -0400

        pidl: Convert the pidl dissector generation code to C99 types

        Switch the Wireshark.pm pidl dissector generation code to using C99
        types, and regenerated the dcerpc pidl dissectors.

        Ping #19116

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Wireshark: Update test for removal of ett initialization
John Thacker [Wed, 3 Jul 2024 11:54:40 +0000 (07:54 -0400)] 
pidl: Wireshark: Update test for removal of ett initialization

Pick up change from Wireshark:

    commit 6e4c81b324e9b1752ce6bc253a09355512b5b387
    Author: John Thacker <johnthacker@gmail.com>
    Date:   Sat Jun 22 11:10:48 2024 -0400

        pidl: Update test for removal of ett initialization

        Also remove trailing whitespace

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Wireshark: Const-ify dcerpc_sub_dissector structures.
John Thacker [Wed, 3 Jul 2024 11:52:42 +0000 (07:52 -0400)] 
pidl: Wireshark: Const-ify dcerpc_sub_dissector structures.

Pick up change from Wireshark:

    commit 8a2a42241fd148ce735e776a6a1e6b49b64d215e
    Author: Darius Davis <darius-wireshark@free-range.com.au>
    Date:   Sun May 19 17:39:38 2024 +1000

        Const-ify dcerpc_sub_dissector structures.

        This moves about 56 kBytes of data from a read-write data section to read-only.

        The various dissectors were _not_ regenerated for this commit.  Instead, this
        commit was produced using the following command:

           find * -type f -exec sed -i -e 's/\(["'\'']\|^\)static dcerpc_sub_dissector/\1static const dcerpc_sub_dissector/' \{\} \;

        This updates the generator script and its test, as well as making an identical
        change to all of the dissectors, regardless of whether or not those dissectors
        were produced by the generator script.

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Wireshark: Don't initialise static hf and ett variables.
John Thacker [Wed, 3 Jul 2024 11:50:55 +0000 (07:50 -0400)] 
pidl: Wireshark: Don't initialise static hf and ett variables.

Pick up change from Wireshark:

    commit 9ca6eff53db29cad7dfc7e57fba4d68e9c838ab5
    Author: Anders Broman <a.broman58@gmail.com>
    Date:   Thu May 2 14:14:29 2024 +0200

        PIDL: Don't initialise static hf and ett variables.

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Wireshark: Remove init of proto variables
John Thacker [Wed, 3 Jul 2024 11:49:15 +0000 (07:49 -0400)] 
pidl: Wireshark: Remove init of proto variables

Pick up change from Wireshark as it applies to PIDL:

    commit 2a9bc63325c99653c5da873c273430add3b5e9dd
    Author: Stig Bjørlykke <stig@bjorlykke.org>
    Date:   Mon Nov 20 08:16:40 2023 +0100

        Remove init of proto variables

        Remove init of proto, header field, expert info and subtree variables.
        This will reduces the binary size by approximate 1266320 bytes due to
        using .bss to zero-initialize the fields.

        The conversion is done using the tools/convert-proto-init.py script

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl: Update Wireshark generated DRSUAPI code
John Thacker [Wed, 3 Jul 2024 11:42:26 +0000 (07:42 -0400)] 
pidl: Update Wireshark generated DRSUAPI code

Picked from Wireshark:

    commit b1249b0be4badc44cbbb30ff414d32d1b884a668
    Author: hidd3ncod3s Sec <hidd3ncod3s@gmail.com>
    Date:   Tue Aug 15 04:29:08 2023 +0000

        DCERPC: Update DRSUAPI support

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months ago.gitlab-ci-main.yml: Add safe.directory '*'
Pavel Filipenský [Thu, 4 Jul 2024 09:08:03 +0000 (11:08 +0200)] 
.gitlab-ci-main.yml: Add safe.directory '*'

This is to fix the error when pushing to personal gitlab repo:

2024-07-04 08:16:05,460 Running: 'git clone --recursive --shared /builds/pfilipen/samba /builds/samba-testbase/master' in '/builds/pfilipen/samba'
Cloning into '/builds/samba-testbase/master'...
fatal: detected dubious ownership in repository at '/builds/pfilipen/samba/.git'
To add an exception for this directory, call:
git config --global --add safe.directory /builds/pfilipen/samba/.git
fatal: Could not read from remote repository.

Instead of adding more and more explicit repositories
we should just allow any, we're in an isolated environment...

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

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jul 10 10:35:00 UTC 2024 on atb-devel-224

13 months agocmdline:burn: list commands to always burn; warn on unknown
Douglas Bagnall [Fri, 5 Jul 2024 02:31:58 +0000 (14:31 +1200)] 
cmdline:burn: list commands to always burn; warn on unknown

We burn arguments to all unknown options containing "pass" (e.g.
"--passionate=false") in case they are a password option, but is bad
in the case where the unknown option takes no argument but the next
option *is* a password (like "--overpass --password2 barney". In that
case "--password2" would be burnt and not "barney".

The burning behaviour doesn't change with this commit, but users will now
see an error message explaining that the option was unknown. This is not
so much aimed at end users -- for who an invalid option will hopefully
lead to --help like output -- but to developers who add a new "pass"
option.

This also slightly speeds up the processing of known password options,
which is a little bit important because we are in a race to replace the
command line in /proc before an attacker sees it.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Jul 10 06:28:08 UTC 2024 on atb-devel-224

13 months agocmdline: samba-tool test for bad option warning
Douglas Bagnall [Fri, 5 Jul 2024 04:13:04 +0000 (16:13 +1200)] 
cmdline: samba-tool test for bad option warning

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agovfs_ceph: Disable the module on unsupported Ceph versions
Anoop C S [Mon, 8 Jul 2024 07:24:06 +0000 (12:54 +0530)] 
vfs_ceph: Disable the module on unsupported Ceph versions

For the last major release(v4.20) we had a warning issued(fe16ae1fe834)
to inform about the plan to disable building vfs_ceph in the absence of
certain required APIs. This is now due to make the changes and further
disable building the module if minimum required libcephfs APIs are not
present. As we speak this requirement includes ceph_select_filesystem()
and *at() variants of libcephfs APIs. These were around since v17(even
earlier for ceph_select_filesystem) which is the lowest non-EOL version
of Ceph available[1] at the moment.

[1] https://docs.ceph.com/en/latest/releases/#ceph-releases-index

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Jul  9 13:05:47 UTC 2024 on atb-devel-224

13 months agoldap_server: Add a ldapsrv debug class to log LDAP queries
Andréas Leroux [Fri, 5 Jul 2024 12:21:33 +0000 (14:21 +0200)] 
ldap_server: Add a ldapsrv debug class to log LDAP queries

Patch updated for recent samba versions in merge request #3295 by kvvloten
Initial patch created by Jeremy Allison (https://www.spinics.net/lists/samba/msg161128.html) to log LDAP server queries/functions in a separate file

Signed-off-by: Andréas Leroux <aleroux@tranquil.it>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Jul  9 08:37:22 UTC 2024 on atb-devel-224

13 months agos3:rpc_server: Initialize array
Andreas Schneider [Tue, 2 Jul 2024 09:41:41 +0000 (11:41 +0200)] 
s3:rpc_server: Initialize array

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/rpc_server/svcctl/srv_svcctl_nt.c:163: var_decl: Declaring variable ""ace"" without initializer.
samba-4.20.0rc2/source3/rpc_server/svcctl/srv_svcctl_nt.c:182: uninit_use_in_call: Using uninitialized value ""*ace"". Field ""ace->object"" is uninitialized when calling ""make_sec_acl"".
  180|    /* create the security descriptor */
  181|
  182|->  if ( !(theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) )
  183|    return NULL;
  184|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jul  8 08:37:46 UTC 2024 on atb-devel-224

13 months agos4:torture: Initialize pointer with NULL
Andreas Schneider [Tue, 2 Jul 2024 09:37:25 +0000 (11:37 +0200)] 
s4:torture: Initialize pointer with NULL

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/rpc/samsync.c:342: var_decl: Declaring variable ""dom_sid"" without initializer.
samba-4.20.0rc2/source4/torture/rpc/samsync.c:385: uninit_use_in_call: Using uninitialized value ""dom_sid"" when calling ""dom_sid_dup"".
  383|    }
  384|    if (samsync_state->domain_handle[database_id]) {
  385|->  samsync_state->sid[database_id] = dom_sid_dup(samsync_state, dom_sid);
  386|    }
  387|"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agoexamples: Initialize char arrays
Andreas Schneider [Fri, 28 Jun 2024 12:36:59 +0000 (14:36 +0200)] 
examples: Initialize char arrays

"Error: UNINIT (CWE-457):
samba-4.20.0rc2/examples/libsmbclient/testacl.c:35: var_decl: Declaring variable ""value"" without initializer.
samba-4.20.0rc2/examples/libsmbclient/testacl.c:254: 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.]
  252|    }
  253|
  254|->  printf(""Attributes for [%s] are:\n%s\n"", path, value);
  255|
  256|    if (stat_and_retry)"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:smbd: Fix invalid memory free
Andreas Schneider [Wed, 26 Jun 2024 14:11:57 +0000 (16:11 +0200)] 
s3:smbd: Fix invalid memory free

"Error: BAD_FREE (CWE-590):
samba-4.20.0rc2/source3/smbd/smb1_process.c:1485: array_free: ""smb1_srv_send"" frees array ""errbuf"".
 1483|    char errbuf[smb_size];
 1484|    error_packet(errbuf, 0, 0, status, __LINE__, __FILE__);
 1485|->  if (!smb1_srv_send(req->xconn,
 1486|       errbuf,
 1487|       true,"

Pair-Programmed-With: Ralph Boehme <slow@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:smbd: Remove trailing spaces in seal.c
Andreas Schneider [Wed, 26 Jun 2024 14:14:47 +0000 (16:14 +0200)] 
s3:smbd: Remove trailing spaces in seal.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:smbd: Remove trailing spaces in smb1_process.c
Andreas Schneider [Wed, 26 Jun 2024 14:13:09 +0000 (16:13 +0200)] 
s3:smbd: Remove trailing spaces in smb1_process.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:registry: Use correct integer sizes
Andreas Schneider [Wed, 26 Jun 2024 12:32:41 +0000 (14:32 +0200)] 
s3:registry: Use correct integer sizes

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:registry: Check for integer overflow
Andreas Schneider [Wed, 26 Jun 2024 12:31:48 +0000 (14:31 +0200)] 
s3:registry: Check for integer overflow

"Error: INTEGER_OVERFLOW (CWE-190):
samba-4.20.0rc2/source3/registry/regfio.c:175: tainted_data_argument: The check ""bytes_read < block_size"" contains the tainted expression ""bytes_read"" which causes ""block_size"" to be considered tainted.
samba-4.20.0rc2/source3/registry/regfio.c:176: overflow: The expression ""block_size - bytes_read"" is deemed overflowed because at least one of its arguments has overflowed.
samba-4.20.0rc2/source3/registry/regfio.c:176: overflow_sink: ""block_size - bytes_read"", which might have underflowed, is passed to ""read(file->fd, buffer + bytes_read, block_size - bytes_read)"". [Note: The source code implementation of the function has been overridden by a builtin model.]
  174|
  175|    while ( bytes_read < block_size ) {
  176|->  if ( (returned = read( file->fd, buffer+bytes_read, block_size-bytes_read )) == -1 ) {
  177|    DEBUG(0,(""read_block: read() failed (%s)\n"", strerror(errno) ));
  178|    return False;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agothird_party: Update nss_wrapper to version 1.1.16
Andreas Schneider [Fri, 5 Jul 2024 11:09:53 +0000 (13:09 +0200)] 
third_party: Update nss_wrapper to version 1.1.16

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jul  8 06:28:47 UTC 2024 on atb-devel-224

13 months agos3:ntlm_auth: make logs more consistent with length check
Jones Syue [Fri, 5 Jul 2024 09:36:46 +0000 (17:36 +0800)] 
s3:ntlm_auth: make logs more consistent with length check

Run ntlm_auth with options --lm-response/--nt-response/--challenge, and pass
wrong length to these options, got error prompted logs about 'only got xxx
bytes', which are not consistent with length check. This patch revise logs
for length check to make it more consistent.

For example --lm-response requires exact 24 hex, let us input three kinds
of length 23 24 25, prompted logs said 'only got 25 bytes' seems confusing.

script:
for length in 23 24 25; \
do \
    ntlm_auth --username=${un} --password=${pw} \
    --lm-response="`openssl rand -hex ${length}`"; \
done;

output:
hex decode of 04db772593f5e6023d0ab4bc67a942c9179963477eb49d failed! (only got 23 bytes)
NT_STATUS_OK: The operation completed successfully. (0x0)
hex decode of 1e57749feb46bedcf969af6cbbe10e21d0232e35c27eb07294 failed! (only got 25 bytes)

After patch it shows 'got 25 bytes, expected 24' seems more consistent:

hex decode of e13e70c9cf2ac1e20015657c4bec53435b1b948febb63f failed! (got 23 bytes, expected 24)
NT_STATUS_OK: The operation completed successfully. (0x0)
hex decode of 64647005243092b036856f572faad262e0b69386d095d60f54 failed! (got 25 bytes, expected 24)

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

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: David Mulder <dmulder@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Jul  6 00:52:02 UTC 2024 on atb-devel-224

13 months agolib: Remove unused py_reparse_symlink_get
Volker Lendecke [Thu, 4 Jul 2024 11:48:37 +0000 (13:48 +0200)] 
lib: Remove unused py_reparse_symlink_get

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotests: Use the general py_reparse_get
Volker Lendecke [Thu, 4 Jul 2024 11:46:38 +0000 (13:46 +0200)] 
tests: Use the general py_reparse_get

This was the only user of py_reparse_symlink_get

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agotests: Remove a pointless ;
Volker Lendecke [Thu, 4 Jul 2024 11:45:44 +0000 (13:45 +0200)] 
tests: Remove a pointless ;

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agolib: Add general py_reparse_get parsing routine
Volker Lendecke [Mon, 17 Jun 2024 17:50:18 +0000 (19:50 +0200)] 
lib: Add general py_reparse_get parsing routine

Will superseed py_reparse_symlink_get

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 months agothird_party/heimdal: Import lorikeet-heimdal-202407041740 (commit 42ba2a6e5dd1bc14a8b...
Ralph Boehme [Thu, 4 Jul 2024 16:00:52 +0000 (18:00 +0200)] 
third_party/heimdal: Import lorikeet-heimdal-202407041740 (commit 42ba2a6e5dd1bc14a8b5ada8c9b8ace85956f6a0)

Fix clock skew error message and memory cache clock skew recovery

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

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

13 months agos3:rpc_server: Initialize array struct security_ace ace[]
Pavel Filipenský [Wed, 3 Jul 2024 15:55:31 +0000 (17:55 +0200)] 
s3:rpc_server: Initialize array struct security_ace ace[]

Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/lease.c:567: var_decl: Declaring variable "h" without initializer.
samba-4.20.0rc2/source4/torture/smb2/lease.c:642: uninit_use_in_call: Using uninitialized value "h" when calling "smb2_util_close".
  640|
  641|    done:
  642|->         smb2_util_close(tree, h);
  643|           smb2_util_close(tree, h2);
  644|

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Jul  5 08:53:08 UTC 2024 on atb-devel-224

13 months agos4:torture: Initialize struct smb2_handle consistently in lease.c
Pavel Filipenský [Wed, 3 Jul 2024 15:53:22 +0000 (17:53 +0200)] 
s4:torture: Initialize struct smb2_handle consistently in lease.c

Error: UNINIT (CWE-457):
samba-4.20.0rc2/source4/torture/smb2/lease.c:567: var_decl: Declaring variable "h" without initializer.
samba-4.20.0rc2/source4/torture/smb2/lease.c:642: uninit_use_in_call: Using uninitialized value "h" when calling "smb2_util_close".
  640|
  641|    done:
  642|->         smb2_util_close(tree, h);
  643|           smb2_util_close(tree, h2);
  644|

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:registry: Initialize struct security_ace ace[]
Pavel Filipenský [Wed, 3 Jul 2024 15:34:47 +0000 (17:34 +0200)] 
s3:registry: Initialize struct security_ace ace[]

Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/registry/reg_dispatcher.c:43: var_decl: Declaring variable "ace" without initializer.
samba-4.20.0rc2/source3/registry/reg_dispatcher.c:66: uninit_use_in_call: Using uninitialized value "*ace". Field "ace->object" is uninitialized when calling "make_sec_acl".
  64|           /* create the security descriptor */
  65|
  66|->         theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace);
  67|           if (theacl == NULL) {
  68|                   return WERR_NOT_ENOUGH_MEMORY;

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:rpcclient: Initialize spoolss_DriverDirectoryInfo info
Pavel Filipenský [Wed, 3 Jul 2024 15:33:20 +0000 (17:33 +0200)] 
s3:rpcclient: Initialize spoolss_DriverDirectoryInfo info

Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/rpcclient/cmd_spoolss.c:1530: var_decl: Declaring variable "info" without initializer.
samba-4.20.0rc2/source3/rpcclient/cmd_spoolss.c:1578: uninit_use_in_call: Using uninitialized value "info" when calling "display_printdriverdir_1".
 1576|
 1577|           if (W_ERROR_IS_OK(result)) {
 1578|->                 display_printdriverdir_1(&info.info1);
 1579|           }
 1580|

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:utils: Initialize DATA_BLOB blob
Pavel Filipenský [Wed, 3 Jul 2024 15:30:51 +0000 (17:30 +0200)] 
s3:utils: Initialize DATA_BLOB blob

Error: UNINIT (CWE-457):
samba-4.20.0rc2/source3/utils/regedit_dialog.c:1965: var_decl: Declaring variable "blob" without initializer.
samba-4.20.0rc2/source3/utils/regedit_dialog.c:2044: uninit_use_in_call: Using uninitialized value "blob" when calling "reg_val_set".
 2042|
 2043|           if (W_ERROR_IS_OK(rv)) {
 2044|->                 rv = reg_val_set(edit->key, name, edit->type, blob);
 2045|           }
 2046|

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agosmbd: Don't talloc_zero where we assign the struct a line below
Volker Lendecke [Thu, 27 Jun 2024 14:46:16 +0000 (16:46 +0200)] 
smbd: Don't talloc_zero where we assign the struct a line below

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): Thu Jul  4 16:31:39 UTC 2024 on atb-devel-224

13 months agolib: Remove a few duplicate prototypes
Volker Lendecke [Thu, 27 Jun 2024 16:20:05 +0000 (18:20 +0200)] 
lib: Remove a few duplicate prototypes

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agolib: Remove unused strnrchr_w
Volker Lendecke [Thu, 27 Jun 2024 15:54:56 +0000 (17:54 +0200)] 
lib: Remove unused strnrchr_w

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agolib: Remove unused strnrchr_m
Volker Lendecke [Thu, 27 Jun 2024 15:54:01 +0000 (17:54 +0200)] 
lib: Remove unused strnrchr_m

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodocs: "share:fake_fscaps" is per share, not global
Volker Lendecke [Wed, 3 Jul 2024 07:58:02 +0000 (09:58 +0200)] 
docs: "share:fake_fscaps" is per share, not global

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agosmbd: Use new symlink_target_path routine
Volker Lendecke [Thu, 4 Jul 2024 09:07:54 +0000 (11:07 +0200)] 
smbd: Use new symlink_target_path routine

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agolibcli: New routine symlink_target_path for [MS-SMB2] 2.2.2.2.1.1
Volker Lendecke [Wed, 3 Jul 2024 13:55:46 +0000 (15:55 +0200)] 
libcli: New routine symlink_target_path for [MS-SMB2] 2.2.2.2.1.1

Right now the only user is the user-space symlink following in
smbd. We will use it in libsmb as well to correctly handle
STOPPED_ON_SYMLINK. When trying to upstream that code I found the
previous_slash function incredibly hard to understand.

This new routine makes copy of "const char *_name_in", so that we can
replace previous_slash with a simple strrchr_m. If that's too
slow (which I doubt, this is "only" chasing symlinks) we can always do
something smarter again.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agosmbd: Rename symlink_target_path to _symlink_target_path
Volker Lendecke [Wed, 3 Jul 2024 13:38:18 +0000 (15:38 +0200)] 
smbd: Rename symlink_target_path to _symlink_target_path

Only temporary, next step is a new more general symlink_target_path
routine, we'll need that in libcli/smb as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agogitlab-ci: Also add the git directory for pipeline in the main mirror
Andreas Schneider [Wed, 3 Jul 2024 11:05:51 +0000 (13:05 +0200)] 
gitlab-ci: Also add the git directory for pipeline in the main mirror

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Jul  4 08:08:49 UTC 2024 on atb-devel-224

13 months agoRevert "pidl: Use non-existent function dissect_ndr_int64()"
John Thacker [Sat, 22 Jun 2024 11:08:27 +0000 (07:08 -0400)] 
Revert "pidl: Use non-existent function dissect_ndr_int64()"

This reverts commit a836b433ed7f0acca546558d2aec359155999f30.

Wireshark's NDR dissector dissects both signed and unsigned types
of the same size and alignment with the same functions, e.g. see
the handling of "udlong" and "dlong." It is passing the FT_UINT64
vs FT_INT64 field type enum value that determines at the last
moment whether a value is cast to signed. dissect_ndr_uint64()
already has the proper behavior for 8-byte aligned signed 64 bit
integers, and a dissect_ndr_int64() function will not need to be
introduced.

Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jul  3 14:19:04 UTC 2024 on atb-devel-224

13 months agosmbd: correctly restore ENOENT if fstatfs() modifies it
Stefan Metzmacher [Wed, 3 Jul 2024 08:58:33 +0000 (10:58 +0200)] 
smbd: correctly restore ENOENT if fstatfs() modifies it

Review with: git show -U5

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 Jul  3 11:41:12 UTC 2024 on atb-devel-224

13 months agopidl:Wireshark Fix the type of array of pointerse to hf_ values
John Thacker [Tue, 25 Jun 2024 22:40:20 +0000 (18:40 -0400)] 
pidl:Wireshark Fix the type of array of pointerse to hf_ values

Picked from Wireshark's fork:

    commit e1d9a226a2b8f2824a0eb162a8dc972e6e6c2dd4
    Author: Guy Harris <gharris@sonic.net>
    Date:   Thu Jun 18 18:14:46 2020 -0700

        Fix the type of arrays of pointers to hf_ values for bitfield routines.

        The static arrays are supposed to be arrays of const pointers to int,
        not arrays of non-const pointers to const int.

        Fixing that means some bugs (scribbling on what's *supposed* to be a
        const array) will be caught (see packet-ieee80211-radiotap.c for
        examples, the first of which inspired this change and the second of
        which was discovered while testing compiles with this change), and
        removes the need for some annoying casts.

        Also make some of those arrays static while we're at it.

        Update documentation and dissector-generator tools.

        Change-Id: I789da5fc60aadc15797cefecfd9a9fbe9a130ccc
        Reviewed-on: https://code.wireshark.org/review/37517
        Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Jul  3 02:35:43 UTC 2024 on atb-devel-224

13 months agopidl:Wireshark Rename tvb_new_subset()
John Thacker [Tue, 25 Jun 2024 22:38:43 +0000 (18:38 -0400)] 
pidl:Wireshark Rename tvb_new_subset()

Picked from Wireshark's fork:

    commit 7cd6906056922e4b8f68f1216d94eaa0809896fe
    Author: Guy Harris <guy@alum.mit.edu>
    Date:   Mon Jan 9 22:18:49 2017 -0800

        Rename tvb_new_subset() to tvb_new_subset_length_caplen().

        This emphasizes that there is no such thing as *the* routine to
        construct a subset tvbuff; you need to choose one of
        tvb_new_subset_remaining() (if you want a new tvbuff that contains
        everything past a certain point in an existing tvbuff),
        tvb_new_subset_length() (if you want a subset that contains everything
        past a certain point, for some number of bytes, in an existing tvbuff),
        and tvb_new_subset_length_caplen() (for all other cases).

        Many of the calls to tvb_new_subset_length_caplen() should really be
        calling one of the other routines; that's the next step.  (This also
        makes it easier to find the calls that need fixing.)

        Change-Id: Ieb3d676d8cda535451c119487d7cd3b559221f2b
        Reviewed-on: https://code.wireshark.org/review/19597
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl:Wireshark Get rid of Boolean "flags" with no bit set
John Thacker [Tue, 25 Jun 2024 22:37:28 +0000 (18:37 -0400)] 
pidl:Wireshark Get rid of Boolean "flags" with no bit set

Picked from Wireshark's fork:

    commit 5ae9af9e50c89d8700e5a166a9c345fc46b3a4ca
    Author: Guy Harris <guy@alum.mit.edu>
    Date:   Sun Nov 6 11:02:51 2016 -0800

        Get rid of Boolean "flags" that don't have any bit set.

        And tweak the Pidl generator for Wireshark not to generate "flags" like
        that.

        (The generator also does field name and true/false strings' case
        differently, so I didn't use it to regenerate the dissectors; that needs
        to be looked at.)

        Change-Id: Ie1657a782ebdb107e58792cedd29bbaa79b17bd4
        Reviewed-on: https://code.wireshark.org/review/18695
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl:Wireshark Fix array of pointers NULL termination
John Thacker [Tue, 25 Jun 2024 22:31:39 +0000 (18:31 -0400)] 
pidl:Wireshark Fix array of pointers NULL termination

Picked from Wireshark's PIDL fork:

    commit c07fd447c362099b04eedb445e8fa469643403f7
    Author: Binh Trinh <beango@gmail.com>
    Date:   Fri Jun 17 21:46:11 2016 -0400

        DCE/RPC: fix array of pointers with NULL

        Change-Id: Ie89f8fd4ec744d427d41866206d5a6784c5b224f
        Reviewed-on: https://code.wireshark.org/review/16004
        Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agopidl:Wireshark Use proto_tree_add_bitmask_with_flags
John Thacker [Tue, 25 Jun 2024 22:30:22 +0000 (18:30 -0400)] 
pidl:Wireshark Use proto_tree_add_bitmask_with_flags

Picked from the Wireshark fork:

    commit 9a5e6a6884b2369527638fecd49c4c58d8c10378
    Author: Michael Mann <mmann78@netscape.net>
    Date:   Wed Jun 15 15:35:51 2016 -0400

        DCE/RPC proto_tree_add_boolean -> proto_tree_add_bitmask_with_flags

        Change-Id: I8891ec90244ffd9609d8443df631a7c8e6453b7e
        Reviewed-on: https://code.wireshark.org/review/15942
        Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Signed-off-by: John Thacker <johnthacker@gmail.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 months agocmdline:burn: add a note about short option combinations
Douglas Bagnall [Tue, 2 Jul 2024 23:50:43 +0000 (11:50 +1200)] 
cmdline:burn: add a note about short option combinations

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: explicitly burn --username
Douglas Bagnall [Tue, 2 Jul 2024 23:23:36 +0000 (11:23 +1200)] 
cmdline:burn: explicitly burn --username

This is the long form of -U in samba-tool.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: use allowlist to ensure more passwords burn
Douglas Bagnall [Sat, 29 Jun 2024 01:44:46 +0000 (13:44 +1200)] 
cmdline:burn: use allowlist to ensure more passwords burn

We treat any option containing 'pass' with suspicion, unless we know it
is OK.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline: test_cmdline tests more burning
Douglas Bagnall [Sat, 29 Jun 2024 01:43:03 +0000 (13:43 +1200)] 
cmdline: test_cmdline tests more burning

We have more secret arguments, like --client-password, --adminpass,
so we are going to use an allowlist for options containing 'pass', but
we don't want to burn the likes of --group=passionfruit.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: do not burn options starting --user-*, --password-*
Douglas Bagnall [Fri, 28 Jun 2024 23:30:19 +0000 (11:30 +1200)] 
cmdline:burn: do not burn options starting --user-*, --password-*

We have options that start with --user or --password that we don't
want to burn. Some grepping says:

      2 --user1
      1 --user2
     10 --user-allowed-to-authenticate-from
      6 --user-allowed-to-authenticate-to
      2 --user-allow-ntlm-auth
     25 --user-authentication-policy
      1 --user-config
      4 --user-domgroups
      5 --user-ext-name
      2 --user-groups
      6 --user-info
     27 --username
      1 --username2
      2 --userou
      1 --users
      2 --user-sidinfo
      6 --user-sids
     14 --user-tgt-lifetime-mins
      2 --password2
    118 --password-file
      2 --password-from-stdin
      # from here, grepping for strings around POPT_ constants
      5 "user"
      2 "user1"
      2 "user2"
      1 "userd"
      1 "user-domgroups"
      1 "user-groups"
      1 "user-info"
      2 "username"
      1 "user-sidinfo"
      1 "user-sids"
      1 passwordd
      4 "password"

Not all of these use lib/cmdline, but I think most do, via Python
which defers to cmdline_burn().

Note that there are options we should burn that aren't on this list,
like --adminpass. That's another matter.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: localise some variables
Douglas Bagnall [Thu, 27 Jun 2024 04:33:16 +0000 (16:33 +1200)] 
cmdline:burn: localise some variables

As this function increases in complexity, it helps to keep things close.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: always return true if burnt
Douglas Bagnall [Thu, 27 Jun 2024 04:03:30 +0000 (16:03 +1200)] 
cmdline:burn: always return true if burnt

Before we have been trying to cram three cases into a boolean return
value:

 * cmdline had secrets, we burnt them       ->  true
 * cmdline had no secrets, all good         ->  false
 * cmdline has NULL string, WTF! emergency! ->  false

This return value is only used by Python which wants to know whether to
go to the trouble of replacing the command line. If samba_cmdline_burn()
returns false, no action is taken.

If samba_cmdline_burn() burns a password and then hits a NULL, it would
be better not to do nothing. It would be better to crash. And that is
what Python will end up doing, by some talloc returning NULL triggering
a MemoryError.

What about the case like {"--foo", NULL, "-Ua%b"} where the secret comes
after the NULL? That will still be ignored by Python, as it is by all C
tools, but we are hoping that can't happen anyway.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: handle arguments separated from their --options
Douglas Bagnall [Thu, 27 Jun 2024 03:40:16 +0000 (15:40 +1200)] 
cmdline:burn: handle arguments separated from their --options

We weren't treating "--password secret" the same as "--password=secret",
which sometimes led to secrets not being redacted.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: do not retain false memories
Douglas Bagnall [Thu, 27 Jun 2024 03:20:27 +0000 (15:20 +1200)] 
cmdline:burn: do not retain false memories

If argv contains a secret option without an '=' (or in the case of
"-U", the username is separated by space), we will get to the
`if (strlen(p) == ulen) { continue; }` without resetting the found
and is_user variables. This *sometimes* has the right effect, because
the next string in argv ought to contain the secret.

But in a case like {"--password", "1234567890"}, where the secret
string is the same length as the option, we *again* take that branch
and the password is not redacted, though the argument after it will be
unless it is also of the same length.

If we always set the flags at the start we avoid this. This makes
things worse in the short term for secrets that are not the same
length as their options, but we'll get to that in another commit soon.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:tests: extend cmdline_burn tests
Douglas Bagnall [Thu, 27 Jun 2024 03:05:03 +0000 (15:05 +1200)] 
cmdline:tests: extend cmdline_burn tests

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agoselftest: run the cmdline tests that we already have
Douglas Bagnall [Thu, 27 Jun 2024 05:04:47 +0000 (17:04 +1200)] 
selftest: run the cmdline tests that we already have

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agocmdline:burn: '-U' does not imply secrets without '%'
Douglas Bagnall [Thu, 20 Jun 2024 21:21:43 +0000 (09:21 +1200)] 
cmdline:burn: '-U' does not imply secrets without '%'

We return true from this function when a secret has been erased,
and were accidentally treating  as if it had secrets.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agodocs-xml:manpages: allow for longer version strings
Douglas Bagnall [Thu, 20 Jun 2024 23:29:36 +0000 (11:29 +1200)] 
docs-xml:manpages: allow for longer version strings

The default value (30) truncates "Samba 4.21.0pre1-DEVELOPERBUILD" to
"Samba 4.21.0pre1-DEVELOPE" in the bottom left corner of the man page.
("Samba 4.21.0pre1-DEVELOPE" is only 25 bytes long, not 30, but let's
not worry about that).

On narrow terminals (< ~75 columns) this makes it more likely that
the version string will run into the date string.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agobuild: --vendor-suffix instead of --vendor-patch-revision --vendor-name
Douglas Bagnall [Thu, 20 Jun 2024 22:40:59 +0000 (10:40 +1200)] 
build: --vendor-suffix instead of --vendor-patch-revision --vendor-name

In practice there isn't a use for two options, and neither quite
matched what people thought they were doing.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agobuildtools: sanitise strange characters in vendor strings
Douglas Bagnall [Thu, 20 Jun 2024 22:38:40 +0000 (10:38 +1200)] 
buildtools: sanitise strange characters in vendor strings

There is no reason to think '-' and '+' are the only characters that
might sneak into a vendor string; Debian habitually use '~'.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
13 months agoctdb-failover: omit "restrict" optimization keyword
Björn Baumbach [Tue, 2 Jul 2024 16:04:40 +0000 (18:04 +0200)] 
ctdb-failover: omit "restrict" optimization keyword

Fails with some compilers with

error: expected ';', ',' or ')' before 'lineptr'

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jul  2 23:52:37 UTC 2024 on atb-devel-224

13 months agoctdb/wscript: Remove long pending unsupported option
Anoop C S [Tue, 2 Jul 2024 05:27:28 +0000 (10:57 +0530)] 
ctdb/wscript: Remove long pending unsupported option

It has been a while since --with-libcephfs option was dropped. Therefore
stop advertising it through waf scripts.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jul  2 09:13:20 UTC 2024 on atb-devel-224

13 months agosource3/wscript: Remove long pending unsupported option
Anoop C S [Tue, 2 Jul 2024 05:26:45 +0000 (10:56 +0530)] 
source3/wscript: Remove long pending unsupported option

It has been a while since --with-libcephfs option was dropped. Therefore
stop advertising it through waf scripts.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agos3:smbd: Avoid compiler warning for unused label
Jo Sutton [Mon, 1 Jul 2024 03:55:13 +0000 (15:55 +1200)] 
s3:smbd: Avoid compiler warning for unused label

If either of HAVE_FSTATFS and HAVE_LINUX_MAGIC_H are not defined, gcc
produces the following error:

../../source3/smbd/open.c: In function ‘reopen_from_fsp’:
../../source3/smbd/open.c:1222:1: error: label ‘namebased_open’ defined but not used [-Werror=unused-label]
 1222 | namebased_open:
      | ^~~~~~~~~~~~~~

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jul  2 04:44:56 UTC 2024 on atb-devel-224

13 months agos4:dsdb: Remove unnecessary MIN()
Jo Sutton [Thu, 18 Jan 2024 02:16:36 +0000 (15:16 +1300)] 
s4:dsdb: Remove unnecessary MIN()

Since we have ensured that val->length >= sizeof(hash->hash),
MIN(val->length, sizeof(hash->hash)) will here always be equal to
sizeof(hash->hash).

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agolib:krb5_wrap: Fix code spelling
Jo Sutton [Wed, 17 Jan 2024 00:21:04 +0000 (13:21 +1300)] 
lib:krb5_wrap: Fix code spelling

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agos4:auth: Correct order of parameters in documentation
Jo Sutton [Tue, 16 Jan 2024 23:45:15 +0000 (12:45 +1300)] 
s4:auth: Correct order of parameters in documentation

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agos3:rpc_server: Fix code spelling
Jo Sutton [Mon, 15 Jan 2024 21:38:27 +0000 (10:38 +1300)] 
s3:rpc_server: Fix code spelling

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>