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

311 Commits

Author SHA1 Message Date
Andreas Schneider
71b40127e1 s3:lib: Fix code spelling
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2023-07-13 05:41:36 +00:00
Volker Lendecke
9321a533cd lib: Add lp_allow_local_address()
Helper function for listing and accessing shares

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2022-11-10 07:27:31 +00:00
Bjoern Jacke
1209c89dcf util_sock: fix assignment of sa_socklen
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

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

Autobuild-User(master): Björn Jacke <bjacke@samba.org>
Autobuild-Date(master): Tue Aug 31 09:54:35 UTC 2021 on sn-devel-184
2021-08-31 09:54:35 +00:00
Volker Lendecke
72540222c2 lib: Properly return errno from open_socket_in()
Before this patch, open_socket_in() relied on quite a bit of code to
not touch errno after for example socket() returned -1. Change this to
explicitly save errno in "ret", such that a later DEBUG() with all its
formatting code can mess it up.

While there, remove the debuglevel parameter. I don't think this
actually useful.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-19 07:09:37 +00:00
Volker Lendecke
72cc8dce4c lib: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-09 22:36:28 +00:00
Volker Lendecke
f3c43c6595 lib: Remove unused client_socket_port()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17 19:35:37 +00:00
Volker Lendecke
de03dba413 lib: Remove unused client_addr()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17 19:35:37 +00:00
Volker Lendecke
630f228fc6 lib: Remove unused open_udp_socket()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17 19:35:37 +00:00
Volker Lendecke
2ccc9df4b3 lib: Move read_udp_v4_socket() to nmbd
This is the only consumer of it

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17 19:35:37 +00:00
Volker Lendecke
2e7f3e5e65 lib: Move send_keepalive() to smbd/smb1_utils.c
This is a SMB1-only packet sent from smbd only

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17 19:35:37 +00:00
Volker Lendecke
3a7480d612 s3:lib: Allow open_socket_out without a timeout
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:37 +00:00
Stefan Metzmacher
a26be7eeed s3:lib: avoid calling async_connect_send() again and again in open_socket_out*()
There's really no need to do that!

Once connect() is called and returned EINPROGRESS, the kernel
knowns what to do and reports any state change via
TEVENT_FD_READ or TEVENT_FD_WRITE.
The actual success or failure is available via
getsockopt(.., SOL_SOCKET, SO_ERROR, ...).

Before this commit we called connect() (via async_connect_send()) again
and again until we reached the final caller provided timeout,
even if the kernel already found out that the destination is
unreachable.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Stefan Metzmacher
d48fba7c09 s3:lib: avoid goto's in open_socket_out_send()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Stefan Metzmacher
ce1a3f2cb2 s3:lib: s/result/req in open_socket_out_send()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Andrew Bartlett
9a02c31deb lib: Explicitly refuse to truncate unix domain socket paths
This avoids creating a socket like:

.../winbindd_privileged/p

instead of

.../winbindd_privileged/pipe

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-10-18 16:07:35 +00:00
Volker Lendecke
a37d9a45d1 tevent: Fix callers of tevent_req_set_endtime
tevent_req_set_endtime internally already calls tevent_req_nomem and thus sets
the error status correctly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-04-24 19:41:15 +02:00
Volker Lendecke
4b84d7cb54 lib: Remove unused getaddinfo_send/recv
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-10-20 20:03:13 +02:00
Mathieu Parent
c315fce17e Fix various spelling errors
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Nov  6 13:43:45 CET 2015 on sn-devel-104
2015-11-06 13:43:45 +01:00
Volker Lendecke
258ce91f31 lib: Move sys_rw* to lib/util
genrand.c will require it soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-10-13 01:23:07 +02:00
Stefan Metzmacher
ce3c77fb45 s3:lib: fix some corner cases of open_socket_out_cleanup()
In case of timeouts we retry the async_connect_send() and forgot
to remember it, this results in an abort() in async_connect_cleanup()
as the fd is already closed when calling fcntl(F_SETFL).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2015-08-17 17:43:36 +02:00
Volker Lendecke
6fc65aaf95 lib: Fix rundown of open_socket_out()
Under valgrind I've seen the abort in async_connect_cleanup kick in. Yes, it's
good that we check these return codes!

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11316
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: "Stefan (metze) Metzmacher" <metze@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jun 30 20:24:37 CEST 2015 on sn-devel-104
2015-06-30 20:24:37 +02:00
Ralph Boehme
6b1f757f83 s3:lib: use talloc_get_type_abort
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Apr 21 22:14:07 CEST 2015 on sn-devel-104
2015-04-21 22:14:07 +02:00
Volker Lendecke
0013001e70 lib: Split out write_data[_iov]
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07 00:12:07 +01:00
Volker Lendecke
214fc09a34 lib: Split out iov_buf[len]
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07 00:12:07 +01:00
Volker Lendecke
a8491cb95a lib: read_data->read_data_ntstatus
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07 00:12:07 +01:00
Volker Lendecke
97b2570a5e lib: Split out sys_[read|write] & friends
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07 00:12:07 +01:00
Volker Lendecke
4b788ffe65 lib: Avoid a talloc in write_data_iov
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-17 00:31:21 +02:00
Stefan Metzmacher
45807028d4 lib/util: move memcache.[ch] to the toplevel 'samba-util' library
This is generic enough that it could be used in all code.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jul 18 15:43:33 CEST 2014 on sn-devel-104
2014-07-18 15:43:33 +02:00
Volker Lendecke
e2683605b0 lib: Add iov_buf
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-23 22:33:08 +02:00
Volker Lendecke
7009b4921c lib: Introduce iov_buflen
.. with overflow protection

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-23 22:33:08 +02:00
Stefan Metzmacher
fd722494e7 s3:lib: avoid talloc_zero_array() in poll_one_fd()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2013-12-14 16:24:48 +01:00
Volker Lendecke
68e6e7e8e8 lib: Remove unused "get_peer_name"
Signed-off-by: Volker Lendecke <vl@samba.org>

Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2013-08-12 17:25:52 +12:00
Volker Lendecke
52c51752e8 lib: Remove unused "client_name"
Signed-off-by: Volker Lendecke <vl@samba.org>

Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2013-08-12 17:25:49 +12:00
Jeremy Allison
5c4772ec1d Re-add umask(0) code removed by commit 3a7c2777ee
Without the umask code the pipe permissions are affected by the
umask of the calling process. As only smbd currently sets its
umask to zero (nmbd and winbindd should do the same) this causes
the winbindd pipe to be unavailable to the nss library code unless
winbindd is run from an init process that explicitly sets umask
to zero. When testing from the command line this can be hard to
track down :-).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jun 18 04:31:27 CEST 2013 on sn-devel-104
2013-06-18 04:31:27 +02:00
Volker Lendecke
d67e614a07 lib: Add before/after hooks to async_connect
This will facilitiate [un]become_root for smbd to connect safely to ctdbd.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
2013-05-17 11:22:45 +02:00
Stefan Metzmacher
935a40f4f2 s3:lib: s/struct event_context/struct tevent_context
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-19 23:47:54 +01:00
Stefan Metzmacher
f3915cf0ec s3:lib: make use of samba_tevent_context_init()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-19 23:47:47 +01:00
Andreas Schneider
3a7c2777ee s3-lib: Use new strict directory create function in create_pipe_sock().
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Jan  9 10:55:23 CET 2013 on sn-devel-104
2013-01-09 10:55:23 +01:00
Volker Lendecke
994eec4d58 s3: Fix Coverity ID 741407 -- resource leak
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Mon Nov 26 19:20:05 CET 2012 on sn-devel-104
2012-11-26 19:20:05 +01:00
Jelmer Vernooij
a9c22de3f4 util_sock: Avoid sys_connect. 2012-03-24 14:51:23 +01:00
Andrew Bartlett
367c567c5f lib/util: Remove sys_poll as it is no longer needed
sys_poll() is only needed if the signal pipe is set up and used, but as
no signal handler ever writes to the pipe, this can all be removed.

signal based events are now handled via tevent.

Andrew Bartlett

Signed-off-by: Jeremy Allison <jra@samba.org>
2012-02-16 15:49:21 -08:00
Christopher R. Hertel (crh)
b5b204184a Rename obscure defined constants.
Replaced the undescriptive SMB_PORT1 and SMB_PORT2 defined constants
with the slightly more descriptive names NBT_SMB_PORT and TCP_SMB_PORT.
Also replaced several hard-coded references to the well-known port
numbers (139 and 445, respectively) as appropriate.

Small changes to clarify some comments regarding the two transport
types.

Signed-off-by: Simo Sorce <idra@samba.org>

Autobuild-User: Simo Sorce <idra@samba.org>
Autobuild-Date: Thu Feb 16 08:29:41 CET 2012 on sn-devel-104
2012-02-16 08:29:41 +01:00
Andreas Schneider
b8c3bfa55b s3-lib: If we create a pipe socket, don't start to listen.
The create_pipe_sock() function should only create the socket as the
name states and not start to listen on it too. We should start to listen
on in the individual places as we need different backlog values.

Autobuild-User: Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date: Mon Aug 29 13:21:43 CEST 2011 on sn-devel-104
2011-08-29 13:21:43 +02:00
Stefan Metzmacher
a2d4197590 s3:lib: s/SMBkeepalive/NBSSkeepalive
metze
2011-07-12 09:44:04 +02:00
Stefan Metzmacher
f0e6e5c37d s3:libsmb: remove unused enum smb_read_errors infrastructure
metze
2011-07-08 14:09:08 +02:00
Volker Lendecke
2dfc898d1a s3: Follow the TALLOC_FREE convention in source3
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Wed Jul  6 11:01:05 CEST 2011 on sn-devel-104
2011-07-06 11:01:05 +02:00
Volker Lendecke
6fcb3bbdae s3: Fix Coverity ID 2586 -- NO_EFFECT
tsocket_address_bsd_sockaddr returns ssize_t, and on some systems socklen_t is
unsigned. So (len < 0) could never have turned true.

Volker
2011-07-06 09:50:02 +02:00
Andreas Schneider
c663dfff88 s3-util: Add a get_remote_hostname() function.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2011-07-04 18:27:55 +10:00
Andrew Bartlett
74eed8f3ed s3-param Remove special case for global_myname(), rename to lp_netbios_name()
There is no reason this can't be a normal constant string in the
loadparm system, now that we have lp_set_cmdline() to handle overrides
correctly.

Andrew Bartlett
2011-06-09 12:40:09 +02:00
Andrew Bartlett
8d4a8389bb s3-talloc Change TALLOC_MEMDUP() to talloc_memdup()
Using the standard macro makes it easier to move code into common, as
TALLOC_MEMDUP isn't standard talloc.
2011-06-09 12:40:08 +02:00