From cy@cschuber.net.gov.bc.ca Fri Aug 13 16:39:40 1999
Return-Path: <cy@cschuber.net.gov.bc.ca>
Received: from point.osg.gov.bc.ca (point.osg.gov.bc.ca [142.32.102.44])
	by hub.freebsd.org (Postfix) with ESMTP id 0344B14FA9
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Aug 1999 16:39:39 -0700 (PDT)
	(envelope-from cy@cschuber.net.gov.bc.ca)
Received: (from daemon@localhost)
	by point.osg.gov.bc.ca (8.8.7/8.8.8) id QAA18262
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Aug 1999 16:41:17 -0700
Received: from da004.inetex.com(139.142.118.19), claiming to be "cwsys.cwsent.com"
 via SMTP by point.osg.gov.bc.ca, id smtpda18259; Fri Aug 13 16:41:03 1999
Received: (from cy@localhost)
	by cwsys.cwsent.com (8.9.3/8.9.1) id OAA38826;
	Fri, 13 Aug 1999 14:15:15 -0700 (PDT)
Message-Id: <199908132115.OAA38826@cwsys.cwsent.com>
Date: Fri, 13 Aug 1999 14:15:15 -0700 (PDT)
From: Cy.Schubert@uumail.gov.bc.ca
Sender: cy@cschuber.net.gov.bc.ca
Reply-To: Cy.Schubert@uumail.gov.bc.ca
To: FreeBSD-gnats-submit@freebsd.org
Subject: pkg_delete doesn't handle absolute pathnames correctly
X-Send-Pr-Version: 3.2

>Number:         13128
>Category:       bin
>Synopsis:       [patch] pkg_delete doesn't handle absolute pathnames correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bapt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 13 16:40:00 PDT 1999
>Closed-Date:    Tue Oct 02 17:07:06 UTC 2012
>Last-Modified:  Tue Oct  2 17:10:17 UTC 2012
>Originator:     Cy Schubert
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
ITSD, Provice of British Columbia
>Environment:

FreeBSD cwsys 3.2-RELEASE FreeBSD 3.2-RELEASE #0: Wed Aug 11 17:35:40 PDT 1999     root@cwsys:/opt2/cvs-320/src/sys/compile/CWSYS  i386

>Description:

If /var/db/pkg/<package name>/+CONTENTS contains absolute pathnames,
files are not deleted.

>How-To-Repeat:

Build a package using make MANPREFIX=/usr/local/somewhere install, then
pkg_delete the package.  The man files are not deleted because
/usr/local//usr/local/somewhere/man/... cannot be found.

>Fix:
	

--- src/usr.sbin/pkg_install/lib/plist.c.orig	Fri Sep 11 00:26:58 1998
+++ src/usr.sbin/pkg_install/lib/plist.c	Fri Aug 13 14:05:43 1999
@@ -389,7 +389,10 @@
 
 	case PLIST_FILE:
 	    last_file = p->name;
-	    sprintf(tmp, "%s/%s", Where, p->name);
+	    if (*p->name == '/')
+	    	strcpy(tmp, p->name);
+	    else
+	    	sprintf(tmp, "%s/%s", Where, p->name);
 	    if (isdir(tmp) && fexists(tmp)) {
 		warnx("cannot delete specified file `%s' - it is a directory!\n"
 	   "this packing list is incorrect - ignoring delete request", tmp);

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->billf 
Responsible-Changed-By: billf 
Responsible-Changed-When: Sat Aug 14 09:58:40 PDT 1999 
Responsible-Changed-Why:  
I've been playing with pkg_* recently, I'll look at this. 
Responsible-Changed-From-To: billf->cy 
Responsible-Changed-By: billf 
Responsible-Changed-When: Mon May 13 14:22:15 PDT 2002 
Responsible-Changed-Why:  
submitter is now a committer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13128 
State-Changed-From-To: open->analyzed 
State-Changed-By: cy 
State-Changed-When: Wed May 15 15:46:20 PDT 2002 
State-Changed-Why:  
Need to find a src committer to mentor me or to commit this for me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13128 
Responsible-Changed-From-To: cy->krion 
Responsible-Changed-By: cy 
Responsible-Changed-When: Tue Nov 22 00:18:02 GMT 2005 
Responsible-Changed-Why:  
Reassigning to the src committer responsible for this code. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13128 
Responsible-Changed-From-To: krion->portmgr 
Responsible-Changed-By: flz 
Responsible-Changed-When: Fri Jul 17 13:42:38 UTC 2009 
Responsible-Changed-Why:  
pkg_install is maintained by portmgr. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13128 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/13128: commit references a PR
Date: Tue, 18 Sep 2012 22:09:37 +0000 (UTC)

 Author: bapt
 Date: Tue Sep 18 22:09:23 2012
 New Revision: 240682
 URL: http://svn.freebsd.org/changeset/base/240682
 
 Log:
   if a file in plist starts with / then do not prefix it with "prefix" [1]
   pkg info -g returns 1 if a file mismatch [2]
   flush stdout in pkg info -g [3]
   clean up quiet mode (-q | --quiet) output of pkg_version(1) [4]
   fix missing error call in uname check added to pkg_version(1) [5]
   fix pkg_add(1) fails to install with -C from bad path [6]
   only resolve path from pkg_add(1) -p if the given prefix do not start with a '/' [7]
   
   PR:		bin/13128 [1]
   		bin/139015 [2]
   		bin/113702 [3]
   		bin/142570 [4]
   		bin/146857 [5]
   		bin/157543 [6]
   Submitted by:	cy [1]
   		Anton Yuzhaninov <citrin@citrin.ru> [2]
   		Ighighi <ighighi@gmail.com> [3]
   		"N.J. Mann" <njm@njm.me.uk> [4]
   		gcooper [5]
   		David Naylor <naylor.b.david@gmail.com> [6]
   		netchild [7]
   MFC after:	2 weeks
 
 Modified:
   head/usr.sbin/pkg_install/add/main.c
   head/usr.sbin/pkg_install/create/perform.c
   head/usr.sbin/pkg_install/info/info.h
   head/usr.sbin/pkg_install/info/perform.c
   head/usr.sbin/pkg_install/info/show.c
   head/usr.sbin/pkg_install/lib/lib.h
   head/usr.sbin/pkg_install/lib/plist.c
   head/usr.sbin/pkg_install/version/perform.c
 
 Modified: head/usr.sbin/pkg_install/add/main.c
 ==============================================================================
 --- head/usr.sbin/pkg_install/add/main.c	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/add/main.c	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -288,7 +288,9 @@ main(int argc, char **argv)
      }
      /* Perform chroot if requested */
      if (Chroot != NULL) {
 -	if (chroot(Chroot))
 +	if (chdir(Chroot))
 +	    errx(1, "chdir to %s failed", Chroot);
 +	if (chroot("."))
  	    errx(1, "chroot to %s failed", Chroot);
      }
      /* Make sure the sub-execs we invoke get found */
 
 Modified: head/usr.sbin/pkg_install/create/perform.c
 ==============================================================================
 --- head/usr.sbin/pkg_install/create/perform.c	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/create/perform.c	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -215,10 +215,14 @@ pkg_perform(char **pkgs)
  
      /* Prefix should add an @cwd to the packing list */
      if (Prefix) {
 -        char resolved_prefix[PATH_MAX];
 -        if (realpath(Prefix, resolved_prefix) == NULL)
 -	    err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
 -	add_plist_top(&plist, PLIST_CWD, resolved_prefix);
 +	if (Prefix[0] != '/') {
 +		char resolved_prefix[PATH_MAX];
 +		if (realpath(Prefix, resolved_prefix) == NULL)
 +		    err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
 +		add_plist_top(&plist, PLIST_CWD, resolved_prefix);
 +	} else {
 +		add_plist_top(&plist, PLIST_CWD, Prefix);
 +	}
      }
  
      /* Add the origin if asked, at the top */
 
 Modified: head/usr.sbin/pkg_install/info/info.h
 ==============================================================================
 --- head/usr.sbin/pkg_install/info/info.h	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/info/info.h	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -77,7 +77,7 @@ extern void	show_plist(const char *, Pac
  extern void	show_files(const char *, Package *);
  extern void	show_index(const char *, const char *);
  extern void	show_size(const char *, Package *);
 -extern void	show_cksum(const char *, Package *);
 +extern int	show_cksum(const char *, Package *);
  extern void	show_origin(const char *, Package *);
  extern void	show_fmtrev(const char *, Package *);
  
 
 Modified: head/usr.sbin/pkg_install/info/perform.c
 ==============================================================================
 --- head/usr.sbin/pkg_install/info/perform.c	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/info/perform.c	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -221,7 +221,7 @@ pkg_do(char *pkg)
  	if ((Flags & SHOW_SIZE) && installed)
  	    show_size("Package Size:\n", &plist);
  	if ((Flags & SHOW_CKSUM) && installed)
 -	    show_cksum("Mismatched Checksums:\n", &plist);
 +	    code += show_cksum("Mismatched Checksums:\n", &plist);
  	if (Flags & SHOW_ORIGIN)
  	    show_origin("Origin:\n", &plist);
  	if (Flags & SHOW_FMTREV)
 @@ -234,7 +234,7 @@ pkg_do(char *pkg)
      leave_playpen();
      if (isTMP)
  	unlink(fname);
 -    return code;
 +    return (code ? 1 : 0);
  }
  
  void
 
 Modified: head/usr.sbin/pkg_install/info/show.c
 ==============================================================================
 --- head/usr.sbin/pkg_install/info/show.c	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/info/show.c	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -61,8 +61,10 @@ show_index(const char *title, const char
  
      strlcpy(line, "???\n", sizeof(line));
  
 -    if (!Quiet)
 +    if (!Quiet) {
          printf("%s%s", InfoPrefix, title);
 +        fflush(stdout);
 +    }
      fp = fopen(fname, "r");
      if (fp == (FILE *) NULL) {
          warnx("show_file: can't open '%s' for reading", fname);
 @@ -88,8 +90,10 @@ show_plist(const char *title, Package *p
      Boolean ign = FALSE;
      char *prefix = NULL;
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      p = plist->head;
      while (p) {
  	if (p->type != type && showall != TRUE) {
 @@ -272,8 +276,10 @@ show_size(const char *title, Package *pl
      char *prefix = NULL;
  
      descr = getbsize(&headerlen, &blksize);
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +        fflush(stdout);
 +    }
      for (p = plist->head; p != NULL; p = p->next) {
  	switch (p->type) {
  	case PLIST_FILE:
 @@ -316,16 +322,19 @@ show_size(const char *title, Package *pl
  }
  
  /* Show files that don't match the recorded checksum */
 -void
 +int
  show_cksum(const char *title, Package *plist)
  {
      PackingList p;
      const char *dir = ".";
      char *prefix = NULL;
      char tmp[FILENAME_MAX];
 +    int errcode = 0;
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
  
      for (p = plist->head; p != NULL; p = p->next)
  	if (p->type == PLIST_CWD) {
 @@ -337,9 +346,10 @@ show_cksum(const char *title, Package *p
  		dir = p->name;
  	} else if (p->type == PLIST_FILE) {
  	    snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
 -	    if (!fexists(tmp))
 +	    if (!fexists(tmp)) {
  		warnx("%s doesn't exist", tmp);
 -	    else if (p->next && p->next->type == PLIST_COMMENT &&
 +		errcode = 1;
 +	    } else if (p->next && p->next->type == PLIST_COMMENT &&
  	             (strncmp(p->next->name, "MD5:", 4) == 0)) {
  		char *cp = NULL, buf[33];
  
 @@ -366,6 +376,7 @@ show_cksum(const char *title, Package *p
  		}
  	    }
  	}
 +    return (errcode);
  }
  
  /* Show an "origin" path (usually category/portname) */
 @@ -373,8 +384,10 @@ void
  show_origin(const char *title, Package *plist)
  {
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      printf("%s\n", plist->origin != NULL ? plist->origin : "");
  }
  
 @@ -383,7 +396,9 @@ void
  show_fmtrev(const char *title, Package *plist)
  {
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr);
  }
 
 Modified: head/usr.sbin/pkg_install/lib/lib.h
 ==============================================================================
 --- head/usr.sbin/pkg_install/lib/lib.h	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/lib/lib.h	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -99,7 +99,7 @@
   * Version of the package tools - increase whenever you make a change
   * in the code that is not cosmetic only.
   */
 -#define PKG_INSTALL_VERSION	20120913
 +#define PKG_INSTALL_VERSION	20120918
  
  #define PKG_WRAPCONF_FNAME	"/var/db/pkg_install.conf"
  #define main(argc, argv)	real_main(argc, argv)
 
 Modified: head/usr.sbin/pkg_install/lib/plist.c
 ==============================================================================
 --- head/usr.sbin/pkg_install/lib/plist.c	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/lib/plist.c	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -458,7 +458,10 @@ delete_package(Boolean ign_err, Boolean 
  
  	case PLIST_FILE:
  	    last_file = p->name;
 -	    sprintf(tmp, "%s/%s", Where, p->name);
 +	    if (*p->name == '/')
 +		strlcpy(tmp, p->name, FILENAME_MAX);
 +	    else
 +		sprintf(tmp, "%s/%s", Where, p->name);
  	    if (isdir(tmp) && fexists(tmp) && !issymlink(tmp)) {
  		warnx("cannot delete specified file '%s' - it is a directory!\n"
  	   "this packing list is incorrect - ignoring delete request", tmp);
 
 Modified: head/usr.sbin/pkg_install/version/perform.c
 ==============================================================================
 --- head/usr.sbin/pkg_install/version/perform.c	Tue Sep 18 22:08:51 2012	(r240681)
 +++ head/usr.sbin/pkg_install/version/perform.c	Tue Sep 18 22:09:23 2012	(r240682)
 @@ -56,10 +56,11 @@ pkg_perform(char **indexarg)
      struct utsname u;
  
      if (uname(&u) == -1) {
 -	warn("%s(): failed to determine uname information", __func__);
 +	warn("%s: failed to determine uname information", __func__);
  	return 1;
      } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) {
 -
 +	warnx("%s: bad release version specified: %s", __func__, u.release);
 +	return 1;
      }
  
      /*
 @@ -321,19 +322,31 @@ show_version(Package plist, const char *
  	ver = strrchr(latest, '-');
  	ver = ver ? &ver[1] : latest;
  	if (cmp < 0 && OUTPUT('<')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '<');
 -	    if (Verbose)
 -		printf("   needs updating (%s has %s)", source, ver);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  <", tmp);
 +		if (Verbose)
 +		    printf("   needs updating (%s has %s)", source, ver);
 +	    }
  	    printf("\n");
  	} else if (cmp == 0 && OUTPUT('=')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '=');
 -	    if (Verbose)
 -		printf("   up-to-date with %s", source);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  =", tmp);
 +		if (Verbose)
 +		    printf("   up-to-date with %s", source);
 +	    }
  	    printf("\n");
  	} else if (cmp > 0 && OUTPUT('>')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '>');
 -	    if (Verbose)
 -		printf("   succeeds %s (%s has %s)", source, source, ver);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  >", tmp);
 +		if (Verbose)
 +		    printf("   succeeds %s (%s has %s)", source, source, ver);
 +	    }
  	    printf("\n");
  	}
      }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: bapt 
State-Changed-When: Tue Sep 18 22:12:07 UTC 2012 
State-Changed-Why:  
awaiting MFC 


Responsible-Changed-From-To: portmgr->bapt 
Responsible-Changed-By: bapt 
Responsible-Changed-When: Tue Sep 18 22:12:07 UTC 2012 
Responsible-Changed-Why:  
awaiting MFC 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13128 
State-Changed-From-To: patched->closed 
State-Changed-By: bapt 
State-Changed-When: Tue Oct 2 17:07:04 UTC 2012 
State-Changed-Why:  
MFCed, thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13128 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/13128: commit references a PR
Date: Tue,  2 Oct 2012 17:05:19 +0000 (UTC)

 Author: bapt
 Date: Tue Oct  2 17:04:53 2012
 New Revision: 241135
 URL: http://svn.freebsd.org/changeset/base/241135
 
 Log:
   MFC r240682
   
   if a file in plist starts with / then do not prefix it with "prefix" [1]
   pkg info -g returns 1 if a file mismatch [2]
   flush stdout in pkg info -g [3]
   clean up quiet mode (-q | --quiet) output of pkg_version(1) [4]
   fix missing error call in uname check added to pkg_version(1) [5]
   fix pkg_add(1) fails to install with -C from bad path [6]
   only resolve path from pkg_add(1) -p if the given prefix do not start with a '/' [7]
   
   PR:		bin/13128 [1]
   		bin/139015 [2]
   		bin/113702 [3]
   		bin/142570 [4]
   		bin/146857 [5]
   		bin/157543 [6]
   Submitted by:	cy [1]
   		Anton Yuzhaninov <citrin@citrin.ru> [2]
   		Ighighi <ighighi@gmail.com> [3]
   		"N.J. Mann" <njm@njm.me.uk> [4]
   		gcooper [5]
   		David Naylor <naylor.b.david@gmail.com> [6]
   		netchild [7]
 
 Modified:
   stable/9/usr.sbin/pkg_install/add/main.c
   stable/9/usr.sbin/pkg_install/create/perform.c
   stable/9/usr.sbin/pkg_install/info/info.h
   stable/9/usr.sbin/pkg_install/info/perform.c
   stable/9/usr.sbin/pkg_install/info/show.c
   stable/9/usr.sbin/pkg_install/lib/lib.h
   stable/9/usr.sbin/pkg_install/lib/plist.c
   stable/9/usr.sbin/pkg_install/version/perform.c
 Directory Properties:
   stable/9/usr.sbin/pkg_install/   (props changed)
   stable/9/usr.sbin/pkg_install/add/   (props changed)
   stable/9/usr.sbin/pkg_install/info/   (props changed)
 
 Modified: stable/9/usr.sbin/pkg_install/add/main.c
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/add/main.c	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/add/main.c	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -288,7 +288,9 @@ main(int argc, char **argv)
      }
      /* Perform chroot if requested */
      if (Chroot != NULL) {
 -	if (chroot(Chroot))
 +	if (chdir(Chroot))
 +	    errx(1, "chdir to %s failed", Chroot);
 +	if (chroot("."))
  	    errx(1, "chroot to %s failed", Chroot);
      }
      /* Make sure the sub-execs we invoke get found */
 
 Modified: stable/9/usr.sbin/pkg_install/create/perform.c
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/create/perform.c	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/create/perform.c	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -215,10 +215,14 @@ pkg_perform(char **pkgs)
  
      /* Prefix should add an @cwd to the packing list */
      if (Prefix) {
 -        char resolved_prefix[PATH_MAX];
 -        if (realpath(Prefix, resolved_prefix) == NULL)
 -	    err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
 -	add_plist_top(&plist, PLIST_CWD, resolved_prefix);
 +	if (Prefix[0] != '/') {
 +		char resolved_prefix[PATH_MAX];
 +		if (realpath(Prefix, resolved_prefix) == NULL)
 +		    err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
 +		add_plist_top(&plist, PLIST_CWD, resolved_prefix);
 +	} else {
 +		add_plist_top(&plist, PLIST_CWD, Prefix);
 +	}
      }
  
      /* Add the origin if asked, at the top */
 
 Modified: stable/9/usr.sbin/pkg_install/info/info.h
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/info/info.h	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/info/info.h	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -77,7 +77,7 @@ extern void	show_plist(const char *, Pac
  extern void	show_files(const char *, Package *);
  extern void	show_index(const char *, const char *);
  extern void	show_size(const char *, Package *);
 -extern void	show_cksum(const char *, Package *);
 +extern int	show_cksum(const char *, Package *);
  extern void	show_origin(const char *, Package *);
  extern void	show_fmtrev(const char *, Package *);
  
 
 Modified: stable/9/usr.sbin/pkg_install/info/perform.c
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/info/perform.c	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/info/perform.c	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -221,7 +221,7 @@ pkg_do(char *pkg)
  	if ((Flags & SHOW_SIZE) && installed)
  	    show_size("Package Size:\n", &plist);
  	if ((Flags & SHOW_CKSUM) && installed)
 -	    show_cksum("Mismatched Checksums:\n", &plist);
 +	    code += show_cksum("Mismatched Checksums:\n", &plist);
  	if (Flags & SHOW_ORIGIN)
  	    show_origin("Origin:\n", &plist);
  	if (Flags & SHOW_FMTREV)
 @@ -234,7 +234,7 @@ pkg_do(char *pkg)
      leave_playpen();
      if (isTMP)
  	unlink(fname);
 -    return code;
 +    return (code ? 1 : 0);
  }
  
  void
 
 Modified: stable/9/usr.sbin/pkg_install/info/show.c
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/info/show.c	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/info/show.c	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -61,8 +61,10 @@ show_index(const char *title, const char
  
      strlcpy(line, "???\n", sizeof(line));
  
 -    if (!Quiet)
 +    if (!Quiet) {
          printf("%s%s", InfoPrefix, title);
 +        fflush(stdout);
 +    }
      fp = fopen(fname, "r");
      if (fp == (FILE *) NULL) {
          warnx("show_file: can't open '%s' for reading", fname);
 @@ -88,8 +90,10 @@ show_plist(const char *title, Package *p
      Boolean ign = FALSE;
      char *prefix = NULL;
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      p = plist->head;
      while (p) {
  	if (p->type != type && showall != TRUE) {
 @@ -272,8 +276,10 @@ show_size(const char *title, Package *pl
      char *prefix = NULL;
  
      descr = getbsize(&headerlen, &blksize);
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +        fflush(stdout);
 +    }
      for (p = plist->head; p != NULL; p = p->next) {
  	switch (p->type) {
  	case PLIST_FILE:
 @@ -316,16 +322,19 @@ show_size(const char *title, Package *pl
  }
  
  /* Show files that don't match the recorded checksum */
 -void
 +int
  show_cksum(const char *title, Package *plist)
  {
      PackingList p;
      const char *dir = ".";
      char *prefix = NULL;
      char tmp[FILENAME_MAX];
 +    int errcode = 0;
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
  
      for (p = plist->head; p != NULL; p = p->next)
  	if (p->type == PLIST_CWD) {
 @@ -337,9 +346,10 @@ show_cksum(const char *title, Package *p
  		dir = p->name;
  	} else if (p->type == PLIST_FILE) {
  	    snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
 -	    if (!fexists(tmp))
 +	    if (!fexists(tmp)) {
  		warnx("%s doesn't exist", tmp);
 -	    else if (p->next && p->next->type == PLIST_COMMENT &&
 +		errcode = 1;
 +	    } else if (p->next && p->next->type == PLIST_COMMENT &&
  	             (strncmp(p->next->name, "MD5:", 4) == 0)) {
  		char *cp = NULL, buf[33];
  
 @@ -366,6 +376,7 @@ show_cksum(const char *title, Package *p
  		}
  	    }
  	}
 +    return (errcode);
  }
  
  /* Show an "origin" path (usually category/portname) */
 @@ -373,8 +384,10 @@ void
  show_origin(const char *title, Package *plist)
  {
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      printf("%s\n", plist->origin != NULL ? plist->origin : "");
  }
  
 @@ -383,7 +396,9 @@ void
  show_fmtrev(const char *title, Package *plist)
  {
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr);
  }
 
 Modified: stable/9/usr.sbin/pkg_install/lib/lib.h
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/lib/lib.h	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/lib/lib.h	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -99,7 +99,7 @@
   * Version of the package tools - increase whenever you make a change
   * in the code that is not cosmetic only.
   */
 -#define PKG_INSTALL_VERSION	20120913
 +#define PKG_INSTALL_VERSION	20120918
  
  #define PKG_WRAPCONF_FNAME	"/var/db/pkg_install.conf"
  #define main(argc, argv)	real_main(argc, argv)
 
 Modified: stable/9/usr.sbin/pkg_install/lib/plist.c
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/lib/plist.c	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/lib/plist.c	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -458,7 +458,10 @@ delete_package(Boolean ign_err, Boolean 
  
  	case PLIST_FILE:
  	    last_file = p->name;
 -	    sprintf(tmp, "%s/%s", Where, p->name);
 +	    if (*p->name == '/')
 +		strlcpy(tmp, p->name, FILENAME_MAX);
 +	    else
 +		sprintf(tmp, "%s/%s", Where, p->name);
  	    if (isdir(tmp) && fexists(tmp) && !issymlink(tmp)) {
  		warnx("cannot delete specified file '%s' - it is a directory!\n"
  	   "this packing list is incorrect - ignoring delete request", tmp);
 
 Modified: stable/9/usr.sbin/pkg_install/version/perform.c
 ==============================================================================
 --- stable/9/usr.sbin/pkg_install/version/perform.c	Tue Oct  2 14:48:03 2012	(r241134)
 +++ stable/9/usr.sbin/pkg_install/version/perform.c	Tue Oct  2 17:04:53 2012	(r241135)
 @@ -56,10 +56,11 @@ pkg_perform(char **indexarg)
      struct utsname u;
  
      if (uname(&u) == -1) {
 -	warn("%s(): failed to determine uname information", __func__);
 +	warn("%s: failed to determine uname information", __func__);
  	return 1;
      } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) {
 -
 +	warnx("%s: bad release version specified: %s", __func__, u.release);
 +	return 1;
      }
  
      /*
 @@ -321,19 +322,31 @@ show_version(Package plist, const char *
  	ver = strrchr(latest, '-');
  	ver = ver ? &ver[1] : latest;
  	if (cmp < 0 && OUTPUT('<')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '<');
 -	    if (Verbose)
 -		printf("   needs updating (%s has %s)", source, ver);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  <", tmp);
 +		if (Verbose)
 +		    printf("   needs updating (%s has %s)", source, ver);
 +	    }
  	    printf("\n");
  	} else if (cmp == 0 && OUTPUT('=')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '=');
 -	    if (Verbose)
 -		printf("   up-to-date with %s", source);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  =", tmp);
 +		if (Verbose)
 +		    printf("   up-to-date with %s", source);
 +	    }
  	    printf("\n");
  	} else if (cmp > 0 && OUTPUT('>')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '>');
 -	    if (Verbose)
 -		printf("   succeeds %s (%s has %s)", source, source, ver);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  >", tmp);
 +		if (Verbose)
 +		    printf("   succeeds %s (%s has %s)", source, source, ver);
 +	    }
  	    printf("\n");
  	}
      }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/13128: commit references a PR
Date: Tue,  2 Oct 2012 17:05:35 +0000 (UTC)

 Author: bapt
 Date: Tue Oct  2 17:05:20 2012
 New Revision: 241136
 URL: http://svn.freebsd.org/changeset/base/241136
 
 Log:
   MFC r240682
   
   if a file in plist starts with / then do not prefix it with "prefix" [1]
   pkg info -g returns 1 if a file mismatch [2]
   flush stdout in pkg info -g [3]
   clean up quiet mode (-q | --quiet) output of pkg_version(1) [4]
   fix missing error call in uname check added to pkg_version(1) [5]
   fix pkg_add(1) fails to install with -C from bad path [6]
   only resolve path from pkg_add(1) -p if the given prefix do not start with a '/' [7]
   
   PR:		bin/13128 [1]
   		bin/139015 [2]
   		bin/113702 [3]
   		bin/142570 [4]
   		bin/146857 [5]
   		bin/157543 [6]
   Submitted by:	cy [1]
   		Anton Yuzhaninov <citrin@citrin.ru> [2]
   		Ighighi <ighighi@gmail.com> [3]
   		"N.J. Mann" <njm@njm.me.uk> [4]
   		gcooper [5]
   		David Naylor <naylor.b.david@gmail.com> [6]
   		netchild [7]
 
 Modified:
   stable/8/usr.sbin/pkg_install/add/main.c
   stable/8/usr.sbin/pkg_install/create/perform.c
   stable/8/usr.sbin/pkg_install/info/info.h
   stable/8/usr.sbin/pkg_install/info/perform.c
   stable/8/usr.sbin/pkg_install/info/show.c
   stable/8/usr.sbin/pkg_install/lib/lib.h
   stable/8/usr.sbin/pkg_install/lib/plist.c
   stable/8/usr.sbin/pkg_install/version/perform.c
 Directory Properties:
   stable/8/usr.sbin/pkg_install/   (props changed)
   stable/8/usr.sbin/pkg_install/add/   (props changed)
   stable/8/usr.sbin/pkg_install/info/   (props changed)
 
 Modified: stable/8/usr.sbin/pkg_install/add/main.c
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/add/main.c	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/add/main.c	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -288,7 +288,9 @@ main(int argc, char **argv)
      }
      /* Perform chroot if requested */
      if (Chroot != NULL) {
 -	if (chroot(Chroot))
 +	if (chdir(Chroot))
 +	    errx(1, "chdir to %s failed", Chroot);
 +	if (chroot("."))
  	    errx(1, "chroot to %s failed", Chroot);
      }
      /* Make sure the sub-execs we invoke get found */
 
 Modified: stable/8/usr.sbin/pkg_install/create/perform.c
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/create/perform.c	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/create/perform.c	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -215,10 +215,14 @@ pkg_perform(char **pkgs)
  
      /* Prefix should add an @cwd to the packing list */
      if (Prefix) {
 -        char resolved_prefix[PATH_MAX];
 -        if (realpath(Prefix, resolved_prefix) == NULL)
 -	    err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
 -	add_plist_top(&plist, PLIST_CWD, resolved_prefix);
 +	if (Prefix[0] != '/') {
 +		char resolved_prefix[PATH_MAX];
 +		if (realpath(Prefix, resolved_prefix) == NULL)
 +		    err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix);
 +		add_plist_top(&plist, PLIST_CWD, resolved_prefix);
 +	} else {
 +		add_plist_top(&plist, PLIST_CWD, Prefix);
 +	}
      }
  
      /* Add the origin if asked, at the top */
 
 Modified: stable/8/usr.sbin/pkg_install/info/info.h
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/info/info.h	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/info/info.h	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -77,7 +77,7 @@ extern void	show_plist(const char *, Pac
  extern void	show_files(const char *, Package *);
  extern void	show_index(const char *, const char *);
  extern void	show_size(const char *, Package *);
 -extern void	show_cksum(const char *, Package *);
 +extern int	show_cksum(const char *, Package *);
  extern void	show_origin(const char *, Package *);
  extern void	show_fmtrev(const char *, Package *);
  
 
 Modified: stable/8/usr.sbin/pkg_install/info/perform.c
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/info/perform.c	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/info/perform.c	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -221,7 +221,7 @@ pkg_do(char *pkg)
  	if ((Flags & SHOW_SIZE) && installed)
  	    show_size("Package Size:\n", &plist);
  	if ((Flags & SHOW_CKSUM) && installed)
 -	    show_cksum("Mismatched Checksums:\n", &plist);
 +	    code += show_cksum("Mismatched Checksums:\n", &plist);
  	if (Flags & SHOW_ORIGIN)
  	    show_origin("Origin:\n", &plist);
  	if (Flags & SHOW_FMTREV)
 @@ -234,7 +234,7 @@ pkg_do(char *pkg)
      leave_playpen();
      if (isTMP)
  	unlink(fname);
 -    return code;
 +    return (code ? 1 : 0);
  }
  
  void
 
 Modified: stable/8/usr.sbin/pkg_install/info/show.c
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/info/show.c	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/info/show.c	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -61,8 +61,10 @@ show_index(const char *title, const char
  
      strlcpy(line, "???\n", sizeof(line));
  
 -    if (!Quiet)
 +    if (!Quiet) {
          printf("%s%s", InfoPrefix, title);
 +        fflush(stdout);
 +    }
      fp = fopen(fname, "r");
      if (fp == (FILE *) NULL) {
          warnx("show_file: can't open '%s' for reading", fname);
 @@ -88,8 +90,10 @@ show_plist(const char *title, Package *p
      Boolean ign = FALSE;
      char *prefix = NULL;
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      p = plist->head;
      while (p) {
  	if (p->type != type && showall != TRUE) {
 @@ -272,8 +276,10 @@ show_size(const char *title, Package *pl
      char *prefix = NULL;
  
      descr = getbsize(&headerlen, &blksize);
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +        fflush(stdout);
 +    }
      for (p = plist->head; p != NULL; p = p->next) {
  	switch (p->type) {
  	case PLIST_FILE:
 @@ -316,16 +322,19 @@ show_size(const char *title, Package *pl
  }
  
  /* Show files that don't match the recorded checksum */
 -void
 +int
  show_cksum(const char *title, Package *plist)
  {
      PackingList p;
      const char *dir = ".";
      char *prefix = NULL;
      char tmp[FILENAME_MAX];
 +    int errcode = 0;
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
  
      for (p = plist->head; p != NULL; p = p->next)
  	if (p->type == PLIST_CWD) {
 @@ -337,9 +346,10 @@ show_cksum(const char *title, Package *p
  		dir = p->name;
  	} else if (p->type == PLIST_FILE) {
  	    snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
 -	    if (!fexists(tmp))
 +	    if (!fexists(tmp)) {
  		warnx("%s doesn't exist", tmp);
 -	    else if (p->next && p->next->type == PLIST_COMMENT &&
 +		errcode = 1;
 +	    } else if (p->next && p->next->type == PLIST_COMMENT &&
  	             (strncmp(p->next->name, "MD5:", 4) == 0)) {
  		char *cp = NULL, buf[33];
  
 @@ -366,6 +376,7 @@ show_cksum(const char *title, Package *p
  		}
  	    }
  	}
 +    return (errcode);
  }
  
  /* Show an "origin" path (usually category/portname) */
 @@ -373,8 +384,10 @@ void
  show_origin(const char *title, Package *plist)
  {
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      printf("%s\n", plist->origin != NULL ? plist->origin : "");
  }
  
 @@ -383,7 +396,9 @@ void
  show_fmtrev(const char *title, Package *plist)
  {
  
 -    if (!Quiet)
 +    if (!Quiet) {
  	printf("%s%s", InfoPrefix, title);
 +	fflush(stdout);
 +    }
      printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr);
  }
 
 Modified: stable/8/usr.sbin/pkg_install/lib/lib.h
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/lib/lib.h	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/lib/lib.h	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -99,7 +99,7 @@
   * Version of the package tools - increase whenever you make a change
   * in the code that is not cosmetic only.
   */
 -#define PKG_INSTALL_VERSION	20120913
 +#define PKG_INSTALL_VERSION	20120918
  
  #define PKG_WRAPCONF_FNAME	"/var/db/pkg_install.conf"
  #define main(argc, argv)	real_main(argc, argv)
 
 Modified: stable/8/usr.sbin/pkg_install/lib/plist.c
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/lib/plist.c	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/lib/plist.c	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -458,7 +458,10 @@ delete_package(Boolean ign_err, Boolean 
  
  	case PLIST_FILE:
  	    last_file = p->name;
 -	    sprintf(tmp, "%s/%s", Where, p->name);
 +	    if (*p->name == '/')
 +		strlcpy(tmp, p->name, FILENAME_MAX);
 +	    else
 +		sprintf(tmp, "%s/%s", Where, p->name);
  	    if (isdir(tmp) && fexists(tmp) && !issymlink(tmp)) {
  		warnx("cannot delete specified file '%s' - it is a directory!\n"
  	   "this packing list is incorrect - ignoring delete request", tmp);
 
 Modified: stable/8/usr.sbin/pkg_install/version/perform.c
 ==============================================================================
 --- stable/8/usr.sbin/pkg_install/version/perform.c	Tue Oct  2 17:04:53 2012	(r241135)
 +++ stable/8/usr.sbin/pkg_install/version/perform.c	Tue Oct  2 17:05:20 2012	(r241136)
 @@ -56,10 +56,11 @@ pkg_perform(char **indexarg)
      struct utsname u;
  
      if (uname(&u) == -1) {
 -	warn("%s(): failed to determine uname information", __func__);
 +	warn("%s: failed to determine uname information", __func__);
  	return 1;
      } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) {
 -
 +	warnx("%s: bad release version specified: %s", __func__, u.release);
 +	return 1;
      }
  
      /*
 @@ -321,19 +322,31 @@ show_version(Package plist, const char *
  	ver = strrchr(latest, '-');
  	ver = ver ? &ver[1] : latest;
  	if (cmp < 0 && OUTPUT('<')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '<');
 -	    if (Verbose)
 -		printf("   needs updating (%s has %s)", source, ver);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  <", tmp);
 +		if (Verbose)
 +		    printf("   needs updating (%s has %s)", source, ver);
 +	    }
  	    printf("\n");
  	} else if (cmp == 0 && OUTPUT('=')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '=');
 -	    if (Verbose)
 -		printf("   up-to-date with %s", source);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  =", tmp);
 +		if (Verbose)
 +		    printf("   up-to-date with %s", source);
 +	    }
  	    printf("\n");
  	} else if (cmp > 0 && OUTPUT('>')) {
 -	    printf("%-34s  %c", tmp, Quiet ? '\0' : '>');
 -	    if (Verbose)
 -		printf("   succeeds %s (%s has %s)", source, source, ver);
 +	    if (Quiet)
 +		printf("%s", tmp);
 +	    else {
 +		printf("%-34s  >", tmp);
 +		if (Verbose)
 +		    printf("   succeeds %s (%s has %s)", source, source, ver);
 +	    }
  	    printf("\n");
  	}
      }
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
