1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

125918 Commits

Author SHA1 Message Date
Jeremy Allison
8a427783e5 smbd: fix pathref unlinking in create_file_unixpath()
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.

This is commonly the case from an SMB1 path-based call
(eg call_trans2qfilepathinfo()) where we use the pathref fsp
(smb_fname->fsp) as the handle. In this case we must not unlink smb_fname->fsp
from it's owner.

The asserts below:

  SMB_ASSERT(fsp->fsp_name->fsp != NULL);
  SMB_ASSERT(fsp->fsp_name->fsp == fsp);

ensure the required invarients are met.

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

Pair-Programmed-With: Ralph Boehme <slow@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Jun  8 20:44:41 UTC 2021 on sn-devel-184
2021-06-08 20:44:41 +00:00
Stefan Metzmacher
7645aca4d0 lib:cmdline: Use getprogname() to avoid possible issues with setproctitle()
Reviewed-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 Jun  8 14:58:58 UTC 2021 on sn-devel-184
2021-06-08 14:58:58 +00:00
Stefan Metzmacher
d3c0d68aa1 s3:cmdline: Use D_ERR() instead of DBG_ERR() for talloc log
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2021-06-08 14:13:28 +00:00
Andreas Schneider
f9ffed0686 lib:cmdline: Also set logfile for the debug system
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jun  8 12:35:34 UTC 2021 on sn-devel-184
2021-06-08 12:35:34 +00:00
Volker Lendecke
9cb3e4314b lib: Slightly simplify server_id_set_disconnected()
The NULL assert is not really required, it will crash nicely if that's
not fulfilled.

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 Jun  4 17:34:06 UTC 2021 on sn-devel-184
2021-06-04 17:34:06 +00:00
Volker Lendecke
581ebbcc31 smbd: Simplify share_mode_entry_do()
Looking at the logic of "ha[d|ve]_share_mode_entry" d->modified=true
can only happen if we remove the last share mode entry . Make this
more explicit, avoid booleans.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
c2092cfc44 libnet: Initialize pointers
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
b9f903fbd5 libnet: Align a few integer types
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
5acb37fd56 nsswitch: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
7f967589ea rpc_server: Use correct PRIu16 for printf of a uint16
Don't rely on correct casting

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
8ee391bbd0 tevent: Remove single-use ev_str_list_[length|add]
This also adds proper error checks, the previous code could (very
theoretically) have leaked memory if an intermediate _add had failed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
b619195689 lib: Open tdb files with O_CLOEXEC
After an exec() the fd's don't make sense anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
87a0a20417 rpc_server: Avoid a cast
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
d4e5ce90cf printing: Factor out remove_from_jobs_list()
remove_from_jobs_changed() and remove_from_jobs_added() only differed
by the keystr.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
93a28a5f24 printing: Simplify pack_devicemode()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
4388ad2a90 lib: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
3f4d85f749 dbwrap_ctdb: Remove "tryonly" from fetch_locked_internal()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
a41af25ebd dbwrap: Remove "db_context->try_fetch_locked()" fn pointer
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Volker Lendecke
8089f5190c dbwrap: Remove unused dbwrap_try_fetch_locked()
Small simplification, this has not been used since 2014 when the
notifyd went in. Can easily be added if needed again.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-04 16:47:34 +00:00
Jeremy Allison
292abd2884 s3: smbd: Fix bug (only in master) introduced by 60ddee64f6.
Commit 60ddee64f6 - smbd: simplify rmdir_internals()

had a bug where it carefully set unlink_flags but then didn't use them in the
following SMB_VFS_UNLINKAT() call.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Jun  3 20:23:38 UTC 2021 on sn-devel-184
2021-06-03 20:23:38 +00:00
Jeremy Allison
b0f28dcd7a s3: smbd: Remove parent_smb_fname(), no longer used.
Moved into the VFS as SMB_VFS_PARENT_PATHNAME() to
allow modules to process the returned parent dirname.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Jun  2 06:30:36 UTC 2021 on sn-devel-184
2021-06-02 06:30:36 +00:00
Jeremy Allison
50a6da636c s3: smbd: check_reduced_name(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:31 +00:00
Jeremy Allison
7dc7a2c048 s3: smbd: check_reduced_name_with_privilege(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:31 +00:00
Jeremy Allison
2e41ffe104 s3: smbd: parent_dirname_compatible_open(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:31 +00:00
Jeremy Allison
6263338f45 s3: smbd: non_widelink_open(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
0dc842b4fa s3: smbd: In inherit_new_acl(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
4f5928d286 s3: smbd: open_file_ntcreate(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
38410ea2f7 s3: smbd: In check_parent_access(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
0dde001c36 s3: smbd: copy_internals(). parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Off-topic. This function is insane and should be removed..

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
b2027f982f s3: smbd: In parent_pathref(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
ad99ee7578 s3: smbd: In can_delete_file_in_directory(), parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
97c12be097 s3: VFS: linux_xfs_sgid. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
fb5749fa6b s3: VFS: gpfs. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
d0e84e28bf s3: VFS: error_inject. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
9cd853da6b s3: VFS: acl_common. parent_smb_fname() -> SMB_VFS_PARENT_PATHNAME().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
71f69b6c1c s3: VFS: shadow_copy2. Implement SMB_VFS_PARENT_PATHNAME().
Allows the snapdirseverywhere code to still find
snapshots even when not in the parent path.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
0e75f9ffab s3: VFS: Add SMB_VFS_PARENT_PATHNAME().
Not yet used.

Default is NTSTATUS version of parent_smb_fname(). Now
to replace all users of parent_smb_fname() with
SMB_VFS_PARENT_PATHNAME() and then remove parent_smb_fname().

Needed due to snapdirseverywhere code in vfs_shadow_copy2.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Jeremy Allison
c500d99e2f s3: lib: Fix talloc heirarcy error in parent_smb_fname().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14722

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-02 05:39:30 +00:00
Andrew Bartlett
58b5513d52 selftest: standardise and shorten winbind socket name
The full path to the winbindd socket must fit within a struct sockaddr_un and this helps us work
where this is quite deep on the server.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Jun  2 04:46:39 UTC 2021 on sn-devel-184
2021-06-02 04:46:39 +00:00
Andrew Bartlett
3bc680c1e3 pidl: Avoid leaving array_size NDR tokens around
In many cases these can and should be consumed as soon as
they are used.

This is not a complete fix, we don't clean up the array_size
token after using it split between an NDR_SCALARS and
an NDR_BUFFERS pass, but it is much better than it was
and helps the winbind case with a large number of groups
(eg 100,000) as otherwise we hit the 65535 NDR token limit.

(This is an arbitary Samba-only limit to avoid DoS conditions)

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Andrew Bartlett
a7d4f93cfd pidl: Avoid leaving array_length NDR tokens around
In many cases these can and should be consumed as soon as
they are used.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Andrew Bartlett
139cca7c20 librpc: Use helper function ndr_get_array_size() in ndr_check_array_size()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14710

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Andrew Bartlett
40aabcb5cf librpc: Add const to cookie pointer in ndr_check_array_{size,length}
This pointer is only used to find the right token in the list
so can be declared const.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Andrew Bartlett
c35f4180a4 libndr: Return error code from ndr_token_peek()
This makes it safer to change our code to remove tokens after use
if failing to obtain a token would result in an error.

This means changing ndr_get_array_size() and ndr_get_array_length()
to also return an error code.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Andrew Bartlett
0cc4478070 selftest: Add test of NDR marshalling from python, starting with wbint
These patches are to address an issue unpacking a very large
winbind.wbint_Principals array (100,000).

We need the NDR_TOKEN_MAX_LIST_SIZE value exposed as
otherwise a well-meaning incrase of this value would
invalidate the test.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Andrew Bartlett
e583140e81 spoolss: Avoid indirection via ndr_get_array_size()
This is set in the call just above and otherwise we will (in the next commit)
need an intermediate variable once we need to check error codes from
ndr_get_array_size().

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02 03:56:36 +00:00
Douglas Bagnall
2f7aa81a9f samba-tool dns zoneoptions: timestamp manipulation options
There was a bug in Samba before 4.9 that marked all records intended
to be static with a current timestamp, and all records intended to be
dynamic with a zero timestamp. This was exactly the opposite of
correct behaviour.

It follows that a domain which has been upgraded past 4.9, but on
which aging is not enabled, records intended to be static will have a
timestamp from before the upgrade date (unless their nodes have
suffered a DNS update, which due to another bug, will change the
timestmap). The following command will make these truly static:

$ samba-tool dns zoneoptions --mark-old-records-static=2018-07-23 -U...

where '2018-07-23' should be replaced by the approximate date of the
upgrade beyond 4.9.

It seems riskier making blanket conversions of static records into
dynamic records, but there are sometimes useful patterns in the names
given to machines that we can exploit. For example, if there is a
group of machines with names like 'desktop-123' that are all supposed
to using dynamic DNS, the adminstrator can go

$ samba-tool dns zoneoptions --mark-records-dynamic-regex='desktop-\d+'

and there's a --mark-records-static-regex for symmetry.

These options are deliberately long and cumbersome to type, so people
have a chance to think before they get to the end. We also introduce a
'--dry-run' (or '-n') option so they can inspect the likely results
before going ahead.

*NOTE* ageing will still not work properly after this commit, due to
other bugs that will be fixed in other commits.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02 03:56:36 +00:00
Douglas Bagnall
074f9e1486 pytest:samba-tool dns: more robust clean-up
If setUp() fails (and here we have a big .setUp), .tearDown is not run,
and that can leave the zone undeleted, breaking all the other tests who
expect to be able to recreate it.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02 03:56:36 +00:00
Douglas Bagnall
b11ea9d7ad samba-tool dns: remove unused imports
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02 03:56:36 +00:00
Douglas Bagnall
eeaa138032 samba-tool dns: move dns_record_match to dnsserver.py
This function is used here and in tests, but the tests should not be
importing things from netcmd.dns, which is really supposed to be UI
code. So we move to a common place.

the only difference is the function raises DNSParseError instead of
CommandError, and netcmd.dns has to catch and wrap that.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02 03:56:36 +00:00