[Fedora-directory-commits] adminserver/admserv/cgi-src40 config.c, 1.16, 1.17

Nathan Kinder nkinder at fedoraproject.org
Wed Jan 28 21:26:01 UTC 2009


Author: nkinder

Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv19994/admserv/cgi-src40

Modified Files:
	config.c 
Log Message:
Resolves: 430364
Summary: Allow listen address to be passed in via installer.



Index: config.c
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/config.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- config.c	4 Dec 2008 20:01:28 -0000	1.16
+++ config.c	28 Jan 2009 21:25:58 -0000	1.17
@@ -1037,13 +1037,9 @@
 #endif
 
 static int validate_addr(char* ip) {
-
-  char systemInfo[SYS_INFO_BUFFER_LENGTH];
-  char buf[PR_NETDB_BUF_SIZE];
-  PRIntn index;
-  PRNetAddr  netaddr, netaddr1;
-  PRStatus   pr_st;
-  PRHostEnt  hostentry;
+  PRNetAddr  netaddr;
+  PRFileDesc *sock = NULL;
+  int ret = 0;
 
   /* If ip address is not define, it means that server should listen on all interfaces */
   if (ip==NULL || *ip=='\0') return 1;
@@ -1052,18 +1048,16 @@
   if (!strcmp(ip, "127.0.0.1")) return 1;
   if (!strcmp(ip, "0.0.0.0")) return 1;
 
-  PR_StringToNetAddr(ip, &netaddr);
-
-  pr_st = PR_GetSystemInfo(PR_SI_HOSTNAME, systemInfo, SYS_INFO_BUFFER_LENGTH);
-
-  pr_st = PR_GetHostByName(systemInfo, buf, PR_NETDB_BUF_SIZE, &hostentry);
-
-  index = 0;
-  while ((index = PR_EnumerateHostEnt(index, &hostentry, 8000, &netaddr1))) {
-    if (netaddr1.inet.ip == netaddr.inet.ip)  return 1;
+  if (PR_StringToNetAddr(ip, &netaddr) == PR_SUCCESS) {
+    if ((sock = PR_NewTCPSocket()) != NULL) {
+      if (PR_Bind(sock, &netaddr) == PR_SUCCESS) {
+        ret = 1;
+      }
+      PR_Close(sock);
+    }
   }
-  
-  return 0;
+
+  return ret;
 }
 
 /*




More information about the Fedora-directory-commits mailing list