The branch, master has been updated
       via  4b86beb s4:selftest: test using the machine account of the rodc 
against itself
       via  e90d5ab selftest/target/Samba4: regenerate the krb5.conf after the 
rodc join
       via  a8b3958 selftest/target/Samba4: splitout a mk_krb5_conf() function
       via  8002406 s4:kdc: split the kdc_tcp_proxy() logic from the main kdc 
logic
       via  e70b09e s4:kdc: split the kdc_udp_proxy() logic from the main kdc 
logic
       via  ad9ac99 s4:kdc: add a kdc_proxy_unavailable_error() helper function
       via  0c78640 s4:kdc: fix calculation of the rodc kvno
       via  a511d37 HEIMDAL:kdc: correctly propagate HDB_ERR_NOT_FOUND_HERE to 
via tgs_parse_request() and _kdc_tgs_rep()
       via  2c7c3d0 lib/socket_wrapper: try to fix the build on solaris
      from  9c342c4 s3: add two missing vfs disconnect calls

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


- Log -----------------------------------------------------------------
commit 4b86beb98b1f600ba01a98a2a44d04c575c42953
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Mar 4 16:57:28 2011 +0100

    s4:selftest: test using the machine account of the rodc against itself
    
    This should test the non proxy rodc kdc path.
    
    metze
    
    Autobuild-User: Stefan Metzmacher <[email protected]>
    Autobuild-Date: Fri Mar  4 22:06:10 CET 2011 on sn-devel-104

commit e90d5ab561e9bbea619ba46cfc7c1a7fc1a05b8f
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Mar 4 10:05:51 2011 +0100

    selftest/target/Samba4: regenerate the krb5.conf after the rodc join
    
    The RODC should be used as KDC, which will forward requests to the RWDC
    if required.
    
    metze

commit a8b3958f38805f18f300aed64bf567339f75e8b3
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Mar 4 10:05:13 2011 +0100

    selftest/target/Samba4: splitout a mk_krb5_conf() function
    
    metze

commit 8002406c51cf1f9f6daebef7e03bfef77f56cf38
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Feb 9 12:17:23 2011 +0100

    s4:kdc: split the kdc_tcp_proxy() logic from the main kdc logic
    
    By having kdc_tcp_proxy_send/recv(), which just asks any writeable
    dc for a reponse blob, we simplify the interaction between
    client-local and local-writeable sockets.
    
    This allows us to make kdc_socket, kdc_process_fn_t, kdc_tcp_call and 
kdc_tcp_socket
    private to kdc.c again.
    
    metze

commit e70b09e8f8f99b2d63047525f1d5e360582f7eaa
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Feb 9 09:07:47 2011 +0100

    s4:kdc: split the kdc_udp_proxy() logic from the main kdc logic
    
    By having kdc_udp_proxy_send/recv(), which just asks any writeable
    dc for a reponse blob, we simplify the interaction between
    client-local and local-writeable sockets.
    
    This allows us to make kdc_udp_call and kdc_udp_socket private to
    kdc.c again.
    
    metze

commit ad9ac99afd04b1f69ca188eb0005a1226520bc7d
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Feb 9 09:06:20 2011 +0100

    s4:kdc: add a kdc_proxy_unavailable_error() helper function
    
    metze

commit 0c78640e674914d3ee7e8233813ee91a44f16440
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Mar 4 16:12:29 2011 +0100

    s4:kdc: fix calculation of the rodc kvno
    
    Bit shifting is non-trivial in C:-)
    
    This
    
        int32_t a = 0x12340000;
        uint32_t b = (a >> 16);
    
    results in 0x00001234, but this
    
        int32_t a = 0xEDCB0000;
        uint32_t b = (a >> 16);
    
    results in 0xFFFFEDCB, while we expected 0x0000EDCB.
    
    metze

commit a511d37d83be3bf47440527ad2b54fd124ba97a5
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Mar 4 14:33:02 2011 +0100

    HEIMDAL:kdc: correctly propagate HDB_ERR_NOT_FOUND_HERE to via 
tgs_parse_request() and _kdc_tgs_rep()
    
    metze

commit 2c7c3d03d5c6b99370f9007aa6fe874d36512be2
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Mar 4 21:14:27 2011 +0100

    lib/socket_wrapper: try to fix the build on solaris
    
    struct msg does not contain msg_control, msg_controllen and msg_flags
    on solaris.
    
    metze

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

Summary of changes:
 lib/socket_wrapper/socket_wrapper.c |   13 +
 selftest/target/Samba4.pm           |  101 +++---
 source4/heimdal/kdc/krb5tgs.c       |    5 +
 source4/kdc/db-glue.c               |   16 +-
 source4/kdc/kdc-glue.h              |   75 +---
 source4/kdc/kdc.c                   |  219 ++++++++++-
 source4/kdc/proxy.c                 |  725 ++++++++++++++++-------------------
 source4/selftest/tests.py           |    1 +
 8 files changed, 647 insertions(+), 508 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/socket_wrapper/socket_wrapper.c 
b/lib/socket_wrapper/socket_wrapper.c
index 02cce3f..cd91327 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -2147,13 +2147,16 @@ _PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, 
size_t len, int flags, con
        tmp.iov_base = discard_const_p(char, buf);
        tmp.iov_len = len;
 
+       ZERO_STRUCT(msg);
        msg.msg_name = discard_const_p(struct sockaddr, to); /* optional 
address */
        msg.msg_namelen = tolen;       /* size of address */
        msg.msg_iov = &tmp;            /* scatter/gather array */
        msg.msg_iovlen = 1;            /* # elements in msg_iov */
+#if 0 /* not available on solaris */
        msg.msg_control = NULL;        /* ancillary data, see below */
        msg.msg_controllen = 0;        /* ancillary data buffer len */
        msg.msg_flags = 0;             /* flags on received message */
+#endif
 
        ret = swrap_sendmsg_before(si, &msg, &tmp, &un_addr, &to_un, &to, 
&bcast);
        if (ret == -1) return -1;
@@ -2264,13 +2267,16 @@ _PUBLIC_ ssize_t swrap_send(int s, const void *buf, 
size_t len, int flags)
        tmp.iov_base = discard_const_p(char, buf);
        tmp.iov_len = len;
 
+       ZERO_STRUCT(msg);
        msg.msg_name = NULL;           /* optional address */
        msg.msg_namelen = 0;           /* size of address */
        msg.msg_iov = &tmp;            /* scatter/gather array */
        msg.msg_iovlen = 1;            /* # elements in msg_iov */
+#if 0 /* not available on solaris */
        msg.msg_control = NULL;        /* ancillary data, see below */
        msg.msg_controllen = 0;        /* ancillary data buffer len */
        msg.msg_flags = 0;             /* flags on received message */
+#endif
 
        ret = swrap_sendmsg_before(si, &msg, &tmp, &un_addr, NULL, NULL, NULL);
        if (ret == -1) return -1;
@@ -2303,13 +2309,17 @@ _PUBLIC_ ssize_t swrap_sendmsg(int s, const struct 
msghdr *omsg, int flags)
        tmp.iov_base = NULL;
        tmp.iov_len = 0;
 
+       msg = *omsg;
+#if 0
        msg.msg_name = omsg->msg_name;             /* optional address */
        msg.msg_namelen = omsg->msg_namelen;       /* size of address */
        msg.msg_iov = omsg->msg_iov;               /* scatter/gather array */
        msg.msg_iovlen = omsg->msg_iovlen;         /* # elements in msg_iov */
+       /* the following is not available on solaris */
        msg.msg_control = omsg->msg_control;       /* ancillary data, see below 
*/
        msg.msg_controllen = omsg->msg_controllen; /* ancillary data buffer len 
*/
        msg.msg_flags = omsg->msg_flags;           /* flags on received message 
*/
+#endif
 
        ret = swrap_sendmsg_before(si, &msg, &tmp, &un_addr, &to_un, &to, 
&bcast);
        if (ret == -1) return -1;
@@ -2461,13 +2471,16 @@ int swrap_writev(int s, const struct iovec *vector, 
size_t count)
        tmp.iov_base = NULL;
        tmp.iov_len = 0;
 
+       ZERO_STRUCT(msg);
        msg.msg_name = NULL;           /* optional address */
        msg.msg_namelen = 0;           /* size of address */
        msg.msg_iov = discard_const_p(struct iovec, vector); /* scatter/gather 
array */
        msg.msg_iovlen = count;        /* # elements in msg_iov */
+#if 0 /* not available on solaris */
        msg.msg_control = NULL;        /* ancillary data, see below */
        msg.msg_controllen = 0;        /* ancillary data buffer len */
        msg.msg_flags = 0;             /* flags on received message */
+#endif
 
        ret = swrap_sendmsg_before(si, &msg, &tmp, &un_addr, NULL, NULL, NULL);
        if (ret == -1) return -1;
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index d4817bb..7eb8b6e 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -459,6 +459,56 @@ Wfz/8alZ5aMezCQzXJyIaJsCLeKABosSwHcpAFmxlQ==
 EOF
 }
 
+sub mk_krb5_conf($$)
+{
+       my ($self, $ctx) = @_;
+
+       unless (open(KRB5CONF, ">$ctx->{krb5_conf}")) {
+               warn("can't open $ctx->{krb5_conf}$?");
+               return undef;
+       }
+       print KRB5CONF "
+#Generated krb5.conf for $ctx->{realm}
+
+[libdefaults]
+ default_realm = $ctx->{realm}
+ dns_lookup_realm = false
+ dns_lookup_kdc = false
+ ticket_lifetime = 24h
+ forwardable = yes
+ allow_weak_crypto = yes
+
+[realms]
+ $ctx->{realm} = {
+  kdc = $ctx->{kdc_ipv4}:88
+  admin_server = $ctx->{kdc_ipv4}:88
+  default_domain = $ctx->{dnsname}
+ }
+ $ctx->{dnsname} = {
+  kdc = $ctx->{kdc_ipv4}:88
+  admin_server = $ctx->{kdc_ipv4}:88
+  default_domain = $ctx->{dnsname}
+ }
+ $ctx->{domain} = {
+  kdc = $ctx->{kdc_ipv4}:88
+  admin_server = $ctx->{kdc_ipv4}:88
+  default_domain = $ctx->{dnsname}
+ }
+
+[appdefaults]
+       pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
+
+[kdc]
+       enable-pkinit = true
+       pkinit_identity = FILE:$ctx->{tlsdir}/kdc.pem,$ctx->{tlsdir}/key.pem
+       pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
+
+[domain_realm]
+ .$ctx->{dnsname} = $ctx->{realm}
+";
+       close(KRB5CONF);
+}
+
 sub provision_raw_prepare($$$$$$$$$$)
 {
        my ($self, $prefix, $server_role, $netbiosname, $netbiosalias,
@@ -635,50 +685,7 @@ sub provision_raw_step1($$)
 
        $self->mk_keyblobs($ctx->{tlsdir});
 
-       unless (open(KRB5CONF, ">$ctx->{krb5_conf}")) {
-               warn("can't open $ctx->{krb5_conf}$?");
-               return undef;
-       }
-       print KRB5CONF "
-#Generated krb5.conf for $ctx->{realm}
-
-[libdefaults]
- default_realm = $ctx->{realm}
- dns_lookup_realm = false
- dns_lookup_kdc = false
- ticket_lifetime = 24h
- forwardable = yes
- allow_weak_crypto = yes
-
-[realms]
- $ctx->{realm} = {
-  kdc = $ctx->{kdc_ipv4}:88
-  admin_server = $ctx->{kdc_ipv4}:88
-  default_domain = $ctx->{dnsname}
- }
- $ctx->{dnsname} = {
-  kdc = $ctx->{kdc_ipv4}:88
-  admin_server = $ctx->{kdc_ipv4}:88
-  default_domain = $ctx->{dnsname}
- }
- $ctx->{domain} = {
-  kdc = $ctx->{kdc_ipv4}:88
-  admin_server = $ctx->{kdc_ipv4}:88
-  default_domain = $ctx->{dnsname}
- }
-
-[appdefaults]
-       pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
-
-[kdc]
-       enable-pkinit = true
-       pkinit_identity = FILE:$ctx->{tlsdir}/kdc.pem,$ctx->{tlsdir}/key.pem
-       pkinit_anchors = FILE:$ctx->{tlsdir}/ca.pem
-
-[domain_realm]
- .$ctx->{dnsname} = $ctx->{realm}
-";
-       close(KRB5CONF);
+       $self->mk_krb5_conf($ctx);
 
        open(PWD, ">$ctx->{nsswrap_passwd}");
        print PWD "
@@ -1191,6 +1198,12 @@ sub provision_rodc($$$)
                return undef;
        }
 
+       # we overwrite the kdc after the RODC join
+       # so that use the RODC as kdc and test
+       # the proxy code
+       $ctx->{kdc_ipv4} = $ret->{SERVER_IP};
+       $self->mk_krb5_conf($ctx);
+
        $ret->{RODC_DC_SERVER} = $ret->{SERVER};
        $ret->{RODC_DC_SERVER_IP} = $ret->{SERVER_IP};
        $ret->{RODC_DC_NETBIOSNAME} = $ret->{NETBIOSNAME};
diff --git a/source4/heimdal/kdc/krb5tgs.c b/source4/heimdal/kdc/krb5tgs.c
index 4af4c29..037934f 100644
--- a/source4/heimdal/kdc/krb5tgs.c
+++ b/source4/heimdal/kdc/krb5tgs.c
@@ -1179,6 +1179,7 @@ tgs_parse_request(krb5_context context,
        kdc_log(context, config, 5, "Ticket-granting ticket account %s does not 
have secrets at this KDC, need to proxy", p);
        if (ret == 0)
            free(p);
+       ret = HDB_ERR_NOT_FOUND_HERE;
        goto out;
     } else if(ret){
        const char *msg = krb5_get_error_message(context, ret);
@@ -2239,6 +2240,10 @@ _kdc_tgs_rep(krb5_context context,
                            &auth_data,
                            &replykey,
                            &rk_is_subkey);
+    if (ret == HDB_ERR_NOT_FOUND_HERE) {
+       /* kdc_log() is called in tgs_parse_request() */
+       goto out;
+    }
     if (ret) {
        kdc_log(context, config, 0,
                "Failed parsing TGS-REQ from %s", from);
diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c
index ed64685..7a3b1f4 100644
--- a/source4/kdc/db-glue.c
+++ b/source4/kdc/db-glue.c
@@ -36,6 +36,13 @@
 #include "kdc/samba_kdc.h"
 #include "kdc/kdc-policy.h"
 
+#define SAMBA_KVNO_GET_KRBTGT(kvno) \
+       ((uint16_t)(((uint32_t)kvno) >> 16))
+
+#define SAMBA_KVNO_AND_KRBTGT(kvno, krbtgt) \
+       ((krb5_kvno)((((uint32_t)kvno) & 0xFFFF) | \
+        ((((uint32_t)krbtgt) << 16) & 0xFFFF0000)))
+
 enum samba_kdc_ent_type
 { SAMBA_KDC_ENT_TYPE_CLIENT, SAMBA_KDC_ENT_TYPE_SERVER,
   SAMBA_KDC_ENT_TYPE_KRBTGT, SAMBA_KDC_ENT_TYPE_TRUST, SAMBA_KDC_ENT_TYPE_ANY 
};
@@ -206,6 +213,7 @@ static krb5_error_code 
samba_kdc_message2entry_keys(krb5_context context,
        uint16_t i;
        uint16_t allocated_keys = 0;
        int rodc_krbtgt_number = 0;
+       int kvno = 0;
        uint32_t supported_enctypes
                = ldb_msg_find_attr_as_uint(msg,
                                            "msDS-SupportedEncryptionTypes",
@@ -245,14 +253,14 @@ static krb5_error_code 
samba_kdc_message2entry_keys(krb5_context context,
                }
        }
 
-
        entry_ex->entry.keys.val = NULL;
        entry_ex->entry.keys.len = 0;
 
-       entry_ex->entry.kvno = ldb_msg_find_attr_as_int(msg, 
"msDS-KeyVersionNumber", 0);
+       kvno = ldb_msg_find_attr_as_int(msg, "msDS-KeyVersionNumber", 0);
        if (is_rodc) {
-               entry_ex->entry.kvno |= (rodc_krbtgt_number << 16);
+               kvno = SAMBA_KVNO_AND_KRBTGT(kvno, rodc_krbtgt_number);
        }
+       entry_ex->entry.kvno = kvno;
 
        /* Get keys from the db */
 
@@ -1334,7 +1342,7 @@ krb5_error_code samba_kdc_fetch(krb5_context context,
        TALLOC_CTX *mem_ctx;
        unsigned int krbtgt_number;
        if (flags & HDB_F_KVNO_SPECIFIED) {
-               krbtgt_number = kvno >> 16;
+               krbtgt_number = SAMBA_KVNO_GET_KRBTGT(kvno);
                if (kdc_db_ctx->rodc) {
                        if (krbtgt_number != kdc_db_ctx->my_krbtgt_number) {
                                return HDB_ERR_NOT_FOUND_HERE;
diff --git a/source4/kdc/kdc-glue.h b/source4/kdc/kdc-glue.h
index 75b6b98..b365cd7 100644
--- a/source4/kdc/kdc-glue.h
+++ b/source4/kdc/kdc-glue.h
@@ -50,59 +50,6 @@ enum kdc_process_ret {
        KDC_PROCESS_FAILED,
        KDC_PROCESS_PROXY};
 
-struct kdc_udp_call {
-       struct tsocket_address *src;
-       DATA_BLOB in;
-       DATA_BLOB out;
-};
-
-/* hold information about one kdc/kpasswd udp socket */
-struct kdc_udp_socket {
-       struct kdc_socket *kdc_socket;
-       struct tdgram_context *dgram;
-       struct tevent_queue *send_queue;
-};
-
-struct kdc_tcp_call {
-       struct kdc_tcp_connection *kdc_conn;
-       DATA_BLOB in;
-       DATA_BLOB out;
-       uint8_t out_hdr[4];
-       struct iovec out_iov[2];
-};
-
-typedef enum kdc_process_ret (*kdc_process_fn_t)(struct kdc_server *kdc,
-                                                TALLOC_CTX *mem_ctx,
-                                                DATA_BLOB *input,
-                                                DATA_BLOB *reply,
-                                                struct tsocket_address 
*peer_addr,
-                                                struct tsocket_address 
*my_addr,
-                                                int datagram);
-
-
-/* hold information about one kdc socket */
-struct kdc_socket {
-       struct kdc_server *kdc;
-       struct tsocket_address *local_address;
-       kdc_process_fn_t process;
-};
-
-/*
-  state of an open tcp connection
-*/
-struct kdc_tcp_connection {
-       /* stream connection we belong to */
-       struct stream_connection *conn;
-
-       /* the kdc_server the connection belongs to */
-       struct kdc_socket *kdc_socket;
-
-       struct tstream_context *tstream;
-
-       struct tevent_queue *send_queue;
-};
-
-
 enum kdc_process_ret kpasswdd_process(struct kdc_server *kdc,
                                      TALLOC_CTX *mem_ctx,
                                      DATA_BLOB *input,
@@ -116,10 +63,22 @@ NTSTATUS hdb_samba4_create_kdc(struct 
samba_kdc_base_context *base_ctx,
                               krb5_context context, struct HDB **db);
 
 /* from proxy.c */
-void kdc_udp_proxy(struct kdc_server *kdc, struct kdc_udp_socket *sock,
-                  struct kdc_udp_call *call, uint16_t port);
-
-void kdc_tcp_proxy(struct kdc_server *kdc, struct kdc_tcp_connection *kdc_conn,
-                  struct kdc_tcp_call *call, uint16_t port);
+struct tevent_req *kdc_udp_proxy_send(TALLOC_CTX *mem_ctx,
+                                     struct tevent_context *ev,
+                                     struct kdc_server *kdc,
+                                     uint16_t port,
+                                     DATA_BLOB in);
+NTSTATUS kdc_udp_proxy_recv(struct tevent_req *req,
+                           TALLOC_CTX *mem_ctx,
+                           DATA_BLOB *out);
+
+struct tevent_req *kdc_tcp_proxy_send(TALLOC_CTX *mem_ctx,
+                                     struct tevent_context *ev,
+                                     struct kdc_server *kdc,
+                                     uint16_t port,
+                                     DATA_BLOB in);
+NTSTATUS kdc_tcp_proxy_recv(struct tevent_req *req,
+                           TALLOC_CTX *mem_ctx,
+                           DATA_BLOB *out);
 
 #endif
diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c
index c5beaba..26365ac 100644
--- a/source4/kdc/kdc.c
+++ b/source4/kdc/kdc.c
@@ -38,6 +38,69 @@
 extern struct krb5plugin_windc_ftable windc_plugin_table;
 extern struct hdb_method hdb_samba4;
 
+static NTSTATUS kdc_proxy_unavailable_error(struct kdc_server *kdc,
+                                           TALLOC_CTX *mem_ctx,
+                                           DATA_BLOB *out)
+{
+       int kret;
+       krb5_data k5_error_blob;
+
+       kret = krb5_mk_error(kdc->smb_krb5_context->krb5_context,
+                            KRB5KDC_ERR_SVC_UNAVAILABLE, NULL, NULL,
+                            NULL, NULL, NULL, NULL, &k5_error_blob);
+       if (kret != 0) {
+               DEBUG(2,(__location__ ": Unable to form krb5 error reply\n"));
+               return NT_STATUS_INTERNAL_ERROR;
+       }
+
+       *out = data_blob_talloc(mem_ctx, k5_error_blob.data, 
k5_error_blob.length);
+       krb5_data_free(&k5_error_blob);
+       if (!out->data) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       return NT_STATUS_OK;
+}
+
+typedef enum kdc_process_ret (*kdc_process_fn_t)(struct kdc_server *kdc,
+                                                TALLOC_CTX *mem_ctx,
+                                                DATA_BLOB *input,
+                                                DATA_BLOB *reply,
+                                                struct tsocket_address 
*peer_addr,
+                                                struct tsocket_address 
*my_addr,
+                                                int datagram);
+
+/* hold information about one kdc socket */
+struct kdc_socket {
+       struct kdc_server *kdc;
+       struct tsocket_address *local_address;
+       kdc_process_fn_t process;
+};
+
+struct kdc_tcp_call {
+       struct kdc_tcp_connection *kdc_conn;
+       DATA_BLOB in;
+       DATA_BLOB out;
+       uint8_t out_hdr[4];
+       struct iovec out_iov[2];
+};
+
+/*
+  state of an open tcp connection
+*/
+struct kdc_tcp_connection {
+       /* stream connection we belong to */
+       struct stream_connection *conn;
+
+       /* the kdc_server the connection belongs to */
+       struct kdc_socket *kdc_socket;
+
+       struct tstream_context *tstream;
+
+       struct tevent_queue *send_queue;
+};
+
+
 static void kdc_tcp_terminate_connection(struct kdc_tcp_connection *kdcconn, 
const char *reason)
 {
        stream_terminate_connection(kdcconn->conn, reason);
@@ -119,6 +182,7 @@ static enum kdc_process_ret kdc_process(struct kdc_server 
*kdc,
        return KDC_PROCESS_OK;
 }
 
+static void kdc_tcp_call_proxy_done(struct tevent_req *subreq);
 static void kdc_tcp_call_writev_done(struct tevent_req *subreq);
 
 static void kdc_tcp_call_loop(struct tevent_req *subreq)
@@ -178,14 +242,94 @@ static void kdc_tcp_call_loop(struct tevent_req *subreq)
        }
 
        if (ret == KDC_PROCESS_PROXY) {
+               uint16_t port;
+
                if (!kdc_conn->kdc_socket->kdc->am_rodc) {
                        kdc_tcp_terminate_connection(kdc_conn,
                                                     "kdc_tcp_call_loop: 
proxying requested when not RODC");
                        return;
                }
-               kdc_tcp_proxy(kdc_conn->kdc_socket->kdc, kdc_conn, call,
-                             
tsocket_address_inet_port(kdc_conn->conn->local_address));
-               goto done;
+               port = tsocket_address_inet_port(kdc_conn->conn->local_address);
+
+               subreq = kdc_tcp_proxy_send(call,
+                                           kdc_conn->conn->event.ctx,
+                                           kdc_conn->kdc_socket->kdc,
+                                           port,
+                                           call->in);
+               if (subreq == NULL) {
+                       kdc_tcp_terminate_connection(kdc_conn,
+                               "kdc_tcp_call_loop: kdc_tcp_proxy_send failed");
+                       return;
+               }
+               tevent_req_set_callback(subreq, kdc_tcp_call_proxy_done, call);
+               return;
+       }
+
+       /* First add the length of the out buffer */
+       RSIVAL(call->out_hdr, 0, call->out.length);
+       call->out_iov[0].iov_base = (char *) call->out_hdr;
+       call->out_iov[0].iov_len = 4;
+
+       call->out_iov[1].iov_base = (char *) call->out.data;
+       call->out_iov[1].iov_len = call->out.length;
+
+       subreq = tstream_writev_queue_send(call,
+                                          kdc_conn->conn->event.ctx,
+                                          kdc_conn->tstream,
+                                          kdc_conn->send_queue,
+                                          call->out_iov, 2);
+       if (subreq == NULL) {
+               kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_call_loop: "
+                               "no memory for tstream_writev_queue_send");
+               return;
+       }
+       tevent_req_set_callback(subreq, kdc_tcp_call_writev_done, call);
+
+       /*


-- 
Samba Shared Repository

Reply via email to