[krbdev.mit.edu #1435] cygwin does not have inet_ntop when compiling kdc

The RT System itself via RT rt-comment at krbdev.mit.edu
Sun Apr 20 19:42:30 EDT 2003


>From liebman at zod.com  Sun Apr 20 19:42:27 2003
Received: from fort-point-station.mit.edu (FORT-POINT-STATION.MIT.EDU [18.7.7.76]) by krbdev.mit.edu (8.9.3) with ESMTP
	id TAA18610; Sun, 20 Apr 2003 19:42:27 -0400 (EDT)
From: liebman at zod.com
Received: from zod.com (66-215-26-54.pas-mres.charterpipeline.net [66.215.26.54])
	by fort-point-station.mit.edu (8.12.4/8.9.2) with ESMTP id h3KNgQGm002403
	for <krb5-bugs at mit.edu>; Sun, 20 Apr 2003 19:42:27 -0400 (EDT)
Received: from liebman by zod.com with local (Exim 4.14)
	id HDO1UE-0001HK-9S
	for krb5-bugs at mit.edu; Sun, 20 Apr 2003 16:42:14 -0700
To: krb5-bugs at mit.edu
Subject: cygwin patch for keb5-current and 1.3alpha2 patch #2
Reply-To: liebman at zod.com
Cc: 
X-send-pr-version: 3.99
Message-Id: <EHDO1UE-0001HK-9S at zod.com>
Date: Sun, 20 Apr 2003 16:42:14 -0700


>Submitter-Id:	net
>Originator:	Christopher B. Liebman
>Organization:
	none
>Confidential:	no
>Synopsis:	cygwin does not have inet_ntop when compiling kdc
>Severity:	non-critical
>Priority:	low
>Category:	krb5-kdc
>Class:		sw-bug
>Release:	krb5-current-20030419
>Environment:
	
System: CYGWIN_NT-5.0 XYZZY 1.3.22(0.78/3/2) 2003-03-18 09:20 i686 unknown unknown Cygwin


>Description:
	when compiling the kdc it fails with inet_ntop as undefined
>How-To-Repeat:
	configure and type make
>Fix:
	Only use inet_ntop if HAVE_INET_NTOP is defined.  The following patch
	edits the 4 files in the kdc that use inet_ntop.
	


diff -u -r krb5-current-dist/src/kdc/dispatch.c krb5-current/src/kdc/dispatch.c
--- krb5-current-dist/src/kdc/dispatch.c	2002-09-17 00:00:34.000000000 -0700
+++ krb5-current/src/kdc/dispatch.c	2003-04-20 14:03:26.000000000 -0700
@@ -55,8 +55,20 @@
 	const char *name = 0;
 	char buf[46];
 
+#ifdef HAVE_INET_NTOP
 	name = inet_ntop (ADDRTYPE2FAMILY (from->address->addrtype),
 			  from->address->contents, buf, sizeof (buf));
+#else
+	if (from->address->addrtype == ADDRTYPE_INET) {
+	    struct sockaddr_in *sin
+		= (struct sockaddr_in *)from->address->contents;
+	    if (name = inet_ntoa (sin->sin_addr))
+	    {
+	        strcpy (buf, name);
+	        name = buf;
+	    }
+	}
+#endif
 	if (name == 0)
 	    name = "[unknown address type]";
 	krb5_klog_syslog(LOG_INFO,
diff -u -r krb5-current-dist/src/kdc/do_as_req.c krb5-current/src/kdc/do_as_req.c
--- krb5-current-dist/src/kdc/do_as_req.c	2002-11-04 00:00:44.000000000 -0800
+++ krb5-current/src/kdc/do_as_req.c	2003-04-20 13:57:28.000000000 -0700
@@ -89,9 +89,14 @@
     ktypes2str(ktypestr, sizeof(ktypestr),
 	       request->nktypes, request->ktype);
 
+#ifdef HAVE_INET_NTOP
     fromstring = inet_ntop(ADDRTYPE2FAMILY (from->address->addrtype),
 			   from->address->contents,
 			   fromstringbuf, sizeof(fromstringbuf));
+#else
+    if (from->address->addrtype == ADDRTYPE_INET)
+	fromstring = (char *) inet_ntoa(*(struct in_addr *)from->address->contents);
+#endif
     if (!fromstring)
 	fromstring = "<unknown>";
 
diff -u -r krb5-current-dist/src/kdc/do_tgs_req.c krb5-current/src/kdc/do_tgs_req.c
--- krb5-current-dist/src/kdc/do_tgs_req.c	2003-04-02 00:00:46.000000000 -0800
+++ krb5-current/src/kdc/do_tgs_req.c	2003-04-20 13:57:28.000000000 -0700
@@ -103,9 +103,15 @@
     if ((retval = setup_server_realm(request->server)))
 	return retval;
 
+#ifdef HAVE_INET_NTOP
     fromstring = inet_ntop(ADDRTYPE2FAMILY(from->address->addrtype),
 			   from->address->contents,
 			   fromstringbuf, sizeof(fromstringbuf));
+#else
+    if (from->address->addrtype == ADDRTYPE_INET)
+	fromstring =
+	    (char *) inet_ntoa(*(struct in_addr *)from->address->contents);
+#endif
     if (!fromstring)
 	fromstring = "<unknown>";
 
diff -u -r krb5-current-dist/src/kdc/network.c krb5-current/src/kdc/network.c
--- krb5-current-dist/src/kdc/network.c	2003-01-04 00:00:42.000000000 -0800
+++ krb5-current/src/kdc/network.c	2003-04-20 13:57:28.000000000 -0700
@@ -742,10 +742,24 @@
     if (cc == -1) {
 	char addrbuf[46];
         krb5_free_data(kdc_context, response);
+#ifdef HAVE_INET_NTOP
 	if (inet_ntop(((struct sockaddr *)&saddr)->sa_family,
 		      addr.contents, addrbuf, sizeof(addrbuf)) == 0) {
 	    strcpy(addrbuf, "?");
 	}
+#else
+        {
+            char* addrstr;
+	    if (addrstr = inet_ntoa(((struct sockaddr_in *)&saddr)->sin_addr))
+	    {
+	        strncpy(addrbuf, addrstr, sizeof(addrbuf));
+	    }
+	    else
+	    {
+	        strcpy(addrbuf, "?");
+	    }
+	}
+#endif
 	com_err(prog, errno, "while sending reply to %s/%d",
 		addrbuf, faddr.port);
 	return;



More information about the krb5-bugs mailing list