samba.git
2 years agoselftest: Add ad member with idmap_autorid backend
Andreas Schneider [Tue, 15 Feb 2022 08:44:34 +0000 (09:44 +0100)]
selftest: Add ad member with idmap_autorid backend

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2 years agos3:trusts_utils: use a password length of 120 for machine accounts
Stefan Metzmacher [Mon, 21 Feb 2022 14:28:53 +0000 (15:28 +0100)]
s3:trusts_utils: use a password length of 120 for machine accounts

This is important when we change the machine password against
an RODC that proxies the request to an RWDC.

An RODC using NetrServerPasswordSet2() to proxy PasswordUpdateForward via
NetrLogonSendToSam() ignores a return of NT_STATUS_INVALID_PARAMETER
and reports NT_STATUS_OK as result of NetrServerPasswordSet2().
This hopefully found the last hole in our very robust machine account
password handling logic inside of trust_pw_change().

The lesson is: try to be as identical to how windows works as possible,
everything else may use is untested code paths on Windows.

A similar problem was fixed by this commit:

    commit 609ca657652862fd9c81fd11f818efb74f72ff55
    Author: Joseph Sutton <josephsutton@catalyst.net.nz>
    Date:   Wed Feb 24 02:03:25 2021 +1300

        provision: Decrease the length of random machine passwords

        The current length of 128-255 UTF-16 characters currently causes
        generation of crypt() passwords to typically fail. This commit
        decreases the length to 120 UTF-16 characters, which is the same as
        that used by Windows.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14984

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Feb 23 08:49:54 UTC 2022 on sn-devel-184

2 years agoupgradehelpers.py: add a comment to update_krbtgt_account_password()
Stefan Metzmacher [Mon, 21 Feb 2022 14:23:54 +0000 (15:23 +0100)]
upgradehelpers.py: add a comment to update_krbtgt_account_password()

The backend generates its own random krbtgt password values.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoprovision: add a comment that the value of krbtgtpass is ignored in the backend
Stefan Metzmacher [Mon, 21 Feb 2022 14:22:50 +0000 (15:22 +0100)]
provision: add a comment that the value of krbtgtpass is ignored in the backend

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoupgradehelpers.py: let update_machine_account_password() use 120 character passwords
Stefan Metzmacher [Mon, 21 Feb 2022 14:22:06 +0000 (15:22 +0100)]
upgradehelpers.py: let update_machine_account_password() use 120 character passwords

We already changed provision to use 120 character passwords with commit
609ca657652862fd9c81fd11f818efb74f72ff55.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoprovision: use 120 characters for the dns account password
Stefan Metzmacher [Mon, 21 Feb 2022 14:08:34 +0000 (15:08 +0100)]
provision: use 120 characters for the dns account password

We should use the same as for the computer account.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agosamba-tool/join_member: let py_net_join_member() choose the password
Stefan Metzmacher [Mon, 21 Feb 2022 14:03:22 +0000 (15:03 +0100)]
samba-tool/join_member: let py_net_join_member() choose the password

It means we'll let trust_pw_new_value() generate the password.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agos3:py_net: allow machinepass=None to py_net_join_member()
Stefan Metzmacher [Mon, 21 Feb 2022 22:48:37 +0000 (23:48 +0100)]
s3:py_net: allow machinepass=None to py_net_join_member()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoctdb-protocol: CID 1499395: Uninitialized variables (UNINIT)
Martin Schwenke [Tue, 15 Feb 2022 22:32:55 +0000 (09:32 +1100)]
ctdb-protocol: CID 1499395: Uninitialized variables (UNINIT)

Issue is reported here:

853      case CTDB_CONTROL_DB_VACUUM: {
854      struct ctdb_db_vacuum db_vacuum;
855
>>>     CID 1499395:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "db_vacuum.full_vacuum_run" when calling "ctdb_db_vacuum_len".
856      CHECK_CONTROL_DATA_SIZE(ctdb_db_vacuum_len(&db_vacuum));
857      return ctdb_control_db_vacuum(ctdb, c, indata, async_reply);
858      }

The problem is that ctdb_bool_len() unnecessarily dereferences its
argument, which in this case is &db_vacuum.full_vacuum_run.  Not a
security issue because the value copied by dereferencing is not used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Feb 23 02:02:06 UTC 2022 on sn-devel-184

2 years agoctdb-tests: Fix missing #include for sigaction(2)
Martin Schwenke [Wed, 16 Feb 2022 11:12:37 +0000 (22:12 +1100)]
ctdb-tests: Fix missing #include for sigaction(2)

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoctdb-tests: Dump a stack trace on abort
Martin Schwenke [Tue, 4 Jan 2022 11:19:19 +0000 (22:19 +1100)]
ctdb-tests: Dump a stack trace on abort

Debugging a test failure here without GDB is not possible.  Dumping a
stack trace gives a good hint.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoexamples: Reformat shell scripts
Andreas Schneider [Sat, 19 Feb 2022 15:06:32 +0000 (16:06 +0100)]
examples: Reformat shell scripts

shfmt -f examples/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Feb 22 16:20:58 UTC 2022 on sn-devel-184

2 years agodocs-xml: Reformat shell scripts
Andreas Schneider [Sat, 19 Feb 2022 07:56:15 +0000 (08:56 +0100)]
docs-xml: Reformat shell scripts

shfmt -f docs-xml | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agobuildtools: Reformat shell scripts
Andreas Schneider [Sat, 19 Feb 2022 07:52:17 +0000 (08:52 +0100)]
buildtools: Reformat shell scripts

shfmt -f buildtools | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoconfigure: Reformat wrapper script
Andreas Schneider [Sat, 19 Feb 2022 07:54:01 +0000 (08:54 +0100)]
configure: Reformat wrapper script

shfmt -w -p -i 0 -fn configure

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoeditorconfig: Change shell to tabs with tab width 8
Andreas Schneider [Sat, 19 Feb 2022 15:10:29 +0000 (16:10 +0100)]
editorconfig: Change shell to tabs with tab width 8

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-dcerpcd: Silence a DEBUG message
Volker Lendecke [Tue, 22 Feb 2022 09:02:57 +0000 (10:02 +0100)]
samba-dcerpcd: Silence a DEBUG message

This is not worth a debuglevel 1 message

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): Tue Feb 22 10:16:44 UTC 2022 on sn-devel-184

2 years agosmbd: We have the fsp available, use fsp_is_alternate_stream()
Volker Lendecke [Fri, 11 Feb 2022 17:49:53 +0000 (18:49 +0100)]
smbd: We have the fsp available, use fsp_is_alternate_stream()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Fix a typo
Volker Lendecke [Mon, 21 Feb 2022 14:26:06 +0000 (15:26 +0100)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Convert get_real_filename_full_scan() to OpenDir_ntstatus()
Volker Lendecke [Mon, 21 Feb 2022 16:43:17 +0000 (17:43 +0100)]
smbd: Convert get_real_filename_full_scan() to OpenDir_ntstatus()

Get us a better error message without going through the lossy errno.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Initialize a pointer
Volker Lendecke [Mon, 21 Feb 2022 16:30:29 +0000 (17:30 +0100)]
smbd: Initialize a pointer

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agovfs: walk_streams() returns NTSTATUS
Volker Lendecke [Mon, 21 Feb 2022 16:19:49 +0000 (17:19 +0100)]
vfs: walk_streams() returns NTSTATUS

Don't go via errno

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: can_delete_directory_fsp() returns NTSTATUS
Volker Lendecke [Mon, 21 Feb 2022 16:19:49 +0000 (17:19 +0100)]
smbd: can_delete_directory_fsp() returns NTSTATUS

Don't go via errno

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Factor out OpenDir_ntstatus()
Volker Lendecke [Mon, 21 Feb 2022 16:17:24 +0000 (17:17 +0100)]
smbd: Factor out OpenDir_ntstatus()

We might have callers interested in the exact NTSTATUS error code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Make OpenDir_fsp() return NTSTATUS
Volker Lendecke [Mon, 21 Feb 2022 16:12:05 +0000 (17:12 +0100)]
smbd: Make OpenDir_fsp() return NTSTATUS

Preparation for making OpenDir return NTSTATUS

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Initialize a pointer
Volker Lendecke [Mon, 21 Feb 2022 16:09:36 +0000 (17:09 +0100)]
smbd: Initialize a pointer

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agoutil: CID 1499409: Memory - corruptions (OVERLAPPING_COPY)
Martin Schwenke [Fri, 18 Feb 2022 01:02:50 +0000 (12:02 +1100)]
util: CID 1499409:  Memory - corruptions  (OVERLAPPING_COPY)

This is quite bizarre:

*** CID 1499409:  Memory - corruptions  (OVERLAPPING_COPY)
/lib/util/debug.c: 1742 in dbghdrclass()
1736       sizeof(tvbuf.buf),
1737       "%ld seconds since the Epoch", (long)t);
1738      }
1739      }
1740
1741      ensure_hostname();
>>>     CID 1499409:  Memory - corruptions  (OVERLAPPING_COPY)
>>>     In the call to function "snprintf", the object pointed to by argument "state.hostname" may overlap with the object pointed to by argument "state.header_str".
1742      state.hs_len = snprintf(state.header_str,
1743      sizeof(state.header_str),
1744      "%s %s %s[%u]: ",
1745      tvbuf.buf,
1746      state.hostname,
1747      state.prog_name,

Coverity doesn't explicitly say so but the only way this can happen is
if state.hostname is not NUL-terminated within its declared length.
ensure_hostname() and debug_set_hostname() ensure NUL-termination, but
the caching effect of ensure_hostname() probably stops Coverity from
being certain about anything.

Try making Coverity happy by using a precision to limit the number of
characters from hostname that can be used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Feb 22 00:17:12 UTC 2022 on sn-devel-184

2 years agoautobuild: Rewrite the symbol checking
Andreas Schneider [Mon, 14 Feb 2022 13:59:13 +0000 (14:59 +0100)]
autobuild: Rewrite the symbol checking

This should be less error prone.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Feb 21 19:36:45 UTC 2022 on sn-devel-184

2 years agos3:utils: Fix missing space in testparm output
Andreas Schneider [Mon, 21 Feb 2022 13:34:06 +0000 (14:34 +0100)]
s3:utils: Fix missing space in testparm output

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Feb 21 15:03:24 UTC 2022 on sn-devel-184

2 years agothird_party: Update waf to verison 2.0.23
Andreas Schneider [Thu, 17 Feb 2022 14:40:20 +0000 (15:40 +0100)]
third_party: Update waf to verison 2.0.23

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Feb 21 10:06:27 UTC 2022 on sn-devel-184

2 years agothird_party:waf: Print the version of waf at the end of the update script
Andreas Schneider [Thu, 17 Feb 2022 14:40:38 +0000 (15:40 +0100)]
third_party:waf: Print the version of waf at the end of the update script

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
2 years agoeditorconfig: Final newlines are pycodestyle
Andreas Schneider [Thu, 17 Feb 2022 19:35:50 +0000 (20:35 +0100)]
editorconfig: Final newlines are pycodestyle

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
2 years agowaf: re-add missing readlink test
Björn Jacke [Wed, 26 Dec 2018 00:03:29 +0000 (01:03 +0100)]
waf: re-add missing readlink test

this was another portability regression that came with the moving to waf

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

Signed-off-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Feb 18 23:12:51 UTC 2022 on sn-devel-184

2 years agoreadlink test: inverse return code
Björn Jacke [Wed, 26 Dec 2018 00:01:14 +0000 (01:01 +0100)]
readlink test: inverse return code

We need to return 0 in case readlink is *broken* here - this is because our waf
CHECK_CODE function does only allow generating defines in case the test succeeds

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

Signed-off-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agowscript: s/default/required/ _static_modules for the acl modules
Björn Jacke [Tue, 15 Feb 2022 13:25:41 +0000 (14:25 +0100)]
wscript: s/default/required/ _static_modules for the acl modules

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs_aixacl: add proper header file
Bjoern Jacke [Fri, 11 Feb 2022 00:45:00 +0000 (00:45 +0000)]
vfs_aixacl: add proper header file

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agoacl: fix function arguments for AIX' and Solaris' sys_acl_get_fd()
Björn Jacke [Fri, 11 Feb 2022 02:38:31 +0000 (03:38 +0100)]
acl: fix function arguments for AIX' and Solaris' sys_acl_get_fd()

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

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agos3: smbd: Fix our leases code to return the correct error in the non-dynamic share...
Jeremy Allison [Thu, 17 Feb 2022 19:12:39 +0000 (11:12 -0800)]
s3: smbd: Fix our leases code to return the correct error in the non-dynamic share case.

We now return INVALID_PARAMETER when trying to open a
different file with a duplicate lease key on the same
(non-dynamic) share. This will enable us to pass another
Windows test suite leases test.

We now behave the same as Windows10.

Remove knownfail.d/smb2-lease-duplicateopen

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@suse.com>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Feb 18 20:12:12 UTC 2022 on sn-devel-184

2 years agos4: torture: Add new SMB2 lease test test_lease_duplicate_open().
Jeremy Allison [Thu, 17 Feb 2022 18:58:32 +0000 (10:58 -0800)]
s4: torture: Add new SMB2 lease test test_lease_duplicate_open().

Checks we return INVALID_PARAMETER when trying to open a
different file with a duplicate lease key on the same share.

Checked against Windows10. Currently fails against smbd
so add knownfail.d/smb2-lease-duplicateopen

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@suse.com>
2 years agos4: torture: Add new SMB2 lease test test_lease_duplicate_create().
Jeremy Allison [Thu, 17 Feb 2022 17:58:27 +0000 (09:58 -0800)]
s4: torture: Add new SMB2 lease test test_lease_duplicate_create().

Checks we return INVALID_PARAMETER when trying to create a
new file with a duplicate lease key on the same share.

Checked against Windows10. Samba already passes this
but we didn't have a test before.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@suse.com>
2 years agosource4/torture: Drop unused variable attribute
Martin Schwenke [Tue, 15 Feb 2022 22:11:43 +0000 (09:11 +1100)]
source4/torture: Drop unused variable attribute

clang complains:

../../source4/client/client.c:1569:11: error: variable 'attribute' set but not used [-Werror,-Wunused-but-set-variable]
        uint16_t attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
                 ^

That is, the variable is initialised and updated but the value is
never used.

Commit 2f377d5101783ed4d8c96a46aaec61895cc7b6ad from 2004 dropped the
use of this variable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Feb 17 19:06:25 UTC 2022 on sn-devel-184

2 years agosource4/torture: Drop unused variable mask
Martin Schwenke [Tue, 15 Feb 2022 22:05:31 +0000 (09:05 +1100)]
source4/torture: Drop unused variable mask

clang complains:

../../source4/torture/smb2/notify.c:871:11: error: variable 'mask' set but not used [-Werror,-Wunused-but-set-variable]
        uint32_t mask;
                 ^

That is, the variable is initialised and updated but the value is
never used.

Looks to have been this way since commit
15d93a5d8e21893e1cca5c989dbf97010aae1622 from 2009.  Just drop it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agosource4/torture: Drop unused variable tdif
Martin Schwenke [Tue, 15 Feb 2022 21:56:10 +0000 (08:56 +1100)]
source4/torture: Drop unused variable tdif

clang complains:

../../source4/torture/basic/denytest.c:1805:11: error: variable 'tdif' set but not used [-Werror,-Wunused-but-set-variable]
                int64_t tdif;
                        ^

That is, the variable is initialised and updated but the value is
never used.

Perhaps it is meant to be used in the nearby torture_comment() call,
but it has been this was since commit
cb1cff90f165d82cbbf1dd87e475a1b13984d45e from 2004.  Just drop it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agosource4/torture: Avoid unused variable
Martin Schwenke [Tue, 15 Feb 2022 21:50:24 +0000 (08:50 +1100)]
source4/torture: Avoid unused variable

clang complains:

../../source4/torture/basic/delete.c:2342:7: error: variable 'correct' set but not used [-Werror,-Wunused-but-set-variable]
        bool correct = true;
             ^

That is, the variable is initialised and updated but the value is
never used.  Similar functions return this variable, so try that.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agovfs_not_implemented: do not mark structs with _PUBLIC_
Martin Schwenke [Tue, 15 Feb 2022 21:44:40 +0000 (08:44 +1100)]
vfs_not_implemented: do not mark structs with _PUBLIC_

Commit 5d295e41af4e9316aee1b4cf1c3087663b7c06a4 accidentally marked
some structs with _PUBLIC_, which causes clang to complain:

../../source3/modules/vfs_not_implemented.c:594:1: error: attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration [-Werror,-Wignored-attributes]
_PUBLIC_
^
../../lib/replace/replace.h:917:33: note: expanded from macro '_PUBLIC_'
                                ^
../../source3/modules/vfs_not_implemented.c:642:1: error: attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration [-Werror,-Wignored-attributes]
_PUBLIC_
^
../../lib/replace/replace.h:917:33: note: expanded from macro '_PUBLIC_'
                                ^

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agoutil: Drop unused variable mask_perms
Martin Schwenke [Tue, 15 Feb 2022 09:27:24 +0000 (20:27 +1100)]
util: Drop unused variable mask_perms

clang complains:

../../source3/smbd/posix_acls.c:2783:9: error: variable 'mask_perms' set but not used [-Werror,-Wunused-but-set-variable]
        mode_t mask_perms = 0;
               ^

That is, the variable is initialised and updated but the value is
never used.

This potentially points to a bug in commit
f735551b9edef66b152261cf6eb2f29b7b69d65b from 2002.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agoutil: Drop unused variable num_received
Martin Schwenke [Tue, 15 Feb 2022 08:37:17 +0000 (19:37 +1100)]
util: Drop unused variable num_received

clang complains:

../../source4/libcli/clilist.c:111:6: error: variable 'num_received' set but not used [-Werror,-Wunused-but-set-variable]
        int num_received = 0;
            ^
../../source4/libcli/clilist.c:268:6: error: variable 'num_received' set but not used [-Werror,-Wunused-but-set-variable]
        int num_received = 0;
            ^

That is, the variable is initialised and updated but the value is
never used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agoutil: Drop unused variable num_chars
Martin Schwenke [Tue, 15 Feb 2022 08:32:52 +0000 (19:32 +1100)]
util: Drop unused variable num_chars

clang complains:

../../lib/util/genrand_util.c:99:9: error: variable 'num_chars' set but not used [-Werror,-Wunused-but-set-variable]
        size_t num_chars = 0;
               ^

That is, the variable is initialised and incremented but the value is
never used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agosmbd: Make strnorm() static to filename.c
Volker Lendecke [Thu, 17 Feb 2022 10:24:38 +0000 (11:24 +0100)]
smbd: Make strnorm() static to filename.c

The caller in vfs_prealloc was a bit unneeded, and strnorm is only
called here.

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): Thu Feb 17 18:11:18 UTC 2022 on sn-devel-184

2 years agovfs: Don't go through strnorm(..., CASE_LOWER)
Volker Lendecke [Thu, 17 Feb 2022 10:19:50 +0000 (11:19 +0100)]
vfs: Don't go through strnorm(..., CASE_LOWER)

With a fixed CASE_LOWER we should go directly to the lowerlevel call, this
makes it more obvious to me.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Fix a typo
Volker Lendecke [Thu, 17 Feb 2022 10:19:42 +0000 (11:19 +0100)]
vfs: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Use ISDOT/ISDOTDOT
Volker Lendecke [Thu, 17 Feb 2022 10:10:00 +0000 (11:10 +0100)]
smbd: Use ISDOT/ISDOTDOT

This is simpler to read for me

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Filter out "::$DATA" for query name information
Volker Lendecke [Fri, 11 Feb 2022 17:09:56 +0000 (18:09 +0100)]
smbd: Filter out "::$DATA" for query name information

Make this piece of code robust against having "::$DATA" passed in.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Simplify open_file_ntcreate()
Volker Lendecke [Fri, 11 Feb 2022 17:07:42 +0000 (18:07 +0100)]
smbd: Simplify open_file_ntcreate()

For streams our caller create_file_unixpath() has already taken care
of properly initializing fsp->base_fsp, so we can rely on
fsp_is_alternate_stream() here instead of looking at the file name.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Only open base_fsp for non-"::$DATA" streams
Volker Lendecke [Fri, 11 Feb 2022 17:09:00 +0000 (18:09 +0100)]
smbd: Only open base_fsp for non-"::$DATA" streams

"is_named_stream()" is more what we really mean here. Make this line robust
against callers passing in "::$DATA".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Use is_named_stream() for checking if we have an ADS
Volker Lendecke [Fri, 11 Feb 2022 15:13:07 +0000 (16:13 +0100)]
vfs: Use is_named_stream() for checking if we have an ADS

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Use fsp_is_alternate_stream(), we checked for fsp!=NULL above
Volker Lendecke [Fri, 11 Feb 2022 14:59:06 +0000 (15:59 +0100)]
smbd: Use fsp_is_alternate_stream(), we checked for fsp!=NULL above

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Slightly simplify openat_pathref_fsp()
Volker Lendecke [Thu, 30 Dec 2021 17:04:55 +0000 (18:04 +0100)]
smbd: Slightly simplify openat_pathref_fsp()

We don't need to look at the full share-relative path to figure out if
we have a stream name, the original smb_fname is sufficient for this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Use fsp_get_pathref_fd() in aio_pthread
Volker Lendecke [Mon, 14 Feb 2022 12:30:43 +0000 (13:30 +0100)]
vfs: Use fsp_get_pathref_fd() in aio_pthread

We only use the fd as "dirfd" in openat, so we don't need an I/O fd
here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agolibsmb: Avoid a call to SMBC_errno()
Volker Lendecke [Sun, 13 Feb 2022 08:25:54 +0000 (09:25 +0100)]
libsmb: Avoid a call to SMBC_errno()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agolibsmb: Avoid a call to SMBC_errno()
Volker Lendecke [Sun, 13 Feb 2022 08:21:47 +0000 (09:21 +0100)]
libsmb: Avoid a call to SMBC_errno()

This involves converting cli_print_queue() to NTSTATUS. No caller
looked at the number of jobs returned.

Review with "git show -b", most of the patch is indentation

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs_gpfs: use linux oplock specific funcions only when available
Bjoern Jacke [Fri, 14 Jan 2022 17:02:32 +0000 (17:02 +0000)]
vfs_gpfs: use linux oplock specific funcions only when available

Signed-off-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Christof Schmitt <cs@samba.org>
Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Wed Feb 16 21:38:12 UTC 2022 on sn-devel-184

2 years agodns.idl/dnsp.idl: add missing DNS ressource record types
Björn Jacke [Tue, 8 Feb 2022 23:06:55 +0000 (00:06 +0100)]
dns.idl/dnsp.idl: add missing DNS ressource record types

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Feb 16 20:43:55 UTC 2022 on sn-devel-184

2 years agodnsp.idl: add missing DNS_RPC_RECORD defines
Björn Jacke [Tue, 8 Feb 2022 13:42:29 +0000 (14:42 +0100)]
dnsp.idl: add missing DNS_RPC_RECORD defines

taken from MSDN 2.2.2.2.5:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/ac793981-1c60-43b8-be59-cdbb5c4ecb8a

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agodocs-xml: Fix idmap_autorid documentation
Andreas Schneider [Tue, 1 Feb 2022 09:05:19 +0000 (10:05 +0100)]
docs-xml: Fix idmap_autorid documentation

What we want to avoid:

$ ./bin/testparm -s | grep "idmap config"
        idmap config * : rangesize = 10000
        idmap config * : range = 10000-19999
        idmap config * : backend = autorid

$ ./bin/wbinfo --name-to-sid BUILTIN/Administrators
S-1-5-32-544 SID_ALIAS (4)

$ ./bin/wbinfo --sid-to-gid S-1-5-32-544
10000

$ ./bin/wbinfo --name-to-sid ADDOMAIN/alice
S-1-5-21-4058748110-895691256-3682847423-1107 SID_USER (1)

$ ./bin/wbinfo --sid-to-gid S-1-5-21-984165912-589366285-3903095728-1107
failed to call wbcSidToGid: WBC_ERR_DOMAIN_NOT_FOUND
Could not convert sid S-1-5-21-984165912-589366285-3903095728-1107 to gid

If only one range is configured we are either not able to map users/groups
from our primary *and* the BUILTIN domain. We need at least two ranges to also
cover the BUILTIN domain!

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Feb 16 17:04:53 UTC 2022 on sn-devel-184

2 years agos3:utils: Add a testparm check for idmap autorid
Andreas Schneider [Tue, 1 Feb 2022 09:07:50 +0000 (10:07 +0100)]
s3:utils: Add a testparm check for idmap autorid

What we want to avoid:

$ ./bin/testparm -s | grep "idmap config"
        idmap config * : rangesize = 10000
        idmap config * : range = 10000-19999
        idmap config * : backend = autorid

$ ./bin/wbinfo --name-to-sid BUILTIN/Administrators
S-1-5-32-544 SID_ALIAS (4)

$ ./bin/wbinfo --sid-to-gid S-1-5-32-544
10000

$ ./bin/wbinfo --name-to-sid ADDOMAIN/alice
S-1-5-21-4058748110-895691256-3682847423-1107 SID_USER (1)

$ ./bin/wbinfo --sid-to-gid S-1-5-21-984165912-589366285-3903095728-1107
failed to call wbcSidToGid: WBC_ERR_DOMAIN_NOT_FOUND
Could not convert sid S-1-5-21-984165912-589366285-3903095728-1107 to gid

If only one range is configured we are either not able to map users/groups
from our primary *and* the BUILTIN domain. We need at least two ranges to also
cover the BUILTIN domain!

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2 years agos3:winbindd: Add a sanity check for the range
Andreas Schneider [Tue, 1 Feb 2022 09:06:30 +0000 (10:06 +0100)]
s3:winbindd: Add a sanity check for the range

What we want to avoid:

$ ./bin/testparm -s | grep "idmap config"
        idmap config * : rangesize = 10000
        idmap config * : range = 10000-19999
        idmap config * : backend = autorid

$ ./bin/wbinfo --name-to-sid BUILTIN/Administrators
S-1-5-32-544 SID_ALIAS (4)

$ ./bin/wbinfo --sid-to-gid S-1-5-32-544
10000

$ ./bin/wbinfo --name-to-sid ADDOMAIN/alice
S-1-5-21-4058748110-895691256-3682847423-1107 SID_USER (1)

$ ./bin/wbinfo --sid-to-gid S-1-5-21-984165912-589366285-3903095728-1107
failed to call wbcSidToGid: WBC_ERR_DOMAIN_NOT_FOUND
Could not convert sid S-1-5-21-984165912-589366285-3903095728-1107 to gid

If only one range is configured we are either not able to map users/groups
from our primary *and* the BUILTIN domain. We need at least two ranges to also
cover the BUILTIN domain!

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2 years agobootstrap: Install mold linker on Fedora 35
Andreas Schneider [Sun, 13 Feb 2022 11:08:57 +0000 (12:08 +0100)]
bootstrap: Install mold linker on Fedora 35

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Feb 15 12:31:43 UTC 2022 on sn-devel-184

2 years agobootstrap: If the mold linker is available prefer it over gold
Andreas Schneider [Sun, 13 Feb 2022 11:01:47 +0000 (12:01 +0100)]
bootstrap: If the mold linker is available prefer it over gold

The gold linker will be deprecated soon. However we got a new linker called
mold:

https://github.com/rui314/mold/

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
2 years agobuiltools: Make abi_gen.sh less prone to errors
Andreas Schneider [Mon, 14 Feb 2022 06:59:52 +0000 (07:59 +0100)]
builtools: Make abi_gen.sh less prone to errors

The mold linker has more hidden symbols and we would need to filter them out
with nm, where objdump tells us which symbols are actually hidden. So we just
need to filter out whatever is hidden.

The use of awk makes it also easier to get what we want.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
2 years agoctdb-tests: Iterate protocol tests internally
Martin Schwenke [Tue, 4 Jan 2022 01:19:49 +0000 (12:19 +1100)]
ctdb-tests: Iterate protocol tests internally

Instead of repeatedly running a test binary.

Run time for these tests reduces from ~90s to ~75s.

When run under valgrind, the run time for protocol_test_001.sh reduces
from ~390s to <1s.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Feb 14 04:32:29 UTC 2022 on sn-devel-184

2 years agoctdb-tests: Add iteration support for protocol tests
Martin Schwenke [Tue, 4 Jan 2022 01:18:33 +0000 (12:18 +1100)]
ctdb-tests: Add iteration support for protocol tests

The current method of repeatedly running a binary has huge overhead,
especially with valgrind.

protocol_test_iterate_tag() allows output that is usually used for
hinting where a test failure occurred to be replaced with a tag
stored in a buffer, which is printed on test failure.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoctdb-tests: Add a test for stalled node triggering election
Martin Schwenke [Sat, 22 Jan 2022 20:08:02 +0000 (07:08 +1100)]
ctdb-tests: Add a test for stalled node triggering election

A stalled node probably continues to hold the cluster lock, so confirm
elections work in this case.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Feb 14 02:46:01 UTC 2022 on sn-devel-184

2 years agoctdb-tests: Factor out functions to detect when generation changes
Martin Schwenke [Sat, 22 Jan 2022 19:42:52 +0000 (06:42 +1100)]
ctdb-tests: Factor out functions to detect when generation changes

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoctdb-recoverd: Consistently log start of election
Martin Schwenke [Sat, 22 Jan 2022 19:21:51 +0000 (06:21 +1100)]
ctdb-recoverd: Consistently log start of election

Elections should now be quite rare, so always log when one begins.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoctdb-recoverd: Always send unknown leader broadcast when starting election
Martin Schwenke [Sat, 22 Jan 2022 19:18:51 +0000 (06:18 +1100)]
ctdb-recoverd: Always send unknown leader broadcast when starting election

This is currently missed when the cluster lock is lost.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoctdb-recoverd: Consistently have caller set election-in-progress
Martin Schwenke [Sat, 22 Jan 2022 18:49:18 +0000 (05:49 +1100)]
ctdb-recoverd: Consistently have caller set election-in-progress

The problem here is that election-in-progress must be set to
potentially avoid restarting the election broadcast timeout in
main_loop(), so this is already done by leader_handler().

Have force_election() set election-in-progress for all election types
and do not bother setting it in cluster_lock_election().

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agoctdb-recoverd: Always cancel election in progress
Martin Schwenke [Fri, 21 Jan 2022 07:09:47 +0000 (18:09 +1100)]
ctdb-recoverd: Always cancel election in progress

Election-in-progress is set by unknown leader broadcast, so needs to
be cleared in all cases when election completes.

This was seen in a case where the leader node stalled, so didn't send
leader broadcasts for some time.  The node continued to hold the
cluster lock, so another node could not become leader.  However, after
the node returned to normal it still did not send leader broadcasts
because election-in-progress was never cleared.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2 years agosmbd: Simplify smbd_dirptr_lanman2_mode_fn()
Volker Lendecke [Sun, 2 Jan 2022 18:26:06 +0000 (19:26 +0100)]
smbd: Simplify smbd_dirptr_lanman2_mode_fn()

Avoid an else, we return in the "true" branch

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 Feb 11 21:53:22 UTC 2022 on sn-devel-184

2 years agotorture: Align integer types
Volker Lendecke [Mon, 7 Feb 2022 14:19:35 +0000 (15:19 +0100)]
torture: Align integer types

finfo.stream_info.out.num_streams is declared as "unsigned int"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agondrdump: Small simplification
Volker Lendecke [Mon, 7 Feb 2022 09:11:36 +0000 (10:11 +0100)]
ndrdump: Small simplification

Remove the talloc_steal(), we can allocate on mem_ctx directly

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agolibsmb: Use fstrcpy where possible
Volker Lendecke [Sun, 6 Feb 2022 20:59:05 +0000 (21:59 +0100)]
libsmb: Use fstrcpy where possible

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Safeguards for getpwuid
Volker Lendecke [Thu, 3 Feb 2022 12:20:11 +0000 (13:20 +0100)]
smbd: Safeguards for getpwuid

Attempt to fix

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfstest: Align two integer types
Volker Lendecke [Thu, 3 Feb 2022 14:23:45 +0000 (15:23 +0100)]
vfstest: Align two integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Simplify streams_xattr_unlinkat()
Volker Lendecke [Fri, 11 Feb 2022 09:20:54 +0000 (10:20 +0100)]
vfs: Simplify streams_xattr_unlinkat()

It would be a logic error to call rmdir on a stream. This simplifies
the logic a bit.

Signed-off-by: Volker Lendecke <vl@samba.org>
2 years agosmbd: Use fsp_is_alternate_stream() where an fsp is available
Volker Lendecke [Fri, 11 Feb 2022 08:59:16 +0000 (09:59 +0100)]
smbd: Use fsp_is_alternate_stream() where an fsp is available

Make it clear that being an alternate data stream handle is much more
a fsp property than a file name property.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Introduce metadata_fsp()
Volker Lendecke [Fri, 11 Feb 2022 08:45:30 +0000 (09:45 +0100)]
smbd: Introduce metadata_fsp()

Centralize the pattern

if (fsp->base_fsp != NULL) {
fsp = fsp->base_fsp;
}

with a descriptive name.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Introduce fsp_is_alternate_stream()
Volker Lendecke [Fri, 11 Feb 2022 08:37:35 +0000 (09:37 +0100)]
smbd: Introduce fsp_is_alternate_stream()

To me this is more descriptive than "fsp->base_fsp != NULL". If this
turns out to be a performance problem, I would go and make this a
static inline in smbd/proto.h.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agowafsamba: replace 'echo -n' with printf
Sergey V. Lobanov [Wed, 9 Feb 2022 21:02:17 +0000 (00:02 +0300)]
wafsamba: replace 'echo -n' with printf

This patch makes samba_cross.py compatible with old bash (e.g. 3.2)

Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Feb 11 07:58:57 UTC 2022 on sn-devel-184

2 years agos3:modules: Fix virusfilter_vfs_openat
Pavel Filipenský [Mon, 7 Feb 2022 22:06:10 +0000 (23:06 +0100)]
s3:modules: Fix virusfilter_vfs_openat

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Feb 10 22:09:06 UTC 2022 on sn-devel-184

2 years agos3:selftest: Add test for virus scanner
Pavel Filipenský [Tue, 8 Feb 2022 14:35:48 +0000 (15:35 +0100)]
s3:selftest: Add test for virus scanner

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoselftest: Fix trailing whitespace in Samba3.pm
Pavel Filipenský [Tue, 8 Feb 2022 14:34:56 +0000 (15:34 +0100)]
selftest: Fix trailing whitespace in Samba3.pm

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agodocs-xml:manpages: Document 'dummy' virusfilter and 'virusfilter:infected files'
Pavel Filipenský [Tue, 8 Feb 2022 21:35:29 +0000 (22:35 +0100)]
docs-xml:manpages: Document 'dummy' virusfilter and 'virusfilter:infected files'

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agos3:modules: Implement dummy virus scanner that uses filename matching
Pavel Filipenský [Tue, 8 Feb 2022 11:07:03 +0000 (12:07 +0100)]
s3:modules: Implement dummy virus scanner that uses filename matching

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14971

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoselftest: Do not force -d0 for smbd/nmbd/winbindd
Andreas Schneider [Wed, 9 Feb 2022 15:33:10 +0000 (16:33 +0100)]
selftest: Do not force -d0 for smbd/nmbd/winbindd

We have the env variable SERVER_LOG_LEVEL which allows you to change
the log level on the command line. If we force -d0 this will not work.

make test TESTS="samba" SERVER_LOG_LEVEL=10

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Only file_free() a self-created fsp in create_file_unixpath()
Volker Lendecke [Thu, 3 Feb 2022 16:17:07 +0000 (17:17 +0100)]
smbd: Only file_free() a self-created fsp in create_file_unixpath()

This fixes a use-after-free in smb_full_audit_create_file() when
calling SMB_VFS_CREATE_FILE with fsp->fsp_name as smb_fname.

create_file_unixpath() has this comment:

 * This is really subtle. If someone passes in an smb_fname
 * where smb_fname actually is taken from fsp->fsp_name, then
 * the lifetime of these objects is meant to be the same.

so it seems legitimate to call CREATE_FILE this way.

When CREATE_FILE runs into an error, create_file_unixpath() does a
file_free, which also takes fsp->fsp_name with
it. smb_full_audit_create_file() wants to log the failure including
the smb_fname after NEXT_CREATE_FILE has exited, but this will then
use the already free'ed data.

Fix by only doing the file_free() on an fsp that
create_file_unixpath() created itself.

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): Thu Feb 10 19:11:33 UTC 2022 on sn-devel-184

2 years agosmbd: Introduce close_file_smb()
Volker Lendecke [Wed, 9 Feb 2022 17:03:33 +0000 (18:03 +0100)]
smbd: Introduce close_file_smb()

This does almost everything that close_file_free() does, but it leaves
the fsp around.

A normal close_file() now calls fsp_unbind_smb() twice. Functionally
this is not a problem, fsp_unbind_smb() is idempotent. The only
potential performance penalty might come from the loops in
remove_smb2_chained_fsp(), but those only are potentially large with
deeply queued smb2 requests. If that turns out to be a problem, we'll
cope with it later. The alternative would be to split up file_free()
into even more routines and make it more difficult to figure out which
of the "rundown/unbind/free" routines to call in any particular
situation.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Factor out fsp_unbind_smb() from file_free()
Volker Lendecke [Wed, 9 Feb 2022 16:23:03 +0000 (17:23 +0100)]
smbd: Factor out fsp_unbind_smb() from file_free()

For example, remove our entry from smbXsrv_open_global.tdb

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agotorture: Add a test to show that full_audit uses a ptr after free
Volker Lendecke [Thu, 3 Feb 2022 14:25:11 +0000 (15:25 +0100)]
torture: Add a test to show that full_audit uses a ptr after free

Run vfstest with this vfstest.cmd under valgrind and you'll see what
happens. Exact explanation a few patches further down...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: Simplify the flow in close_file_free()
Volker Lendecke [Wed, 2 Feb 2022 11:42:08 +0000 (12:42 +0100)]
smbd: Simplify the flow in close_file_free()

We are no longer called on base_fsp's in SHUTDOWN_CLOSE. That
simplifies the logic in the common case, we now have a linear flow for
the very often-called close_file()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>