MEDIUM: tools: make str2sa_range() check for the sockpair's FD usability

Just like for inherited sockets, we want to make sure that FDs that are
mentioned in "sockpair@" are actually usable. Right now this test is
performed by the callers, but not everywhere. Typically, the following
config will fail if fd #5 is not bound:

  frontend
      bind sockpair@5

But this one will pass if fd #6 is not bound:

  backend
      server s1 sockpair@6

Now both will return an error in such a case:
   - 'bind' : cannot use file descriptor '5' : Bad file descriptor.
   - 'server s1' : cannot use file descriptor '6' : Bad file descriptor.

As such the test in str2listener() is not needed anymore (and it was
wrong by the way, as it used to test for the socket by overwriting the
local address with a new address that's made of the FD encoded on 16
bits and happens to still be at the same place, but that strictly
depends on whatever the kernel wants to put there).
diff --git a/src/tools.c b/src/tools.c
index db17fda..e543fd6 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -943,6 +943,8 @@
 		ss.ss_family = AF_UNSPEC;
 
 	if (ss.ss_family == AF_CUST_SOCKPAIR) {
+		struct sockaddr_storage ss2;
+		socklen_t addr_len;
 		char *endptr;
 
 		new_fd = strtol(str2, &endptr, 10);
@@ -951,6 +953,13 @@
 			goto out;
 		}
 
+		/* just verify that it's a socket */
+		addr_len = sizeof(ss2);
+		if (getsockname(new_fd, (struct sockaddr *)&ss2, &addr_len) == -1) {
+			memprintf(err, "cannot use file descriptor '%d' : %s.\n", new_fd, strerror(errno));
+			goto out;
+		}
+
 		((struct sockaddr_in *)&ss)->sin_addr.s_addr = new_fd;
 		((struct sockaddr_in *)&ss)->sin_port = 0;
 	}