FreeBSD(98) 2.0 and later よくある質問 : ネットワーク : 嘘つきネームサーバの対策を行なおうとして、libcをSUNSECUREを定義してコンパイルしました。しかし、逆引きの後の正引きを行なってくれないのはどうしてですか?
Previous: WIDE版sendmailを使いたいのですが、FreeBSD用のWIDE版Makefileがありません。どうしたらいいですか?
Next: FreeBSD(98)を``ディスクレス''で使用することはできますか?

8.8. 嘘つきネームサーバの対策を行なおうとして、libcをSUNSECUREを定義してコンパイルしました。しかし、逆引きの後の正引きを行なってくれないのはどうしてですか?

それは、SUNSECUREを定義しても、それを使っているところがどこにもないか らです。gethostbyaddrはIPアドレスから引いた値を無条件で返すことしかで きません。BIND-4.9.3を参考にして作成した、以下のパッチをあてることで、 SUNSECUREの定義が有効になります。なお、このパッチは非公式なものであり、 使用を推奨するものではありません。また、ネットワークの名前が取得できな くなることがあります。

<hr>

---- cut here ---- cut here ---- cut here ---- cut here ----
*** lib/libc/Makefile.orig	Mon May  8 23:56:11 1995
--- lib/libc/Makefile	Tue May  9 15:05:09 1995
***************
*** 8,14 ****
  LIB=c
  SHLIB_MAJOR= 2
  SHLIB_MINOR= 1
! CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS
  AINC=	-I${.CURDIR}/${MACHINE}
  CLEANFILES+=tags
  INSTALL_PIC_ARCHIVE=	yes
--- 8,14 ----
  LIB=c
  SHLIB_MAJOR= 2
  SHLIB_MINOR= 1
! CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -DSUNSECURITY
  AINC=	-I${.CURDIR}/${MACHINE}
  CLEANFILES+=tags
  INSTALL_PIC_ARCHIVE=	yes
*** lib/libc/net/gethostnamadr.c.orig	Mon May  8 23:41:11 1995
--- lib/libc/net/gethostnamadr.c	Tue May  9 17:24:10 1995
***************
*** 37,42 ****
--- 37,46 ----
  #include <ctype.h>
  #include <errno.h>
  #include <string.h>
+ #ifdef SUNSECURITY
+ #include <arpa/nameser.h>
+ #include <syslog.h>
+ #endif
  
  extern struct hostent * _gethostbyhtname  __P((const char *));
  extern struct hostent * _gethostbydnsname __P((const char *));
***************
*** 156,161 ****
--- 160,171 ----
  {
  	struct hostent *hp = 0;
  	int nserv = 0;
+ #ifdef SUNSECURITY
+ 	struct hostent *rhp = 0;
+ 	char **haddr;
+ 	char hname2[MAXDNAME+1];
+ 	char *addr2;
+ #endif
  
  	if (!service_done)
  		init_services();
***************
*** 176,181 ****
--- 186,213 ----
  		}
  		nserv++;
  	}
+ #ifdef SUNSECURITY
+ 	/*
+ 	 * turn off search as the name should be absolute,
+ 	 * 'localhost' should be matched by defnames
+ 	 */
+ 	strncpy(hname2, hp->h_name, MAXDNAME);
+ 	hname2[MAXDNAME] = '\0';
+ 	if (!(rhp = gethostbyname(hname2))) {
+ 		syslog(LOG_NOTICE|LOG_AUTH,
+ 		       "gethostbyaddr: No A record for %s (verifying [%s])",
+ 		       hname2, inet_ntoa(*((struct in_addr *)addr)));
+ 		return (NULL);
+ 	}
+ 	for (haddr = rhp->h_addr_list; *haddr; haddr++)
+ 		if (memcmp(*haddr,
+ 			addr, INADDRSZ)== 0)
+ 			return hp;
+ 	syslog(LOG_NOTICE|LOG_AUTH,
+ 	       "gethostbyaddr: A record of %s != PTR record [%s]",
+ 	       hname2, inet_ntoa(*((struct in_addr *)addr)));
+ 	return (NULL);
+ #endif
  	return hp;
  }
  
*** lib/libresolv/Makefile.orig	Tue May  9 00:48:56 1995
--- lib/libresolv/Makefile	Tue May  9 00:49:19 1995
***************
*** 1,7 ****
  #	@(#)Makefile	8.1 (Berkeley) 6/4/93
  
  LIB=resolv
! CFLAGS+=-DDEBUG -DLIBC_SCCS
  
  .PATH:	${.CURDIR}/../libc/net
  
--- 1,7 ----
  #	@(#)Makefile	8.1 (Berkeley) 6/4/93
  
  LIB=resolv
! CFLAGS+=-DDEBUG -DLIBC_SCCS -DSUNSECURITY
  
  .PATH:	${.CURDIR}/../libc/net
  
---- cut here ---- cut here ---- cut here ---- cut here ----
<hr>


FreeBSD(98) 2.0 and later よくある質問 : ネットワーク : 嘘つきネームサーバの対策を行なおうとして、libcをSUNSECUREを定義してコンパイルしました。しかし、逆引きの後の正引きを行なってくれないのはどうしてですか?
Previous: WIDE版sendmailを使いたいのですが、FreeBSD用のWIDE版Makefileがありません。どうしたらいいですか?
Next: FreeBSD(98)を``ディスクレス''で使用することはできますか?