Subject: pkg/24955: Portability enhancement for pkg_install (and friends)
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <eric@cirr.com>
List: pkgsrc-bugs
Date: 03/28/2004 23:17:58
>Number:         24955
>Category:       pkg
>Synopsis:       Improve the portability of pkg_install and friends
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 29 05:19:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Eric Schnoebelen
>Release:        HP-UX B.11.11
>Organization:
Eric Schnoebelen		eric@cirr.com		http://www.cirr.com
	    Beneath revolution (Linux) there's also evolution (*BSD) 
			    -- Andre Oppermann, Apr. 1998
>Environment:
    HP-UX peake B.11.11 U 9000/782 2005225191 unlimited-user license
>Description:
	The package tools use FILENAME_MAX as a buffer size in a
	number of places where the buffer is expected to contain
	an entire path name.  As far as I can tell, the standards
	documents only define FILENAME_MAX to be the length of the
	"basename" component of a pathname, not the length of an
	entire pathname.

	To make matters worse, on HP-UX, the value reflects the maximum
	length provided by the traditional v7/System III/System V file
	system.  To _really_ learn the maximum file (base) name length,
	pathconf(2) _should_ be used.
>How-To-Repeat:
	compile the packaging utils on an HP-UX system and then attempt
	to process a package database.
>Fix:
#
#   Replace all occurances of FILENAME_MAX with PATH_MAX, with  appears 
#   to more accurately reflect the intent of the authors.
#
Index: add/extract.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/extract.c,v
retrieving revision 1.7
diff -b -u -w -r1.7 extract.c
--- add/extract.c	23 Sep 2003 13:22:37 -0000	1.7
+++ add/extract.c	29 Mar 2004 05:16:34 -0000
@@ -81,7 +81,7 @@
 rollback(char *name, char *home, plist_t *start, plist_t *stop)
 {
 	plist_t *q;
-	char    try[FILENAME_MAX], bup[FILENAME_MAX], *dir;
+	char    try[PATH_MAX], bup[PATH_MAX], *dir;
 
 	dir = home;
 	for (q = start; q != stop; q = q->next) {
@@ -159,7 +159,7 @@
 	}
 	/* Do it */
 	while (p) {
-		char    cmd[FILENAME_MAX];
+		char    cmd[PATH_MAX];
 
 		switch (p->type) {
 		case PLIST_NAME:
@@ -173,7 +173,7 @@
 			if (Verbose)
 				printf("extract: %s/%s\n", Directory, p->name);
 			if (!Fake) {
-				char    try[FILENAME_MAX];
+				char    try[PATH_MAX];
 
 				if (strrchr(p->name, '\'')) {
 					cleanup(0);
@@ -187,7 +187,7 @@
 					(void) chflags(try, 0);	/* XXX hack - if truly immutable, rename fails */
 #endif
 					if (preserve && PkgName) {
-						char    pf[FILENAME_MAX];
+						char    pf[PATH_MAX];
 
 						if (make_preserve_name(pf, sizeof(pf), PkgName, try)) {
 							if (rename(try, pf)) {
@@ -205,7 +205,7 @@
 				if (rename(p->name, try) == 0) {
 					/* note in pkgdb */
 					{
-						char   *s, t[FILENAME_MAX];
+						char   *s, t[PATH_MAX];
 						int     rc;
 
 						(void) snprintf(t, sizeof(t), "%s/%s", Directory, p->name);
@@ -266,7 +266,7 @@
 					 * that would probably affect too much code I prefer
 					 * not to touch - HF */
 					{
-						char   *s, t[FILENAME_MAX], *u;
+						char   *s, t[PATH_MAX], *u;
 						int     rc;
 
 						if (p->name[0] == '/')
Index: add/main.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/main.c,v
retrieving revision 1.6
diff -b -u -w -r1.6 main.c
--- add/main.c	20 Dec 2003 04:23:05 -0000	1.6
+++ add/main.c	29 Mar 2004 05:16:34 -0000
@@ -63,7 +63,7 @@
 char   *Group = NULL;
 char   *PkgName = NULL;
 char   *Directory = NULL;
-char    FirstPen[FILENAME_MAX];
+char    FirstPen[PATH_MAX];
 add_mode_t AddMode = NORMAL;
 Boolean	Replace = FALSE;
 
Index: add/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
retrieving revision 1.15
diff -b -u -w -r1.15 perform.c
--- add/perform.c	14 Jan 2004 23:55:29 -0000	1.15
+++ add/perform.c	29 Mar 2004 05:16:34 -0000
@@ -57,7 +57,7 @@
 
 static int read_buildinfo(char **);
 
-static char LogDir[FILENAME_MAX];
+static char LogDir[PATH_MAX];
 static int zapLogDir;		/* Should we delete LogDir? */
 
 static package_t Plist;
@@ -118,14 +118,14 @@
 static int
 pkg_do(const char *pkg)
 {
-	char    playpen[FILENAME_MAX];
-	char    replace_from[FILENAME_MAX];
-	char    replace_via[FILENAME_MAX];
-	char    replace_to[FILENAME_MAX];
+	char    playpen[PATH_MAX];
+	char    replace_from[PATH_MAX];
+	char    replace_via[PATH_MAX];
+	char    replace_to[PATH_MAX];
 	char   *buildinfo[BI_ENUM_COUNT];
 	int	replacing = 0;
 	char   *where_to;
-	char   dbdir[FILENAME_MAX];
+	char   dbdir[PATH_MAX];
 	const char *exact, *extra1;
 	FILE   *cfile;
 	int     errc, err_prescan;
@@ -145,7 +145,7 @@
 	/* Are we coming in for a second pass, everything already extracted?
 	 * (Slave mode) */
 	if (!pkg) {
-		fgets(playpen, FILENAME_MAX, stdin);
+		fgets(playpen, PATH_MAX, stdin);
 		playpen[strlen(playpen) - 1] = '\0';	/* remove newline! */
 		if (chdir(playpen) == FAIL) {
 			warnx("add in SLAVE mode can't chdir to %s", playpen);
@@ -375,8 +375,8 @@
 		char   *s;
 
 		if ((s = strrchr(PkgName, '-')) != NULL) {
-			char    buf[FILENAME_MAX];
-			char    installed[FILENAME_MAX];
+			char    buf[PATH_MAX];
+			char    installed[PATH_MAX];
 
 			/*
 			 * See if the pkg is already installed. If so, we might
@@ -402,7 +402,7 @@
 						 * (from +REQUIRED_BY) that require this pkg
 						 */
 						FILE *rb;                     /* +REQUIRED_BY file */
-						char pkg2chk[FILENAME_MAX];
+						char pkg2chk[PATH_MAX];
 
 						rb = fopen(replace_from, "r");
 						if (! rb) {
@@ -417,7 +417,7 @@
 							package_t depPlist;
 							FILE *depf;
 							plist_t *depp;
-							char depC[FILENAME_MAX];
+							char depC[PATH_MAX];
 							
 							s = strrchr(pkg2chk, '\n');
 							if (s)
@@ -441,8 +441,8 @@
 							fclose(depf);
 							
 							for (depp = depPlist.head; depp; depp = depp->next) {
-								char base_new[FILENAME_MAX];
-								char base_exist[FILENAME_MAX];
+								char base_new[PATH_MAX];
+								char base_exist[PATH_MAX];
 								char *s2;
 								
 								if (depp->type != PLIST_PKGDEP)
@@ -522,7 +522,7 @@
 
 	/* See if there are conflicting packages installed */
 	for (p = Plist.head; p; p = p->next) {
-		char    installed[FILENAME_MAX];
+		char    installed[PATH_MAX];
 
 		if (p->type != PLIST_PKGCFL)
 			continue;
@@ -540,7 +540,7 @@
 	 */
 	err_prescan=0;
 	for (p = Plist.head; p; p = p->next) {
-		char installed[FILENAME_MAX];
+		char installed[PATH_MAX];
 		
 		if (p->type != PLIST_PKGDEP)
 			continue;
@@ -573,7 +573,7 @@
 			}
 			
 			if (skip >= 0) {
-				char    buf[FILENAME_MAX];
+				char    buf[PATH_MAX];
 		
 				(void) snprintf(buf, sizeof(buf),
 				    skip ? "%.*s[0-9]*" : "%.*s-[0-9]*",
@@ -607,7 +607,7 @@
 
 	/* Now check the packing list for dependencies */
 	for (exact = NULL, p = Plist.head; p; p = p->next) {
-		char    installed[FILENAME_MAX];
+		char    installed[PATH_MAX];
 
 		if (p->type == PLIST_BLDDEP) {
 			exact = p->name;
@@ -718,7 +718,7 @@
 
 	/* Time to record the deed? */
 	if (!NoRecord && !Fake) {
-		char    contents[FILENAME_MAX];
+		char    contents[PATH_MAX];
 
 		umask(022);
 		if (getuid() != 0)
Index: add/verify.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/verify.c,v
retrieving revision 1.5
diff -b -u -w -r1.5 verify.c
--- add/verify.c	23 Sep 2003 13:22:38 -0000	1.5
+++ add/verify.c	29 Mar 2004 05:16:34 -0000
@@ -90,7 +90,7 @@
 	struct stat	st;
 	const char    *const *ep;
 	char		buf[BUFSIZ];
-	char		f[FILENAME_MAX];
+	char		f[PATH_MAX];
 	int		i;
 
 	if (cmd == NULL) {
Index: admin/main.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/admin/main.c,v
retrieving revision 1.14
diff -b -u -w -r1.14 main.c
--- admin/main.c	7 Feb 2004 10:37:52 -0000	1.14
+++ admin/main.c	29 Mar 2004 05:16:34 -0000
@@ -112,8 +112,8 @@
 	plist_t *p;
 	package_t Plist;
 	char   *PkgName, *dirp = NULL, *md5file;
-	char    file[FILENAME_MAX];
-	char    dir[FILENAME_MAX];
+	char    file[PATH_MAX];
+	char    dir[PATH_MAX];
 
 	f = fopen(CONTENTS_FNAME, "r");
 	if (f == NULL)
@@ -151,7 +151,7 @@
 							free(md5file);
 						}
 					} else if (strncmp(p->next->name, SYMLINK_HEADER, SymlinkHeaderLen) == 0) {
-						char	buf[FILENAME_MAX + SymlinkHeaderLen];
+						char	buf[PATH_MAX + SymlinkHeaderLen];
 						int	cc;
 
 						(void) strlcpy(buf, SYMLINK_HEADER, sizeof(buf));
@@ -221,10 +221,10 @@
 	FILE	       *f;
 	plist_t	       *p;
 	package_t	Plist;
-	char 		contents[FILENAME_MAX];
+	char 		contents[PATH_MAX];
 	char	       *PkgDBDir, *PkgName, *dirp;
-	char 		file[FILENAME_MAX];
-	char		dir[FILENAME_MAX];
+	char 		file[PATH_MAX];
+	char		dir[PATH_MAX];
 	int		cnt = 0;
 
 	if (!pkgdb_open(ReadWrite))
@@ -316,7 +316,7 @@
 	DIR	       *dp;
 	struct dirent  *de;
 	char	       *PkgDBDir;
-	char		cachename[FILENAME_MAX];
+	char		cachename[PATH_MAX];
 
 	pkgcnt = 0;
 	filecnt = 0;
@@ -439,8 +439,8 @@
 	const char	*prog;
 	Boolean		 use_default_sfx = TRUE;
 	Boolean 	 show_basename_only = FALSE;
-	char		 lsdir[FILENAME_MAX];
-	char		 sfx[FILENAME_MAX];
+	char		 lsdir[PATH_MAX];
+	char		 sfx[PATH_MAX];
 	char		*lsdirp = NULL;
 	int		 ch;
 
@@ -541,7 +541,7 @@
 					rc = chdir(*argv);
 					if (rc == -1) {
 						/* found nothing - try 'pkg-[0-9]*' */
-						char try[FILENAME_MAX];
+						char try[PATH_MAX];
 					
 						snprintf(try, sizeof(try), "%s-[0-9]*", *argv);
 						if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
@@ -587,7 +587,7 @@
 			int     rc;
 			const char *basep, *dir;
 			char cwd[MAXPATHLEN];
-			char base[FILENAME_MAX];
+			char base[PATH_MAX];
 
 			dir = lsdirp ? lsdirp : dirname_of(*argv);
 			basep = basename_of(*argv);
@@ -629,7 +629,7 @@
 			int     rc;
 			const char *basep, *dir;
 			char cwd[MAXPATHLEN];
-			char base[FILENAME_MAX];
+			char base[PATH_MAX];
 			char *p;
 
 			dir = lsdirp ? lsdirp : dirname_of(*argv);
Index: create/main.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/create/main.c,v
retrieving revision 1.5
diff -b -u -w -r1.5 main.c
--- create/main.c	23 Sep 2003 07:13:49 -0000	1.5
+++ create/main.c	29 Mar 2004 05:16:34 -0000
@@ -53,7 +53,7 @@
 char   *Preserve = NULL;
 char   *SrcDir = NULL;
 char   *realprefix = NULL;
-char    PlayPen[FILENAME_MAX];
+char    PlayPen[PATH_MAX];
 size_t  PlayPenSize = sizeof(PlayPen);
 int	update_pkgdb = 1;
 int	create_views = 0;
Index: create/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/create/perform.c,v
retrieving revision 1.6
diff -b -u -w -r1.6 perform.c
--- create/perform.c	23 Sep 2003 07:13:49 -0000	1.6
+++ create/perform.c	29 Mar 2004 05:16:34 -0000
@@ -56,7 +56,7 @@
 static void
 make_dist(const char *home, const char *pkg, const char *suffix, const package_t *plist)
 {
-	char    tball[FILENAME_MAX];
+	char    tball[PATH_MAX];
 	const plist_t *p;
 	int     ret;
 	char   *args[50];	/* Much more than enough. */
@@ -233,7 +233,7 @@
 	package_t plist;
 	char   *suffix;		/* What we tack on to the end of the finished package */
 	lpkg_t *lpp;
-	char    installed[FILENAME_MAX];
+	char    installed[PATH_MAX];
 
 	lpp = TAILQ_FIRST(pkgs);
 	pkg = lpp->lp_name;	/* Only one arg to create */
Index: create/pl.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/create/pl.c,v
retrieving revision 1.7
diff -b -u -w -r1.7 pl.c
--- create/pl.c	7 Feb 2004 10:37:52 -0000	1.7
+++ create/pl.c	29 Mar 2004 05:16:34 -0000
@@ -124,8 +124,8 @@
 	plist_t *tmp;
 	plist_t *p;
 	char    buf[ChecksumHeaderLen + LegibleChecksumLen];
-	char    target[FILENAME_MAX + SymlinkHeaderLen];
-	char    name[FILENAME_MAX];
+	char    target[PATH_MAX + SymlinkHeaderLen];
+	char    name[PATH_MAX];
 	char   *cwd = home;
 	char   *srcdir = NULL;
 	int     dirc;
@@ -159,7 +159,7 @@
 			 * starts, it's ok to do this somewhere here
 			 */
 			if (update_pkgdb) {
-				char   *s, t[FILENAME_MAX];
+				char   *s, t[PATH_MAX];
 
 				(void) snprintf(t, sizeof(t), "%s%s%s",
 					cwd,
Index: delete/main.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/delete/main.c,v
retrieving revision 1.10
diff -b -u -w -r1.10 main.c
--- delete/main.c	14 Jan 2004 23:55:29 -0000	1.10
+++ delete/main.c	29 Mar 2004 05:16:34 -0000
@@ -191,7 +191,7 @@
 		/* Only delete the given packages' files from pkgdb, do not
 		 * touch the pkg itself. Used by "make reinstall" in
 		 * bsd.pkg.mk */
-		char	cachename[FILENAME_MAX];
+		char	cachename[PATH_MAX];
 
 		if (!pkgdb_open(ReadWrite)) {
 			err(EXIT_FAILURE, "cannot open %s", _pkgdb_getPKGDB_FILE(cachename, sizeof(cachename)));
Index: delete/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/delete/perform.c,v
retrieving revision 1.11
diff -b -u -w -r1.11 perform.c
--- delete/perform.c	7 Feb 2004 10:37:52 -0000	1.11
+++ delete/perform.c	29 Mar 2004 05:16:34 -0000
@@ -85,9 +85,9 @@
 static void require_print(void);
 static int undepend(const char *, void *);
 
-static char LogDir[FILENAME_MAX];
-static char linebuf[FILENAME_MAX];
-static char pkgdir[FILENAME_MAX];
+static char LogDir[PATH_MAX];
+static char linebuf[PATH_MAX];
+static char pkgdir[PATH_MAX];
 
 static package_t Plist;
 
@@ -121,8 +121,8 @@
 undepend(const char *deppkgname, void *vp)
 {
 	char   *pkg2delname = vp;
-	char    fname[FILENAME_MAX], ftmp[FILENAME_MAX];
-	char    fbuf[FILENAME_MAX];
+	char    fname[PATH_MAX], ftmp[PATH_MAX];
+	char    fbuf[PATH_MAX];
 	FILE   *fp, *fpwr;
 	int     s;
 
@@ -180,9 +180,9 @@
 static int
 unview(const char *pkgname)
 {
-	char  fname[FILENAME_MAX], ftmp[FILENAME_MAX];
-	char  fbuf[FILENAME_MAX];
-	char  dbdir[FILENAME_MAX];
+	char  fname[PATH_MAX], ftmp[PATH_MAX];
+	char  fbuf[PATH_MAX];
+	char  dbdir[PATH_MAX];
 	FILE *fp, *fpwr;
 	int  s;
 	int  cc;
@@ -282,7 +282,7 @@
 	lpp = TAILQ_FIRST(&lpdelq);
 	for (; lpp; lpp = TAILQ_NEXT(lpp, lp_link)) {
 		int rm_installed;                /* delete expanded pkg, not @pkgdep value */
-		char installed[FILENAME_MAX];
+		char installed[PATH_MAX];
 		
 		/* go to the db dir */
 		if (chdir(pkgdir) == FAIL) {
@@ -493,7 +493,7 @@
 		/* prepare for recursion */
 		chdir(_pkgdb_getPKGDB_DIR());
 		if (ispkgpattern(lpp->lp_name)) {
-			char installed[FILENAME_MAX];
+			char installed[PATH_MAX];
 			if (findmatchingname(".", lpp->lp_name, note_whats_installed, installed) != 1) {
 				warnx("cannot remove dependency for pkg-pattern %s", lpp->lp_name);
 				fail = 1;
@@ -606,8 +606,8 @@
 	plist_t	       *p;
 	FILE	       *cfile;
 	FILE	       *fp;
-	char    	home[FILENAME_MAX];
-	char    	view[FILENAME_MAX];
+	char    	home[PATH_MAX];
+	char    	view[PATH_MAX];
 	int		cc;
 	Boolean		is_depoted_pkg = FALSE;
 
@@ -620,13 +620,13 @@
 	if (!fexists(LogDir) || !(isdir(LogDir) || islinktodir(LogDir))) {
 		/* Check if the given package name matches something
 		 * with 'pkg-[0-9]*' */
-		char	        try[FILENAME_MAX];
+		char	        try[PATH_MAX];
 		lpkg_head_t     trypkgs;
 		lpkg_t	       *lpp;
 		int		qlen = 0;
 
 		TAILQ_INIT(&trypkgs);
-		snprintf(try, FILENAME_MAX, "%s-[0-9]*", pkg);
+		snprintf(try, PATH_MAX, "%s-[0-9]*", pkg);
 		if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
 			add_to_list_fn, &trypkgs) == 0) {
 			warnx("package '%s' not installed", pkg);
@@ -656,7 +656,7 @@
 
 		return 0;
 	}
-	if (!getcwd(home, FILENAME_MAX)) {
+	if (!getcwd(home, PATH_MAX)) {
 		cleanup(0);
 		errx(2, "unable to get current working directory!");
 	}
Index: info/main.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/info/main.c,v
retrieving revision 1.8
diff -b -u -w -r1.8 main.c
--- info/main.c	22 Mar 2004 11:44:24 -0000	1.8
+++ info/main.c	29 Mar 2004 05:16:35 -0000
@@ -57,7 +57,7 @@
 Boolean File2Pkg = FALSE;
 Boolean Quiet = FALSE;
 char   *InfoPrefix = "";
-char    PlayPen[FILENAME_MAX];
+char    PlayPen[PATH_MAX];
 size_t  PlayPenSize = sizeof(PlayPen);
 char   *CheckPkg = NULL;
 size_t  termwidth = 0;
Index: info/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/info/perform.c,v
retrieving revision 1.14
diff -b -u -w -r1.14 perform.c
--- info/perform.c	20 Dec 2003 04:23:05 -0000	1.14
+++ info/perform.c	29 Mar 2004 05:16:35 -0000
@@ -64,8 +64,8 @@
 pkg_do(char *pkg)
 {
 	Boolean installed = FALSE, isTMP = FALSE;
-	char    log_dir[FILENAME_MAX];
-	char    fname[FILENAME_MAX];
+	char    log_dir[PATH_MAX];
+	char    fname[PATH_MAX];
 	struct stat sb;
 	char   *cp = NULL;
 	int     code = 0;
@@ -79,7 +79,7 @@
 		int     len;
 
 		if (*pkg != '/') {
-			if (!getcwd(fname, FILENAME_MAX)) {
+			if (!getcwd(fname, PATH_MAX)) {
 				cleanup(0);
 				err(EXIT_FAILURE, "fatal error during execution: getcwd");
 			}
@@ -91,7 +91,7 @@
 		cp = fname;
 	} else {
 		if ((cp = fileFindByPath(pkg)) != NULL) {
-			strncpy(fname, cp, FILENAME_MAX);
+			strncpy(fname, cp, PATH_MAX);
 		}
 	}
 
@@ -142,8 +142,8 @@
 			{
 				/* Check if the given package name matches
 				 * something with 'pkg-[0-9]*' */
-				char    try[FILENAME_MAX];
-				snprintf(try, FILENAME_MAX, "%s-[0-9]*", pkg);
+				char    try[PATH_MAX];
+				snprintf(try, PATH_MAX, "%s-[0-9]*", pkg);
 				if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
 					add_to_list_fn, &pkgs) > 0) {
 					return 0;	/* we've just appended some names to the pkgs list,
@@ -167,7 +167,7 @@
          * any sense.
          */
 	if (Flags & SHOW_INDEX) {
-		char    tmp[FILENAME_MAX];
+		char    tmp[PATH_MAX];
 
 		(void) snprintf(tmp, sizeof(tmp), "%-19s ", pkg);
 		show_index(tmp, COMMENT_FNAME);
@@ -267,7 +267,7 @@
 foundpkg(const char *found, void *vp)
 {
 	char *data = vp;
-	char buf[FILENAME_MAX+1];
+	char buf[PATH_MAX+1];
 
 	/* we only want to display this if it really is a directory */
 	snprintf(buf, sizeof(buf), "%s/%s", data, found);
@@ -291,7 +291,7 @@
 static int
 CheckForPkg(char *pkgspec, char *dbdir)
 {
-	char    buf[FILENAME_MAX];
+	char    buf[PATH_MAX];
 	int     error;
 
 	if (strpbrk(pkgspec, "<>[]?*{")) {
@@ -311,8 +311,8 @@
 	if (error) {
 		/* found nothing - try 'pkg-[0-9]*' */
 		
-		char    try[FILENAME_MAX];
-		snprintf(try, FILENAME_MAX, "%s-[0-9]*", pkgspec);
+		char    try[PATH_MAX];
+		snprintf(try, PATH_MAX, "%s-[0-9]*", pkgspec);
 		if (findmatchingname(dbdir, try, foundpkg, dbdir) > 0) {
 			error = 0;
 		}
@@ -355,7 +355,7 @@
 			/* Show all packges with description */
 			if ((dirp = opendir(dbdir)) != (DIR *) NULL) {
 				while ((dp = readdir(dirp)) != (struct dirent *) NULL) {
-					char    tmp2[FILENAME_MAX];
+					char    tmp2[PATH_MAX];
 
 					if (strcmp(dp->d_name, ".") == 0 ||
 					    strcmp(dp->d_name, "..") == 0)
Index: lib/file.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/file.c,v
retrieving revision 1.12
diff -b -u -w -r1.12 file.c
--- lib/file.c	14 Jan 2004 23:55:29 -0000	1.12
+++ lib/file.c	29 Mar 2004 05:16:35 -0000
@@ -255,10 +255,10 @@
 char   *
 fileGetURL(const char *spec)
 {
-	char    host[MAXHOSTNAMELEN], file[FILENAME_MAX];
+	char    host[MAXHOSTNAMELEN], file[PATH_MAX];
 	const char *cp;
 	char   *rp;
-	char    pen[FILENAME_MAX];
+	char    pen[PATH_MAX];
 	int     rc;
 
 	rp = NULL;
@@ -272,7 +272,7 @@
 		warnx("URL `%s' has bad host part!", spec);
 		return NULL;
 	}
-	cp = fileURLFilename(spec, file, FILENAME_MAX);
+	cp = fileURLFilename(spec, file, PATH_MAX);
 	if (!*cp) {
 		warnx("URL `%s' has bad filename part!", spec);
 		return NULL;
@@ -302,7 +302,7 @@
 static char *
 resolvepattern1(const char *name)
 {
-	static char tmp[FILENAME_MAX];
+	static char tmp[PATH_MAX];
 	char *cp;
 
 	if (IS_URL(name)) {
@@ -338,7 +338,7 @@
 static char *
 resolvepattern(const char *name)
 {
-	char tmp[FILENAME_MAX];
+	char tmp[PATH_MAX];
 	char *cp;
 	const char *suf;
 
@@ -375,7 +375,7 @@
 char   *
 fileFindByPath(const char *fname)
 {
-	char    tmp[FILENAME_MAX];
+	char    tmp[PATH_MAX];
 	struct path *path;
 
 	/*
@@ -515,7 +515,7 @@
 void
 copy_file(char *dir, char *fname, char *to)
 {
-	char    fpath[FILENAME_MAX];
+	char    fpath[PATH_MAX];
 
 	(void) snprintf(fpath, sizeof(fpath), "%s%s%s",
 			(fname[0] != '/') ? dir : "",
@@ -530,7 +530,7 @@
 void
 move_file(char *dir, char *fname, char *to)
 {
-	char    fpath[FILENAME_MAX];
+	char    fpath[PATH_MAX];
 
 	(void) snprintf(fpath, sizeof(fpath), "%s%s%s",
 			(fname[0] != '/') ? dir : "",
@@ -545,7 +545,7 @@
 void
 remove_files(const char *path, const char *pattern)
 {
-	char	fpath[FILENAME_MAX];
+	char	fpath[PATH_MAX];
 	glob_t	globbed;
 	int	i;
 
@@ -583,7 +583,7 @@
 unpack(const char *pkg, const char *flist)
 {
 	char args[10] = "-";
-	char cmd[FILENAME_MAX];
+	char cmd[PATH_MAX];
 	const char *decompress_cmd = NULL;
 	const char *suf;
 
@@ -630,7 +630,7 @@
 void
 format_cmd(char *buf, size_t size, char *fmt, char *dir, char *name)
 {
-	char    scratch[FILENAME_MAX * 2];
+	char    scratch[PATH_MAX * 2];
 	char   *bufp;
 	char   *cp;
 
Index: lib/ftpio.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/ftpio.c,v
retrieving revision 1.8
diff -b -u -w -r1.8 ftpio.c
--- lib/ftpio.c	20 Dec 2003 04:23:05 -0000	1.8
+++ lib/ftpio.c	29 Mar 2004 05:16:35 -0000
@@ -609,7 +609,7 @@
 {
 	char *pattern;
 	char *bestmatch;
-	char base[FILENAME_MAX];
+	char base[PATH_MAX];
 
 	pattern=strrchr(wildcardurl, '/');
 	if (pattern == NULL){
@@ -638,7 +638,7 @@
 	if (bestmatch == NULL)
 		return -1;
 
-	snprintf(expandedurl, FILENAME_MAX, "%s%s", base, bestmatch);
+	snprintf(expandedurl, PATH_MAX, "%s%s", base, bestmatch);
 	if (Verbose)
 		printf("best match: '%s'\n", expandedurl);
 
@@ -649,9 +649,9 @@
 static char *
 ftp_expand_URL(const char *base, char *pattern)
 {
-	char *s, buf[FILENAME_MAX];
-	char tmpname[FILENAME_MAX];
-	char best[FILENAME_MAX];
+	char *s, buf[PATH_MAX];
+	char tmpname[PATH_MAX];
+	char best[PATH_MAX];
 	int rc, tfd;
 
 	rc = ftp_start(base);
@@ -705,7 +705,7 @@
 	if (access(tmpname, R_OK)==0) {
 		int matches;
 		FILE *f;
-		char filename[FILENAME_MAX];
+		char filename[PATH_MAX];
 
 		f=fopen(tmpname, "r");
 		if (f == NULL) {
@@ -723,8 +723,8 @@
 			 * suffix here
 			 */
 
-			char s_filename[FILENAME_MAX];
-			char s_pattern[FILENAME_MAX];
+			char s_filename[PATH_MAX];
+			char s_pattern[PATH_MAX];
 	    
 			filename[strlen(filename)-1] = '\0';
 
@@ -756,9 +756,9 @@
 static char *
 http_expand_URL(const char *base, char *pattern)
 {
-	char    best[FILENAME_MAX];
+	char    best[PATH_MAX];
 	char    line[BUFSIZ];
-	char    filename[FILENAME_MAX];
+	char    filename[PATH_MAX];
 	FILE   *fp;
 	int	pipefds[2];
 	int     state;
@@ -795,7 +795,7 @@
 	if ((fp=fdopen(pipefds[0], "r")) == NULL)
 		warn("can't fdopen pipe end");
 	else {
-		char s_pattern[FILENAME_MAX];
+		char s_pattern[PATH_MAX];
 		int len, offset;
 
 		/* strip of .t[bg]z for comparison */
@@ -809,7 +809,7 @@
 			len = offset = 0;
 			while ((len=http_extract_fn(line+offset, filename,
 						      sizeof(filename))) > 0) {
-				char s_filename[FILENAME_MAX];
+				char s_filename[PATH_MAX];
 
 				offset += len;
 				strip_txz(s_filename, NULL, filename);
@@ -851,7 +851,7 @@
 http_extract_fn(char *input, char *outbuf, size_t outbuflen)
 {
 	/* partial copied hrefs from previous calls are saved here */
-	static char tempbuf[FILENAME_MAX];
+	static char tempbuf[PATH_MAX];
 	/* fill state of tempbuf */
 	static int tempbuffill = 0;
 	/* parsing state information */
@@ -1168,12 +1168,12 @@
 {
 	char *pkg;
 	int rc;
-	char base[FILENAME_MAX];
-	char pkg_path[FILENAME_MAX];
+	char base[PATH_MAX];
+	char pkg_path[PATH_MAX];
 
 	{
 		/* Verify if the URL is really ok */
-		char expnd[FILENAME_MAX];
+		char expnd[PATH_MAX];
 
 		rc=expandURL(expnd, url);
 		if (rc == -1) {
@@ -1265,7 +1265,7 @@
 		usage();
 
 	while(argv[0] != NULL) {
-		char newurl[FILENAME_MAX];
+		char newurl[PATH_MAX];
 	    
 		printf("Expand %s:\n", argv[0]);
 		rc = expandURL(newurl, argv[0]);
@@ -1276,7 +1276,7 @@
 
 		/* test out connection caching */
 		if (1) {
-			char *s, buf[FILENAME_MAX];
+			char *s, buf[PATH_MAX];
 		    
 			if ((s=getenv(PKG_FTPIO_CNT)) && atoi(s)>0){
 				(void) snprintf(buf, sizeof(buf),"%d", atoi(s)-1);
Index: lib/lib.h
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/lib.h,v
retrieving revision 1.9
diff -b -u -w -r1.9 lib.h
--- lib/lib.h	7 Feb 2004 10:37:53 -0000	1.9
+++ lib/lib.h	29 Mar 2004 05:16:35 -0000
@@ -156,7 +156,7 @@
 /* The name of the "prefix" environment variable given to scripts */
 #define PKG_PREFIX_VNAME	"PKG_PREFIX"
 
-#define	PKG_PATTERN_MAX	FILENAME_MAX	/* max length of pattern, including nul */
+#define	PKG_PATTERN_MAX	PATH_MAX	/* max length of pattern, including nul */
 #define	PKG_SUFFIX_MAX	10	/* max length of suffix, including nul */
 
 enum {
Index: lib/pen.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/pen.c,v
retrieving revision 1.12
diff -b -u -w -r1.12 pen.c
--- lib/pen.c	23 Sep 2003 07:13:53 -0000	1.12
+++ lib/pen.c	29 Mar 2004 05:16:35 -0000
@@ -53,8 +53,8 @@
 #endif
 
 /* For keeping track of where we are */
-static char Current[FILENAME_MAX];
-static char Previous[FILENAME_MAX];
+static char Current[PATH_MAX];
+static char Previous[PATH_MAX];
 static int CurrentSet;		/* rm -fr Current only if it's really set! */
                                 /* CurrentSet is set to 0 before strcpy()s
 				 * to prevent rm'ing of a partial string
@@ -158,7 +158,7 @@
 	}
 	if (Current[0])
 		strlcpy(Previous, Current, sizeof(Previous));
-	else if (!getcwd(Previous, FILENAME_MAX)) {
+	else if (!getcwd(Previous, PATH_MAX)) {
 		cleanup(0);
 		err(EXIT_FAILURE, "fatal error during execution: getcwd");
 	}
Index: lib/pkgdb.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c,v
retrieving revision 1.19
diff -b -u -w -r1.19 pkgdb.c
--- lib/pkgdb.c	9 Sep 2003 13:34:21 -0000	1.19
+++ lib/pkgdb.c	29 Mar 2004 05:16:35 -0000
@@ -80,7 +80,7 @@
 static DB   *pkgdbp;
 #endif
 static char *pkgdb_dir = NULL;
-static char  pkgdb_cache[FILENAME_MAX];
+static char  pkgdb_cache[PATH_MAX];
 
 #if HAVE_DBOPEN
 /*
@@ -93,7 +93,7 @@
 pkgdb_open(int mode)
 {
 	BTREEINFO info;
-	char	cachename[FILENAME_MAX];
+	char	cachename[PATH_MAX];
 
 	/* try our btree format first */
 	info.flags = 0;
@@ -142,7 +142,7 @@
 	vald.data = (void *) val;
 	vald.size = strlen(val) + 1;
 
-	if (keyd.size > FILENAME_MAX || vald.size > FILENAME_MAX)
+	if (keyd.size > PATH_MAX || vald.size > PATH_MAX)
 		return -1;
 
 	return (*pkgdbp->put) (pkgdbp, &keyd, &vald, R_NOOVERWRITE);
@@ -214,7 +214,7 @@
 
 	keyd.data = (char *) key;
 	keyd.size = strlen(key) + 1;
-	if (keyd.size > FILENAME_MAX)
+	if (keyd.size > PATH_MAX)
 		return -1;
 
 	return (*pkgdbp->del) (pkgdbp, &keyd, 0);
@@ -234,7 +234,7 @@
 	int	type;
 	int	ret;
 	int	cc;
-	char	cachename[FILENAME_MAX];
+	char	cachename[PATH_MAX];
 
 	if (pkgdbp == NULL) {
 		return 0;
Index: lib/plist.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/plist.c,v
retrieving revision 1.8
diff -b -u -w -r1.8 plist.c
--- lib/plist.c	7 Feb 2004 10:37:53 -0000	1.8
+++ lib/plist.c	29 Mar 2004 05:16:35 -0000
@@ -243,7 +243,7 @@
 plist_cmd(char *s, char **arg)
 {
 	const cmd_t *cmdp;
-	char    cmd[FILENAME_MAX + 20];	/* 20 == fudge for max cmd len */
+	char    cmd[PATH_MAX + 20];	/* 20 == fudge for max cmd len */
 	char   *cp;
 	char   *sp;
 
@@ -270,12 +270,12 @@
 void
 read_plist(package_t *pkg, FILE * fp)
 {
-	char    pline[FILENAME_MAX];
+	char    pline[PATH_MAX];
 	char   *cp;
 	int     cmd;
 	int     len;
 
-	while (fgets(pline, FILENAME_MAX, fp) != (char *) NULL) {
+	while (fgets(pline, PATH_MAX, fp) != (char *) NULL) {
 		for (len = strlen(pline); len &&
 		    isspace((unsigned char) pline[len - 1]);) {
 			pline[--len] = '\0';
@@ -341,7 +341,7 @@
 	char   *Where = ".", *last_file = "";
 	int     fail = SUCCESS;
 	Boolean preserve;
-	char    tmp[FILENAME_MAX], *name = NULL;
+	char    tmp[PATH_MAX], *name = NULL;
 
 	if (!pkgdb_open(ReadWrite)) {
 		err(EXIT_FAILURE, "cannot open pkgdb");
@@ -397,7 +397,7 @@
 							}
 						}
 					} else if (strncmp(p->next->name, SYMLINK_HEADER, SymlinkHeaderLen) == 0) {
-						char	buf[FILENAME_MAX + SymlinkHeaderLen];
+						char	buf[PATH_MAX + SymlinkHeaderLen];
 						int	cc;
 
 						(void) strlcpy(buf, SYMLINK_HEADER,
@@ -426,9 +426,9 @@
 					if (delete_hierarchy(tmp, ign_err, nukedirs))
 						fail = FAIL;
 					if (preserve && name) {
-						char    tmp2[FILENAME_MAX];
+						char    tmp2[PATH_MAX];
 
-						if (make_preserve_name(tmp2, FILENAME_MAX, name, tmp)) {
+						if (make_preserve_name(tmp2, PATH_MAX, name, tmp)) {
 							if (fexists(tmp2)) {
 								if (rename(tmp2, tmp))
 									warn("preserve: unable to restore %s as %s",
Index: lib/str.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/str.c,v
retrieving revision 1.7
diff -b -u -w -r1.7 str.c
--- lib/str.c	29 Oct 2003 23:00:28 -0000	1.7
+++ lib/str.c	29 Mar 2004 05:16:35 -0000
@@ -324,7 +324,7 @@
 alternate_match(const char *pattern, const char *pkg)
 {
 	char   *sep;
-	char    buf[FILENAME_MAX];
+	char    buf[PATH_MAX];
 	char   *last;
 	char   *alt;
 	char   *cp;
@@ -373,7 +373,7 @@
 	char   *cp;
 	char   *sep;
 	char   *ver;
-	char    name[FILENAME_MAX];
+	char    name[PATH_MAX];
 	int	op;
 	int     n;
 
@@ -469,7 +469,7 @@
 	strip_txz(tmp_pattern, pat_sfx, pattern);
 	
 	while ((dp = readdir(dirp)) != (struct dirent *) NULL) {
-		char    tmp_file[FILENAME_MAX];
+		char    tmp_file[PATH_MAX];
 		
 		if (strcmp(dp->d_name, ".") == 0 ||
 		    strcmp(dp->d_name, "..") == 0)
@@ -565,7 +565,7 @@
 char *
 findbestmatchingname(const char *dir, const char *pattern)
 {
-	char    buf[FILENAME_MAX];
+	char    buf[PATH_MAX];
 
 	buf[0] = '\0';
 	if (findmatchingname(dir, pattern, findbestmatchingname_fn, buf) > 0
@@ -625,7 +625,7 @@
 {
 	char *note = vp;
 
-	(void) strlcpy(note, found, FILENAME_MAX);
+	(void) strlcpy(note, found, PATH_MAX);
 	return 0;
 }
 
@@ -637,7 +637,7 @@
 {
 	lpkg_head_t *pkgs = vp;
 	lpkg_t *lpp;
-	char fn[FILENAME_MAX];
+	char fn[PATH_MAX];
 
 	snprintf(fn, sizeof(fn), "%s/%s", _pkgdb_getPKGDB_DIR(), pkg);
 	if (isdir(fn) || islinktodir(fn)) {
>Release-Note:
>Audit-Trail:
>Unformatted: