Subject: bin/14072: using full pathname to tar command in pkg_{add,info}
To: None <gnats-bugs@gnats.netbsd.org>
From: Stoned Elipot <seb@script.jussieu.fr>
List: netbsd-bugs
Date: 09/26/2001 13:57:32
>Number:         14072
>Category:       bin
>Synopsis:       using full pathname to tar command in pkg_{add,info
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 26 04:58:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Stoned Elipot
>Release:        current
>Organization:
SCRIPT, Paris VII University, France
>Environment:
System: SunOS deep-space-9 5.8 Generic_108528-07 sun4u sparc SUNW,Ultra-60
>Description:
pkg_add and pkg_info do not use full pathname to exec the tar command
this leads to troubles on non-netbsd platform (like Solaris/Zoularis) or
even on NetBSD if one as a weird tar command early in his PATH !?
>How-To-Repeat:
create a binary pkg on Solaris/Zoularis. Then try to pkg_add it you will
find yourself putting $ZOULARISBASE/bin in front of your path to make
pkg_add run to good tar.

So one can put ZOULARISBASE/bin (or /usr/bin on NetBSD) in front of his PATH 
when using pkg_{add,info} on Solaris/Zoularis to avoid picking up the wrong tar
command, but as pkg_create *already* use a full pathname to tar I figured 
making pkg_{add,info} following the same behaviour was the way to go.
>Fix:

Index: add/extract.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pkg_install/add/extract.c,v
retrieving revision 1.22
diff -u -r1.22 extract.c
--- extract.c	2000/07/24 20:09:15	1.22
+++ extract.c	2001/09/26 11:28:22
@@ -34,7 +34,7 @@
 #include "add.h"
 
 #define TAR_ARGS	" cf - "
-#define TARX_CMD	"|" TAR_CMD " xf - -C "
+#define TARX_CMD	"|" TAR_FULLPATHNAME " xf - -C "
 
 /* 
  * This macro is used to determine if the 'where_args'  buffer is big enough to add the
@@ -50,16 +50,16 @@
 		|| (strlen(str) + 3 + perm_count >= maxargs))
 
 #define PUSHOUT(todir) /* push out string */				\
-        if (where_count > sizeof(TAR_CMD) + sizeof(TAR_ARGS)-1) {	\
+        if (where_count > sizeof(TAR_FULLPATHNAME) + sizeof(TAR_ARGS)-1) {	\
 		    strcat(where_args, TARX_CMD);			\
 		    strcat(where_args, todir);				\
 		    if (system(where_args)) {				\
 			cleanup(0);					\
 			errx(2, "can not invoke %lu byte %s pipeline: %s", \
-				(u_long)strlen(where_args), TAR_CMD,	\
+				(u_long)strlen(where_args), TAR_FULLPATHNAME,	\
 				where_args);				\
 		    }							\
-		    strcpy(where_args, TAR_CMD TAR_ARGS);		\
+		    strcpy(where_args, TAR_FULLPATHNAME TAR_ARGS);	\
 		    where_count = strlen(where_args);			\
 	}								\
 	if (perm_count) {						\
@@ -118,7 +118,7 @@
 		cleanup(0);
 		errx(2, "can't get argument list space");
 	}
-	strcpy(where_args, TAR_CMD TAR_ARGS);
+	strcpy(where_args, TAR_FULLPATHNAME TAR_ARGS);
 	/*
 	 * we keep track of how many characters are stored in 'where_args' with 'where_count'.
 	 * Note this doesn't include the trailing null character.
Index: lib/file.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pkg_install/lib/file.c,v
retrieving revision 1.47
diff -u -r1.47 file.c
--- file.c	2001/03/05 16:46:23	1.47
+++ file.c	2001/09/26 11:28:22
@@ -667,7 +667,7 @@
 	} else
 		strcat(args, "z");
 	strcat(args, "xpf");
-	if (vsystem("%s %s %s %s", TAR_CMD, args, pkg, flist ? flist : "")) {
+	if (vsystem("%s %s %s %s", TAR_FULLPATHNAME, args, pkg, flist ? flist : "")) {
 		warnx("%s extract of %s failed!", TAR_CMD, pkg);
 		return 1;
 	}
>Release-Note:
>Audit-Trail:
>Unformatted: