[SCM] Samba Shared Repository - branch v4-2-test updated

Karolin Seeger kseeger at samba.org
Mon Jun 29 22:41:11 MDT 2015


The branch, v4-2-test has been updated
       via  fcc7112 docs: overhaul the description of "smb encrypt" to include SMB3 encryption.
       via  645ec21 pidl: Make the compilation of PIDL producing the same results if the content hasn't change
       via  cbd98bf s3: smbd: Codenomicon crash in do_smb_load_module().
       via  251544b selftest: Change chgdcpass environment to use winbindd
       via  4bacf0d winbindd: Sync secrets.ldb into secrets.tdb on startup
       via  fc6074c winbindd: Use pdb_get_domain_info() to get exactly the local domain info when we are an AD DC
       via  7896b84 selftest: Run winbind tests in chgdcpass environment
       via  4099e13 s3: smbd: Use separate flag to track become_root()/unbecome_root() state.
       via  b02152f docs-xml: Update sharesec manpage to reflect current output
       via  94c5af4 selftest: Add test for sharesec command
       via  8fafa9d sharesec: Use non-numerical output for sharesec
       via  3e219f4 ctdb-ib: make sure the tevent_fd is removed before the fd is closed
       via  a66870b libcli/smb: make sure we remove the writev_send() request when a request is destroyed
       via  b909752 libcli/smb: add smb1 requests to the pending array before writev_send()
       via  1fdf3b3 libcli/smb: make sure the writev_send of smbXcli_conn_samba_suicide() is removed before closing the socket
       via  2eeecae libcli/smb: remove unused split of read_fd and write_fd
       via  92c456d libcli/smb: close the socket fd at the end of smbXcli_conn_disconnect()
       via  1b55fab libcli/smb: use tevent_req_received(req) in read_smb_recv()
       via  e34065b lib/async_req: remove the tevent_fd as early as possible via a wait_for_read_cleanup() hook
       via  4d10c2b lib/async_req: remove the tevent_fd as early as possible via a read_packet_cleanup() hook
       via  41b593a lib/async_req: use tevent_req_nomem/tevent_req_post in read_packet_send()
       via  cc01ff4 lib/async_req: s/result/req/ in read_packet_send()
       via  4b39759 lib/async_req: remove the tevent_fd as early as possible via a writev_cleanup() hook
       via  d7d9f4e lib/async_req: simplify async_connect_* using a _cleanup() hook
       via  ad8c901 lib/async_req: s/result/req/ in async_connect_send()
       via  65dc14c lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}
       via  a9e2d2a s3:libsmb: convert nb_trans_send/recv internals to tdgram
       via  109e579 s3:libsmb: convert nb_packet_reader to tstream_* functions
       via  af62a4a s3:libsmb: convert nb_packet_client to tstream_* functions
       via  7d01a20 s3:libsmb: let nb_packet_server_destructor() explicitly destroy the tevent_fd
       via  5f6eed5 s3:libsmb: remove pending requests as early as possible via a smbsock_any_connect_cleanup() hook
       via  511674a s3:libsmb: remove subreqs as early as possible via a smbsock_connect_cleanup() hook
       via  e791b77 s3:libsmb: remove the cli_session_request as early as possible via a nb_connect_cleanup() hook
       via  c4c55a1 s3:lib/addrchange: make use of tdgram_* in addrchange_*()
       via  2bda2dd s3:lib/addrchange: look at the correct nl_pid in addrchange_done()
       via  8693ae9 s3:lib/background: make sure we destroy a pending read_packet_send() before closing the pipe fd
       via  2409e6d s3:wscript: move lib/util_tsock.c from 'TLDAP' to 'samba3util'
       via  d576029 s4:libcli/raw: make sure smbcli_transport_connect_send/recv correctly cleanup on error
       via  69a6b05 lib/tsocket: add tdgram_inet_udp_broadcast_socket()
       via  f9f27a9 lib/tsocket: add tdgram_bsd_existing_socket() helper function
       via  cc18cd2 lib: Add tevent_req_simple_recv_unix
       via  251141b Group creation: Add msSFU30Name only when --nis-domain was given
       via  aa658dc s3:param/loadparm fix testparm --show-all-parameters
      from  cb3eb21 tdb: version 1.3.6

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test


- Log -----------------------------------------------------------------
commit fcc711255ae1b16d69e6d796a24d3119b9866309
Author: Michael Adam <obnox at samba.org>
Date:   Thu Apr 23 10:38:15 2015 +0200

    docs: overhaul the description of "smb encrypt" to include SMB3 encryption.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11366
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Apr 24 00:53:20 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 51ae17b0703eaa481d602ffc7d8231a629fcb5fd)
    
    Autobuild-User(v4-2-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-2-test): Tue Jun 30 06:40:27 CEST 2015 on sn-devel-104

commit 645ec2191c7d28bf26517549f41a95953f79f150
Author: Matthieu Patou <mat at matws.net>
Date:   Mon Sep 22 21:52:14 2014 -0700

    pidl: Make the compilation of PIDL producing the same results if the content hasn't change
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11356
    
    Newer perl versions don't generate stable results anymore.
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Change-Id: I2fb1e12da392ca85bfd0fb8b50b69851076144ee
    Signed-off-by: Matthieu Patou <mat at matws.net>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    (cherry picked from commit 4986359816704f38d4fad3ddd0d07a0f0a25b335)

commit cbd98bfcba70834096f37169623ebfdbdbc1a5b3
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jun 18 10:21:07 2015 -0700

    s3: smbd: Codenomicon crash in do_smb_load_module().
    
    Inside api_pipe_bind_req() we look for a pipe module name using
    
    dcerpc_default_transport_endpoint(pkt,
                                    NCACN_NP, table)
    
    which returns NULL when given invalid pkt data from the Codenomicon fuzzer.
    
    This gets passed directly to smb_probe_module(), which then calls
    do_smb_load_module() which tries to deref the (NULL) module name.
    
    https://bugzilla.samba.org/show_bug.cgi?id=11342
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Jun 18 22:14:01 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 5a82cc21379e3fe28441cd82647313c9390b41e7)

commit 251544b70c9e7a6950eeefbe81bd37f55fc3369d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 17 12:05:58 2015 +1200

    selftest: Change chgdcpass environment to use winbindd
    
    This allows us to test that winbindd starts up without secrets.tdb, as happens after
    a classicupgrade.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10991
    (backport of master commit db59f9ec731e3abbeba3070925a6dedaac26e6e5)

commit 4bacf0d4cedfdca35fa8555c101667917d57395c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 12 11:57:07 2015 +1200

    winbindd: Sync secrets.ldb into secrets.tdb on startup
    
    This ensures that the domain SID and machine account password are written into
    secrets.tdb if the secrets.tdb file was either never written or was deleted.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10991
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    (backport of master commit 5de7621cbfba1e1fb52cddf41a5a13d027d45b46)

commit fc6074c603aeab206d6f86a4cc8514633b16ec77
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 12 11:54:21 2015 +1200

    winbindd: Use pdb_get_domain_info() to get exactly the local domain info when we are an AD DC
    
    This also triggers pdb_samba_dsdb_init_secrets(), to force the
    correct SID into secrets.tdb.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=10991
    (backport of master commit b209cd1677b306d72e56a98ecb02db421a5ca35a)

commit 7896b84d5cbc5cb46e22c3f2c12fc9abb46ab939
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 17 11:10:15 2015 +1200

    selftest: Run winbind tests in chgdcpass environment
    
    This ensures that winbind both starts and operates without a secrets.tdb
    
    (chgdcpass deliberatly removes the secrets.tdb file after provision, like has happend with classicupgrade).
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    (backport of master commit 5bb647b78806413a94f959d0b2b417a97b7a2173)

commit 4099e13a116f5154f9de966be33c5efb6bf287ad
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jun 17 10:23:30 2015 -0700

    s3: smbd: Use separate flag to track become_root()/unbecome_root() state.
    
    Early function exit can mean backup_priv is set but we haven't called
    become_root(). *Lots* of work by the reviewers went in to checking this
    isn't a security issue.
    
    Found by Codenomicon at the Redmond plugfest.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11339
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Jun 25 22:14:58 CEST 2015 on sn-devel-104
    
    (cherry picked from commit e2c4b8967d33b610f9f076c614352e4b8fc7c558)

commit b02152f4878be145dada2cb5394cabf13cc89eba
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jun 9 10:29:21 2015 -0700

    docs-xml: Update sharesec manpage to reflect current output
    
    Update the sharesec man page to reflect the output currently used, and
    also add a note that the OWNER and GROUP fields are not used for share
    ACLs.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11324
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Wed Jun 17 13:36:23 CEST 2015 on sn-devel-104
    (cherry picked from commit 8406d4dd1593b4a4d7bcbdc7b7c7893339f8e814)

commit 94c5af49c5c722cc62e2b23176dac8cb00051b64
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jun 9 10:28:17 2015 -0700

    selftest: Add test for sharesec command
    
    Add a test for the sharesec command to ensure that it works, and to also
    verify that the output does not change.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11324
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit a6650d74d1b7cc051637c1a19daff5a8009f405b)

commit 8fafa9d718eff356953fcac5a4467a754cd5cbc5
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Jun 9 09:50:18 2015 -0700

    sharesec: Use non-numerical output for sharesec
    
    This is an easy change to get the sharesec output back to the format
    used before. It is also easier to understand than the output of the
    flags.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11324
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0b9fa2849dc8b7c61467a6517c40e6e15c104d4a)

commit 3e219f463c398c3dbacb66427946815a13c08b78
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 5 10:30:39 2015 +0200

    ctdb-ib: make sure the tevent_fd is removed before the fd is closed
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 53ff3e4f31f3debd98f9293171c023a0a406858d)

commit a66870b9ae422f4a3e84333d3724539a9ae65600
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 29 16:14:40 2015 +0200

    libcli/smb: make sure we remove the writev_send() request when a request is destroyed
    
    This way smbXcli_conn_disconnect() removes all tevent_fd structures attached to
    the sock_fd before closing it.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 006042ac126261e87089fb9835c28789e8aeae1b)

commit b909752b904f2bec6a6af056ee3490e4e928b909
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 29 15:48:26 2015 +0200

    libcli/smb: add smb1 requests to the pending array before writev_send()
    
    This way we have a change to destroy the pending writev_send request before
    closing the socket in smbXcli_conn_disconnect().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f3982eb2c7f1d17a013dacfd430a3752e6ef4ae4)

commit 1fdf3b348fe979ab1fd1892f58a147aa3a4eb9a0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri May 29 15:29:31 2015 +0200

    libcli/smb: make sure the writev_send of smbXcli_conn_samba_suicide() is removed before closing the socket
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 59338434274799db1ac60b082a6453bd924c5f4c)

commit 2eeecae74150572aa314983462646e13ea11acac
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 13:22:19 2015 +0200

    libcli/smb: remove unused split of read_fd and write_fd
    
    The tevent epoll backend supports separate read and write tevent_fd structure
    on a single fd, so there's no need for a dup() anymore.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8f42df235dc825a103631fdf0e37e1c1d03cf420)

commit 92c456d8e932d177c1825070d8a2b488959bced6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 13:09:11 2015 +0200

    libcli/smb: close the socket fd at the end of smbXcli_conn_disconnect()
    
    We need to cancel all pending requests before closing the socket fds,
    otherwise we cause problem with the interaction with the epoll event backend.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 46e1aa22b12eacc3567f7897716ae07837545c23)

commit 1b55fab3c3a0c4547d39886e33fead9dc2a6421d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:29:55 2015 +0200

    libcli/smb: use tevent_req_received(req) in read_smb_recv()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 26c4b3fc9db507557b2539dd7d1f9e593c3fa35a)

commit e34065b0aee5130f384622cb73f411a0f69cbaac
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: remove the tevent_fd as early as possible via a wait_for_read_cleanup() hook
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 64640cc99c7b8543ee8d35ca243c57c048cdb490)

commit 4d10c2b3eb5a37204146ba1a663ccc46383bec13
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: remove the tevent_fd as early as possible via a read_packet_cleanup() hook
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit a2a7cbc66c4713493e6ade45d0cdde25f64c9007)

commit 41b593ac6796136629bb146343e71a5934989d14
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: use tevent_req_nomem/tevent_req_post in read_packet_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 9a116b28bab20507760f50f25214635a60ea6c43)

commit cc01ff4f5b0c72182965919b71a39b9532c738f5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: s/result/req/ in read_packet_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 4f05f68abc1d756bb114260e80d3532f3f959fec)

commit 4b39759a02110dba93c2166d81e29a8ce0b6e455
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: remove the tevent_fd as early as possible via a writev_cleanup() hook
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0c1109695639a177d3d739b343e7588a6ecf0949)

commit d7d9f4ed3f12f7ab06b0745ce50a8817edc18dac
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 22:28:14 2015 +0200

    lib/async_req: simplify async_connect_* using a _cleanup() hook
    
    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 at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit d5a4b30f894f0d4d4fa728ebd2c435254bf3b142)

commit ad8c901f58714fc91ea0fd16c994525398d5a912
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 5 13:58:19 2015 +0200

    lib/async_req: s/result/req/ in async_connect_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit be8c2ff10353df00f05cd378c251a33a9e08563a)

commit 65dc14c188f9d506362893bb916d10ffcb1f49b5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 12:25:38 2015 +0200

    lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit ccd038e1523a69197a9aaeca00305b0958f09ff0)

commit a9e2d2acb80d6592c803350d7e214b3b8067aef0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 04:43:27 2015 +0200

    s3:libsmb: convert nb_trans_send/recv internals to tdgram
    
    This simplifies/fixes the cleanup, because we need to remove any
    tevent_fd object before closing the socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit a3282911f6ceb76b2ada567e569a55af8c7ef160)

commit 109e579b72dbd06621bda311d3bc6c557ff91228
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 02:18:26 2015 +0200

    s3:libsmb: convert nb_packet_reader to tstream_* functions
    
    By using the tstream abstraction we don't need to take care
    error handling regarding dangling tevent_fd structures.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit ecb4d041de89441941a112ab3a724887e568117e)

commit af62a4a661ebaaa4c65bd0e232cf90e7d8695aef
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 01:53:44 2015 +0200

    s3:libsmb: convert nb_packet_client to tstream_* functions
    
    By using the tstream abstraction we don't need to take care
    error handling regarding dangling tevent_fd structures.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 3ecf4ec6574de9bdd5a2d55529ed81b17c74d452)

commit 7d01a20ca26b776782d07d93bee03657df3d19b5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 02:20:00 2015 +0200

    s3:libsmb: let nb_packet_server_destructor() explicitly destroy the tevent_fd
    
    The need to destroy the tevent_fd before closing the socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 9ccf8e6d36618498c4952bb1d4b74152f75ab793)

commit 5f6eed51a24de3e94b1b643af319462bf73d1ece
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:01:30 2015 +0200

    s3:libsmb: remove pending requests as early as possible via a smbsock_any_connect_cleanup() hook
    
    Once we got an error or a valid connection we should destroy all other
    connection attempts as early as possible.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 058d84747e75a5f97a02e31bac9c8d0d147174bc)

commit 511674aaed9d60a979a31f8b126cd917d3c4ea78
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:01:05 2015 +0200

    s3:libsmb: remove subreqs as early as possible via a smbsock_connect_cleanup() hook
    
    open_socket_out_send() or nb_connect_send() likely use socket fds and
    tevent_fd objects. We should clean them up as early as possible.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 04f89d4255ed95631aa8f0ada4bcf5f888e126d4)

commit e791b7753c070f977b750c36f8775da1e9332686
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:00:17 2015 +0200

    s3:libsmb: remove the cli_session_request as early as possible via a nb_connect_cleanup() hook
    
    cli_session_request_send() is likely to use tevent_fd objects on the given
    socket fd, so we need to destroy the request before closing the socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 992be06f165c3d05e85d16baf514dba49f55d1ec)

commit c4c55a1b91c18fcbb73fd4e886055700c1fda87e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 12:17:24 2015 +0200

    s3:lib/addrchange: make use of tdgram_* in addrchange_*()
    
    This makes the cleanup handling easier to get right,
    as we need to make sure any tevent_fd is removed before
    closing a socket fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0d161e42d9aeb155eae2b04eccec497b21de8029)

commit 2bda2dde3588b3433e696362fc3d497d1b5c3418
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 5 14:19:00 2015 +0200

    s3:lib/addrchange: look at the correct nl_pid in addrchange_done()
    
    state->fromaddr is the address we got from recvfrom_send/recv.
    
    state->addr is completely untouched after tevent_req_create().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 257bc586c22f9a7f34b913823d5c89592d433454)

commit 8693ae906ed86f010bb7166e45f5b8c15dd27b36
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 13:31:17 2015 +0200

    s3:lib/background: make sure we destroy a pending read_packet_send() before closing the pipe fd
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 9d3444ad887bb3a118eaecd141c79dfd6de53f41)

commit 2409e6ddf597f875d1896ee61cb922d28cc86412
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 03:45:36 2015 +0200

    s3:wscript: move lib/util_tsock.c from 'TLDAP' to 'samba3util'
    
    tstream_read_packet_send/recv() is a generic helper function...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (similar to commit 0c108f55d9c3cca0bde1c15c66dccabbc40e6133)

commit d5760294d2ee2edb0332552a878147d703f5838d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 28 14:25:27 2015 +0200

    s4:libcli/raw: make sure smbcli_transport_connect_send/recv correctly cleanup on error
    
    We need to make sure that we remove any pending writev_send or read_smb_send
    request before closing the socket fd. As a side effect we always close the
    socket fd if we don't return success for any any reason.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit dd037b0be4ed2df7239cb61bd3d4bb868bb09126)

commit 69a6b057c8b405cdef927bc9731424ee3f7dffd7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 11:39:38 2015 +0200

    lib/tsocket: add tdgram_inet_udp_broadcast_socket()
    
    This is similar to tdgram_inet_udp_socket(), but it allows
    the use of ipv4 broadcast traffic.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 36b97d0bb9fe004f3d8a500f3af83dff34f86d7b)

commit f9f27a93057b6a623f2bd0af09956194cb80544c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 21 11:37:06 2015 +0200

    lib/tsocket: add tdgram_bsd_existing_socket() helper function
    
    This is similar to tstream_bsd_existing_socket().
    Both help to migrate strange code path to using the tstream or tdgram
    abstractions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 3a8b7b0518b33b016d2dbb8dd23d35ef1c6aaa5c)

commit cc18cd23ee963a500435ba290181022fe6d671a6
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 8 09:00:31 2014 +0000

    lib: Add tevent_req_simple_recv_unix
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f5c17d41e085e083ef970692ff7f50f7a6642ea3)

commit 251141b8e5bf29febd151a5d8db42748e62f6a26
Author: Marc Muehlfeld <mmuehlfeld at samba.org>
Date:   Thu Jun 11 21:20:55 2015 +0200

    Group creation: Add msSFU30Name only when --nis-domain was given
    
    This fixes a bug, that all new created groups automatically get an
    msSFU30Name attribute added. This should only be the case, when
    we also have a nis-domain (samba-tool --nis-domain=...).
    
    Bugreport: https://bugzilla.samba.org/show_bug.cgi?id=11315
    
    Signed-off-by: Marc Muehlfeld <mmuehlfeld at samba.org>
    Reviewed-by: Christian Ambach <ambi at samba.org>
    
    Autobuild-User(master): Christian Ambach <ambi at samba.org>
    Autobuild-Date(master): Tue Jun 16 11:58:02 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 9df07e6f1bcea55fcdab777c3f45a1a6ca88f69e)

commit aa658dc7832738efecb1088b55be10367be0703a
Author: Christian Ambach <ambi at samba.org>
Date:   Mon Jun 8 23:48:54 2015 +0200

    s3:param/loadparm fix testparm --show-all-parameters
    
    it didn't know about the new types of config parameters
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11170
    
    Signed-off-by: Christian Ambach <ambi at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Tue Jun  9 11:49:18 CEST 2015 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 ctdb/ib/ibwrapper.c                         |  21 +-
 docs-xml/manpages/sharesec.1.xml            |  16 +-
 docs-xml/smbdotconf/security/smbencrypt.xml | 232 ++++++++++++++---
 lib/async_req/async_sock.c                  | 369 +++++++++-------------------
 lib/async_req/async_sock.h                  |  12 -
 lib/tsocket/tsocket.h                       |  71 ++++++
 lib/tsocket/tsocket_bsd.c                   |  54 ++++
 lib/util/modules.c                          |   5 +
 lib/util/tevent_unix.c                      |  13 +
 lib/util/tevent_unix.h                      |   1 +
 libcli/smb/read_smb.c                       |   2 +
 libcli/smb/smbXcli_base.c                   | 124 +++++++---
 pidl/lib/Parse/Pidl/Dump.pm                 |   4 +-
 pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm     |   2 +-
 pidl/lib/Parse/Pidl/Samba4/Header.pm        |   2 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm    |   2 +-
 pidl/lib/Parse/Pidl/Samba4/Python.pm        |  48 ++--
 pidl/lib/Parse/Pidl/Util.pm                 |   1 +
 pidl/lib/Parse/Pidl/Wireshark/NDR.pm        |   6 +-
 python/samba/samdb.py                       |   3 +-
 selftest/knownfail                          |   2 +
 selftest/target/Samba4.pm                   |   7 +-
 source3/lib/addrchange.c                    |  91 ++++---
 source3/lib/background.c                    |   8 +
 source3/libsmb/namequery.c                  | 102 +++++---
 source3/libsmb/smbsock_connect.c            | 101 ++++++--
 source3/libsmb/unexpected.c                 | 203 ++++++++-------
 source3/param/loadparm.c                    |   2 +-
 source3/script/tests/test_sharesec.sh       | 111 +++++++++
 source3/selftest/tests.py                   |   3 +
 source3/smbd/trans2.c                       |   8 +-
 source3/utils/sharesec.c                    |   4 +-
 source3/winbindd/winbindd_util.c            |  85 ++++++-
 source3/wscript_build                       |   9 +-
 source4/libcli/raw/clisocket.c              |  59 +++--
 source4/selftest/tests.py                   |   2 +-
 36 files changed, 1184 insertions(+), 601 deletions(-)
 create mode 100755 source3/script/tests/test_sharesec.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/ib/ibwrapper.c b/ctdb/ib/ibwrapper.c
index 3daab3e..51d39da 100644
--- a/ctdb/ib/ibwrapper.c
+++ b/ctdb/ib/ibwrapper.c
@@ -134,16 +134,16 @@ static int ibw_ctx_priv_destruct(struct ibw_ctx_priv *pctx)
 {
 	DEBUG(DEBUG_DEBUG, ("ibw_ctx_priv_destruct(%p)\n", pctx));
 
+	/*
+	 * tevent_fd must be removed before the fd is closed
+	 */
+	TALLOC_FREE(pctx->cm_channel_event);
+
 	/* destroy cm */
 	if (pctx->cm_channel) {
 		rdma_destroy_event_channel(pctx->cm_channel);
 		pctx->cm_channel = NULL;
 	}
-	if (pctx->cm_channel_event) {
-		/* TODO: do we have to do this here? */
-		talloc_free(pctx->cm_channel_event);
-		pctx->cm_channel_event = NULL;
-	}
 	if (pctx->cm_id) {
 		rdma_destroy_id(pctx->cm_id);
 		pctx->cm_id = NULL;
@@ -166,6 +166,11 @@ static int ibw_conn_priv_destruct(struct ibw_conn_priv *pconn)
 	/* pconn->wr_index is freed by talloc */
 	/* pconn->wr_index[i] are freed by talloc */
 
+	/*
+	 * tevent_fd must be removed before the fd is closed
+	 */
+	TALLOC_FREE(pconn->verbs_channel_event);
+
 	/* destroy verbs */
 	if (pconn->cm_id!=NULL && pconn->cm_id->qp!=NULL) {
 		rdma_destroy_qp(pconn->cm_id);
@@ -182,12 +187,6 @@ static int ibw_conn_priv_destruct(struct ibw_conn_priv *pconn)
 		pconn->verbs_channel = NULL;
 	}
 
-	/* must be freed here because its order is important */
-	if (pconn->verbs_channel_event) {
-		talloc_free(pconn->verbs_channel_event);
-		pconn->verbs_channel_event = NULL;
-	}
-
 	/* free memory regions */
 	ibw_free_mr(&pconn->buf_send, &pconn->mr_send);
 	ibw_free_mr(&pconn->buf_recv, &pconn->mr_recv);
diff --git a/docs-xml/manpages/sharesec.1.xml b/docs-xml/manpages/sharesec.1.xml
index 6a201cc..7e13d49 100644
--- a/docs-xml/manpages/sharesec.1.xml
+++ b/docs-xml/manpages/sharesec.1.xml
@@ -154,10 +154,9 @@
 	If not specified it defaults to 1. Using values other than 1 may
 	cause strange behaviour.</para>
 
-	<para>The owner and group specify the owner and group SIDs for the
-	object. If a SID in the format S-1-x-y-z is specified this is used,
-	otherwise the name specified is resolved using the server on which
-	the file or directory resides.</para>
+	<para>The owner and group specify the owner and group SIDs for
+	the object. Share ACLs do not specify an owner or a group, so
+	these fields are empty.</para>
 
 	<para>ACLs specify permissions granted to the SID. This SID
 	can be specified in S-1-x-y-z format or as a name in which case
@@ -227,10 +226,11 @@
 	<programlisting>
 	host:~ # sharesec share -v
 	REVISION:1
-	OWNER:(NULL SID)
-	GROUP:(NULL SID)
-	ACL:S-1-1-0:ALLOWED/0/0x101f01ff
-	ACL:S-1-5-21-1866488690-1365729215-3963860297-17724:ALLOWED/0/FULL
+	CONTROL:SR|DP
+	OWNER:
+	GROUP:
+	ACL:S-1-1-0:ALLOWED/0x0/FULL
+	ACL:S-1-5-21-1866488690-1365729215-3963860297-17724:ALLOWED/0x0/FULL
 	</programlisting>
 </refsect1>
 
diff --git a/docs-xml/smbdotconf/security/smbencrypt.xml b/docs-xml/smbdotconf/security/smbencrypt.xml
index b55af85..14b32c2 100644
--- a/docs-xml/smbdotconf/security/smbencrypt.xml
+++ b/docs-xml/smbdotconf/security/smbencrypt.xml
@@ -4,40 +4,206 @@
                  basic="1"
 		 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
 <description>
+	<para>
+	This parameter controls whether a remote client is allowed or required
+	to use SMB encryption. It has different effects depending on whether
+	the connection uses SMB1 or SMB2 and newer:
+	</para>
 
-    <para>This is a new feature introduced with Samba 3.2 and above. It is an
-    extension to the SMB/CIFS protocol negotiated as part of the UNIX extensions.
-    SMB encryption uses the GSSAPI (SSPI on Windows) ability to encrypt
-    and sign every request/response in a SMB protocol stream. When
-    enabled it provides a secure method of SMB/CIFS communication,
-    similar to an ssh protected session, but using SMB/CIFS authentication
-    to negotiate encryption and signing keys. Currently this is only
-    supported by Samba 3.2 smbclient, and hopefully soon Linux CIFSFS
-    and MacOS/X clients. Windows clients do not support this feature.
-    </para>
-
-    <para>This controls whether the remote client is allowed or required to use SMB encryption. Possible values 
-    are <emphasis>auto</emphasis>, <emphasis>mandatory</emphasis> 
-    and <emphasis>disabled</emphasis>. This may be set on a per-share
-    basis, but clients may chose to encrypt the entire session, not
-    just traffic to a specific share. If this is set to mandatory
-    then all traffic to a share <emphasis>must</emphasis>
-    be encrypted once the connection has been made to the share.
-    The server would return "access denied" to all non-encrypted
-    requests on such a share. Selecting encrypted traffic reduces
-    throughput as smaller packet sizes must be used (no huge UNIX
-    style read/writes allowed) as well as the overhead of encrypting
-    and signing all the data.
-    </para>
-
-    <para>If SMB encryption is selected, Windows style SMB signing (see
-    the <smbconfoption name="server signing"/> option) is no longer necessary,
-    as the GSSAPI flags use select both signing and sealing of the data.
-    </para>
-
-    <para>When set to auto or default, SMB encryption is offered, but not enforced.
-    When set to mandatory, SMB encryption is required and if set 
-    to disabled, SMB encryption can not be negotiated.</para>
+	<itemizedlist>
+	<listitem>
+		<para>
+		If the connection uses SMB1, then this option controls the use
+		of a Samba-specific extension to the SMB protocol introduced in
+		Samba 3.2 that makes use of the Unix extensions.
+		</para>
+	</listitem>
+
+	<listitem>
+		<para>
+		If the connection uses SMB2 or newer, then this option controls
+		the use of the SMB-level encryption that is supported in SMB
+		version 3.0 and above and available in Windows 8 and newer.
+		</para>
+	</listitem>
+	</itemizedlist>
+
+	<para>
+		This parameter can be set globally and on a per-share bases.
+		Possible values are
+		<emphasis>off</emphasis> or <emphasis>disabled</emphasis>,
+		<emphasis>auto</emphasis> or <emphasis>enabled</emphasis>, and
+		<emphasis>mandatory</emphasis> or <emphasis>required</emphasis>.
+		A special value is <emphasis>default</emphasis> which is
+		the implicit default setting.
+	</para>
+
+	<variablelist>
+		<varlistentry>
+		<term><emphasis>Effects for SMB1</emphasis></term>
+		<listitem>
+		<para>
+		The Samba-specific encryption of SMB1 connections is an
+		extension to the SMB protocol negotiated as part of the UNIX
+		extensions.  SMB encryption uses the GSSAPI (SSPI on Windows)
+		ability to encrypt and sign every request/response in a SMB
+		protocol stream. When enabled it provides a secure method of
+		SMB/CIFS communication, similar to an ssh protected session, but
+		using SMB/CIFS authentication to negotiate encryption and
+		signing keys. Currently this is only supported smbclient of by
+		Samba 3.2 and newer, and hopefully soon Linux CIFSFS and MacOS/X
+		clients. Windows clients do not support this feature.
+		</para>
+
+		<para>This may be set on a per-share
+		basis, but clients may chose to encrypt the entire session, not
+		just traffic to a specific share. If this is set to mandatory
+		then all traffic to a share <emphasis>must</emphasis>
+		be encrypted once the connection has been made to the share.
+		The server would return "access denied" to all non-encrypted
+		requests on such a share. Selecting encrypted traffic reduces
+		throughput as smaller packet sizes must be used (no huge UNIX
+		style read/writes allowed) as well as the overhead of encrypting
+		and signing all the data.
+		</para>
+
+		<para>
+		If SMB encryption is selected, Windows style SMB signing (see
+		the <smbconfoption name="server signing"/> option) is no longer
+		necessary, as the GSSAPI flags use select both signing and
+		sealing of the data.
+		</para>
+
+		<para>
+		When set to auto or default, SMB encryption is offered, but not
+		enforced.  When set to mandatory, SMB encryption is required and
+		if set to disabled, SMB encryption can not be negotiated.
+		</para>
+		</listitem>
+		</varlistentry>
+
+		<varlistentry>
+		<term><emphasis>Effects for SMB2</emphasis></term>
+		<listitem>
+		<para>
+		Native SMB transport encryption is available in SMB version 3.0
+		or newer. It is only offered by Samba if
+		<emphasis>server max protocol</emphasis> is set to
+		<emphasis>SMB3</emphasis> or newer.
+		Clients supporting this type of encryption include
+		Windows 8 and newer,
+		Windows server 2012 and newer,
+		and smbclient of Samba 4.1 and newer.
+		</para>
+
+		<para>
+		The protocol implementation offers various options:
+		</para>
+
+		<itemizedlist>
+			<listitem>
+			<para>
+			The capability to perform SMB encryption can be
+			negotiated during prorocol negotiation.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Data encryption can be enabled globally. In that case,
+			an encryption-capable connection will have all traffic
+			in all its sessions encrypted. In particular all share
+			connections will be encrypted.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Data encryption can also be enabled per share if not
+			enabled globally. For an encryption-capable connection,
+			all connections to an encryption-enabled share will be
+			encrypted.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Encryption can be enforced. This means that session
+			setups will be denied on non-encryption-capable
+			connections if data encryption has been enabled
+			globally. And tree connections will be denied for
+			non-encryption capable connections to shares with data
+			encryption enabled.
+			</para>
+			</listitem>
+		</itemizedlist>
+
+		<para>
+		These features can be crontrolled with settings of
+		<emphasis>smb encrypt</emphasis> as follows:
+		</para>
+
+		<itemizedlist>
+			<listitem>
+			<para>
+			Leaving it as default or explicitly setting
+			<emphasis>default</emphasis> globally will enable
+			negotiation of encryption but will not turn on
+			data encryption globally or per share.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Setting it to <emphasis>enabled</emphasis> globally will
+			enable negotiation and turn on data encryption globally.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Setting it to <emphasis>required</emphasis> globally
+			will enable negotiation and enforce data encryption
+			globally.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Setting it to <emphasis>off</emphasis> globally will
+			completely disable the encryption feature.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Setting it to <emphasis>enabled</emphasis> on a share
+			will turn on data encryption for this share if
+			negotiation has been enabled globally.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Setting it to <emphasis>required</emphasis> on a share
+			will enforce data encryption for this share if
+			negotiation has been enabled globally. Note that this
+			allows enforcing to be controlled in Samba more
+			fine-grainedly than in Windows.  This is a small
+			deviation from the MS-SMB2 protocol document.
+			</para>
+			</listitem>
+
+			<listitem>
+			<para>
+			Setting it to <emphasis>off</emphasis> for a share has
+			no effect.
+			</para>
+			</listitem>
+		</itemizedlist>
+		</listitem>
+		</varlistentry>
+	</variablelist>
 </description>
 
 <value type="default">default</value>
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 74b2cb7..2f3225d 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -32,188 +32,10 @@
 #include "lib/util/tevent_unix.h"
 #include "lib/util/samba_util.h"
 
-#ifndef TALLOC_FREE
-#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
-#endif
-
-struct sendto_state {
-	int fd;
-	const void *buf;
-	size_t len;
-	int flags;
-	const struct sockaddr_storage *addr;
-	socklen_t addr_len;
-	ssize_t sent;
-};
-
-static void sendto_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data);
-
-struct tevent_req *sendto_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-			       int fd, const void *buf, size_t len, int flags,
-			       const struct sockaddr_storage *addr)
-{
-	struct tevent_req *result;
-	struct sendto_state *state;
-	struct tevent_fd *fde;
-
-	result = tevent_req_create(mem_ctx, &state, struct sendto_state);
-	if (result == NULL) {
-		return result;
-	}
-	state->fd = fd;
-	state->buf = buf;
-	state->len = len;
-	state->flags = flags;
-	state->addr = addr;
-
-	switch (addr->ss_family) {
-	case AF_INET:
-		state->addr_len = sizeof(struct sockaddr_in);
-		break;
-#if defined(HAVE_IPV6)
-	case AF_INET6:
-		state->addr_len = sizeof(struct sockaddr_in6);
-		break;
-#endif
-	case AF_UNIX:
-		state->addr_len = sizeof(struct sockaddr_un);
-		break;
-	default:
-		state->addr_len = sizeof(struct sockaddr_storage);
-		break;
-	}
-
-	fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, sendto_handler,
-			    result);
-	if (fde == NULL) {
-		TALLOC_FREE(result);
-		return NULL;
-	}
-	return result;
-}
-
-static void sendto_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data)
-{
-	struct tevent_req *req = talloc_get_type_abort(
-		private_data, struct tevent_req);
-	struct sendto_state *state =
-		tevent_req_data(req, struct sendto_state);
-
-	state->sent = sendto(state->fd, state->buf, state->len, state->flags,
-			     (const struct sockaddr *)state->addr,
-			     state->addr_len);
-	if ((state->sent == -1) && (errno == EINTR)) {
-		/* retry */
-		return;
-	}
-	if (state->sent == -1) {
-		tevent_req_error(req, errno);
-		return;
-	}
-	tevent_req_done(req);
-}
-
-ssize_t sendto_recv(struct tevent_req *req, int *perrno)
-{
-	struct sendto_state *state =
-		tevent_req_data(req, struct sendto_state);
-
-	if (tevent_req_is_unix_error(req, perrno)) {
-		return -1;
-	}
-	return state->sent;
-}
-
-struct recvfrom_state {
-	int fd;
-	void *buf;
-	size_t len;
-	int flags;
-	struct sockaddr_storage *addr;
-	socklen_t *addr_len;
-	ssize_t received;
-};
-
-static void recvfrom_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data);
-
-struct tevent_req *recvfrom_send(TALLOC_CTX *mem_ctx,
-				 struct tevent_context *ev,
-				 int fd, void *buf, size_t len, int flags,
-				 struct sockaddr_storage *addr,
-				 socklen_t *addr_len)
-{
-	struct tevent_req *result;
-	struct recvfrom_state *state;
-	struct tevent_fd *fde;
-
-	result = tevent_req_create(mem_ctx, &state, struct recvfrom_state);
-	if (result == NULL) {
-		return result;
-	}
-	state->fd = fd;
-	state->buf = buf;
-	state->len = len;
-	state->flags = flags;
-	state->addr = addr;
-	state->addr_len = addr_len;
-
-	fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, recvfrom_handler,
-			    result);
-	if (fde == NULL) {
-		TALLOC_FREE(result);
-		return NULL;
-	}
-	return result;
-}
-
-static void recvfrom_handler(struct tevent_context *ev,
-			       struct tevent_fd *fde,
-			       uint16_t flags, void *private_data)
-{
-	struct tevent_req *req = talloc_get_type_abort(
-		private_data, struct tevent_req);
-	struct recvfrom_state *state =
-		tevent_req_data(req, struct recvfrom_state);
-
-	state->received = recvfrom(state->fd, state->buf, state->len,
-				   state->flags, (struct sockaddr *)state->addr,
-				   state->addr_len);
-	if ((state->received == -1) && (errno == EINTR)) {
-		/* retry */
-		return;
-	}
-	if (state->received == 0) {
-		tevent_req_error(req, EPIPE);
-		return;
-	}
-	if (state->received == -1) {
-		tevent_req_error(req, errno);
-		return;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list