Subject: bin/17323: pkg_add uses hardcoded '/usr/bin/ftp' command
To: None <gnats-bugs@gnats.netbsd.org>
From: Stoned Elipot <seb@script.jussieu.fr>
List: netbsd-bugs
Date: 06/19/2002 14:02:01
>Number:         17323
>Category:       bin
>Synopsis:       pkg_add uses hardcoded '/usr/bin/ftp' command
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 19 05:03:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Stoned Elipot
>Release:        -current sources used under Solaris 8
>Organization:
SCRIPT, Paris VII University, France
>Environment:
System: SunOS voyager 5.8 Generic_108528-14 sun4u sparc SUNW,Ultra-60

>Description:
pkg_add (usr.sbin/pkg_install/lib/ftpio.c in fact) uses hardcoded '/usr/bin/ftp'
for binary packages retrieval but it expects it to be lukemftp.

>How-To-Repeat:
Install zoularis and try to do pkg_add SOMEURLTOABINARYPKG...
>Fix:
The following patches add FTP_CMD and FTP_FULLPATHNAME support in the spirit
of the pre-existing TAR_CMD and TAR_FULLPATHNAME.
Under Solaris those are set from Makefile.inc to 'ftp' and
'${ZOULARISBASE}/bin/${FTP_CMD}'. Default values are set in lib/lib.h.

While here LOCALBASE in Makefile.inc is set to '/usr/pkg' which is now
the default for Solaris (see pkgsrc/mk/defs.SunOS.mk).

Index: Makefile.inc
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pkg_install/Makefile.inc,v
retrieving revision 1.17
diff -u -r1.17 Makefile.inc
--- Makefile.inc	2002/06/10 09:14:26	1.17
+++ Makefile.inc	2002/06/19 10:19:35
@@ -22,11 +22,14 @@
 CHGRP?= /usr/bin/chgrp
 WARNS=2
 .elif ${OPSYS} == "SunOS"
-LOCALBASE?= /usr/local
+LOCALBASE?= /usr/pkg
 TAR_CMD?= tar
+FTP_CMD?= ftp
 ZOULARISBASE?=	${LOCALBASE}/bsd
 TAR_FULLPATHNAME?= ${ZOULARISBASE}/bin/${TAR_CMD}
+FTP_FULLPATHNAME?= ${ZOULARISBASE}/bin/${FTP_CMD}
 CPPFLAGS+=-DTAR_CMD='"${TAR_CMD}"' -DTAR_FULLPATHNAME='"${TAR_FULLPATHNAME}"'
+CPPFLAGS+=-DFTP_CMD='"${FTP_CMD}"' -DFTP_FULLPATHNAME='"${FTP_FULLPATHNAME}"'
 BINDIR=${ZOULARISBASE}/bin
 CHMOD?= /usr/bin/chmod
 CHOWN?= /usr/bin/chown
cvs server: Diffing add
cvs server: Diffing admin
cvs server: Diffing create
cvs server: Diffing delete
cvs server: Diffing info
cvs server: Diffing lib
Index: lib/ftpio.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pkg_install/lib/ftpio.c,v
retrieving revision 1.37
diff -u -r1.37 ftpio.c
--- ftpio.c	2002/06/10 09:14:28	1.37
+++ ftpio.c	2002/06/19 10:19:36
@@ -297,7 +297,7 @@
 	    
 	    if (Verbose)
 		    fprintf(stderr, "ftp -detv %s\n", base);
-	    rc1 = execl("/usr/bin/ftp", "ftp", "-detv", base, NULL);
+	    rc1 = execl(FTP_FULLPATHNAME, FTP_CMD, "-detv", base, NULL);
 	    warn("setupCoproc: execl() failed");
 	    exit(1);
 	    break;
Index: lib/lib.h
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/pkg_install/lib/lib.h,v
retrieving revision 1.41
diff -u -r1.41 lib.h
--- lib.h	2002/06/10 09:14:28	1.41
+++ lib.h	2002/06/19 10:19:37
@@ -66,6 +66,16 @@
 #define TAR_FULLPATHNAME	"/usr/bin/tar"
 #endif
 
+/* Define ftp as a string, in case the ftp client is called something else */
+#ifndef FTP_CMD
+#define FTP_CMD "ftp"
+#endif
+
+/* Full path name of FTP_CMD */
+#ifndef FTP_FULLPATHNAME
+#define FTP_FULLPATHNAME	"/usr/bin/ftp"
+#endif
+
 /* Where we put logging information by default, else ${PKG_DBDIR} if set */
 #ifndef DEF_LOG_DIR
 #define DEF_LOG_DIR		"/var/db/pkg"
>Release-Note:
>Audit-Trail:
>Unformatted: