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

5345 Commits

Author SHA1 Message Date
Björn Baumbach
485743dac3 s3:libsmb: fix a typo in a comment
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-01 03:50:35 +00:00
Jeremy Allison
4f80f5f904 s3: libsmb: cli_state_save_tcon(). Don't deepcopy tcon struct when temporarily swapping out a connection on a cli_state.
This used to make a deep copy of either
cli->smb2.tcon or cli->smb1.tcon, but this leaves
the original tcon pointer in place which will then get
TALLOC_FREE()'d when the new tree connection is made on
this cli_state.

As there may be pipes open on the old tree connection with
talloc'ed state allocated using the original tcon pointer as a
talloc parent we can't deep copy and then free this pointer
as that will fire the destructors on the pipe memory and
mark them as not connected.

This call is used to temporarily swap out a tcon pointer
(whilst keeping existing pipes open) to allow a new tcon
on the same cli_state and all users correctly call
cli_state_restore_tcon() once they are finished with
the new tree connection.

Just return the existing pointer and set the old value to NULL.
We know we MUST be calling cli_state_restore_tcon() below
to restore the original tcon tree connection pointer before
closing the session.

Remove the knownfail.d entry.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Feb  2 21:05:25 UTC 2021 on sn-devel-184
2021-02-02 21:05:25 +00:00
Jeremy Allison
faba89ad59 s3: libsmb: Ensure we disconnect the temporary SMB1 tcon pointer on failure to set up encryption.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13992

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2021-02-02 19:54:34 +00:00
Andreas Schneider
878b4a71aa s3:libsmb: Use C99 initializer for py_cli_notify_state_methods
error: missing field 'ml_meth' initializer [-Werror,-Wmissing-field-initializers]
        { NULL }
               ^

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-02-01 21:50:32 +00:00
Volker Lendecke
d4bbaee890 libsmb: Simplify add_ace()
Use ADD_TO_ARRAY()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-22 19:54:38 +00:00
Volker Lendecke
3fa00ac31a libsmb: Simplify sec_desc_parse()
Avoid CALLOC for just one struct dom_sids

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-22 19:54:38 +00:00
Andreas Schneider
181afa9f68 s3:libsmb: Use cli_credentials directly
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): Wed Jan 13 21:32:52 UTC 2021 on sn-devel-184
2021-01-13 21:32:52 +00:00
Andreas Schneider
78c4043a28 s3:libsmb: Pass cli_credentials to get_ipc_connect_master_ip()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2021-01-13 20:28:34 +00:00
Andreas Schneider
be18d600f7 s3:libsmb: Pass cli_credentials to get_ipc_connect()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2021-01-13 20:28:34 +00:00
Volker Lendecke
4aa3ff574f lib: Move sockaddr_storage_to_samba_sockaddr() to lib/
This can be useful outside of source3/libsmb/namequery.c as Samba
moves towards samba_sockaddr.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
2021-01-11 13:19:32 +00:00
Volker Lendecke
d0eaa14325 libsmb: Use hex_byte() in urldecode_talloc()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-08 20:31:33 +00:00
Stefan Metzmacher
752a8f870d s3:pylibsmb: remove unused SECINFO_DEFAULT_FLAGS
commit 42be033b0b removed the last
reference.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 13:59:38 +00:00
Stefan Metzmacher
3ffb817506 s3:pylibsmb: add notify() support
The operation is a bit different from others,
as results are returned in an async fashion.
It returns a request handle.

  notify_req = conn.notify(fnum=fnum,
                           buffer_size=0xffff,
                           completion_filter=libsmb.FILE_NOTIFY_CHANGE_ALL,
                           recursive=True)

  # ... do other operations on conn.*() ...

  changes = notify_req.get_changes(wait=False)
  # changes is likely to be None if no result arrived yet

  # ... do other operations on conn.*() ...

  changes = notify_req.get_changes(wait=True)
  # changes is a list of change dictionaries
  # each containing "name" (a string) and
  # "action" (an integer, e.g. libsmb.NOTIFY_ACTION_REMOVED)

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 13:59:38 +00:00
Stefan Metzmacher
fde65c2f29 s3:pylibsmb: add echo() support
In tests it's sometimes to have a no-op in order to check the
transport is still alive.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 13:59:38 +00:00
Stefan Metzmacher
084c22403f s3:pylibsmb: PyErr_NTSTATUS_IS_ERR_RAISE => PyErr_NTSTATUS_NOT_OK_RAISE
We want to raise an exception for everything that's not NT_STATUS_OK.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 13:59:38 +00:00
Björn Baumbach
76121ae7cf s3:libsmb: set correct min and max smb protocol when smb2 is enforced on connect
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14105

Pair-programmed-with: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Björn Baumbach <bb@sernet.de>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 13:59:38 +00:00
Björn Baumbach
f40da74e14 s3:libsmb: set min smb protocol when enforcing smb1 on connect
Otherwise the connect fails if the configured client min protocol is
higher than NT1.

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

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 13:59:37 +00:00
Volker Lendecke
d327f664cc libsmb: Remove unused dns_lookup_list_async()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-11 18:29:32 +00:00
Volker Lendecke
7614cce0bd libsmb: No need to call dns_lookup_list_async() in discover_dc_dns()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-11 18:29:32 +00:00
Volker Lendecke
9d7c048e0b libsmb: Use ads_dns_query_srv() in discover_dc_dns()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-11 18:29:32 +00:00
Volker Lendecke
d92a85fb12 libsmb: No need to call dns_lookup_list_async() in resolve_ads()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-11 18:29:32 +00:00
Volker Lendecke
b9f9157115 libsmb: Use ads_dns_query_srv() in resolve_ads()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-11 18:29:32 +00:00
Volker Lendecke
f03113582f libsmb: Slightly beautify internal_resolve_name()
We have "goto done;" at the end of every if-branch, we don't need
else.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-30 22:24:38 +00:00
Volker Lendecke
d82cd10f95 libsmb: Move a variable closer to its use in internal_resolve_name()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-30 22:24:38 +00:00
Volker Lendecke
7fc62fd112 libsmb: Align integer types
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-30 22:24:38 +00:00
Volker Lendecke
f85adfb2ef libsmb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-30 22:24:37 +00:00
Volker Lendecke
a613ebc09d dsgetdcname: Fix talloc hierarchy
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-30 22:24:37 +00:00
Andreas Schneider
1a86474912 s3:libsmb: Return early if dir is NULL
This makes sure we do not dereference a NULL poineter.

Found by covscan.

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): Thu Nov 26 11:07:09 UTC 2020 on sn-devel-184
2020-11-26 11:07:09 +00:00
Andreas Schneider
6123bd25ad s3:libsmb: Fix clang warnings that fnum might be used uninitialized
Found by covscan.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-26 09:44:41 +00:00
Volker Lendecke
d680d39268 pylibsmb: Add rename()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 22:56:40 +00:00
Volker Lendecke
7457674396 libsmb: Make cli_nt_pipes_close() static
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 22:56:40 +00:00
Volker Lendecke
8bc77a0f86 pylibsmb: Multi-threaded use is now possible with SMB2
No non-async callees are used anymore

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 Nov 19 04:12:11 UTC 2020 on sn-devel-184
2020-11-19 04:12:11 +00:00
Volker Lendecke
a4e3092bd0 pylibsmb: Remove unused py_cli_state->is_smb1
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
47b773addc libsmb: Remove unused sync cli_smb2_list()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
6baceb4de4 pylibsmb: Remove SMB2 special case for cli_list()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
9dde2dc99b libsmb: Use async cli_smb2_list_send() in cli_list_send()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
8101c18362 libsmb: Prepare cli_list_send()/recv() for single-issue subreqs
This prepares cli_list_recv() for the lowerlevel NT_STATUS_RETRY that
will come in once cli_list_send() uses cli_smb2_list_send() as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
1f11b7b447 libsmb: Convert cli_list_recv() to single-recv
This converts the higher-level cli_list_recv() to the new
cli_smb2_list_recv() calling convention to just issue one entry per
recv() call in preparation of using the async cli_smb2_list_send() in
cli_list_send().

For SMB1 this will be a performance degradation, as we have to make
copies out of the arrays that cli_trans_recv() returns, but soon this
will become a performance improvement for the SMB2 directory
listing. And as hopefully most deployments these days are SMB2, I
think we can live with the SMB1 client directory listing
degradation. Also, we can also convert the lowerlevel SMB1 directory
listing routines in case someone actually sees problems from this
here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
d1269ef979 libsmb: Make cli_smb2_list() asynchronous
Return directory entries as soon as possible via
cli_smb2_list_recv(). This returns just one entry per call to
cli_smb2_list_recv() right out of the buffer without assembling
potentially thousands of entries in a big array. You must call
cli_smb2_recv() until an error (except NT_STATUS_RETRY) happens. This
reduces our latency for smbclient's "dir" command significantly for
large directories. In the future I hope I can do the same thing also for
SMBC_readdir_ctx() to improve all users of our published libsmbclient.

Initial attempts of this routine issued fresh smb2_query_directory
requests asynchronously while the receivers of the entries did their
processing, for example showing them in smbclient's "dir"
command. However, this breaks because for example the "showacls"
smbclient option needs to do synchronous smb requests to do their job,
which we can't do while async requests are pending. Thus I came up
with a semi-synchronous approach to issue additional
smb2_query_directory requests from within cli_smb2_list_recv() and
return NT_STATUS_RETRY. This means that we will call back our caller
via the tevent_req_notify function when a fresh entry is available.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19 02:48:40 +00:00
Volker Lendecke
7bd040f60a libsmb: Remove unused sync cli_smb2_rename()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Nov 16 21:18:16 UTC 2020 on sn-devel-184
2020-11-16 21:18:16 +00:00
Volker Lendecke
1fdcfdcffb libsmb: Make cli_rename_send()/recv() smb2-capable
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:46 +00:00
Volker Lendecke
db1fa2392d libsmb: Make cli_rename_send()/_recv() a proper tevent_req engine
This will make it more obvious to add SMB2 soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:46 +00:00
Volker Lendecke
1ce7c596be libsmb: Make cli_smb2_rename async
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:46 +00:00
Volker Lendecke
2ea885f96f libsmb: Make get_fnum_from_path() async
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
42be033b0b pylibsmb: Move set_acl() to python
The previous code was not available in threaded environments

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
3b81cc900f pylibsmb: Add set_sd()
setacl() on a fnum, available asynchronously

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
97fca81af0 libsmb: Remove unused sync cli_smb2_set_security_descriptor()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
e617cb5fa1 libsmb: Make cli_set_security_descriptor() async
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
472c16d554 pylibsmb: Move get_acl() to python
The previous code was not available in threaded environments

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
57f8e7eb11 pylibsmb: Add get_sd()
getacl() on a fnum, available asynchronously

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
edf26b29cf libsmb: Remove unused sync cli_smb2_query_security_descriptor()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
207ca06189 libsmb: Make cli_query_security_descriptor() async
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:45 +00:00
Volker Lendecke
2562890724 pylibsmb: Export a few SMB constants
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:44 +00:00
Volker Lendecke
d33cec8d44 pylibsmb: Merge remove_dir() into its only caller
Now that delete_tree is in python code, align py_smb_rmdir() with the
other functions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:44 +00:00
Volker Lendecke
5ee42dd0e9 pylibsmb: Merge unlink_file() into its only caller
Now that delete_tree is in python code, align py_smb_unlink() with the
other functions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:44 +00:00
Volker Lendecke
13aecb22f7 pylibsmb: Move deltree to python code
This is much shorter. There's also another aspect: I'm working on
improving cli_list() to not collect all files before starting to call
the callback function. This means that the cli_list cb will be called
from within tevent_loop_once(). In pylibsmb.c's deltree code this
would create a nested event loop. By moving the deltree code into the
python world this nested event loop is avoided. Now the python code
will first collect everything and then start to delete, avoiding the
nesting. A future development should make listing directories a
generator or something like that.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:44 +00:00
Volker Lendecke
2cff5990da pylibsmb: Add a compatible python-level wrapper
Right now this is empty, but it is the basis for moving complexity out
or pylibsmb.c into python code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-16 19:53:44 +00:00
Volker Lendecke
3e8ce497f3 libsmb: Remove cli_state->dfs_mountpoint
Not used anymore

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): Wed Nov  4 20:17:47 UTC 2020 on sn-devel-184
2020-11-04 20:17:47 +00:00
Volker Lendecke
a7d39ed143 libsmb: Remove "mntpoint" argument from cli_list_trans() callback
This was unused in the callers, also do this for symmetry.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04 18:55:40 +00:00
Volker Lendecke
4ebe72b942 libsmb: Remove "mntpoint" argument from cli_list() callback
do_list()/do_list_helper() in source3/client/client.c was the only user of this
argument. And that use was wrong.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04 18:55:40 +00:00
Volker Lendecke
7ea5c1f05d libsmb: Fix a signed/unsigned warning
"num_bytes" is uint32_t, "received" is uint16_t. The multiplication
seems to implicitly widen "received" to int, leading to a
signed/unsigned warning. This cast makes that warning go away.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04 18:55:39 +00:00
Volker Lendecke
669414efac libsmb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04 18:55:39 +00:00
Volker Lendecke
0851afdffd libsmb: Improve wording of a comment in cli_smb2_list
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04 18:55:39 +00:00
Andreas Schneider
1298280a22 auth:creds: Rename CRED_USE_KERBEROS values
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
2020-11-03 15:25:37 +00:00
Volker Lendecke
d845e90e0e libsmb: Simplify cli_resolve_path()
The additional conditions in cli_dfs_check_error() were covered
earlier in cli_resolve_path() via cli_conn_have_dfs(). Without those
it's more obvious to directly call NT_STATUS_EQUAL here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-21 19:04:39 +00:00
Volker Lendecke
d93e0f0978 libsmb: Factor out cli_conn_have_dfs() from cli_resolve_path()
This also does the checks from cli_dfs_check_error(), which can be
removed in the next step.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-21 19:04:39 +00:00
Volker Lendecke
4ad0e4d210 libsmb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-21 19:04:39 +00:00
Volker Lendecke
7ce22e2f57 libsmb: Use a direct struct initialization to avoid a memset
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-21 19:04:39 +00:00
Volker Lendecke
41c78d1888 libsmb: Use ZERO_STRUCTP
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-21 19:04:38 +00:00
Volker Lendecke
b64949d544 libsmb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-21 19:04:38 +00:00
Andreas Schneider
50b59b4c28 s3:libsmb: Remove max_protocol from clidfs do_connect()
The if check for max_protocol == 0 is part of lp_client_max_protocol().

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:46 +00:00
Andreas Schneider
2159582610 s3:libcmb: Remove max_protocol from cli_cm_connect()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:46 +00:00
Andreas Schneider
4aac9daf09 s3:libsmb: Remove max_protocol from cli_cm_open()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:46 +00:00
Andreas Schneider
5245ab3c4d s3:libsmb: Pass cli_credentials to cli_resolve_path(), using helper variables.
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:46 +00:00
Andreas Schneider
df1623abd7 s3:libsmb: Pass cli_credentials to cli_cm_open()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:46 +00:00
Andreas Schneider
c834911124 s3:libsmb: Pass cli_credentials to cli_cm_connect()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:45 +00:00
Andreas Schneider
276563de06 s3:libsmb: Pass cli_credentials to clidfs do_connect()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:45 +00:00
Andreas Schneider
4ddec1ca25 s3:libsmb: Remove force_encrypt from cli_check_msdfs_proxy()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:45 +00:00
Andreas Schneider
615a9a6816 s3:libsmb: Remove force_encrypt from clidfs do_connect()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:45 +00:00
Andreas Schneider
d27e237cf3 s3:libsmb: Remove force_encrypt from cli_cm_connect()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:45 +00:00
Andreas Schneider
a9fbc8dae8 s3:libsmb: Remove force_encrypt from cli_cm_open()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-09 19:16:45 +00:00
Volker Lendecke
f67c8f9562 libsmb: Make cli_smb2_list() prototype more descriptive
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-30 15:58:38 +00:00
Volker Lendecke
6ee90adf73 libsmb: Make cli_list() prototype more descriptive
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-30 15:58:38 +00:00
Volker Lendecke
08c4dd586f libsmb: Fix CID 1467087: Resource leaks
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): Wed Sep 23 18:20:36 UTC 2020 on sn-devel-184
2020-09-23 18:20:36 +00:00
Volker Lendecke
c6a11d8dcd libsmb: Use talloc_realloc() correctly in resolve_hosts()
On realloc failure the old value is still around

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-23 16:54:38 +00:00
Volker Lendecke
a357282153 libsmb: Protect against rogue getaddrinfo result
Probably a "won't happen", but to me this looked fishy

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-23 16:54:38 +00:00
Volker Lendecke
ed263ef47c libsmb: README.Coding for resolve_hosts()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-23 16:54:38 +00:00
Volker Lendecke
8e31c4e69c libsmb: Use direct struct initialization
Give the compiler more hints

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-23 16:54:38 +00:00
Jeremy Allison
67498ffd78 s3: libsmb: Cleanup - in internal_resolve_name() only write the out parameters on success.
All callers already correctly initialize them.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Sep 15 11:33:35 UTC 2020 on sn-devel-184
2020-09-15 11:33:35 +00:00
Jeremy Allison
526fdaa747 s3: libsmb: namequery. Rename remove_duplicate_addrs2_sa() to remove_duplicate_addrs2()
It's now the only function.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
d627ef1488 s3: libsmb: namequery.c: Remove unused remove_duplicate_addrs2().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
5b6245d14b s3: libsmb: namequery.c: Remove now unused internal_resolve_name() wrapper.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
a679c6c5a1 s3: libsmb: namequery.c: Remove now unused convert_ss2service().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
7d37b8ba1b s3: libsmb: namequery.c: Remove now unused ip_service_to_samba_sockaddr().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
757934e864 3: libsmb: namequery: Convert _internal_resolve_name() -> internal_resolve_name() returning talloced samba_sockaddr arrays.
Wrapper function internal_resolve_name() is now commented out,
along with the now unused ip_service_to_samba_sockaddr() and
convert_ss2service() functions.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
d3f6eccc98 s3: libsmb: namequery: Add utility function sockaddr_array_to_samba_sockaddr_array().
Not yet used. Will help convert _internal_resolve_name() to internal_resolve_name().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
ef62fa93be s3: libsmb: Rename prioritize_ipv4_list_sa() -> prioritize_ipv4_list() now it's the only use.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
5a2b5c74c9 s3: libsmb: Remove unused prioritize_ipv4_list().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
e0d060c632 s3: libsmb: Tidy up the talloc heirarchy allocation in get_dc_list().
Always allocate the return_salist off the frame pointer.
Only talloc_move() to return ctx on successful return.

Cleans up a nasty else in the exit path that caused
problems in the past - we can now always TALLOC_FREE(return_salist)
without remembering if we need to return it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
f03a6ef66b s3: libsmb: Convert get_dc_list() to call internal_resolve_name() not _internal_resolve_name().
prioritize_ipv4_list() is no longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
5b8f5971e0 s3: libsmb: Remove now unused internal functions ip_service_compare() and sort_service_list().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:40 +00:00
Jeremy Allison
e6c581f0e1 s3: libsmb: Convert get_pdc_ip() to call internal_resolve_name() not _internal_resolve_name().
NB. sort_service_list() and ip_service_compare() are now no
longer used so comment them out for removal.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
be85a463f4 s3: libsmb: Convert find_master_ip() to call internal_resolve_name() not _internal_resolve_name().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
3b1542a1e9 s3: libsmb: Convert resolve_name_list() to call internal_resolve_name() not _internal_resolve_name().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
178bd3847b s3: libsmb: Convert resolve_name() to call internal_resolve_name() not _internal_resolve_name().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
185f3027f0 s3: libsmb: Rename internal_resolve_name_sa() -> internal_resolve_name()
That's now the only external interface to it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
489102b044 s3: libsmb: Remove the internal_resolve_name() external interface.
Change the internal version from internal_resolve_name() -> _internal_resolve_name().
Only external caller calls internal_resolve_name_sa().

After this we can rename internal_resolve_name_sa() back to internal_resolve_name()
as all internal use in namequery.c is via _internal_resolve_name().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
a8ec446d9d s3: libsmb: Fix discover_dc_netbios() to call internal_resolve_name_sa().
All callers of internal_resolve_name() are now internal to namequery.c

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
fb8acf1717 s3: libsmb: Add internal_resolve_name_sa(). A wrapper for internal_resolve_name().
Not yet used. Now to fix the callers, and convert internal_resolve_name().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <jra@samba.org>
2020-09-15 10:09:39 +00:00
Jeremy Allison
c5b1d4ffc5 s3: libsmb: Add prioritize_ipv4_list_sa().
Re-arranges a samba_sockaddr array in IPv4 preference.

Not yet used so compiles but ifdef'ed out. Needed for conversion
of internal_resolve_name().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
1181e5e1fe s3: libsmb: Add remove_duplicate_addrs2_sa() - uses samba_sockaddr.
Not yet used, will be used when we migrate internal_resolve_name()
to samba_sockaddr.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
1cb9611b7b s3: libsmb: Convert internal function get_dc_list() to return a samba_sockaddr array.
Callers now don't need to convert. Getting closer to making internal_resolve_name()
return samba_sockaddr array.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
`
2020-09-15 10:09:39 +00:00
Jeremy Allison
b59de9e5ee s3: libsmb: Rename get_sorted_dc_list_sa() -> get_sorted_dc_list().
Everyone now uses samba_sockaddr arrays.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
8ae5408d1f s3: libsmb: Remove get_sorted_dc_list(). No longer used.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:39 +00:00
Jeremy Allison
ffed032bf0 s3: libsmb: Remove last caller of get_sorted_dc_list() from rpc_dc_name().
Now only get_sorted_dc_list_sa() left.
Now we can remove get_sorted_dc_list() and rename
get_sorted_dc_list_sa() back to get_sorted_dc_list().

One more external user of struct ip_service gone.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:38 +00:00
Jeremy Allison
2b7629f3f3 s3: libsmb: Add function get_sorted_dc_list_sa(). Returns samba_sockaddr array.
Now to fix callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:38 +00:00
Jeremy Allison
1eecdd9401 s3: libsmb: Rename get_kdc_list_sa() back to get_kdc_list().
The samba_sockaddr interface is now the only one.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:38 +00:00
Jeremy Allison
0562154afa s3: libsmb: Remove get_kdc_list(). No more callers.
Next we can rename get_kdc_list_sa() -> get_kdc_list().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:38 +00:00
Jeremy Allison
47e104c496 s3: libsmb: Add get_kdc_list_sa() returns samba_sockaddr array.
Not yet used, but uses the previous utility functions.
Now to convert the get_kdc_list() callers and remove
one more external use of ip_service.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:38 +00:00
Jeremy Allison
afd83fa5e1 s3: libsmb: Add sort_sa_list() compare function. Not yet used.
Ready for when we start returning ordered samba_sockaddr arrays.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:38 +00:00
Jeremy Allison
78b191c4a0 s3: libsmb: Make sort_addr_list() and sort_service_list() take size_t counts.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:37 +00:00
Jeremy Allison
ced8fbc705 s3: libsmb: Make prioritize_ipv4_list() use size_t counts.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:37 +00:00
Jeremy Allison
d8ff36520f s3: libsmb: Fix the count returns in discover_dc_netbios(), discover_dc_dns(), process_dc_dns() to return size_t * counts.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:37 +00:00
Noel Power
1a10a430eb s3/libsmb: cleanup discover_dc_dns() Fix potential leak
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-15 10:09:37 +00:00
Noel Power
ed1e1e0b46 s3/libsmb: cleanup discover_dc_dns, only set out params on success
Signed-off-by: Noel Power <npower@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
62e99efa3d lib: addns: Fix ads_dns_lookup_ns(), ads_dns_query_dcs(), ads_dns_query_gcs(), ads_dns_query_kdcs(), ads_dns_query_pdc() to return size_t *.
Easier to do all callers at once.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
a8e0d46ead s3: libsmb: internal_resolve_name() - get rid of the icount variables.
Plus the paranoia check. Everything now uses size_t * returns.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
1fc49be483 s3: libsmb: Make resolve_ads() return a size_t * address count.
All resolve_XXXX() functions inside internal_resolve_name()
now use size_t and we can clean this up.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Noel Power<npower@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
2a1c57f6fc s3: libsmb: Fix resolve_hosts() to return size_t * count of addresses.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
f5dda19dd4 s3: libsmb: cleanup resolve_hosts() - don't change return values on fail.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
e034072c96 libcli: nbt: Fix resolve_lmhosts_file_as_sockaddr() to return size_t * count of addresses.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:37 +00:00
Jeremy Allison
af6aaf6243 s3: libsmb: Convert the WINS and broadcast name functions to return size_t * num addresses.
Have to do both at once as they are intimately related.
The uglyness inside internal_resolve_name() will go away
once all the resove_XXX() functions return size_t values.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-15 10:09:36 +00:00
Noel Power
dbab4626ef s3/libsmb: Cleanup parse_node_status() only set out params on success
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-15 10:09:36 +00:00
Jeremy Allison
923648b0c4 s3: libsmb: Convert node_status_query() and associated functions and callers to expect a size_t * return.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2020-09-15 10:09:36 +00:00
Jeremy Allison
21de9077a5 s3: libsmb: Fix bug in get_dc_list() introduced by ip-service cleanup.
Do an early return on error. On success assign to the correct
variables that are going to get copied into the 'out' parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed Sep  9 10:31:17 UTC 2020 on sn-devel-184
2020-09-09 10:31:17 +00:00
Noel Power
7a3c368d78 s3: libsmb: Cleanup in get_dc_list()
Don't modify out params (unless successful result),

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Sep  7 14:46:58 UTC 2020 on sn-devel-184
2020-09-07 14:46:58 +00:00
Jeremy Allison
170051d61e s3: libsmb: Now we only have namecache_store_sa(), rename it back to namecache_store().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
2989d736c4 s3: libsmb: Remove use of struct ip_service from the namecache code.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
9da8d26fe0 s3: libsmb: Remove the last caller of namecache_store().
Convert to a struct samba_sockaddr array and use namecache_store_sa().

We can now remove the use of 'struct ip_list' from
the namecache code.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
3dad456d8c s3: libsmb: Add internal conversion function ip_service_to_samba_sockaddr().
Compiles but commented out as not yet used. Next commit will
change that.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
1593231e0e s3: libsmb: Use namecache_store_sa() instead of namecache_store().
Removes one more struct ip_service usage.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
0e59fee291 s3: libsmb: Add namecache_store_sa(). Doesn't store ports and takes a samba_sockaddr array.
Now uses ipstr_list_make_sa(). Now convert
the callers, remove namecache_store() and
then rename namecache_store_sa() back to namecache_store().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
7835e2cb48 s3: libsmb: Add internal ipstr_list_make_sa().
Duplicates ipstr_list_make() with samba_sockaddr, but doesn't store
ports. The duplication is temporary as the ipstr_list_make() function
will go away once namecache_store is converted to samba_sockaddr.

Compiles but commented out as not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
39ecff712f s3: libsmb: Cleanup - resolve_name() get names from internal_resolve_names() which is guaranteed not to return zero addresses.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:44 +00:00
Jeremy Allison
c6cc05f597 s3: libsmb: Remove commented out wrapper for internal_resolve_name().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
f36a0be9a7 s3: libsmb: Comment out wrapper function internal_resolve_name(). Rename _internal_resolve_name() -> internal_resolve_name().
We can now remove the wrapper.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
57349b65cc s3: libsmb: Remove now unused dup_ip_service_array().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
68e12688f2 s3: libsmb: Finally change _internal_resolve_name() to return a talloc'ed ip_service array.
The wrapper internal_resolve_name() is now functionaly identical to _internal_resolve_name()
so we can remove it and rename _internal_resolve_name() back to internal_resolve_name().

dup_ip_service_array() is now no longer used, so comment it
out as it's a staic function.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
863ab1af62 s3: libsmb: Make _internal_resolve_name() return a size_t pointer for count.
Getting closer to being a idential to the wrapper function
internal_resolve_name() which we can then remove.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
31674946b7 s3: libsmb: _internal_resolve_name() code cleanup.
Only set *return_iplist just before success return.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
5e819231b3 s3: libsmb: _internal_resolve_name() code cleanup.
Only set *return_count just before success return.
Preparing to move all counts to size_t.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Noel Power
e68e0402cc s3/libsmb: Cleanup coding in convert_ss2service()
Don't update out params when unsuccessful

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
6b0b726105 s3: libsmb: Cleanup coding in convert_ss2service().
Will make it easier to return a talloc'ed array.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
9e4b5349f2 s3: libsmb: Change convert_ss2service() and it's one caller to take and return unsigned counts.
Getting closer to making _internal_resolve_name() return a pointer to size_t
for a count.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
cb01b5e433 s3: libsmb: Make namecache_store() take an unsigned count.
Counts can never be negative.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
f39ff1367a s3: libsmb: _internal_resolve_name(). Remove unused free(s).
*return_iplist is guaranteeded to be always NULL here.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:43 +00:00
Jeremy Allison
4d4bf8eedb s3: libsmb: Convert namecache_fetch() and it's only caller to return a talloc'ed array of struct samba_sockaddr.
Eventually everything will be talloced arrays of samba_sockaddr.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
9ffb18856b s3: libsmb: Cleanup the code to do one address return given an IP address to _internal_resolve_name().
Will make easier to move to talloc later.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
aa20df217c s3: libsmb: Change remove_duplicate_addrs2() to take and return size_t, not int.
Will make converting _internal_resolve_name() to return a size_t easier.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
e065fc8e28 s3: libsmb: Move talloc_stackframe() initialization to the front of _internal_resolve_name().
Ensure we free correctly on all exit paths.
This will allow us to move the internal calls to
talloc more easily.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
f5bb322e66 s3: libsmb: Rename internal_resolve_name_talloc() -> internal_resolve_name().
No more non-talloc callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
a68d329b40 s3: libsmb: Remove internal_resolve_name() externally. All callers now use internal_resolve_name_talloc().
Make the wrapped internal_resolve_name() function static as _internal_resolve_name().

Now we can rename the callers back from internal_resolve_name_talloc() -> internal_resolve_name()
as all external callers are talloc-based.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Noel Power
e5fd57d6e5 s3/libsmb: Cleanup, don't modify out params except on success
All callers don't use out params on failure.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
a16d023c15 s3: libsmb: Make discover_dc_netbios() use internal_resolve_name_talloc().
No more external users of internal_resolve_name().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
fed4b6341c s3: libsmb: Make get_dc_list() use internal_resolve_name_talloc().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
37eaee03e0 s3: libsmb: Make get_pdc_ip() use internal_resolve_name_talloc().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
55b589e9b0 s3: libsmb: Make find_master_ip() use internal_resolve_name_talloc().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Noel Power
12e346d9d8 s3/libsmb: resolve_name_list don't update out params except for success
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
505272a893 s3: libsmb: Make resolve_name_list() use internal_resolve_name_talloc().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:42 +00:00
Jeremy Allison
e18eb94f42 s3: libsmb: namequery - Make resolve_name() use internal_resolve_name_talloc().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
c6fc75a73b s3: libsmb: namequery - Add internal_resolve_name_talloc().
This is a wrapper function for internal_resolve_name()
that converts the replies from malloc() -> talloc().

Now to move the callers, and I can move the talloc
code down one level again.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
c0ccdd7038 s3: libsmb: Make get_dc_list() internal to namequery.c return talloc'ed ip_service array.
Moving closer to the target of making internal_resolve_name()
use talloc.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
973ca8a5c0 s3: libsmb: Cleanup - use early return in get_dc_list().
No logic change. Makes later code changes clearer.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
46f7ab8f37 s3: libsmb: Change get_dc_list() to return a size_t count parameter.
Remove paranoia checks and casts from callers, move internally.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
b9bc1e59bd s3: libsmb: Change to an early return in get_dc_list().
No logic change. Will make later code changes clearer.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
3b3f92a2fa s3: libsmb: Cleanup - rename ctx -> frame for a talloc_stackframe to match modern coding standards.
We will be passing in a real TALLOC_CTX soon.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
23fb64f35a s3: libsmb: Rename get_sorted_dc_list_talloc() -> get_sorted_dc_list()
There are no non-talloc callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
a0984e5064 s3: libsmb: Remove get_sorted_dc_list().
No more callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
b4164093cf s3: libsmb: Move callers of get_sorted_dc_list() -> get_sorted_dc_list_talloc().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:41 +00:00
Jeremy Allison
f305a140d1 s3: libsmb: Add get_sorted_dc_list_talloc().
Talloc version of get_sorted_dc_list_talloc().
Makes use of dup_ip_service_array().
Now to move the callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Jeremy Allison
6deb23c618 s3: libads: Rename get_kdc_list_talloc() -> get_kdc_list().
It's the only version now.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Jeremy Allison
b7182c4417 s3: libsmb: Remove now unused get_kdc_list() (non-talloc version).
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Jeremy Allison
e8a491691d s3: libsmb: Add get_kdc_list_talloc().
Talloc version of get_kdc_list(). Makes use of dup_ip_service_array().
Now to move the callers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Jeremy Allison
02016acb2d s3: libsmb: Add utility funtion dup_ip_service_array().
Preparing to return ip_service arrays as talloc, not
malloc. Commented out as not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Jeremy Allison
6bee431be3 s3: libsmb: Cleanup - Use helper variable for return from namecache_fetch() in internal_resolve_name().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Noel Power
a4073ae55c s3: libsmb: Cleanup in resolve_name_list().
Don't modify out params (unless successful result).

Signed-off-by: Noel Power <npower@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-07 13:23:40 +00:00
Jeremy Allison
6c28d71511 s3: libsmb: Cleanup - correctly error on sockaddr_storage_to_samba_sockaddr() fail.
Instead of jumping out and leaking the memory onto ctx,
skip bad conversions and error out if there are no addresses
to return (and cleanup the memory there).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:40 +00:00
Noel Power
b95eea6b29 s3: libsmb: Cleanup - ensure we initialize all stack variables to 'safe' values when calling resolve_name_list()
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-07 13:23:39 +00:00
Jeremy Allison
13acac25cb s3: libsmb: Cleanup - ensure we initialize all stack variables to 'safe' values when calling get_sorted_dc_list() that may not touch returns on error.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:39 +00:00
Jeremy Allison
f11dce99cc s3: libsmb: discover_dc_netbios(). Remember to free on error return.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2020-09-07 13:23:39 +00:00
Matthew DeVore
c2ac923c6a s3: safe_string: do not include string_wrappers.h
Rather than have safe_string.h #include string_wrappers.h, make users of
string_wrappers.h include it explicitly.

includes.h now no longer includes string_wrappers.h transitively. Still
allow includes.h to #include safe_string.h for now so that as many
modules as possible get the safety checks in it.

Signed-off-by: Matthew DeVore <matvore@google.com>
Reviewed-by: David Mulder <dmulder@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-28 00:56:34 +00:00
Jeremy Allison
f8b7ee024b s3: libsmb: Remove one more ugly sockaddr cast in resolve_name_list() by converting to samba_sockaddr.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Aug 27 08:16:37 UTC 2020 on sn-devel-184
2020-08-27 08:16:37 +00:00
Jeremy Allison
42d01987d3 s3: libsmb: Inside get_dc_list() move one more sockaddr_storage -> samba_sockaddr.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-27 06:52:30 +00:00
Jeremy Allison
102e2a26d3 s3: libsmb: Cleanup - remove an ugly sockaddr_in cast inside resolve_wins_send().
Use samba_sockaddr for its intended purpose.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Aug 25 17:43:17 UTC 2020 on sn-devel-184
2020-08-25 17:43:17 +00:00
Jeremy Allison
a388f79150 s3: libsmb: Cleanup - Pass samba_sockaddr directly to nb_trans_send().
Saves an ugly internal cast. We know this must be AF_INET.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:33 +00:00
Jeremy Allison
5151278ccc s3: libsmb: Cleanup - Remove a union in sock_packet_read_got_socket() that was an early attempt a samba_sockaddr.
Just use samba_sockaddr.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
189c741052 s3: libsmb: Cleanup - Remove the last two sockaddr casts in namequery.c in name_query_validator().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
54454b30ff s3: libsmb: Cleanup - Remove two more sockaddr casts inside remove_duplicate_addrs2().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
2056b0d9c3 s3: libsmb: Cleanup - Use samba_sockaddr as intended in resolve_name() to make ugly casts go away.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
a559eebc14 s3: libsmb: Cleanup - convert addr_compare() to using samba_sockaddr internally.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
0ef885c02d s3: libsmb: Cleanup - make name_query_send() use samba_sockaddr internally.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
d67c4a84dd s3: libsmb: Cleanup - make name_status_lmhosts() use samba_sockaddr internally.
Use existing utility function instead of direct memcmp.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
fa6d5bb3c9 s3: libsmb: Cleanup - make node_status_query_send() use samba_sockaddr internally.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
e3d9962ed3 s3: libsmb: Cleanup - Longlines cleanup for README.Coding standards.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
fbc65a2433 s3: libsmb: Cleanup - change parameter and callers of set_socket_addr_v4() to samba_sockaddr.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Jeremy Allison
928fb89273 s3: libsmb: Cleanup - Remove one call to set_socket_addr_v4().
The stack variable sockaddr_storage ss wasn't being used at all.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
2020-08-25 16:21:32 +00:00
Andreas Schneider
dd1cacb6a2 s3:libsmb: Make cli_cm_force_encryption_creds() static
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:43 +00:00
Andreas Schneider
d0062d312c s3:libsmb: Use cli_credentials_set_smb_encryption()
This also adds a SMBC_ENCRYPTLEVEL_DEFAULT to 'enum
smbc_smb_encrypt_level' in order to use the smb.conf default value.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:42 +00:00
Stefan Metzmacher
8a5bc0a6a1 s3:libsmb: Add encryption support to cli_full_connection_creds*()
Pair-Programmed-With: Andreas Schneider <asn@samba.org>

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-19 16:22:42 +00:00
Andreas Schneider
ba04151a01 s3:libsmb: Remove signing_state from cli_full_connection_creds()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:42 +00:00
Andreas Schneider
886f245ace s3:libsmb: Remove signing_state from cli_full_connection_creds_send()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:42 +00:00
Andreas Schneider
6f552204d4 s3:client: Turn off smb signing for message op
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:42 +00:00
Andreas Schneider
62a4705dbc s3:libsmb: Use 'enum smb_signing_setting' in cliconnect.c
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:42 +00:00
Andreas Schneider
8c06dc1365 s3:pylibsmb: Add ipc=True support for CLI_FULL_CONNECTION_IPC
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:41 +00:00
Andreas Schneider
c58a301c27 s3:libsmb: Introduce CLI_FULL_CONNECTION_IPC
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19 16:22:41 +00:00
Matthew DeVore
53a1d034f3 lib/util: Standardize use of st_[acm]time ns
Commit 810397f89a, and possibly others, broke the build for macOS and
other environments which don't have st_[acm]tim fields on 'struct stat'.

Multiple places in the codebase used the config.h values to determine
how to access the nanosecond or microsecond values of the stat
timestamps, so rather than add more, centralize them all into
lib/util/time.c.

Also allow pvfs_fileinfo.c to read nanosecond-granularity timestamps on
platforms where it didn't before, since its #if branches were not
complete.

Signed-off-by: Matthew DeVore <matvore@google.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Aug 15 08:51:09 UTC 2020 on sn-devel-184
2020-08-15 08:51:09 +00:00
Volker Lendecke
9aa6b0cd2e libsmb: Fix CID 1465860 Control flow issues (DEADCODE)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Aug 11 18:00:26 UTC 2020 on sn-devel-184
2020-08-11 18:00:26 +00:00
Jeremy Allison
6a9c785928 s3: libsmb: Cleanup - Remove the last use of a struct sockaddr_storage variable in dsgetdcname.c
Remove from process_dc_netbios().

This is a logic change, but as all the logic did was force a round-trip
through converting an already guaranteed numeric hostname printed by
print_sockaddr() inside discover_dc_netbios() to a struct
sockaddr_storage and then discard the result (!) I think it's harmless.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Aug  7 07:58:14 UTC 2020 on sn-devel-184
2020-08-07 07:58:13 +00:00
Jeremy Allison
1b42b79cc8 s3: libsmb: Cleanup - Move dsgetdcname.c to using struct samba_sockaddr internally.
Mostly renames of ss -> sa and access union members. No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
eb5a473864 s3: libsmb: Change dns_lookup_list_async() and associated functions to return a struct samba_sockaddr * array.
This fullfills the promise to Andreas and Metze
of all new code using struct samba_sockaddr.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
3b13d4d65a s3: libsmb: Add utility function sockaddr_storage_to_samba_sockaddr().
As requested by Andreas and Metze, ensure new code uses
struct samba_sockaddr. This is part of changing dns_lookup_list_async()
and callers to use struct samba_sockaddr.

Currently putting this into namequery.c even though it's
used inside dsgetdcname.c as I have future patches that
heavily make use of this to convert sockaddr_storage -> samba_sockaddr.

I'm not committed to putting it here, it may fit better
in lib/util/util_net.[ch]. It just needs to be somewhere
other functions inside source/libsmb/*.c can get to it,
and currently namequery.h exports the most stuff.

Not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
d882add695 s3: libsmb: Make discover_dc_dns() use async DNS.
Change to call dns_lookup_list_async(). This is
doing the samba SRV lookup followed by A and AAAA
record host lookup as resolve_ads() does and so
benefits from the same changes to make it async.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
6411c64d06 s3: libsmb: Make dns_lookup_list_async() available to other Samba callers.
This allows the async DNS lookups to be re-used inside the dsgetdcname() internals
code as previously described.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
f87ce5b08a s3: libsmb: Remove dns_lookup_list(). No longer used.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
bc307f1e37 s3: libsmb: Use dns_lookup_list_async() instead of dns_lookup_list().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Jeremy Allison
5ffcd883dd s3: libsmb: Add dns_lookup_list_async() - not yet used.
Take a list of hostnames and does async A and AAAA (if
supported) lookups on them. Interface compatible with
dns_lookup_list() (with the addition of one extra
parameter returning the query name list, for use inside
dsgetdcname() internals later) and we'll replace it in the next
commit. Waits for lp_get_async_dns_timeout() seconds to complete.

Commented out as not yet used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-08-07 06:34:37 +00:00
Volker Lendecke
04b2db7d88 libsmb: Fix CID 1465656 Resource leak
This is very likely a false positive, because Coverity does not see
that we only assign "dns_addrs" when NT_STATUS_IS_OK(status), so we
might not want this. But it is a fresh finding and looks cleaner this
way.

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 Aug  6 20:23:53 UTC 2020 on sn-devel-184
2020-08-06 20:23:53 +00:00
Jeremy Allison
860510b196 s3: libsmb: Move all calls to convert_ss2service() to one place now all methods return a sockaddr_storage.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>

Autobuild-User(master): Isaac Boukris <iboukris@samba.org>
Autobuild-Date(master): Tue Aug  4 10:13:53 UTC 2020 on sn-devel-184
2020-08-04 10:13:53 +00:00
Jeremy Allison
03112db121 s3: libsmb: Now all resolution functions return a ss_list on success, we only need one local variable for this.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:43 +00:00
Jeremy Allison
ecaa424448 s3: libsmb: Change resolve_ads() to return a talloc'ed ss_list, matching the other name resolution methods.
Now we can move all the convert_ss2service() calls to one place.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:43 +00:00
Jeremy Allison
d53ade5beb s3: libsmb: Rewrite resolve_ads() to use the previously added dns_lookup_list() function.
Clean up internals - a LOT.

This one needs careful review. Ditch the (unused) port returns from
the SRV replies.

Internally uses talloc'ed arrays of struct sockaddr_storage
which it then convert to MALLOC'ed struct ip_service.

Still returns struct ip_service but this will be
fixed in the next commit.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:43 +00:00
Jeremy Allison
d0fa32bdcd s3: libsmb: Add in (currently unused) function dns_lookup_list().
This function takes a list of names returned from a DNS SRV
query which didn't have returned IP addresses and returns an
array of struct sockaddr_storage.

Currently synchronous, but this is the function that will
be changed to be asynchronous later.

Compiles but commented out for now so we don't get "unused
function" warnings.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
97781fe0ae s3: libsmb: Pass in TALLOC_CTX * parameter to resolve_ads() instead of creating one internally.
Pass in talloc_tos() to make it match the other resolve_XXX() functions.

No memory leaks as this is used for transient data and is cleaned up
when the calling frame in internal_resolve_name() is destroyed.

Preparing to have it return a talloc'ed struct sockaddr_storage array
rather than a malloc'ed struct ip_service array.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
2297c883b5 s3: libsmb: Cleanup - ensure ss_list variables are initialized with NULL.
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
eaea3c0a62 s3: libsmb: Cleanup - put talloc parameter first in name_resolve_bcast().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
cef158a75c s3: libsmb: Cleanup - put talloc parameter first in resolve_wins().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
7ad92b3702 s3/s4: Cleanup. Move TALLOC_CTX * parameter to be first in resolve_lmhosts_file_as_sockaddr() to match modern conventions.
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
f12cee2361 s3: libsmb: Cleanup - put talloc parameter first in resolve_hosts().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
53474b57e1 s3: libsmb: Cleanup - reformatting name_resolve_bcast() parameters inside internal_resolve_name().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
1cb67bd31c s3: libsmb: Cleanup - reformatting resolve_wins() parameters inside internal_resolve_name().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
e8db4b0909 s3: libsmb: Cleanup - reformatting resolve_lmhosts_file_as_sockaddr() parameters inside internal_resolve_name().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
d42ba0b1b6 s3: libsmb: Cleanup - reformatting 2nd use of resolve_ads() parameters inside internal_resolve_name().
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
cd3cc111a4 s3: libsmb: Cleanup - reformatting resolve_ads() parameters inside internal_resolve_name().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
dd165b2c96 s3: libsmb: Cleanup - reformatting resolve_hosts() parameters inside internal_resolve_name().
No logic changes.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
2ad4889919 s3: libsmb: Cleanup - Remove incorrect comment in resolve_ads(). The DNS code copes fine with IPv6 addresses.
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:42 +00:00
Jeremy Allison
e07fa95349 s3: libsmb: Cleanup - modernize DEBUG -> DBG_ in internal_resolve_name()
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:41 +00:00
Jeremy Allison
14433e2afa s3: libsmb: Cleanup - split allocation and NULL check in internal_resolve_name().
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:41 +00:00
Jeremy Allison
1499fd8a2e s3: libsmb: Cleanup - use helper 'ok' bool for internal_resolve_name().
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:41 +00:00
Jeremy Allison
4abcb3001e s3: libsmb: Cleanup - use helper 'ok' bool for name_resolve_bcast().
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:41 +00:00
Jeremy Allison
d48d60595a s3: libsmb: Cleanup - use helper 'ok' bool for resolve_wins().
No logic change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
2020-08-04 08:51:41 +00:00