rpms/suck/F-7 suck-4.3.2-ipv6.patch,NONE,1.1 suck.spec,1.11,1.12

Jochen Schmitt (s4504kr) fedora-extras-commits at redhat.com
Sun Sep 2 19:34:38 UTC 2007


Author: s4504kr

Update of /cvs/extras/rpms/suck/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29404

Modified Files:
	suck.spec 
Added Files:
	suck-4.3.2-ipv6.patch 
Log Message:
Add forgotten file

suck-4.3.2-ipv6.patch:

--- NEW FILE suck-4.3.2-ipv6.patch ---
diff -urN suck-4.3.2.orig/active.c suck-4.3.2/active.c
--- suck-4.3.2.orig/active.c	2001-09-15 00:06:40.000000000 +0200
+++ suck-4.3.2/active.c	2007-08-15 13:33:49.000000000 +0200
@@ -181,7 +181,6 @@
 	
 	/* connect to localhost NNTP server */
 	int fd;
-	struct hostent *hi;
 	char *inbuf;
 	unsigned int port;
 
@@ -190,7 +189,7 @@
 		do_debug("Connecting to %s on port %d\n", master->localhost, port);
 	}
 	
-	if((fd = connect_to_nntphost(master->localhost, &hi, NULL, port, master->local_ssl, &master->local_ssl_struct)) >= 0) {
+	if((fd = connect_to_nntphost(master->localhost, NULL, 0, NULL, port, master->local_ssl, &master->local_ssl_struct)) >= 0) {
 		/* get the announcement line */
 		if(sgetline(fd, &inbuf, master->local_ssl, master->local_ssl_struct) < 0) {
 			close(fd);
diff -urN suck-4.3.2.orig/both.c suck-4.3.2/both.c
--- suck-4.3.2.orig/both.c	2003-03-25 23:38:45.000000000 +0100
+++ suck-4.3.2/both.c	2007-08-15 13:33:49.000000000 +0200
@@ -138,35 +138,13 @@
 	return retval;
 }
 
-/*---------------------------------------------*/
-struct hostent *get_hostent(const char *host) {
-	struct in_addr saddr;
-	int c;
-	struct hostent *hi = NULL;
-
-	if(host==NULL) { 
-		error_log(ERRLOG_REPORT,both_phrases[0], NULL); 
-	}
-	else {
-		c=*host;
-		if(isdigit(c)) {
- 			saddr.s_addr = inet_addr(host); 
- 			hi = gethostbyaddr((char *)&saddr,sizeof(struct in_addr),AF_INET);
-		}
-		else {
-			hi = gethostbyname(host);
-		}
-	}
-	return hi;
-}
 /*--------------------------------------------*/
-int connect_to_nntphost(const char *host, struct hostent **hi, FILE *msgs, unsigned short int portnr, int do_ssl, void **ssl) {
-	char *ptr, *realhost;
-	struct in_addr *aptr;
-	struct in_addr saddr;
-	struct sockaddr_in address;
+int connect_to_nntphost(const char *host, char *hname, size_t hnlength, FILE *msgs, unsigned short int portnr, int do_ssl, void **ssl)
+{
+	char *realhost, *pport;
 	char sport[10];
-	int sockfd = -1;
+	struct addrinfo *l, hint = { 0 };
+	int r, sockfd = -1;
 	
 #ifdef HAVE_LIBSSL
 	SSL *ssl_struct = NULL;
@@ -184,65 +162,60 @@
 	}
 #endif
 	/* handle host:port type syntax */
-	realhost = strdup(host);
-	if(realhost == NULL) {
-		MyPerror("out of memory copying host name");
-		return sockfd;
-	}
-	ptr = strchr(realhost, ':');
-	if(ptr != NULL) {
-		*ptr = '\0';  /* null terminate host name */
-		portnr = atoi(++ptr); /* get port number */
-	}
-	
-	
-	
-	sprintf(sport, "%hu", portnr);	/* cause print_phrases wants all strings */
-	print_phrases(msgs, both_phrases[1], sport, NULL);
-
-	/* Find the internet address of the NNTP server */
- 	*hi = get_hostent(realhost);
- 	if(*hi == NULL) {
+	realhost = alloca(strlen(host) + 1);
+	strcpy(realhost, host);
+	pport = strchr(realhost, ':');
+	if(pport != NULL) {
+		*pport = '\0';	/* null terminate host name */
+		++pport;	/* get port number */
+	}
+	else
+	{
+		snprintf(sport, sizeof(sport), "%hu", portnr);	/* cause print_phrases wants all strings */
+		pport = sport;
+	}
+	print_phrases(msgs, both_phrases[1], pport, NULL);
+	hint.ai_socktype = SOCK_STREAM;
+	hint.ai_flags = AI_ADDRCONFIG | AI_CANONNAME;
+	r = getaddrinfo(realhost, pport, &hint, &l);
+	if(r != 0 || l == NULL)
+	{
 		error_log(ERRLOG_REPORT,"%v1%: ",realhost, NULL);
   		MyPerror(both_phrases[2]);
-		free(realhost);
  	}
-	else {
-		free(realhost);
-		print_phrases(msgs, both_phrases[3], (*hi)->h_name, NULL);
- 		while((ptr = *((*hi)->h_aliases)) != NULL) {
-			print_phrases(msgs, both_phrases[4], ptr, NULL );
-			(*hi)->h_aliases++;
-		}
- 		if((*hi)->h_addrtype != AF_INET) {
-  			error_log(ERRLOG_REPORT, both_phrases[5], NULL);
-		}
-		else {
-			while((aptr = (struct in_addr *)*((*hi)->h_addr_list)++) != NULL) {
-				saddr = *aptr;
-				print_phrases(msgs, both_phrases[17], inet_ntoa(*aptr), NULL);
-			}
-
-			/* Create a socket */
- 			if((sockfd = socket( AF_INET, SOCK_STREAM, SOCKET_PROTOCOL)) == -1) {
-				MyPerror(both_phrases[6]);
-			}
-			else { 
-				address.sin_family = AF_INET;
-				address.sin_port = htons(portnr);  /* NNTP port */
-				address.sin_addr= saddr;
-
-				/* Establish a connection */
-				if(connect(sockfd, (struct sockaddr *)&address, sizeof address ) == -1) {
-					MyPerror(both_phrases[7]);
-					close(sockfd);
-					sockfd = -1;
-				}
-				else {
-					print_phrases(msgs,both_phrases[8], (*hi)->h_name, NULL);
+	else
+	{
+		struct addrinfo *p = l;
+		print_phrases(msgs, both_phrases[3], p->ai_canonname, NULL);
+                if((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
+		{
+            		MyPerror(both_phrases[6]);
+                }
+                else
+		{
+                        if(connect(sockfd, p->ai_addr, p->ai_addrlen) == -1)
+			{
+                                MyPerror(both_phrases[7]);
+                                close(sockfd);
+                                sockfd = -1;
+                        }
+                        else
+			{
+				char lhost[256], lport[64];
+				r = getnameinfo(p->ai_addr, p->ai_addrlen, lhost, sizeof(lhost),
+						lport, sizeof(lport), 0);
+				if(r == 0)
+				{
+                        		print_phrases(msgs,both_phrases[8], lhost, NULL);
+					if(hname && hnlength)
+					{
+						strncpy(hname, lhost, hnlength);
+						hname[hnlength] = '\0';
+					}
 				}
-			}
+                        }
 		}
+		freeaddrinfo(l);
 #ifdef HAVE_LIBSSL
 		if(sockfd > -1 && do_ssl == TRUE) {
 			if((ssl_struct = SSL_new(test1)) == NULL) {
diff -urN suck-4.3.2.orig/both.h suck-4.3.2/both.h
--- suck-4.3.2.orig/both.h	2002-08-28 00:54:34.000000000 +0200
+++ suck-4.3.2/both.h	2007-08-15 13:33:49.000000000 +0200
@@ -9,7 +9,7 @@
 /* declarations */
 int sgetline(int fd, char **sbuf, int, void *);
 int sputline(int fd, const char *outbuf, int, void *);
-int connect_to_nntphost(const char *host, struct hostent **, FILE *, unsigned short int, int, void **);
+int connect_to_nntphost(const char *host, char *hname, size_t hnlength, FILE *msgs, unsigned short int portnr, int do_ssl, void **ssl);
 void disconnect_from_nntphost(int, int, void **);
 char *number(char *sp, int *intPtr);
 char *get_long(char *, long *);
diff -urN suck-4.3.2.orig/rpost.c suck-4.3.2/rpost.c
--- suck-4.3.2.orig/rpost.c	2007-08-15 13:33:17.000000000 +0200
+++ suck-4.3.2/rpost.c	2007-08-15 13:33:49.000000000 +0200
@@ -28,7 +28,7 @@
 #ifndef PL_na
 # define PL_na (na)
 #endif
-#endif /* OLD_PERL */u
+#endif /* OLD_PERL */
 #endif
 
 #ifdef HAVE_DIRENT_H
@@ -117,7 +117,7 @@
 int main(int argc, char *argv[], char *env[]) {
 	char *inbuf;
 	int response, retval, loop, fargc, i;
-	struct hostent *hi;
+	char hname[256];
 	struct stat sbuf;
 	char **args, **fargs;
 	Args myargs;
@@ -244,7 +244,7 @@
 			retval = RETVAL_ERROR;
 		}
 		else {
-			myargs.sockfd = connect_to_nntphost( myargs.host, &hi, myargs.status_fptr, myargs.portnr, myargs.do_ssl, &myargs.ssl_struct);
+			myargs.sockfd = connect_to_nntphost(myargs.host, hname, sizeof(hname), myargs.status_fptr, myargs.portnr, myargs.do_ssl, &myargs.ssl_struct);
 			if(myargs.sockfd < 0) {
 				retval = RETVAL_ERROR;
 			}
@@ -299,7 +299,7 @@
 				retval = do_article(&myargs, stdin);
 			}
 	
-			print_phrases(myargs.status_fptr, rpost_phrases[4], hi->h_name, NULL);
+			print_phrases(myargs.status_fptr, rpost_phrases[4], hname, NULL);
 			if(myargs.debug == TRUE) {
 				do_debug("Sending quit");
 			}
diff -urN suck-4.3.2.orig/suck.c suck-4.3.2/suck.c
--- suck-4.3.2.orig/suck.c	2003-03-28 20:24:54.000000000 +0100
+++ suck-4.3.2/suck.c	2007-08-15 13:33:49.000000000 +0200
@@ -665,7 +665,6 @@
 
 	char *inbuf;
 	int nr, resp, retval = RETVAL_OK;
-	struct hostent *hi;
 	FILE *fp;
 	
 	
@@ -696,7 +695,7 @@
 	}
 	fp = (which_time == CONNECT_FIRST) ? master->msgs : NULL;
 
-	master->sockfd = connect_to_nntphost( master->host, &hi, fp, master->portnr, master->do_ssl, &master->ssl_struct);
+	master->sockfd = connect_to_nntphost( master->host, NULL, 0, fp, master->portnr, master->do_ssl, &master->ssl_struct);
 	
 	if(master->sockfd < 0 ) {
 		retval = RETVAL_ERROR;
diff -urN suck-4.3.2.orig/testhost.c suck-4.3.2/testhost.c
--- suck-4.3.2.orig/testhost.c	2003-03-23 16:34:46.000000000 +0100
+++ suck-4.3.2/testhost.c	2007-08-15 13:33:49.000000000 +0200
@@ -59,7 +59,6 @@
 int main(int argc, char *argv[]) {
 
 	int sockfd, response, loop, cmd, quiet, mode_reader, do_ssl, retval = RETVAL_OK;
-	struct hostent *hi;
 	struct stat sbuf;
 	unsigned short int portnr;
 	FILE *fptr = stdout;		/* used to print output to */
@@ -229,7 +228,7 @@
 	if(retval == RETVAL_OK) {
 		load_phrases(phrases);	/* this is here so everything displays okay */
 
-		sockfd = connect_to_nntphost( host, &hi, (quiet == FALSE)?  fptr : NULL, portnr, do_ssl, &ssl_struct);
+		sockfd = connect_to_nntphost(host, NULL, 0, (quiet == FALSE)?  fptr : NULL, portnr, do_ssl, &ssl_struct);
 		if(sockfd < 0 ) {
 			retval = RETVAL_ERROR;
 		}


Index: suck.spec
===================================================================
RCS file: /cvs/extras/rpms/suck/F-7/suck.spec,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- suck.spec	2 Sep 2007 19:30:36 -0000	1.11
+++ suck.spec	2 Sep 2007 19:34:05 -0000	1.12
@@ -1,7 +1,7 @@
 Name: suck
 Summary: Download news from remote NNTP server
 Version: 4.3.2
-Release: 17%{?dist}
+Release: 17%{?dist}.1
 Source: http://www.sucknews.org/%{name}-%{version}.tar.gz
 Source1: active-ignore
 Source2: suck-4.3.2.site
@@ -86,7 +86,7 @@
 %config(noreplace) %{_sysconfdir}/sysconfig/suck/site
 
 %changelog
-* Wed Aug 15 2007 Jochen Schmitt <Jochen herr-schmitt de> 4.3.2-17
+* Wed Aug 15 2007 Jochen Schmitt <Jochen herr-schmitt de> 4.3.2-17.1
 - Rework for 64-bit systems (use /usr/lib instead of /usr/lib64)
 
 * Wed Aug 15 2007 Jochen Schmitt <Jochen herr-schmitt de> 4.3.2-16




More information about the fedora-extras-commits mailing list