s4-kdc: Migrate to tsocket_address.
[ira/wip.git] / source4 / kdc / kpasswdd.c
index d3965912908ecc2bf87e764d77df411c43e16775..18adf0a248774c908cb75b02617c338c88e4e16c 100644 (file)
@@ -24,6 +24,7 @@
 #include "smbd/service_task.h"
 #include "lib/events/events.h"
 #include "lib/socket/socket.h"
+#include "lib/tsocket/tsocket.h"
 #include "system/network.h"
 #include "../lib/util/dlinklist.h"
 #include "lib/ldb/include/ldb.h"
@@ -418,8 +419,8 @@ bool kpasswdd_process(struct kdc_server *kdc,
                      TALLOC_CTX *mem_ctx, 
                      DATA_BLOB *input, 
                      DATA_BLOB *reply,
-                     struct socket_address *peer_addr,
-                     struct socket_address *my_addr,
+                     struct tsocket_address *peer_addr,
+                     struct tsocket_address *my_addr,
                      int datagram_reply)
 {
        bool ret;
@@ -435,6 +436,9 @@ bool kpasswdd_process(struct kdc_server *kdc,
        DATA_BLOB kpasswd_req, kpasswd_rep;
        struct cli_credentials *server_credentials;
        struct gensec_security *gensec_security;
+       struct sockaddr_storage ss;
+       ssize_t socklen;
+       struct socket_address *socket_address;
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
 
        char *keytab_name;
@@ -530,7 +534,20 @@ bool kpasswdd_process(struct kdc_server *kdc,
        }
 #endif
 
-       nt_status = gensec_set_my_addr(gensec_security, my_addr);
+       socklen = tsocket_address_bsd_sockaddr(my_addr, (struct sockaddr *) &ss,
+                               sizeof(struct sockaddr_storage));
+       if (socklen < 0) {
+               talloc_free(tmp_ctx);
+               return false;
+       }
+       socket_address = socket_address_from_sockaddr(tmp_ctx,
+                       (struct sockaddr *) &ss, socklen);
+       if (socket_address == NULL) {
+               talloc_free(tmp_ctx);
+               return false;
+       }
+
+       nt_status = gensec_set_my_addr(gensec_security, socket_address);
        if (!NT_STATUS_IS_OK(nt_status)) {
                talloc_free(tmp_ctx);
                return false;