From sec@42.org  Tue May 19 15:43:01 2009
Return-Path: <sec@42.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8196B1065678
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 May 2009 15:43:01 +0000 (UTC)
	(envelope-from sec@42.org)
Received: from ice.42.org (v6.42.org [IPv6:2001:608:9::1])
	by mx1.freebsd.org (Postfix) with ESMTP id 45CAE8FC15
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 May 2009 15:43:00 +0000 (UTC)
	(envelope-from sec@42.org)
Received: by ice.42.org (Postfix, from userid 1000)
	id 8975122AC4; Tue, 19 May 2009 17:41:22 +0200 (CEST)
Message-Id: <20090519154253.8975122AC4@ice.42.org>
Date: Tue, 19 May 2009 17:41:22 +0200 (CEST)
From: Stefan `Sec` Zehl <sec@42.org>
Reply-To: Stefan `Sec` Zehl <sec@42.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: portupgrade deletes user data without question or backup.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         134714
>Category:       ports
>Synopsis:       ports-mgmt/portupgrade deletes user data without question or backup.
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 19 15:50:01 UTC 2009
>Closed-Date:    Thu Apr 12 11:08:22 UTC 2012
>Last-Modified:  Thu Apr 12 11:08:22 UTC 2012
>Originator:     Stefan `Sec` Zehl
>Release:        FreeBSD 7.2-PRERELEASE amd64
>Organization:
>Environment:
System: FreeBSD ice 7.2-PRERELEASE FreeBSD 7.2-PRERELEASE #2: Mon Mar 23 23:42:21 CET 2009 root@ice:/usr/obj/usr/src/sys/ICE amd64


	
>Description:

This just happened to me again -- I really think it should be fixed by
now.

Portupgrade of any port where some of the ports files have been modified
deletes these files even though these changes are detected first.

The only thing you get is a message like this scrolling by:

| pkg_delete: '/usr/local/etc/munin/templates/munin-comparison-day.tmpl'
| fails original MD5 checksum - deleted anyway.

This message makes me angry every time this happens. If it knows there
is something wrong, ask me how to proceed, or at least back up the
modified file.

Yes, I know that the underlying problem lies with pkg_delete and the
"-f" option. I think it is simply wrong for portupgrade to call
pkg_delete with "-f" and blindly assume everything is ok.

	
>How-To-Repeat:
	
>Fix:

Several options come to my mind.

a) Make pkg_delete return via exit code wether changed files were
   detected and keep the backup in this case.

b) Create an option for pkg_delete to only skip dependencies, and let
   portupgrade fail/ask the user in case this doesn't work.

c) Let portupgrade check the output from pkg_delete for these messages
   and handle the cases itself.

	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sem 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue May 19 23:11:10 UTC 2009 
Responsible-Changed-Why:  
Fix synopsis and assign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
State-Changed-From-To: open->suspended 
State-Changed-By: sem 
State-Changed-When: Wed May 20 08:55:11 UTC 2009 
State-Changed-Why:  
I think it's relate to badly formed ports, not portupgrade 

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

From: Stefan `Sec` Zehl <sec@42.org>
To: Sergey Matveychuk <sem@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/134714: ports-mgmt/portupgrade deletes user data without question or backup.
Date: Wed, 20 May 2009 11:05:17 +0200

 On Wed, May 20, 2009 at 12:54 +0400, Sergey Matveychuk wrote:
 > man pkg_delete says:
 >      -f, --force
 >              Force removal of the package, even if a dependency is 
 > recorded or
 >              the deinstall or require script fails.
 > 
 > Nothing about changed files.
 
 Yet it deletes these files.
 
 > Even if pkg_delete will leave the file, the port overwrite it when will 
 > install. So, badly formed port should be fixed. Ports I've made tell 
 > users when deinstall something like that: "please note, the files will 
 > not be removed:... if you will not use the application anymore, remove 
 > them yourself".
 
 The port might be wrong in that it should have installed the templates
 as *.sample files I give you that. Still having FreeBSD tell you
 blatantly: "You changed this file, I don't care about your work, I'll
 djust delete it" makes me angry. I argue that this should be fixed. Even
 considering that we never will know what files a user will change from a
 port in his specific configuration.
 
 Why are we even keeping checksums if we don't use them where they could
 help?
 
 Please don't close my PRs just because you didn't have that problem yet.
 
 CU,
     Sec
 -- 
 When in doubt, invent a chinese proverb.

From: Sergey Matveychuk <sem@FreeBSD.org>
To: bug-followup@FreeBSD.org, sec@42.org
Cc:  
Subject: Re: ports/134714: ports-mgmt/portupgrade deletes user data without
 question or backup.
Date: Wed, 20 May 2009 12:54:02 +0400

 man pkg_delete says:
       -f, --force
               Force removal of the package, even if a dependency is 
 recorded or
               the deinstall or require script fails.
 
 Nothing about changed files.
 
 Even if pkg_delete will leave the file, the port overwrite it when will 
 install. So, badly formed port should be fixed. Ports I've made tell 
 users when deinstall something like that: "please note, the files will 
 not be removed:... if you will not use the application anymore, remove 
 them yourself".
 -- 
 Dixi.
 Sem.
Responsible-Changed-From-To: sem->ruby 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Jul 25 01:49:38 UTC 2009 
Responsible-Changed-Why:  
sem@ has turned over maintainership of portupgrade to the ruby mailing list. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
Responsible-Changed-From-To: ruby->pgollucci 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Thu Sep 9 23:11:22 UTC 2010 
Responsible-Changed-Why:  
I will take it 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
State-Changed-From-To: suspended->open 
State-Changed-By: pgollucci 
State-Changed-When: Thu Sep 9 23:14:53 UTC 2010 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
Responsible-Changed-From-To: pgollucci->freebsd-ports-bugs 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Fri Sep 24 06:22:17 UTC 2010 
Responsible-Changed-Why:  
going to have enotime for the next 2 weeks, sorry 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
Responsible-Changed-From-To: freebsd-ports-bugs->ruby 
Responsible-Changed-By: steve 
Responsible-Changed-When: Mon Jan 3 17:19:33 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
State-Changed-From-To: open->suspended 
State-Changed-By: arved 
State-Changed-When: Mon Jul 25 11:48:32 UTC 2011 
State-Changed-Why:  
Correct state is suspended. 

This is not only a bug in portupgrade but a general problem of the  
ports collection 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
Responsible-Changed-From-To: ruby->freebsd-ports-bugs 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Wed Feb 22 05:23:21 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
State-Changed-From-To: suspended->closed 
State-Changed-By: crees 
State-Changed-When: Thu Apr 12 11:08:21 UTC 2012 
State-Changed-Why:  
You're absolutely right that it's a problem, but it's with the 
referenced port.  The files should be installed as samples and copied 
over if missing.  This is not a portupgrade bug. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134714 
>Unformatted:
