Imported Upstream version 2.5.2p1
[debian/amanda] / common-src / krb4-security.c
index 6a3dad380be0713e9afabfafcb66dbc24a70ad4f..b4ca980c2a7de080b758c9a70356a25081723516 100644 (file)
@@ -69,7 +69,7 @@ int kuserok(AUTH_DAT *, char *);
  */
 struct krb4_handle {
     security_handle_t sech;    /* MUST be first */
-    struct sockaddr_in peer;   /* host on other side */
+    struct sockaddr_in6 peer;  /* host on other side */
     char hostname[MAX_HOSTNAME_LENGTH+1];      /* human form of above */
     char proto_handle[32];     /* protocol handle for this req */
     int sequence;              /* last sequence number we received */
@@ -156,6 +156,8 @@ const security_driver_t krb4_security_driver = {
     krb4_stream_read_sync,
     krb4_stream_read_cancel,
     sec_close_connection_none,
+    NULL,
+    NULL
 };
 
 /*
@@ -375,9 +377,9 @@ krb4_connect(
        return;
     }
     if ((se = getservbyname(KAMANDA_SERVICE_NAME, "udp")) == NULL)
-       port = (int)htons(KAMANDA_SERVICE_DEFAULT);
+       port = (int)KAMANDA_SERVICE_DEFAULT;
     else
-       port = se->s_port;
+       port = ntohs(se->s_port);
     snprintf(handle, SIZEOF(handle), "%ld", (long)time(NULL));
     inithandle(kh, he, (int)port, handle);
     (*fn)(arg, &kh->sech, S_OK);
@@ -451,9 +453,9 @@ inithandle(
      * Setup our peer info.  We don't do anything with the sequence yet,
      * so just leave it at 0.
      */
-    kh->peer.sin_family = (sa_family_t)AF_INET;
-    kh->peer.sin_port = (in_port_t)port;
-    kh->peer.sin_addr = *(struct in_addr *)he->h_addr;
+    kh->peer.sin6_family = (sa_family_t)AF_INET6;
+    kh->peer.sin6_port = (in_port_t)port;
+    kh->peer.sin6_addr = *(struct in6_addr *)he->h_addr;
     strncpy(kh->proto_handle, handle, SIZEOF(kh->proto_handle) - 1);
     kh->proto_handle[SIZEOF(kh->proto_handle) - 1] = '\0';
     kh->sequence = 0;
@@ -532,7 +534,7 @@ krb4_sendpkt(
      * Add the body, and send it
      */
     dgram_cat(&netfd, pkt->body);
-    if (dgram_send_addr(kh->peer, &netfd) != 0) {
+    if (dgram_send_addr(&kh->peer, &netfd) != 0) {
        security_seterror(&kh->sech,
            "send %s to %s failed: %s", pkt_type2str(pkt->type),
            kh->hostname, strerror(errno));
@@ -972,7 +974,7 @@ recvpkt_callback(
     void *     cookie)
 {
     char handle[32];
-    struct sockaddr_in peer;
+    struct sockaddr_in6 peer;
     pkt_t pkt;
     int sequence;
     struct krb4_handle *kh;
@@ -995,9 +997,7 @@ recvpkt_callback(
 
     for (kh = handleq_first(); kh != NULL; kh = handleq_next(kh)) {
        if (strcmp(kh->proto_handle, handle) == 0 &&
-           memcmp(&kh->peer.sin_addr, &peer.sin_addr,
-           SIZEOF(peer.sin_addr)) == 0 &&
-           kh->peer.sin_port == peer.sin_port) {
+           cmp_sockaddr(&kh->peer, &peer, 0) == 0) {
            kh->sequence = sequence;
 
            /*
@@ -1021,12 +1021,12 @@ recvpkt_callback(
     if (accept_fn == NULL)
        return;
 
-    he = gethostbyaddr((void *)&peer.sin_addr, SIZEOF(peer.sin_addr), AF_INET);
+    he = gethostbyaddr((void *)&peer.sin6_addr, SIZEOF(peer.sin6_addr), AF_INET6);
     if (he == NULL)
        return;
     kh = alloc(SIZEOF(*kh));
     security_handleinit(&kh->sech, &krb4_security_driver);
-    inithandle(kh, he, (int)peer.sin_port, handle);
+    inithandle(kh, he, (int)peer.sin6_port, handle);
 
     /*
      * Check the security of the packet.  If it is bad, then pass NULL
@@ -1315,7 +1315,7 @@ check_ticket(
 
     /* get the checksum out of the ticket */
     rc = krb_rd_req(&ticket, CLIENT_HOST_PRINCIPLE, inst,
-       kh->peer.sin_addr.s_addr, &auth, CLIENT_HOST_KEY_FILE);
+       kh->peer.sin6_addr.s_addr, &auth, CLIENT_HOST_KEY_FILE);
     if (rc != 0) {
        security_seterror(&kh->sech,
            "krb_rd_req failed for %s: %s (%d)", kh->hostname,
@@ -1695,7 +1695,7 @@ net_read(
     char *buf = vbuf;  /* ptr arith */
     ssize_t n;
     int neof = 0;
-    fd_set readfds;
+    SELECT_ARG_TYPE readfds;
     struct timeval tv;
 
     while (size > 0) {