1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
Commit Graph

130390 Commits

Author SHA1 Message Date
Andreas Schneider
f2591ff727 testprogs: Reformat functionalprep.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/functionalprep.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2022-08-04 12:56:37 +00:00
Andreas Schneider
91035d48f2 testprogs: Reformat dom_parse.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/dom_parse.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2022-08-04 12:56:37 +00:00
Andreas Schneider
eab5cdb66f testprogs: Reformat dfree.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/dfree.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2022-08-04 12:56:37 +00:00
Andreas Schneider
9bc3ba8f37 testprogs: Reformat demote-saveddb.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/demote-saveddb.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2022-08-04 12:56:37 +00:00
Andreas Schneider
0cdd204693 testprogs: Reformat dbcheck.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/dbcheck.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>

Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Thu Aug  4 10:11:30 UTC 2022 on sn-devel-184
2022-08-04 10:11:30 +00:00
Andreas Schneider
ae3452244d testprogs: Reformat dbcheck-oldrelease.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/dbcheck-oldrelease.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2022-08-04 09:11:29 +00:00
Andreas Schneider
9757229b2b testprogs: Reformat dbcheck-links.sh
shfmt -w -p -i 0 -fn testprogs/blackbox/dbcheck-links.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2022-08-04 09:11:29 +00:00
Ralph Boehme
61c6a00f55 mdssvc: check if the user closed the query before trying to read the HTTP response from Elasticsearch
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14915

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed Aug  3 14:00:36 UTC 2022 on sn-devel-184
2022-08-03 14:00:36 +00:00
Ralph Boehme
c9ecd33ad7 mdssvc: fold two if blocks into one
No change in behaviour.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
ac13935a58 mdssvc: don't trigger http reconnect if a search was cancelled
Calling tevent_req_error() triggers a HTTP reconnect in mds_es_search_done() as
mds_es_search_recv() returns the error so we call mds_es_reconnect_on_error().

slq (which is s->slq) or s->mds_es_ctx will be NULL if the user closed a search
or disconnected a share with an active mdssvc IPC pipe, no need to trigger a
HTTP reconnect for those cases.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
1150d121b7 mdssvc: fix check if search connection state is gone
This was dead code: before this patchset noone set s->mds_es_ctx->mds_ctx to
NULL. A previous commit changed that so now the mds_es_ctx destructor sets
s->mds_es_ctx to NULL if a search "s" was currently in-flight.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
9b0e61ff75 mdssvc: reapply default search destructor when marking a search non-pending
This is needed to ensure searches that are scheduled more then once to the
Elasticsarch server (because the first run didn't return all results) get
removed from the list of searches in case the user closes the query.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
9b56c7030f mdssvc: prevent a crash when pending search finishes after the client closed the search connection
When a search is in-flight and currently being processed against the
Elasticsearch server, we set s->pending. In the destructor of "s" we check "pending"
and reject deallocation of the object.

One instance where "s" is requested to be deallocated is when the client closes
the top-level per-share search connection. This will implicitly close all
searches associated with the mds_ctx from mds_ctx_destructor_cb():

	while (mds_ctx->query_list != NULL) {
		/*
		 * slq destructor removes element from list.
		 * Don't use TALLOC_FREE()!
		 */
		talloc_free(mds_ctx->query_list);
	}

So when this happens the Elasticsearch backend query object stays around,
alongside with any active tevent_req request and a tevent_req timer set with
tevent_req_set_endtime() in mds_es_search_send().

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14915
RN: mdssvc crashes when searches are pending and the client closes the mdssvc IPC pipe

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
2fc2c7d4b0 mdssvc: move calling mds_es_search_set_pending() to mds_es_next_search_trigger()
This makes the calls to mds_es_search_set_pending() and
mds_es_search_unset_pending() symmetric. No change in behaviour.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
5b750d6b33 mdssvc: consolidate calls of mds_es_search_unset_pending()
Both codepaths were mds_es_search_unset_pending() is currently called end up
going through the higher level callback mds_es_search_done(). Moving the call to
mds_es_search_unset_pending() ensures we call it consistently and don't miss it
in some error code path.

Otherwise no change in behaviour.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
c0d46796d4 mdssvc: update a comment
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14915

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Ralph Boehme
3254622a30 mdssvc: fix a comment
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14915

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2022-08-03 13:00:36 +00:00
Jeremy Allison
93b6db3328 s3: smbd: Convert smb_file_rename_information() to use filename_convert_dirfsp().
There is only one last user of filename_convert(), in filename_convert_smb1_search_path().

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

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Aug  2 20:46:38 UTC 2022 on sn-devel-184
2022-08-02 20:46:38 +00:00
Jeremy Allison
0e7a151c2f s3: smbd: Convert smb_file_link_information() to use filename_convert_dirfsp().
One less use of filename_convert().

Later we should optimize this by passing in
the src_dirfsp from the caller.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
e960f4b30b s3: smbd: Convert smb2_file_rename_information() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
3b3cab8188 s3: smbd: Convert smb_set_file_unix_hlink() to use filename_convert_dirfsp().
One less use of filename_convert().

Later we should optimize this by passing in
the src_dirfsp from the caller.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
22403ec72e s3: smbd: Convert reply_ntrename() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
8b667db0f7 s3: smbd: Convert reply_mv() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
b14e4f5925 s3: smbd: Convert reply_mkdir() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
79257334c2 s3: smbd: Convert reply_unlink() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
dc309e6062 s3: smbd: Convert cmd_utime() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
ab9397726e s3: smbd: Convert smbd_smb2_create_durable_lease_check() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
c3737300ed s3: smbd: Convert _srvsvc_NetSetFileSecurity() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
d89ec90c87 s3: smbd: Convert _srvsvc_NetGetFileSecurity() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
1006b1af4b s3: smbd: Convert call_trans2setfilepathinfo() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
a9ed7f6064 s3: smbd: Convert call_trans2qfilepathinfo() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
c71368a080 s3: smbd: Convert reply_setatr() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
a457d59e98 s3: smbd: Convert reply_getatr() to use filename_convert_dirfsp().
One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
2a9d7beb9e s3: smbd: Add dirfsp parameter to create_directory().
Not yet used but passed down to SMB_VFS_CREATE().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
a6c34ec3c2 s3: smbd: Add src_dirfsp and dst_dirfsp parameters to copy_internals().
Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
b80e51137c s3: smbd: Add old_dirfsp and new_dirfsp parameters to hardlink_internals().
Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
1d658bbe65 s3: smbd: Add dst_dirfsp parameter to rename_internals_fsp().
Not yet used, but when this is fully plumbed though we can
look at optimizing and removing the code inside rename_internals_fsp()
that currently gets it's own dst_dirfsp.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
0b33ec49e3 s3: smbd: Add dirfsp parameter to unlink_internals().
Not yet used but passed to SMB_VFS_CREATE().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
d9f144acb6 s3: smbd: Add src_dirfsp and dst_dirfsp parameters to rename_internals().
Not yet used (but passed to SMB_VFS_CREATE_FILE()).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
beb10e8bbe s3: smbd: In reply_ntrename(), don't call filename_convert() if we know it's a stream rename.
There is no point in calling filename_convert() on a raw stream name.
It can never find the file anyway (and never returns a valid smb_fname->fsp).
Use the same logic as SMB2_FILE_RENAME_INFORMATION_INTERNAL now does
and generate smb_fname_new directly.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
c673ca15c5 s3: smbd: Tweak the logic of smb2_file_rename_information().
There's no point in calling filename_convert() and then
just ignoring the returned smb_fname if it's a raw stream name.
Only call filename_convert() if we know it isn't a raw stream
name.

Ignore stream/non-stream mismatches in src and dst in
smb2_file_rename_information, let rename_internals_fsp()
take care of that as the error returns inside rename_internals_fsp()
are tested by raw.streams.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
b9006f33b4 s3: smbd: Inside filename_convert_dirfsp_nosymlink(), don't require UCF_PREP_CREATEFILE when parsing a stream name that doesn't already exist.
We don't require it for a new file. Without this change, we have
to add UCF_PREP_CREATEFILE to the destination flags when we are
doing renames to a destination stream name, but not when doing
renames to a destination file name, which makes for inconsistent API use.

filename_convert_dirfsp() is now a drop in replacement
for filename_convert(), even for the ugly SMB1 POSIX
cases.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
2c4719a0cd s3: smbd: In filename_convert_dirfsp(), don't let an SMB1+POSIX client see a symlink to a directory with no permissions.
This isn't 100% correct, but it gets us close enough
to the old behavior for SMB1+POSIX libsmbclient. If we went through a
symlink, and we got NT_STATUS_ACCESS_DENIED on the directory
containing the target, just don't allow the client to see the
intermediate path.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:32 +00:00
Jeremy Allison
5249cb3d0f s3: smbd: In filename_convert_dirfsp_nosymlink(), in SMB1-only POSIX mode, allow a pathname referencing a symlink to be returned.
Doesn't contain a valid smb_fname->fsp pointer of course,
and is only used by the SMB1 code to take a reference to
a smylink name for manipulation (unlinkat, readlinkat etc.).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:31 +00:00
Jeremy Allison
6fd8f7fd18 s3: smbd: In filename_convert_dirfsp(), allow SMB1+POSIX to traverse non-terminal symlinks.
This is the behavior of filename_convert() and
we need to allow it for the legacy SMB1+POSIX libsmbclient
libraries already deployed out there.

When we add SMB2 POSIX we must disallow symlink
traversal over any symlinks, the client must
resolve symlinks locally.

Add a note to show this is where we need to add
an error for SMB2+POSIX names with UCF_POSIX_PATHNAMES
set.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-02 19:49:31 +00:00
Andreas Schneider
766151bf5b lib:replace: Only include <sys/mount.h> on non-Linux systems
Details at:
https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Aug  2 11:05:14 UTC 2022 on sn-devel-184
2022-08-02 11:05:14 +00:00
Andreas Schneider
9459f85511 Revert "lib:replace: Remove <sys/mount.h> from filesys.h"
This reverts commit 7a6bd22798.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-08-02 10:11:35 +00:00
Martin Schwenke
3aecd6e7b5 ctdb-common: CID 1507498: Control flow issues (DEADCODE)
Fix typo in error checking.  While here adjust the bottom of the
range, making errno 0 invalid.

Add corresponding test cases using an alternative syntax for errno packets
(#nnn[;] - trailing ';' is optional).

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 Aug  1 09:19:55 UTC 2022 on sn-devel-184
2022-08-01 09:19:55 +00:00
Andreas Schneider
7a6bd22798 lib:replace: Remove <sys/mount.h> from filesys.h
You need to be careful if you include <sys/mount.h> or <linux/mount.h>
at least since glibc 2.36.

Details at:
https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E

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

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): Fri Jul 29 13:08:36 UTC 2022 on sn-devel-184
2022-07-29 13:08:36 +00:00
Joseph Sutton
15c86028a8 CVE-2022-32743 s4:rpc_server/netlogon: Reconnect to samdb as workstation account
This ensures that the database update can be attributed to the
workstation account, rather than to the anonymous SID, in the audit
logs.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Thu Jul 28 23:41:27 UTC 2022 on sn-devel-184
2022-07-28 23:41:27 +00:00