summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
AgeCommit message (Collapse)AuthorFilesLines
2025-04-18s3:lib: remove unused open_socket_out_defer_send/recvStefan Metzmacher1-102/+0
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-18s3:lib: pass 'protocol' to open_socket_out_send()Stefan Metzmacher1-4/+9
For now this is always explicitly IPPROTO_TCP, but that will change when we add support for IPPROTO_QUIC. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-18s3:lib: let open_socket_out_send() use samba_sockaddr to avoid ↵Stefan Metzmacher1-15/+17
strict-aliasing warnings Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-18s3:lib: split out open_socket_in_protocol()Stefan Metzmacher1-2/+12
This will be useful if we want to listen on IPPROTO_QUIC sockets. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-01-02silence DNS lookup mismatch messagesMichael Tokarev1-5/+5
There's just too much useless noise in the logs, especially when the PTR record just doesn't exist. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2023-07-13s3:lib: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2022-11-10lib: Add lp_allow_local_address()Volker Lendecke1-0/+1
Helper function for listing and accessing shares Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2021-08-31util_sock: fix assignment of sa_socklenBjoern Jacke1-0/+9
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-03-19lib: Properly return errno from open_socket_in()Volker Lendecke1-78/+79
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-09lib: Fix a typoVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17lib: Remove unused client_socket_port()Volker Lendecke1-8/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17lib: Remove unused client_addr()Volker Lendecke1-5/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17lib: Remove unused open_udp_socket()Volker Lendecke1-53/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17lib: Move read_udp_v4_socket() to nmbdVolker Lendecke1-42/+0
This is the only consumer of it Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-08-17lib: Move send_keepalive() to smbd/smb1_utils.cVolker Lendecke1-14/+0
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-02-26s3:lib: Allow open_socket_out without a timeoutVolker Lendecke1-1/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26s3:lib: avoid calling async_connect_send() again and again in open_socket_out*()Stefan Metzmacher1-48/+0
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-26s3:lib: avoid goto's in open_socket_out_send()Stefan Metzmacher1-12/+10
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26s3:lib: s/result/req in open_socket_out_send()Stefan Metzmacher1-11/+11
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-10-18lib: Explicitly refuse to truncate unix domain socket pathsAndrew Bartlett1-1/+12
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>
2018-04-24tevent: Fix callers of tevent_req_set_endtimeVolker Lendecke1-1/+0
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>
2017-10-20lib: Remove unused getaddinfo_send/recvVolker Lendecke1-82/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2015-11-06Fix various spelling errorsMathieu Parent1-1/+1
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-10-13lib: Move sys_rw* to lib/utilVolker Lendecke1-2/+2
genrand.c will require it soon Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2015-08-17s3:lib: fix some corner cases of open_socket_out_cleanup()Stefan Metzmacher1-0/+3
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-06-30lib: Fix rundown of open_socket_out()Volker Lendecke1-12/+33
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-04-21s3:lib: use talloc_get_type_abortRalph Boehme1-1/+1
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
2014-12-07lib: Split out write_data[_iov]Volker Lendecke1-81/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07lib: Split out iov_buf[len]Volker Lendecke1-43/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07lib: read_data->read_data_ntstatusVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-12-07lib: Split out sys_[read|write] & friendsVolker Lendecke1-0/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-17lib: Avoid a talloc in write_data_iovVolker Lendecke1-9/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-07-18lib/util: move memcache.[ch] to the toplevel 'samba-util' libraryStefan Metzmacher1-1/+1
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-04-23lib: Add iov_bufVolker Lendecke1-0/+25
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-04-23lib: Introduce iov_buflenVolker Lendecke1-5/+23
.. with overflow protection Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-12-14s3:lib: avoid talloc_zero_array() in poll_one_fd()Stefan Metzmacher1-14/+5
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2013-08-12lib: Remove unused "get_peer_name"Volker Lendecke1-79/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2013-08-12lib: Remove unused "client_name"Volker Lendecke1-5/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2013-06-18Re-add umask(0) code removed by commit 3a7c2777ee0de37d758fe81d67d6836a8354825eJeremy Allison1-2/+7
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-05-17lib: Add before/after hooks to async_connectVolker Lendecke1-2/+2
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-02-19s3:lib: s/struct event_context/struct tevent_contextStefan Metzmacher1-5/+5
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-19s3:lib: make use of samba_tevent_context_init()Stefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2013-01-09s3-lib: Use new strict directory create function in create_pipe_sock().Andreas Schneider1-44/+6
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
2012-11-26s3: Fix Coverity ID 741407 -- resource leakVolker Lendecke1-0/+1
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-03-24util_sock: Avoid sys_connect.Jelmer Vernooij1-7/+13
2012-02-16lib/util: Remove sys_poll as it is no longer neededAndrew Bartlett1-2/+2
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-16Rename obscure defined constants.Christopher R. Hertel (crh)1-2/+3
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
2011-08-29s3-lib: If we create a pipe socket, don't start to listen.Andreas Schneider1-6/+0
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-07-12s3:lib: s/SMBkeepalive/NBSSkeepaliveStefan Metzmacher1-2/+2
metze
2011-07-08s3:libsmb: remove unused enum smb_read_errors infrastructureStefan Metzmacher1-20/+0
metze