misc/94032: Enhancement to pkg_add to add -4 flag to force ipv4
Josh Carroll
josh.carroll at gmail.com
Thu Mar 2 10:30:21 PST 2006
>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 at 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:
More information about the freebsd-bugs
mailing list