Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jul 2012 15:56:30 +0000
From:      exxo@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r239472 - in soc2012/exxo: freebsd-head/include/rpcsvc freebsd-head/usr.bin/ypwhich openssl-1.0.1c/apps openssl-1.0.1c/crypto/bio
Message-ID:  <20120716155630.4B3DD106566B@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: exxo
Date: Mon Jul 16 15:56:29 2012
New Revision: 239472
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239472

Log:
  Openssl TODO fixes and ypwhich patch

Modified:
  soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h
  soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c
  soc2012/exxo/openssl-1.0.1c/apps/s_client.c
  soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c
  soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h

Modified: soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h
==============================================================================
--- soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h	Mon Jul 16 15:14:33 2012	(r239471)
+++ soc2012/exxo/freebsd-head/include/rpcsvc/yp_prot.h	Mon Jul 16 15:56:29 2012	(r239472)
@@ -199,7 +199,7 @@
 struct dom_binding {
 	struct dom_binding *dom_pnext;
 	char dom_domain[YPMAXDOMAIN + 1];
-	struct sockaddr_in dom_server_addr;
+	struct sockaddr_storage dom_server_addr;
 	u_short dom_server_port;
 	int dom_socket;
 	CLIENT *dom_client;
@@ -238,7 +238,11 @@
 
 /* network order, of course */
 struct ypbind_binding {
-	struct in_addr	ypbind_binding_addr;
+    	sa_family_t	ypbind_binding_family;
+	union {
+		struct in_addr	in;
+		struct in6_addr	in6;
+	} ypbind_binding_addr;
 	u_short		ypbind_binding_port;
 };
 

Modified: soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c
==============================================================================
--- soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c	Mon Jul 16 15:14:33 2012	(r239471)
+++ soc2012/exxo/freebsd-head/usr.bin/ypwhich/ypwhich.c	Mon Jul 16 15:56:29 2012	(r239472)
@@ -83,26 +83,32 @@
 	exit(ERR_USAGE);
 }
 
+#define ypb_family ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_family
+#define ypb_addr ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr
 
 /*
  * Like yp_bind except can query a specific host
  */
 static int
-bind_host(char *dom, struct sockaddr_in *lsin)
+bind_host(char *dom, const char *host)
 {
 	struct hostent *hent = NULL;
 	struct ypbind_resp ypbr;
 	struct timeval tv;
 	CLIENT *client;
-	int sock, r;
-	struct in_addr ss_addr;
+	int r;
+	char str[INET6_ADDRSTRLEN];
+	size_t len;
+	union {
+		struct in_addr	in;
+		struct in6_addr	in6;
+	} ss_addr;
 
-	sock = RPC_ANYSOCK;
 	tv.tv_sec = 15;
 	tv.tv_usec = 0;
-	client = clntudp_create(lsin, YPBINDPROG, YPBINDVERS, tv, &sock);
+	client = clnt_create_timed(host, YPBINDPROG, YPBINDVERS, "udp", &tv);
 	if (client == NULL) {
-		warnx("can't clntudp_create: %s", yperr_string(YPERR_YPBIND));
+		warnx("can't clnt_create_timed: %s", yperr_string(YPERR_YPBIND));
 		return (YPERR_YPBIND);
 	}
 
@@ -124,14 +130,16 @@
 		}
 	}
 	clnt_destroy(client);
-
-	ss_addr = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr;
-	/*printf("%08x\n", ss_addr);*/
-	hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET);
+	bcopy(&ypb_addr, &ss_addr, sizeof(ss_addr));
+	if (ypb_family == AF_INET)
+		len = sizeof(ss_addr.in);
+	else /* AF_INET6 */
+		len = sizeof(ss_addr.in6);
+	hent = gethostbyaddr((char *)&ss_addr, len, ypb_family);
 	if (hent)
 		printf("%s\n", hent->h_name);
 	else
-		printf("%s\n", inet_ntoa(ss_addr));
+		printf("%s\n", inet_ntop(ypb_family, &ss_addr, str, INET6_ADDRSTRLEN));
 	return (0);
 }
 
@@ -141,8 +149,7 @@
 	char *domnam = NULL, *master;
 	char *map = NULL;
 	struct ypmaplist *ypml, *y;
-	struct hostent *hent;
-	struct sockaddr_in lsin;
+	char *host;
 	int notrans, mode;
 	int c, r;
 	u_int i;
@@ -166,38 +173,20 @@
 			mode++;
 			break;
 		default:
-			usage();
+		    usage();
 		}
 
 	if (!domnam)
 		yp_get_default_domain(&domnam);
 
 	if (mode == 0) {
-		switch (argc-optind) {
-		case 0:
-			bzero(&lsin, sizeof lsin);
-			lsin.sin_family = AF_INET;
-			lsin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
-			if (bind_host(domnam, &lsin))
+	    	if (argc-optind == 0 || argc-optind == 1) {
+			host = argc-optind ? argv[optind] : "127.0.0.1";
+			if (bind_host(domnam, host))
 				exit(ERR_NOBINDING);
-			break;
-		case 1:
-			bzero(&lsin, sizeof lsin);
-			lsin.sin_family = AF_INET;
-			if ((lsin.sin_addr.s_addr = inet_addr(argv[optind])) == INADDR_NONE) {
-				hent = gethostbyname(argv[optind]);
-				if (!hent)
-					errx(ERR_NOSUCHHOST, "host %s unknown", argv[optind]);
-				bcopy((char *)hent->h_addr_list[0],
-					(char *)&lsin.sin_addr, sizeof lsin.sin_addr);
-			}
-			if (bind_host(domnam, &lsin))
-				exit(ERR_NOBINDING);
-			break;
-		default:
-			usage();
 		}
+		else
+			usage();
 		exit(0);
 	}
 

Modified: soc2012/exxo/openssl-1.0.1c/apps/s_client.c
==============================================================================
--- soc2012/exxo/openssl-1.0.1c/apps/s_client.c	Mon Jul 16 15:14:33 2012	(r239471)
+++ soc2012/exxo/openssl-1.0.1c/apps/s_client.c	Mon Jul 16 15:56:29 2012	(r239472)
@@ -686,8 +686,7 @@
 		else if (strcmp(*argv,"-connect") == 0)
 			{
 			if (--argc < 1) goto bad;
-			/* TODO 
-			if (!extract_host_port(*(++argv),&host,NULL,&port)) */
+			if (!BIO_extract_addr(*(++argv),&host,&port,NULL))
 				goto bad;
 			}
 		else if	(strcmp(*argv,"-verify") == 0)

Modified: soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c
==============================================================================
--- soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c	Mon Jul 16 15:14:33 2012	(r239471)
+++ soc2012/exxo/openssl-1.0.1c/crypto/bio/b_sock.c	Mon Jul 16 15:56:29 2012	(r239472)
@@ -113,8 +113,7 @@
 #endif
 
 static int get_ip(const char *str,unsigned char *ip);
-static int parse_ip(char *str, char **host, char **port, int *is_inet6);
-static int fill_addr(union sa_storage *sa, char *host, char *port, int is_inet6, int is_local);
+static int fill_addr(union sa_storage *sa, const char *host, const char *port, int is_inet6, int is_local);
 #if 0
 static void ghbn_free(struct hostent *a);
 static struct hostent *ghbn_dup(struct hostent *a);
@@ -774,42 +773,44 @@
 	return(1);
 	}
 
-static int parse_ip(char *str, char **host, char **port, int *is_inet6)
+int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6)
 	{
 	char *tmp;
 	char *h = *host = NULL;
 	char *p = *port = NULL;
 
-	*is_inet6 = 0; 
-	if (*str == '\0')
+	if (is_inet6)
+	    *is_inet6 = 0; 
+	if (*addr == '\0')
 		return (0);
-	if (*str == '[' && (tmp = strchr(str + 1, ']')))
+	if (*addr == '[' && (tmp = strchr(addr + 1, ']')))
 		{  
-		h = str + 1; 
+		h = addr + 1; 
 		*tmp++ = '\0';
 		if (*tmp == ':')
 			p = tmp + 1; 
 		else if (*tmp != '\0')
 			return (0);
-		*is_inet6 = 1; 
+		if (is_inet6)
+		    *is_inet6 = 1; 
 		}  
 	else
 		{  
-		if ((tmp = strchr(str, ':')))
+		if ((tmp = strchr(addr, ':')))
 			{
-			h = str;
+			h = addr;
 			*tmp++ = '\0';
 			p = tmp;
 			}
-		else if ((tmp = strchr(str, '/')))
+		else if ((tmp = strchr(addr, '/')))
 			{
 			if (*(tmp + 1) != '\0')
 			return (0);
-			p = str;
+			p = addr;
 			*tmp = '\0';
 			}
 		else
-			h = str;
+			h = addr;
 		}  
 	if (h && (*h == '\0' || !strcmp(h, "*")))
 		h = NULL;
@@ -820,7 +821,7 @@
 	return (1);
 	}
 
-static int fill_addr(union sa_storage *sa, char *host, char *port, int is_inet6, int is_local)
+static int fill_addr(union sa_storage *sa, const char *host, const char *port, int is_inet6, int is_local)
 	{ 
 	unsigned short p;
 	int sa_len = 0;
@@ -889,7 +890,7 @@
 	char *h, *p;
 	int is_inet6 = 0;
 
-	if (parse_ip(host, &h, &p, &is_inet6) != 1)
+	if (BIO_extract_addr(host, &h, &p, &is_inet6) != 1)
 		{
 		BIOerr(BIO_F_BIO_GET_HOST_ADDR,BIO_R_INVALID_IP_ADDRESS);
 		return (0);
@@ -912,7 +913,7 @@
 
 	if (BIO_sock_init() != 1) return(INVALID_SOCKET);
 	if ((str=BUF_strdup(host)) == NULL) return(INVALID_SOCKET);
-	if (parse_ip(str, &h, &p, &is_inet6) != 1)
+	if (BIO_extract_addr(str, &h, &p, &is_inet6) != 1)
 		{
 		BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_INVALID_IP_ADDRESS);
 		goto err;

Modified: soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h
==============================================================================
--- soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h	Mon Jul 16 15:14:33 2012	(r239471)
+++ soc2012/exxo/openssl-1.0.1c/crypto/bio/bio.h	Mon Jul 16 15:56:29 2012	(r239472)
@@ -76,10 +76,12 @@
 # endif
 #endif
 
-/* TODO Under which conditions include the following ? */
+/* TODO Under which conditions include the following OPENSSL_SYS_UNIX ? */
+#ifdef OPENSSL_SYS_UNIX
 #include <netdb.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#endif
 
 #ifdef  __cplusplus
 extern "C" {
@@ -780,6 +782,7 @@
 int BIO_get_port(const char *str, unsigned short *port_ptr);
 int BIO_get_host_ip(const char *str, unsigned char *ip);
 int BIO_get_host_ip6(const char *str, unsigned char *ip, unsigned char mode);
+int BIO_extract_addr(char *addr, char **host, char **port, int *is_inet6);
 int BIO_get_accept_socket(char *host_port,int mode);
 int BIO_accept(int sock,char **ip_port);
 int BIO_sock_init(void );



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120716155630.4B3DD106566B>