From owner-freebsd-bugs@FreeBSD.ORG Thu Mar 2 18:30:21 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 94FB116A420 for ; Thu, 2 Mar 2006 18:30:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D9FC043D7B for ; Thu, 2 Mar 2006 18:30:04 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k22IU4jd068513 for ; Thu, 2 Mar 2006 18:30:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k22IU4Zv068511; Thu, 2 Mar 2006 18:30:04 GMT (envelope-from gnats) Resent-Date: Thu, 2 Mar 2006 18:30:04 GMT Resent-Message-Id: <200603021830.k22IU4Zv068511@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Josh Carroll Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E4B316A422 for ; Thu, 2 Mar 2006 18:27:12 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id C28DC43D46 for ; Thu, 2 Mar 2006 18:27:11 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k22IRBXv093171 for ; Thu, 2 Mar 2006 18:27:11 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k22IRBWs093170; Thu, 2 Mar 2006 18:27:11 GMT (envelope-from nobody) Message-Id: <200603021827.k22IRBWs093170@www.freebsd.org> Date: Thu, 2 Mar 2006 18:27:11 GMT From: Josh Carroll To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: misc/94032: Enhancement to pkg_add to add -4 flag to force ipv4 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Mar 2006 18:30:21 -0000 >Number: 94032 >Category: misc >Synopsis: Enhancement to pkg_add to add -4 flag to force ipv4 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 02 18:30:04 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Josh Carroll >Release: 6.0-RELEASE-p4 >Organization: n/a >Environment: FreeBSD pflog.net 6.0-RELEASE-p4 FreeBSD 6.0-RELEASE-p4 #11: Wed Jan 25 09:11:41 PST 2006 root@pflog.net:/usr/obj/usr/src/sys/DEBLIN i386 >Description: In some circumstances, a user with both IPv4 and IPv6 will have trouble with pkg_add, as it tries to use the PF_INET6 family. The fetch program supports a -4 flags, but currently, pkg_add does not have a way to force use of IPv4. It appears as though libfetch supports this, so I have added a -4 flag to pkg_add, which sets the proper flag in the call to fetchGetURL. The attached patch appears to patch cleanly against 5.4-R, 6.0-R, and 6.1-BETA2, and should be 100% backward compatible (e.g. unless the user supplies the -4 flag, it should operate the same as before). Thanks, Josh >How-To-Repeat: n/a >Fix: To apply: cd /usr/src patch -p1 < /path/to/pkg_install.patch diff -u -p -r src.old/usr.sbin/pkg_install/add/main.c src/usr.sbin/pkg_install/add/main.c --- src.old/usr.sbin/pkg_install/add/main.c Thu Oct 27 11:38:48 2005 +++ src/usr.sbin/pkg_install/add/main.c Wed Mar 1 18:57:12 2006 @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD: src/usr.sbin/pkg_ins #include "lib.h" #include "add.h" -static char Options[] = "hvIRfnrp:SMt:C:"; +static char Options[] = "hvIRfnrp:SMt:C:4"; char *Prefix = NULL; char *Chroot = NULL; @@ -147,6 +147,10 @@ main(int argc, char **argv) case 'C': Chroot = optarg; + break; + + case '4': + ForceIpv4 = TRUE; break; case 'h': diff -u -p -r src.old/usr.sbin/pkg_install/add/pkg_add.1 src/usr.sbin/pkg_install/add/pkg_add.1 --- src.old/usr.sbin/pkg_install/add/pkg_add.1 Sun Feb 13 14:25:30 2005 +++ src/usr.sbin/pkg_install/add/pkg_add.1 Thu Mar 2 10:12:58 2006 @@ -23,7 +23,7 @@ .Nd a utility for installing software package distributions .Sh SYNOPSIS .Nm -.Op Fl vInfrRMS +.Op Fl vInfrRMS4 .Op Fl t Ar template .Op Fl p Ar prefix .Op Fl C Ar chrootdir @@ -82,6 +82,8 @@ will search them in each directory named .Ev PKG_PATH . .It Fl v Turn on verbose output. +.It Fl 4 +Use ipv4. .It Fl I If any installation scripts (pre-install or post-install) exist for a given package, do not execute them. diff -u -p -r src.old/usr.sbin/pkg_install/lib/global.c src/usr.sbin/pkg_install/lib/global.c --- src.old/usr.sbin/pkg_install/lib/global.c Sun Oct 17 22:34:54 2004 +++ src/usr.sbin/pkg_install/lib/global.c Wed Mar 1 18:57:12 2006 @@ -27,6 +27,7 @@ __FBSDID("$FreeBSD: src/usr.sbin/pkg_ins /* These are global for all utils */ Boolean Quiet = FALSE; Boolean Verbose = FALSE; +Boolean ForceIpv4 = FALSE; Boolean Fake = FALSE; Boolean Force = FALSE; int AutoAnswer = FALSE; diff -u -p -r src.old/usr.sbin/pkg_install/lib/lib.h src/usr.sbin/pkg_install/lib/lib.h --- src.old/usr.sbin/pkg_install/lib/lib.h Tue Jun 14 08:05:43 2005 +++ src/usr.sbin/pkg_install/lib/lib.h Wed Mar 1 18:57:12 2006 @@ -229,6 +229,7 @@ int version_cmp(const char *, const cha /* Externs */ extern Boolean Quiet; extern Boolean Verbose; +extern Boolean ForceIpv4; extern Boolean Fake; extern Boolean Force; extern int AutoAnswer; diff -u -p -r src.old/usr.sbin/pkg_install/lib/url.c src/usr.sbin/pkg_install/lib/url.c --- src.old/usr.sbin/pkg_install/lib/url.c Tue Jun 29 12:06:42 2004 +++ src/usr.sbin/pkg_install/lib/url.c Thu Mar 2 10:15:17 2006 @@ -42,6 +42,9 @@ fileGetURL(const char *base, const char int pfd[2], pstat, r, w = 0; char *hint; int fd; + /* support up to 15 optional flags to fetchGetURL */ + char flags[16]; + char *pflags = flags; rp = NULL; /* Special tip that sysinstall left for us */ @@ -95,8 +98,14 @@ fileGetURL(const char *base, const char else strcpy(fname, spec); - if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) { - printf("Error: FTP Unable to get %s: %s\n", + if(Verbose) + *pflags++ = 'v'; + if(ForceIpv4) + *pflags++ = '4'; + *pflags = '\0'; + + if ((ftp = fetchGetURL(fname, pflags)) == NULL) { + printf("Error: FTP Unable to get %s: %s\n", fname, fetchLastErrString); return NULL; } >Release-Note: >Audit-Trail: >Unformatted: