summaryrefslogtreecommitdiff
path: root/lib/async_req
Commit message (Collapse)AuthorAgeFilesLines
* lib/async_req/async_sock.c set socket close on execGary Lockyer2017-12-181-0/+1
| | | | | | | | | | Set SOCKET_CLOEXEC on the sockets returned by accept. This ensures that the socket is unavailable to any child process created by system(). Making it harder for malicious code to set up a command channel, as seen in the exploit for CVE-2015-0240 Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib: tevent: Use system <tevent.h>, not internal header path (except in ↵Jeremy Allison2017-08-161-1/+1
| | | | | | | self-test). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib/async_req: add writev_cancel()Stefan Metzmacher2016-10-261-2/+36
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* async_req: make async_connect_send() "reentrant"Ralph Boehme2016-08-041-3/+13
| | | | | | | | | | | | | | | | | Allow callers to pass in socket fds that where already passed to an earlier call of async_connect_send(). Callers expect this behaviour and it was working until 05d4dbda8357712cb81008e0d611fdb0e7239587 broke it. The proper fix would be to change callers to close the fd and start from scratch with a fresh socket. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12105 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Thu Aug 4 05:03:21 CEST 2016 on sn-devel-144
* lib: Fix a signed/unsigned mixupVolker Lendecke2016-06-131-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Add accept_send/recvVolker Lendecke2016-06-072-0/+88
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/async_req: do not install async_connect_send_test.Günther Deschner2015-12-011-1/+2
| | | | | | | Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* selftest: Fix memset parameters in test for async_connect_send()Andrew Bartlett2015-10-211-1/+1
| | | | | | | | | | | | | | | | This fixes: ../lib/async_req/async_connect_send_test.c: In function ‘main’: ../lib/async_req/async_connect_send_test.c:88:3: error: ‘memset’ used with constant zero length parameter; this could be due to transposed parameters [-Werror=memset-transposed-args] memset(&addr, sizeof(addr), 0); ^ Bug: https://bugzilla.samba.org/show_bug.cgi?id=11564 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Oct 21 17:31:00 CEST 2015 on sn-devel-104
* async_req: fix non-blocking connect()Ralph Boehme2015-10-201-29/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | According to Stevens UNIX Network Programming and various other sources, the correct handling for non-blocking connect() is: - when the initial connect() return -1/EINPROGRESS polling the socket for *writeability* - in the poll handler call getsocktopt() with SO_ERROR to get the finished connect() return value Simply calling connect() a second time without error checking is probably wrong and not portable. For a successfull connect() Linux returns 0, but Solaris will return EISCONN: 24254: 0.0336 0.0002 connect(4, 0xFEFFECAC, 16, SOV_DEFAULT) Err#150 EINPROGRESS 24254: AF_INET name = 10.10.10.143 port = 1024 24254: 0.0349 0.0001 port_associate(3, 4, 0x00000004, 0x0000001D,0x080648A8) = 0 24254: 0.0495 0.0146 port_getn(3, 0xFEFFEB50, 1, 1, 0xFEFFEB60) = 1 [0] 24254: 0.0497 0.0002 connect(4, 0x080646E4, 16, SOV_DEFAULT) Err#133 EISCONN 24254: AF_INET name = 10.10.10.143 port = 1024 Bug: https://bugzilla.samba.org/show_bug.cgi?id=11564 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* selftest: add a test for async_connect_send()Ralph Boehme2015-10-202-0/+134
| | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=11564 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* async_req: check for errors when monitoring socket for readabilityUri Simchoni2015-07-152-5/+44
| | | | | | | | | | | | | | | | | | Add an option to wait_for_read_send(), so that the request, upon calling back, report whether the socket actually contains data or is in EOF/error state. EOF is signalled via the EPIPE error. This is useful for clients which do not expect data to arrive but wait for readability to detect a closed socket (i.e. they do not intend to actually read the socket when it's readable). Actual data arrival would indicate a bug in this case, so the check can be used to print an error message. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11397 Signed-off-by: Uri Simchoni <urisimchoni@gmail.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib: Fix CID 710685 Unchecked return value from libraryVolker Lendecke2015-06-231-1/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix CID 1306765 Unchecked return value from libraryVolker Lendecke2015-06-161-1/+7
| | | | | | | | | | | | This one might be a bit controversial. I don't see from man fcntl how this could fail. But if it does, we definitely do want to know about it. And here we don't have any good way to tell our caller, so abort. 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 16 19:22:52 CEST 2015 on sn-devel-104
* lib: Fix CID 1306764 Unchecked return valueVolker Lendecke2015-06-161-1/+1
| | | | | | | tevent_req_oom exists right for this case :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: "Stefan (metze) Metzmacher" <metze@samba.org>
* lib/async_req: remove the tevent_fd as early as possible via a ↵Stefan Metzmacher2015-06-121-9/+21
| | | | | | | | | wait_for_read_cleanup() hook BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: remove the tevent_fd as early as possible via a ↵Stefan Metzmacher2015-06-121-4/+20
| | | | | | | | | read_packet_cleanup() hook BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: use tevent_req_nomem/tevent_req_post in read_packet_send()Stefan Metzmacher2015-06-121-7/+4
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: s/result/req/ in read_packet_send()Stefan Metzmacher2015-06-121-6/+6
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: remove the tevent_fd as early as possible via a ↵Stefan Metzmacher2015-06-121-14/+27
| | | | | | | | | writev_cleanup() hook BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: simplify async_connect_* using a _cleanup() hookStefan Metzmacher2015-06-121-35/+33
| | | | | | | | | | This makes sure we remove the tevent_fd as soon as possible and always reset the old_sockflags. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: s/result/req/ in async_connect_send()Stefan Metzmacher2015-06-121-9/+8
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}Stefan Metzmacher2015-06-122-190/+0
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib: Move "iov_buf.[ch]" to lib/utilVolker Lendecke2015-02-241-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Use iov_advance in writev_handlerVolker Lendecke2014-12-302-26/+10
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Make set_blocking() available independentlyVolker Lendecke2014-09-181-1/+1
| | | | | | | | async_connect_send() needs this, and I don't want to pull in samba-util just for this Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* CVE-2013-4408:async_sock: add some overflow detection to read_packet_handler()Stefan Metzmacher2013-12-091-0/+5
| | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=10185 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add before/after hooks to async_connectVolker Lendecke2013-05-172-8/+37
| | | | | | | 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>
* lib: Make async_sock includable on its ownVolker Lendecke2012-09-251-0/+1
| | | | | Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Tue Sep 25 18:03:46 CEST 2012 on sn-devel-104
* lib/async_req: Retry read_packet with read(2)Volker Lendecke2012-03-231-0/+4
| | | | | | | This way it will also work with pipes Autobuild-User: Volker Lendecke <vl@samba.org> Autobuild-Date: Fri Mar 23 17:31:24 CET 2012 on sn-devel-104
* build: avoid util.h as a public header name due to conflict with MacOSAndrew Bartlett2011-09-231-1/+1
|
* s3: Fix bug 8385Volker Lendecke2011-08-251-26/+14
| | | | | | | | | | | | Poll and select behave differently regarding error handling. When doing the connect(2), we can not rely on poll telling us both readability and writability upon error. Just always try a second connect(2). At least on Linux it returns 0 when it succeeded. Signed-off-by: Jeremy Allison <jra@samba.org> Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Thu Aug 25 19:39:12 CEST 2011 on sn-devel-104
* build: provide tevent-util as a public libraryAndrew Bartlett2011-08-081-1/+1
| | | | | | | This is needed so that OpenChange can get at _tevent_req_nterr(), which is referenced by generated PIDL output. Andrew Bartlett
* Add wait_for_read_send/recvVolker Lendecke2011-07-282-0/+60
| | | | Wait for readability of a socket as a tevent_req
* Fix bug #8197 - winbind does not properly detect when a DC connection is dead.Jeremy Allison2011-06-061-6/+32
| | | | | | | | | | | | | | | Only waiting for writability doesn't get fd errors back with poll. So always begin by selecting for readability, and if we get it then see if bytes were available to read or it really is an error condition. If bytes were available, remove the select on read as we know we will retrieve the error when we've finished writing and start reading the reply (or the write will timeout or fail). Metze and Volker please check. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Mon Jun 6 21:53:16 CEST 2011 on sn-devel-104
* async_rec/async_sock.c - add an additional "const"Matthias Dieter Wallnöfer2011-03-231-1/+2
| | | | | | | | | In order to suppress a build warning. Acked-by: Volker and Metze Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date: Wed Mar 23 10:26:23 CET 2011 on sn-devel-104
* s3-waf: add UTIL_TEVENT subsystem (as in ../lib/util/wscript)Günther Deschner2011-02-141-1/+2
| | | | Guenther
* Use sockaddr_storage in async sendto/recvfromVolker Lendecke2010-12-292-11/+28
|
* async_send->sendto, async_recv->recvfromVolker Lendecke2010-12-282-42/+53
|
* s4: Remove the old perl/m4/make/mk-based build system.Jelmer Vernooij2010-10-311-4/+0
| | | | | | | | The new waf-based build system now has all the same functionality, and the old build system has been broken for quite some time. Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sun Oct 31 02:01:44 UTC 2010 on sn-devel-104
* s4-waf: inline LIBREPLACE_NETWORK into 'replace'Stefan Metzmacher2010-04-121-1/+1
| | | | metze
* s4-waf: removed the AUTOGENERATED markersAndrew Tridgell2010-04-061-3/+0
| | | | we won't be using the mk -> wscript generator again
* s4-waf: mark the wscript files as python so vim/emacs knows how to highlight ↵Andrew Tridgell2010-04-061-0/+2
| | | | them
* build: commit all the waf build files in the treeAndrew Tridgell2010-04-061-0/+9
|
* async_sock: return -1/EPIPE if we're getting an end of file on read.Stefan Metzmacher2009-09-211-0/+4
| | | | | | This makes the error handling in the callers easier. metze
* Fix a = vs == error in writev_handlerVolker Lendecke2009-06-151-1/+1
|
* async_sock: try fix the source4 build on FreeBSD, Solaris, SLES8Stefan Metzmacher2009-06-083-6/+11
| | | | metze
* Fix an uninitialized variable read in async_connect_sendVolker Lendecke2009-06-061-5/+5
|
* Only err on readability if writev_send was explicitly asked to do soVolker Lendecke2009-06-041-1/+1
| | | | A socket might be readable for other reasons
* Handle EINTR in async_sock.cVolker Lendecke2009-05-301-0/+16
|
* libwbclient: Add async call framework.Kai Blin2009-05-302-2/+3
|