[comp.sys.ibm.pc.rt] Fix for libc, part 1 of 3, IBM/4.3

brunner@bullhead.uucp (12/05/89)

Subject: Fix for libc (part 1)
Index: /usr/src/lib/libc IBM/4.3

Description:
	The C library name resolver code distributed in the December
	release does not contain all of the routines in the post-4.3
	Berkeley release. Compilation of Tahoe-release versions of
	sendmail (5.61) and named (4.8) fail. This kit adds files to
	and patches existing files in the include and libc source trees.

	When this kit is installed and the library has been rebuilt and
	reinstalled replacement of named and sendmail only requires the
	usual make install sequence. (See /usr/src/Makefile, and
	/usr/src/lib/libc/Makefile)

	Sendmail version 5.61 and named (aka "BIND") version 4.8 are
	available via anonymous ftp at numerous sites on the Internet.
	For the benefit of sites without Internet access, compressed tar
	images of each are available via uucp from ibmsupt, the sizes
	are:

		314397 named4.8.tar.Z
		473205 sendmail5.61.tar.Z

	It is strongly recommended that the versions of sendmail and
	named shipped with the December 88 release be replaced with
	these versions.

	This is part 1 of a 3 part patch installation kit. The contents
	of the kit are:

part 1  patchs to the following files in /usr/src/include:
	netdb.h, resolve and arpa/nameser.h

part 2  shar file containing the following files in /usr/src/lib/libc:
	gen/{setenv.c, strcasecmp.c}
	net/{herror.c, res_query.c}
        
part 3  patchs to the following files in /usr/src/lib/libc:
	gen/{Makefile, getenv.c}
	net/{Makefile, res_comp.c, res_debug.c, res_init.c, res_mkquery.c,
	and res_send.c}

Fix:	Change directories to /usr/src/include and apply the following
	patch, e.g.,

		patch -p1 < this_file

	Proceede to the next part of the kit.


diff -r -c include.dist/netdb.h include.fix/netdb.h
*** include.dist/netdb.h	Fri Dec  9 11:27:48 1988
--- include.fix/netdb.h	Wed Nov 22 14:41:26 1989
***************
*** 2,23 ****
   * 5799-WZQ (C) COPYRIGHT = NONE
   * LICENSED MATERIALS - PROPERTY OF IBM
   */
! /* $Header:netdb.h 12.0$ */
  /* $ACIS:netdb.h 12.0$ */
! /* $Source: /ibm/acis/usr/src/include/RCS/netdb.h,v $ */
  
  #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidnetdb = "$Header:netdb.h 12.0$";
  #endif
  
  #include <sys/nfs_defines.h>
  
  /*
!  * Copyright (c) 1980 Regents of the University of California.
!  * All rights reserved.  The Berkeley software License Agreement
!  * specifies the terms and conditions for redistribution.
   *
!  *	@(#)netdb.h	5.7 (Berkeley) 5/12/86
   */
  
  #ifdef NFS
--- 2,34 ----
   * 5799-WZQ (C) COPYRIGHT = NONE
   * LICENSED MATERIALS - PROPERTY OF IBM
   */
! /* $Header: netdb.h,v 12.2 89/11/22 14:41:24 root Locked $ */
  /* $ACIS:netdb.h 12.0$ */
! /* $Source: /fish/src/include/RCS/netdb.h,v $ */
  
  #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidnetdb = "$Header: netdb.h,v 12.2 89/11/22 14:41:24 root Locked $";
  #endif
  
  #include <sys/nfs_defines.h>
  
  /*
!  * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
!  * All rights reserved.
   *
!  * Redistribution and use in source and binary forms are permitted
!  * provided that the above copyright notice and this paragraph are
!  * duplicated in all such forms and that any documentation,
!  * advertising materials, and other materials related to such
!  * distribution and use acknowledge that the software was developed
!  * by the University of California, Berkeley.  The name of the
!  * University may not be used to endorse or promote products derived
!  * from this software without specific prior written permission.
!  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
!  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
!  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
!  *
!  *	@(#)netdb.h	5.10 (Berkeley) 6/27/88
   */
  
  #ifdef NFS
***************
*** 80,90 ****
  
  /*
   * Error return codes from gethostbyname() and gethostbyaddr()
   */
  
! extern  int h_errno;	
  
! #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
  #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
  #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
! #define NO_ADDRESS	4 /* Valid host name, no address, look for MX record */
--- 91,103 ----
  
  /*
   * Error return codes from gethostbyname() and gethostbyaddr()
+  * (left in extern int h_errno).
   */
  
! extern  int h_errno;
  
! #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
  #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
  #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
! #define	NO_DATA		4 /* Valid name, no data record of requested type */
! #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
diff -r -c include.dist/resolv.h include.fix/resolv.h
*** include.dist/resolv.h	Fri Dec  9 11:27:57 1988
--- include.fix/resolv.h	Mon Nov 20 14:07:53 1989
***************
*** 2,22 ****
   * 5799-WZQ (C) COPYRIGHT = NONE
   * LICENSED MATERIALS - PROPERTY OF IBM
   */
! /* $Header:resolv.h 12.0$ */
  /* $ACIS:resolv.h 12.0$ */
! /* $Source: /ibm/acis/usr/src/include/RCS/resolv.h,v $ */
  
  #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidresolv = "$Header:resolv.h 12.0$";
  #endif
  
- 
  /*
!  * Copyright (c) 1983 Regents of the University of California.
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)resolv.h	5.4 (Berkeley) 2/22/86
   */
  
  /*
--- 2,21 ----
   * 5799-WZQ (C) COPYRIGHT = NONE
   * LICENSED MATERIALS - PROPERTY OF IBM
   */
! /* $Header: resolv.h,v 12.1 89/11/20 14:07:52 root Locked $ */
  /* $ACIS:resolv.h 12.0$ */
! /* $Source: /fish/src/include/RCS/resolv.h,v $ */
  
  #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidresolv = "$Header: resolv.h,v 12.1 89/11/20 14:07:52 root Locked $";
  #endif
  
  /*
!  * Copyright (c) 1983, 1987 Regents of the University of California.
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)resolv.h	5.5 (Berkeley) 5/12/87
   */
  
  /*
***************
*** 25,31 ****
--- 24,33 ----
  
  
  #define	MAXNS		3		/* max # name servers we'll track */
+ #define	MAXDNSRCH	3		/* max # default domain levels to try */
+ #define	LOCALDOMAINPARTS 2		/* min levels in name that is "local" */
  
+ #define	RES_TIMEOUT	4		/* seconds between retries */
  
  struct state {
  	int	retrans;	 	/* retransmition time interval */
***************
*** 36,41 ****
--- 38,44 ----
  #define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
  	u_short	id;			/* current packet id */
  	char	defdname[MAXDNAME];	/* default domain */
+ 	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
  };
  
  /*
***************
*** 50,55 ****
--- 53,61 ----
  #define RES_RECURSE	0x0040		/* recursion desired */
  #define RES_DEFNAMES	0x0080		/* use default domain name */
  #define RES_STAYOPEN	0x0100		/* Keep TCP socket open */
+ #define RES_DNSRCH	0x0200		/* search up local domain tree */
+ 
+ #define RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
  
  extern struct state _res;
  extern char *p_cdname(), *p_rr(), *p_type(), *p_class();
diff -r -c include.dist/arpa/nameser.h include.fix/arpa/nameser.h
*** include.dist/arpa/nameser.h	Fri Dec  9 11:27:11 1988
--- include.fix/arpa/nameser.h	Mon Nov 20 14:08:18 1989
***************
*** 2,21 ****
   * 5799-WZQ (C) COPYRIGHT = NONE
   * LICENSED MATERIALS - PROPERTY OF IBM
   */
! /* $Header:nameser.h 12.0$ */
  /* $ACIS:nameser.h 12.0$ */
! /* $Source: /ibm/acis/usr/src/include/arpa/RCS/nameser.h,v $ */
  
  #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidnameser = "$Header:nameser.h 12.0$";
  #endif
  
  /*
   * Copyright (c) 1983 Regents of the University of California.
!  * All rights reserved.  The Berkeley software License Agreement
!  * specifies the terms and conditions for redistribution.
   *
!  *	@(#)nameser.h	5.11 (Berkeley) 2/14/86
   */
  
  /*
--- 2,32 ----
   * 5799-WZQ (C) COPYRIGHT = NONE
   * LICENSED MATERIALS - PROPERTY OF IBM
   */
! /* $Header: nameser.h,v 12.1 89/11/20 14:08:17 root Locked $ */
  /* $ACIS:nameser.h 12.0$ */
! /* $Source: /fish/src/include/arpa/RCS/nameser.h,v $ */
  
  #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidnameser = "$Header: nameser.h,v 12.1 89/11/20 14:08:17 root Locked $";
  #endif
  
  /*
   * Copyright (c) 1983 Regents of the University of California.
!  * All rights reserved.
   *
!  * Redistribution and use in source and binary forms are permitted
!  * provided that the above copyright notice and this paragraph are
!  * duplicated in all such forms and that any documentation,
!  * advertising materials, and other materials related to such
!  * distribution and use acknowledge that the software was developed
!  * by the University of California, Berkeley.  The name of the
!  * University may not be used to endorse or promote products derived
!  * from this software without specific prior written permission.
!  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
!  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
!  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
!  *
!  *	@(#)nameser.h	5.18 (Berkeley) 6/27/88
   */
  
  /*
***************
*** 38,54 ****
  /*
   * Currently defined opcodes
   */
! #define QUERY		0		/* standard query */
! #define IQUERY		1		/* inverse query */
! #define CQUERYM		2		/* completion query (multiple) */
! #define CQUERYU		3		/* completion query (unique) */
  	/* non standard */
! #define UPDATEA		100		/* add resource record */
! #define UPDATED		101		/* delete resource record */
! #define UPDATEM		102		/* modify resource record */
! #define ZONEINIT	103		/* initial zone transfer */
! #define ZONEREF		104		/* incremental zone referesh */
  
  /*
   * Currently defined response codes
   */
--- 49,68 ----
  /*
   * Currently defined opcodes
   */
! #define QUERY		0x0		/* standard query */
! #define IQUERY		0x1		/* inverse query */
! #define STATUS		0x2		/* nameserver status query */
! /*#define xxx		0x3		/* 0x3 reserved */
  	/* non standard */
! #define UPDATEA		0x9		/* add resource record */
! #define UPDATED		0xa		/* delete a specific resource record */
! #define UPDATEDA	0xb		/* delete all nemed resource record */
! #define UPDATEM		0xc		/* modify a specific resource record */
! #define UPDATEMA	0xd		/* modify all named resource record */
  
+ #define ZONEINIT	0xe		/* initial zone transfer */
+ #define ZONEREF		0xf		/* incremental zone referesh */
+ 
  /*
   * Currently defined response codes
   */
***************
*** 59,65 ****
  #define NOTIMP		4		/* not implemented */
  #define REFUSED		5		/* query refused */
  	/* non standard */
! #define NOCHANGE	100		/* update failed to change db */
  
  /*
   * Type values for resources and queries
--- 73,79 ----
  #define NOTIMP		4		/* not implemented */
  #define REFUSED		5		/* query refused */
  	/* non standard */
! #define NOCHANGE	0xf		/* update failed to change db */
  
  /*
   * Type values for resources and queries
***************
*** 83,88 ****
--- 97,103 ----
  #define T_UINFO		100		/* user (finger) information */
  #define T_UID		101		/* user ID */
  #define T_GID		102		/* group ID */
+ #define T_UNSPEC	103		/* Unspecified format (binary data) */
  	/* Query type values which do not appear in resource records */
  #define T_AXFR		252		/* transfer zone of authority */
  #define T_MAILB		253		/* transfer mailbox records */
***************
*** 99,104 ****
--- 114,128 ----
  #define C_ANY		255		/* wildcard match */
  
  /*
+  * Status return codes for T_UNSPEC conversion routines
+  */
+ #define CONV_SUCCESS 0
+ #define CONV_OVERFLOW -1
+ #define CONV_BADFMT -2
+ #define CONV_BADCKSUM -3
+ #define CONV_BADBUFLEN -4
+ 
+ /*
   * Structure for query header, the order of the fields is machine and
   * compiler dependent, in our case, the bits within a byte are assignd 
   * least significant first, while the order of transmition is most 
***************
*** 108,115 ****
  typedef struct {
  	u_short	id;		/* query identification number */
  #if defined (sun) || defined (sel) || defined (pyr) || defined (is68k) \
! || defined (tahoe) || defined (ibm032) || defined (ibm370) \
! || defined (BIT_ZERO_ON_LEFT)
  	/* Bit zero on left:  Gould and similar architectures */
  			/* fields in third byte */
  	u_char	qr:1;		/* response flag */
--- 132,138 ----
  typedef struct {
  	u_short	id;		/* query identification number */
  #if defined (sun) || defined (sel) || defined (pyr) || defined (is68k) \
! || defined (tahoe)  || defined (ibm032) || defined (BIT_ZERO_ON_LEFT)
  	/* Bit zero on left:  Gould and similar architectures */
  			/* fields in third byte */
  	u_char	qr:1;		/* response flag */
***************
*** 123,129 ****
  	u_char	unused:2;	/* unused bits */
  	u_char	rcode:4;	/* response code */
  #else
! #if defined (vax) || defined (BIT_ZERO_ON_RIGHT)
  	/* Bit zero on right:  VAX */
  			/* fields in third byte */
  	u_char	rd:1;		/* recursion desired */
--- 146,152 ----
  	u_char	unused:2;	/* unused bits */
  	u_char	rcode:4;	/* response code */
  #else
! #if defined (vax) || defined(ns32000) || defined (BIT_ZERO_ON_RIGHT)
  	/* Bit zero on right:  VAX */
  			/* fields in third byte */
  	u_char	rd:1;		/* recursion desired */
***************
*** 165,169 ****
  	char	*r_data;		/* pointer to data */
  };
  
! extern	u_short	getshort();
! extern	u_long	getlong();
--- 188,227 ----
  	char	*r_data;		/* pointer to data */
  };
  
! extern	u_short	_getshort();
! extern	u_long	_getlong();
! 
! /*
!  * Inline versions of get/put short/long.
!  * Pointer is advanced; we assume that both arguments
!  * are lvalues and will already be in registers.
!  * cp MUST be u_char *.
!  */
! #define GETSHORT(s, cp) { \
! 	(s) = *(cp)++ << 8; \
! 	(s) |= *(cp)++; \
! }
! 
! #define GETLONG(l, cp) { \
! 	(l) = *(cp)++ << 8; \
! 	(l) |= *(cp)++; (l) <<= 8; \
! 	(l) |= *(cp)++; (l) <<= 8; \
! 	(l) |= *(cp)++; \
! }
! 
! 
! #define PUTSHORT(s, cp) { \
! 	*(cp)++ = (s) >> 8; \
! 	*(cp)++ = (s); \
! }
! 
! /*
!  * Warning: PUTLONG destroys its first argument.
!  */
! #define PUTLONG(l, cp) { \
! 	(cp)[3] = l; \
! 	(cp)[2] = (l >>= 8); \
! 	(cp)[1] = (l >>= 8); \
! 	(cp)[0] = l >> 8; \
! 	(cp) += sizeof(u_long); \
! }

Eric Brunner, Consultant, IBM AWD Palo Alto	(415) 855-4486
inet: brunner@monet.berkeley.edu
uucp: uunet!ibmsupt!brunner