components/procmail/patches/03-procmail-3.22-ipv6.patch
branchs11-update
changeset 2723 138732f62341
equal deleted inserted replaced
2722:dc566ca73390 2723:138732f62341
       
     1 --- procmail-3.22/src/autoconf.ipv6	2006-10-24 14:46:44.000000000 +0200
       
     2 +++ procmail-3.22/src/autoconf	2006-10-24 14:51:01.000000000 +0200
       
     3 @@ -68,8 +68,6 @@
       
     4  #	#define NOfsync
       
     5  #Ok	#define endpwent()
       
     6  #Ok	#define endgrent()
       
     7 -#Ok	#define endhostent()
       
     8 -#Ok	#define endservent()
       
     9  #Ok	#define endprotoent()
       
    10  #	#define h_0addr_list h_addr
       
    11  #Ok	#define NOpw_passwd
       
    12 @@ -896,7 +894,7 @@
       
    13   {uid_t vuid_t;i+=vuid_t=1;}
       
    14   {gid_t vgid_t;i+=vgid_t=1;}
       
    15  #ifndef NO_COMSAT
       
    16 - {struct hostent vhostent;i+=!(vhostent.h_addr_list=0);}
       
    17 + {struct addrinfo res; i+=!(res.ai_socktype=0);}
       
    18  #endif
       
    19  #ifndef NOuname
       
    20   {struct utsname vutsname;i+=!(*vutsname.nodename='\0');}
       
    21 @@ -917,8 +915,6 @@
       
    22    test -z "$i3" && grepfor mode_t 'typedef int mode_t;' && i3=I
       
    23    test -z "$i4" && grepfor uid_t 'typedef int uid_t;' && i4=I
       
    24    test -z "$i5" && grepfor gid_t 'typedef int gid_t;' && i5=I
       
    25 -  test -z "$i6" && grepfor h_addr_list '#define h_0addr_list h_addr' && i6=I
       
    26 -  test -z "$i6" && grepfor hostent '#define h_0addr_list h_addr' && i6=I
       
    27    test -z "$i6" && grepfor member '#define h_0addr_list h_addr' && i6=I
       
    28    test -z "$i7" && grepfor utsname "#define NOuname			      \
       
    29  /* <sys/utsname.h> is there, but empty */" && i7=I
       
    30 @@ -1048,8 +1044,12 @@
       
    31   {struct utsname b;uname(&b);}
       
    32  #endif
       
    33  #ifndef NO_COMSAT
       
    34 - gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent();
       
    35 - endprotoent();
       
    36 + {
       
    37 + struct addrinfo *res, hints;
       
    38 + memset(&hints, '\0', sizeof(hints));
       
    39 + if(getaddrinfo(COMSAThost,BIFF_serviceport,&hints,&res))
       
    40 + 	freeaddrinfo(res);
       
    41 + }
       
    42  #endif
       
    43   _exit(0);
       
    44   return 0;}
       
    45 @@ -1103,14 +1103,9 @@
       
    46  /* <sys/utsname.h> defines it, the libraries don't */"
       
    47  grepfor endpwent '#define endpwent()'
       
    48  grepfor endgrent '#define endgrent()'
       
    49 -if grepfor gethostbyname '#define NO_COMSAT'
       
    50 +if grepfor getaddrinfo '#define NO_COMSAT'
       
    51  then
       
    52  :
       
    53 -else
       
    54 -  grepfor getprotobyname '#define UDP_protocolno 17'
       
    55 -  grepfor endhostent '#define endhostent()'
       
    56 -  grepfor endservent '#define endservent()'
       
    57 -  grepfor endprotoent '#define endprotoent()'
       
    58  fi
       
    59  grepfor strstr '#define SLOWstrstr' ||
       
    60   grepfor clock '#define SLOWstrstr'
       
    61 @@ -1239,39 +1234,9 @@
       
    62  	printf("/* Insufficient memory to perform the benchmark! */\n");
       
    63  #endif /* SLOWstrstr */
       
    64  #ifndef NO_COMSAT
       
    65 -#ifndef UDP_protocolno
       
    66 -     ;{ const struct protoent*p;
       
    67 -	if(p=getprotobyname(COMSATprotocol))
       
    68 -	 { printf("#define UDP_protocolno %d\n",p->p_proto);
       
    69 -#else
       
    70 -     ;{ if(1)
       
    71 -	 {
       
    72 -#endif
       
    73 -	   ;{ const struct servent*serv;
       
    74 -	      if(serv=getservbyname(COMSATservice,COMSATprotocol))
       
    75 -		 printf("#define BIFF_serviceport \"%d\"\n",
       
    76 -		  ntohs(serv->s_port));
       
    77 -	    }
       
    78 -#ifdef AF_INET
       
    79 -	   ;{ const struct hostent*host;
       
    80 -	      if(!strcmp("localhost",COMSAThost)&&
       
    81 -	       (host=gethostbyname(COMSAThost))&&
       
    82 -	       host->h_0addr_list&&host->h_addrtype==AF_INET&&
       
    83 -	       host->h_length)
       
    84 -	       { int j=host->h_length;
       
    85 -		 const unsigned char*ad=(void*)host->h_0addr_list;
       
    86 -		 printf("#define IP_localhost {");
       
    87 -		 printf("%d",*ad++);
       
    88 -		 while(--j)
       
    89 -		    printf(",%d",*ad++);
       
    90 -		 puts("}");
       
    91 -	       }
       
    92 -	    }
       
    93 +#ifndef AF_INET
       
    94 +	puts("#define NO_COMSAT");
       
    95  #endif /* AF_INET */
       
    96 -	 }
       
    97 -	else
       
    98 -	   puts("#define NO_COMSAT");
       
    99 -      }
       
   100  #endif /* NO_COMSAT */
       
   101       ;{ unsigned long s=(size_t)~0;int bits;
       
   102  	for(bits=1;s>>=1;bits++);
       
   103 --- procmail-3.22/src/network.h.ipv6	1999-04-17 08:18:45.000000000 +0200
       
   104 +++ procmail-3.22/src/network.h	2006-10-24 14:46:44.000000000 +0200
       
   105 @@ -1,19 +1,13 @@
       
   106  /*$Id: network.h,v 1.7 1997/04/02 03:15:41 srb Exp $*/
       
   107  
       
   108 -#include <sys/socket.h>			/* socket() sendto() AF_INET
       
   109 +#include <sys/socket.h>			/* socket() sendto() */
       
   110  					/* SOCK_DGRAM */
       
   111 -#include <netdb.h>			/* gethostbyname() getservbyname()
       
   112 -					/* getprotobyname() */
       
   113 -#include <netinet/in.h>			/* htons() struct sockaddr_in */
       
   114 +#include <netdb.h>			/* getaddrinfo() */
       
   115  
       
   116  #ifndef BIFF_serviceport
       
   117  #define BIFF_serviceport	COMSATservice
       
   118  #endif
       
   119  
       
   120 -#ifndef h_0addr_list
       
   121 -#define h_0addr_list	h_addr_list[0]		      /* POSIX struct member */
       
   122 -#endif
       
   123 -
       
   124  #ifndef NO_const      /* since network.h is outside the autoconf const check */
       
   125  #ifdef const		    /* loop, we need this backcheck for some systems */
       
   126  #undef const
       
   127 --- procmail-3.22/src/comsat.c.ipv6	2006-10-24 14:46:44.000000000 +0200
       
   128 +++ procmail-3.22/src/comsat.c	2006-10-24 14:46:44.000000000 +0200
       
   129 @@ -27,7 +27,8 @@
       
   130  #include "comsat.h"
       
   131  
       
   132  static int csvalid;		     /* is it turned on with a good address? */
       
   133 -static struct sockaddr_in csaddr;
       
   134 +static struct addrinfo cai;
       
   135 +static struct sockaddr *csaddr;
       
   136  static char*cslastf,*cslgname;
       
   137  
       
   138  void setlfcs(folder)const char*folder;		/* set lastfolder for comsat */
       
   139 @@ -62,56 +63,32 @@
       
   140  }
       
   141  
       
   142  int setcomsat(chp)const char*chp;
       
   143 -{ char*chad;int newvalid; struct sockaddr_in newaddr;
       
   144 +{ char*chad;int newvalid; struct addrinfo *res, hints;
       
   145    chad=strchr(chp,SERV_ADDRsep);			     /* @ separator? */
       
   146    if(!chad&&!renvint(-1L,chp))
       
   147       return csvalid=0;					/* turned off comsat */
       
   148    newvalid=1;
       
   149    if(chad)
       
   150       *chad++='\0';				      /* split the specifier */
       
   151 +  if(!chad||!*chp)					       /* no service */
       
   152 +     chp=BIFF_serviceport;				/* new balls please! */
       
   153    if(!chad||!*chad)						  /* no host */
       
   154 -#ifndef IP_localhost			      /* Is "localhost" preresolved? */
       
   155       chad=COMSAThost;					/* nope, use default */
       
   156 -#else /* IP_localhost */
       
   157 -   { static const unsigned char ip_localhost[]=IP_localhost;
       
   158 -     newaddr.sin_family=AF_INET;
       
   159 -     tmemmove(&newaddr.sin_addr,ip_localhost,sizeof ip_localhost);
       
   160 -   }
       
   161 -  else
       
   162 -#endif /* IP_localhost */
       
   163 -   { const struct hostent*host;		      /* what host?  paranoid checks */
       
   164 -     if(!(host=gethostbyname(chad))||!host->h_0addr_list)
       
   165 -      { bbzero(&newaddr.sin_addr,sizeof newaddr.sin_addr);
       
   166 -	newvalid=0;			     /* host can't be found, too bad */
       
   167 -      }
       
   168 -     else
       
   169 -      { newaddr.sin_family=host->h_addrtype;	     /* address number found */
       
   170 -	tmemmove(&newaddr.sin_addr,host->h_0addr_list,host->h_length);
       
   171 -      }
       
   172 -     endhostent();
       
   173 -   }
       
   174 -  if(newvalid)						  /* so far, so good */
       
   175 -   { int s;
       
   176 -     if(!chad||!*chp)					       /* no service */
       
   177 -	chp=BIFF_serviceport;				/* new balls please! */
       
   178 -     s=strtol(chp,&chad,10);
       
   179 -     if(chp!=chad)			       /* the service is not numeric */
       
   180 -	newaddr.sin_port=htons((short)s);		    /* network order */
       
   181 -     else
       
   182 -      { const struct servent*serv;
       
   183 -	serv=getservbyname(chp,COMSATprotocol);		   /* so get its no. */
       
   184 -	if(serv)
       
   185 -	   newaddr.sin_port=serv->s_port;
       
   186 -	else
       
   187 -	 { newaddr.sin_port=htons((short)0);		  /* no such service */
       
   188 -	   newvalid=0;
       
   189 -	 }
       
   190 -	endservent();
       
   191 -      }
       
   192 -   }
       
   193 +  bzero(&hints,sizeof(hints));
       
   194 +  hints.ai_socktype=SOCK_DGRAM;
       
   195 +  hints.ai_flags=AI_ADDRCONFIG;
       
   196 +  if(getaddrinfo(chad,chp,&hints,&res))
       
   197 +     newvalid=0;
       
   198 +  
       
   199    onguard();				    /* update the address atomically */
       
   200    if(csvalid=newvalid)
       
   201 -     tmemmove(&csaddr,&newaddr,sizeof(newaddr));
       
   202 +   { if(csaddr)
       
   203 +        free(csaddr);
       
   204 +     csaddr=malloc(res->ai_addrlen);
       
   205 +     tmemmove(csaddr,res->ai_addr,res->ai_addrlen);
       
   206 +     tmemmove(&cai,res,sizeof(cai));
       
   207 +     freeaddrinfo(res);
       
   208 +   }
       
   209    offguard();
       
   210    return newvalid;
       
   211  }
       
   212 @@ -132,8 +109,8 @@
       
   213     }
       
   214    strlcat(buf,COMSATxtrsep,linebuf);			 /* custom seperator */
       
   215    strlcat(buf,p,linebuf);			  /* where was it delivered? */
       
   216 -  if((s=socket(AF_INET,SOCK_DGRAM,UDP_protocolno))>=0)
       
   217 -   { sendto(s,buf,strlen(buf),0,(struct sockaddr*)&csaddr,sizeof(csaddr));
       
   218 +  if((s=socket(cai.ai_family,cai.ai_socktype,cai.ai_protocol))>=0)
       
   219 +   { sendto(s,buf,strlen(buf),0,csaddr,cai.ai_addrlen);
       
   220       rclose(s);
       
   221       yell("Notified comsat:",buf);
       
   222     }