Subject: Collected Debian patches for remctl
Author: Russ Allbery <rra@debian.org>

Since I am also upstream for this package, there will normally not be any
patches to apply to the upstream source.  However, occasionally I'll pull
up specific upstream commits prior to making an upstream release.  When
this happens, this patch will collect all of those modifications.

I use Git to maintain both the upstream source and the Debian packages,
and generating individual patches rather than using git cherry-pick takes
extra work for no gain.  Since I'm also upstream, there's no need to
separate the patches for later upstream submission.  Hence, I take this
approach with a unified patch when it's necessary.

For full commit history and separated commits, see the upstream Git
repsitory.
--- remctl-3.0.orig/tests/portable/getaddrinfo-t.c
+++ remctl-3.0/tests/portable/getaddrinfo-t.c
@@ -236,7 +236,10 @@ main(void)
         skip("lookup of addrinfo-test.invalid succeeded");
     else {
         result = test_getaddrinfo("addrinfo-test.invalid", NULL, NULL, &ai);
-        is_int(EAI_NONAME, result, "lookup of invalid address");
+        if (result == EAI_AGAIN || result == EAI_FAIL)
+            skip("lookup of invalid address returns DNS failure");
+        else
+            is_int(EAI_NONAME, result, "lookup of invalid address");
     }
 
     host = gethostbyname("cnn.com");
--- remctl-3.0.orig/tests/util/network-t.c
+++ remctl-3.0/tests/util/network-t.c
@@ -259,7 +259,7 @@ test_all(const char *source_ipv4, const
         fd = fds[i];
         if (listen(fd, 1) < 0) {
             sysdiag("cannot listen to socket %d", fd);
-            ok_block(3, 0, "all address server test");
+            ok_block(4, 0, "all address server test (part %d)", i);
         } else {
             ok(1, "all address server test (part %d)", i);
             size = sizeof(saddr);
@@ -289,7 +289,7 @@ test_all(const char *source_ipv4, const
         }
     }
     if (count == 1)
-        skip_block(3, "only one listening socket");
+        skip_block(4, "only one listening socket");
     network_bind_all_free(fds);
 }
 
@@ -410,7 +410,7 @@ test_timeout_ipv4(void)
         _exit(0);
     } else {
         socket_type block[20];
-        int i;
+        int i, err;
 
         close(fd);
         c = network_connect_host("127.0.0.1", 11119, NULL, 1);
@@ -427,14 +427,23 @@ test_timeout_ipv4(void)
             if (block[i] == INVALID_SOCKET)
                 break;
         }
-        diag("Finally timed out on socket %d", i);
-        ok(block[i] == INVALID_SOCKET, "Timeout: later connection timed out");
-        is_int(ETIMEDOUT, socket_errno, "...with correct error");
+        err = socket_errno;
+        if (i == ARRAY_SIZE(block))
+            skip_block(2, "short listen queue does not prevent connections");
+        else {
+            diag("Finally timed out on socket %d", i);
+            ok(block[i] == INVALID_SOCKET, "Later connection timed out");
+            if (err == ECONNRESET)
+                skip("connections rejected without timeout");
+            else
+                skip("error code would have been %d (ETIMEDOUT: %d)", err,
+                     ETIMEDOUT);
+        }
         alarm(0);
         kill(child, SIGTERM);
         waitpid(child, NULL, 0);
         close(c);
-        for (; i >= 0; i--)
+        for (i--; i >= 0; i--)
             if (block[i] != INVALID_SOCKET)
                 close(block[i]);
     }
@@ -484,7 +493,7 @@ main(void)
     if (ipv6)
         test_all(NULL, NULL);
     else
-        skip_block(6, "IPv6 not configured");
+        skip_block(8, "IPv6 not configured");
     test_create_ipv4(NULL);
 
     /* This won't make a difference for loopback connections. */
@@ -493,7 +502,7 @@ main(void)
     if (ipv6)
         test_all("127.0.0.1", "::1");
     else
-        skip_block(6, "IPv6 not configured");
+        skip_block(8, "IPv6 not configured");
     test_create_ipv4("127.0.0.1");
 
     /* Test network_accept_any. */
--- remctl-3.0.orig/perl/Makefile.PL.in
+++ remctl-3.0/perl/Makefile.PL.in
@@ -1,7 +1,7 @@
 # Makefile.PL for libremctl Perl bindings.  -*- perl -*-
 #
 # Written by Russ Allbery
-# Copyright 2007
+# Copyright 2007, 2012
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # See LICENSE for licensing terms.
@@ -38,7 +38,7 @@ $lddlflags =~ s%(^| )-L% $additions -L%;
 package MY;
 sub const_loadlibs {
     my $loadlibs = shift->SUPER::const_loadlibs (@_);
-    $loadlibs =~ s%^(LD_RUN_PATH =.*[\s:])$main::PATH(:|\n)%$1$2%m;
+    $loadlibs =~ s%^(LD_RUN_PATH =.*[\s:])\Q$main::PATH\E(:|\n)%$1$2%m;
     return $loadlibs;
 }
 package main;
