The branch, master has been updated
       via  962d5854bd9 s3:lib/util_sock: allow {before,after}_connect hooks to 
be passed to open_socket_out_send()
       via  44568e21ee5 lib/async_req: let async_connect_send() pass the fd to 
{before,after}_connect hooks
      from  a168389def8 lib: Remove [set|drop]_effective_capability and enum 
smbd_capability

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 962d5854bd96384995e07b0ea3728b7cb63600b8
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Dec 18 12:47:15 2025 +0100

    s3:lib/util_sock: allow {before,after}_connect hooks to be passed to 
open_socket_out_send()
    
    async_connect_send() already has these hooks now open_socket_out_send()
    callers can pass them through.
    
    This will be useful for IPPROTO_SMBDIRECT sockets to setup things
    between the socket() and connect() syscalls.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Tue Jan 13 08:13:04 UTC 2026 on atb-devel-224

commit 44568e21ee5db46f3532fcd7053f1ea9a057ad12
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Dec 18 12:47:15 2025 +0100

    lib/async_req: let async_connect_send() pass the fd to 
{before,after}_connect hooks
    
    This will be useful for IPPROTO_SMBDIRECT sockets to setup things
    between the socket() and connect() syscalls.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

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

Summary of changes:
 lib/async_req/async_sock.c       | 12 ++++++------
 lib/async_req/async_sock.h       |  4 ++--
 source3/include/proto.h          |  5 ++++-
 source3/lib/util_sock.c          | 11 ++++++++---
 source3/libsmb/smbsock_connect.c | 20 ++++++++++++++++----
 source3/rpc_client/local_np.c    |  8 ++++----
 6 files changed, 40 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index b25d4cc3731..3c66b39c55d 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -141,8 +141,8 @@ struct async_connect_state {
        socklen_t address_len;
        struct sockaddr_storage address;
 
-       void (*before_connect)(void *private_data);
-       void (*after_connect)(void *private_data);
+       void (*before_connect)(int fd, void *private_data);
+       void (*after_connect)(int fd, void *private_data);
        void *private_data;
 };
 
@@ -168,8 +168,8 @@ static void async_connect_connected(struct tevent_context 
*ev,
 struct tevent_req *async_connect_send(
        TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd,
        const struct sockaddr *address, socklen_t address_len,
-       void (*before_connect)(void *private_data),
-       void (*after_connect)(void *private_data),
+       void (*before_connect)(int fd, void *private_data),
+       void (*after_connect)(int fd, void *private_data),
        void *private_data)
 {
        struct tevent_req *req;
@@ -213,13 +213,13 @@ struct tevent_req *async_connect_send(
        }
 
        if (state->before_connect != NULL) {
-               state->before_connect(state->private_data);
+               state->before_connect(fd, state->private_data);
        }
 
        state->result = connect(fd, address, address_len);
 
        if (state->after_connect != NULL) {
-               state->after_connect(state->private_data);
+               state->after_connect(fd, state->private_data);
        }
 
        if (state->result == 0) {
diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h
index 743f7260787..3e601166ba1 100644
--- a/lib/async_req/async_sock.h
+++ b/lib/async_req/async_sock.h
@@ -45,8 +45,8 @@ int samba_socket_poll_or_sock_error(int fd);
 struct tevent_req *async_connect_send(
        TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd,
        const struct sockaddr *address, socklen_t address_len,
-       void (*before_connect)(void *private_data),
-       void (*after_connect)(void *private_data),
+       void (*before_connect)(int fd, void *private_data),
+       void (*after_connect)(int fd, void *private_data),
        void *private_data);
 int async_connect_recv(struct tevent_req *req, int *perrno);
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e13584c4d6c..854945e8db7 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -497,7 +497,10 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX 
*mem_ctx,
                                        int protocol,
                                        const struct sockaddr_storage *pss,
                                        uint16_t port,
-                                       int timeout);
+                                       int timeout,
+                                       void (*before_connect)(int fd, void 
*private_data),
+                                       void (*after_connect)(int fd, void 
*private_data),
+                                       void *private_data);
 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
 
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 44c38de5ccf..d88596ba426 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -407,7 +407,10 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX 
*mem_ctx,
                                        int protocol,
                                        const struct sockaddr_storage *pss,
                                        uint16_t port,
-                                       int timeout)
+                                       int timeout,
+                                       void (*before_connect)(int fd, void 
*private_data),
+                                       void (*after_connect)(int fd, void 
*private_data),
+                                       void *private_data)
 {
        char addr[INET6_ADDRSTRLEN];
        struct tevent_req *req;
@@ -472,7 +475,8 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
 
        state->connect_subreq = async_connect_send(
                state, state->ev, state->fd, &state->saddr.u.sa,
-               state->saddr.sa_socklen, NULL, NULL, NULL);
+               state->saddr.sa_socklen,
+               before_connect, after_connect, private_data);
        if (tevent_req_nomem(state->connect_subreq, NULL)) {
                return tevent_req_post(req, ev);
        }
@@ -540,7 +544,8 @@ NTSTATUS open_socket_out(const struct sockaddr_storage 
*pss, uint16_t port,
                goto fail;
        }
 
-       req = open_socket_out_send(frame, ev, IPPROTO_TCP, pss, port, timeout);
+       req = open_socket_out_send(frame, ev, IPPROTO_TCP, pss, port, timeout,
+                                  NULL, NULL, NULL);
        if (req == NULL) {
                goto fail;
        }
diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c
index b6189d1891e..403435c45d9 100644
--- a/source3/libsmb/smbsock_connect.c
+++ b/source3/libsmb/smbsock_connect.c
@@ -207,7 +207,10 @@ static struct tevent_req *nb_connect_send(TALLOC_CTX 
*mem_ctx,
                                      IPPROTO_TCP,
                                      addr,
                                      port,
-                                     5000);
+                                     5000,
+                                     NULL,
+                                     NULL,
+                                     NULL);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -317,7 +320,10 @@ static void nb_connect_done(struct tevent_req *subreq)
                                              IPPROTO_TCP,
                                              state->addr,
                                              NBT_SMB_PORT,
-                                             5000);
+                                             5000,
+                                             NULL,
+                                             NULL,
+                                             NULL);
                if (tevent_req_nomem(subreq, req)) {
                        return;
                }
@@ -685,7 +691,10 @@ static bool smbsock_connect_submit_next(struct tevent_req 
*req)
                                                 IPPROTO_TCP,
                                                 state->addr,
                                                 s->transport.port,
-                                                5000);
+                                                5000,
+                                                NULL,
+                                                NULL,
+                                                NULL);
                if (tevent_req_nomem(s->subreq, req)) {
                        return false;
                }
@@ -705,7 +714,10 @@ static bool smbsock_connect_submit_next(struct tevent_req 
*req)
                                                 IPPROTO_QUIC,
                                                 state->addr,
                                                 s->transport.port,
-                                                5000);
+                                                5000,
+                                                NULL,
+                                                NULL,
+                                                NULL);
                if (tevent_req_nomem(s->subreq, req)) {
                        return false;
                }
diff --git a/source3/rpc_client/local_np.c b/source3/rpc_client/local_np.c
index 10c6434e397..e66e375f484 100644
--- a/source3/rpc_client/local_np.c
+++ b/source3/rpc_client/local_np.c
@@ -55,8 +55,8 @@ struct np_sock_connect_state {
 
 static void np_sock_connect_cleanup(
        struct tevent_req *req, enum tevent_req_state req_state);
-static void np_sock_connect_before(void *private_data);
-static void np_sock_connect_after(void *private_data);
+static void np_sock_connect_before(int fd, void *private_data);
+static void np_sock_connect_after(int fd, void *private_data);
 static void np_sock_connect_connected(struct tevent_req *subreq);
 static void np_sock_connect_written(struct tevent_req *subreq);
 static void np_sock_connect_read_done(struct tevent_req *subreq);
@@ -147,12 +147,12 @@ static void np_sock_connect_cleanup(
        }
 }
 
-static void np_sock_connect_before(void *private_data)
+static void np_sock_connect_before(int fd, void *private_data)
 {
        become_root();
 }
 
-static void np_sock_connect_after(void *private_data)
+static void np_sock_connect_after(int fd, void *private_data)
 {
        unbecome_root();
 }


-- 
Samba Shared Repository

Reply via email to