From nobody@FreeBSD.org  Tue Dec 16 23:04:23 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C38261065674
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 Dec 2008 23:04:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id B18B08FC25
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 Dec 2008 23:04:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id mBGN4NTx023002
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 16 Dec 2008 23:04:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id mBGN4NWK023001;
	Tue, 16 Dec 2008 23:04:23 GMT
	(envelope-from nobody)
Message-Id: <200812162304.mBGN4NWK023001@www.freebsd.org>
Date: Tue, 16 Dec 2008 23:04:23 GMT
From: Vladimir Chukharev <chukharev@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: periodic/daily/100.clean-disks and port lang/sbcl
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         129697
>Category:       conf
>Synopsis:       [patch] fix misbehavior of periodic/daily/100.clean-disks vs. port lang/sbcl
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 16 23:10:01 UTC 2008
>Closed-Date:    
>Last-Modified:  Mon Nov 22 10:20:17 UTC 2010
>Originator:     Vladimir Chukharev
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
>Environment:
FreeBSD chu.me.tut.fi 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Sat Dec 13 11:26:37 EET 2008     root@chu.me.tut.fi:/usr/obj/usr/src/sys/CHU  i386
>Description:
FreebBSD port lang/sbcl installs a file /usr/local/lib/sbcl/sbcl.core
This file has the name corresponding to the core dumps and it gets
deleted by a cron job /etc/periodic/daily/100.clean-disks if enabled in
/etc/periodic.conf.
>How-To-Repeat:
Install the port lang/sbcl and enable the cron job by setting in
/etc/periodic.conf :

daily_clean_disks_enable="YES"
daily_clean_disks_days=0

As root, run /etc/periodic/daily/100.clean-disks
The file /usr/local/lib/sbcl/sbcl.core will be deleted.
>Fix:
The attached patch introduces a new variable daily_clean_disks_ignore
where the port can put a list of files to be kept, e.g. in periodic.conf:
daily_clean_disks_ignore="sbcl.core"

I hope that the port maintainer will add this line e.g. to the port message
when the patch is applied.

Comments?

Patch attached with submission follows:

--- /etc/periodic/daily/100.clean-disks	2007-12-24 12:11:21.000000000 +0200
+++ progs/100.clean-disks	2008-12-17 00:50:59.000000000 +0200
@@ -29,10 +29,18 @@
 	    echo ""
 	    echo "Cleaning disks:"
 	    set -f noglob
-	    args="$args -name "`echo "$daily_clean_disks_files" |
+	    args="$args ( -name "`echo "$daily_clean_disks_files" |
 		sed -e 's/^[ 	]*//' \
 		    -e 's/[ 	]*$//' \
-		    -e 's/[ 	][ 	]*/ -o -name /g'`
+		    -e 's/[ 	][ 	]*/ -o -name /g'`" )"
+
+	    if ! [ -z "$daily_clean_disks_ignore" ]
+		then
+			args="$args -a ! ( -name "`echo "$daily_clean_disks_ignore" |
+			sed -e 's/^[ 	]*//' \
+				-e 's/[ 	]*$//' \
+				-e 's/[ 	][ 	]*/ -o -name /g'`" )"
+		fi
 
 	    case "$daily_clean_disks_verbose" in
 		[Yy][Ee][Ss])
@@ -41,9 +49,9 @@
 		    print=;;
 	    esac
 
-	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
-		\( $args \) -atime +$daily_clean_disks_days -delete $print |
-		tee /dev/stderr | wc -l)
+	    command="find / ( ! -fstype local -o -fstype rdonly ) -a -prune -o \
+		( $args ) -atime +$daily_clean_disks_days -delete $print "
+	    rc=$($command | tee /dev/stderr | wc -l)
 	    [ -z "$print" ] && rc=0
 	    [ $rc -gt 1 ] && rc=1
 	    set -f glob


>Release-Note:
>Audit-Trail:

From: "V.Chukharev" <chukharev@mail.ru>
To: bug-followup@freebsd.org
Cc: bf2006a@yahoo.com, stas@freebsd.org
Subject: Re: conf/129697: [patch] fix misbehavior of
 periodic/daily/100.clean-disks vs. port lang/sbcl
Date: Thu, 26 Feb 2009 22:15:44 +0200

 ------------xXxCcXc7yyywJqmosxGFwo
 Content-Type: text/plain; charset=koi8-r
 Content-Transfer-Encoding: 7bit
 
 I have made a new patch. Now it uses full path to the preserved files.
 Among other files, sbcl installs two a.out files, and preserving all
 files with this name like the original patch did is too much I think.
 
 I've used the patch with the following lines in /etc/periodic.conf for few days now.
 
 daily_clean_disks_enable="YES"				# Delete files daily
 #daily_clean_disks_files="[#,]* .#* a.out *.core *.CKP .emacs_[0-9]*"
 daily_clean_disks_days=2				# If older than this
 daily_clean_disks_ignore="$daily_clean_disks_ignore /usr/local/lib/sbcl/sbcl.core"		# lang/sbcl
 daily_clean_disks_ignore="$daily_clean_disks_ignore /usr/local/lib/sbcl/sb-bsd-sockets/a.out"	# lang/sbcl
 daily_clean_disks_ignore="$daily_clean_disks_ignore /usr/local/lib/sbcl/sb-posix/a.out"		# lang/sbcl
 daily_clean_disks_ignore="$daily_clean_disks_ignore /usr/local/lib/maxima/5.*/binary-sbcl/maxima.core"	# math/maxima
 
 
 Of course, all these changes to periodic is actially only a temporary amendment. The real 
 solution is to enforce the ports policy of renaming all files corresponding to the special 
 cases. I have filed another PR ports/131790 with a feature request to portlint that it warns 
 about the name collisions like these.
 
 I CC to port maintainers of math/maxima and lang/sbcl so that they know about the issue
 and might try to rename the offending files.
 
 -- 
 V. Chukharev
 ------------xXxCcXc7yyywJqmosxGFwo
 Content-Disposition: attachment; filename=100.clean-disks.patch2.txt
 Content-Type: text/plain; name=100.clean-disks.patch2.txt
 Content-Transfer-Encoding: 7bit
 
 --- /etc/periodic/daily/100.clean-disks.orig	2007-12-24 12:11:21.000000000 +0200
 +++ /etc/periodic/daily/100.clean-disks	2009-02-25 15:12:53.000000000 +0200
 @@ -29,10 +29,18 @@
  	    echo ""
  	    echo "Cleaning disks:"
  	    set -f noglob
 -	    args="$args -name "`echo "$daily_clean_disks_files" |
 +	    args="$args ( -name "`echo "$daily_clean_disks_files" |
  		sed -e 's/^[ 	]*//' \
  		    -e 's/[ 	]*$//' \
 -		    -e 's/[ 	][ 	]*/ -o -name /g'`
 +		    -e 's/[ 	][ 	]*/ -o -name /g'`" )"
 +
 +	    if ! [ -z "$daily_clean_disks_ignore" ]
 +		then
 +			args="$args -a ! ( -path "`echo "$daily_clean_disks_ignore" |
 +			sed -e 's/^[ 	]*//' \
 +				-e 's/[ 	]*$//' \
 +				-e 's/[ 	][ 	]*/ -o -path /g'`" )"
 +		fi
  
  	    case "$daily_clean_disks_verbose" in
  		[Yy][Ee][Ss])
 @@ -41,9 +49,9 @@
  		    print=;;
  	    esac
  
 -	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
 -		\( $args \) -atime +$daily_clean_disks_days -delete $print |
 -		tee /dev/stderr | wc -l)
 +	    command="find / ( ! -fstype local -o -fstype rdonly ) -a -prune -o ( \
 +		( $args ) -atime +$daily_clean_disks_days -delete $print )"
 +	    rc=$($command | tee /dev/stderr | wc -l)
  	    [ -z "$print" ] && rc=0
  	    [ $rc -gt 1 ] && rc=1
  	    set -f glob
 
 ------------xXxCcXc7yyywJqmosxGFwo--
 

From: chukharev@mail.ru
To: bug-followup@freebsd.org
Cc:  
Subject: Re: conf/129697: [patch] fix misbehavior of
 periodic/daily/100.clean-disks vs. port lang/sbcl
Date: Tue, 20 Oct 2009 23:14:02 +0300

 This PR is similar to http://www.FreeBSD.org/cgi/query-pr.cgi?pr=conf/35545
 and http://www.freebsd.org/cgi/query-pr.cgi?pr=conf/84752
 
 -- 
 Vladimir Chukharev
 Tampere University of Technology

From: chukharev@mail.ru
To: bug-followup@freebsd.org
Cc:  
Subject: Re: conf/129697: [patch] fix misbehavior of
 periodic/daily/100.clean-disks vs. port lang/sbcl
Date: Sun, 22 Nov 2009 21:18:47 +0200

 The old patch worked for me for at least six months with no problems. Then I made
 something in Windows (the machine is dual boot notebook), and found the following.
 The windows filesystem is automatically mounted by gnome, it is not marked as read-only
 but write operations on it are not allowed. So it is scanned by 100.clean-disks
 resulting in messages in mails like
      rm: #SharedObjects: Operation not supported
 
 A new version of the patch includes one more variable, daily_clean_disks_prune,
 containing a list of directories to ignore with all their subdirectories.
 Additionally, the new variables get empty strings as default values and comments
 document meaning of the variables in /etc/defaults/periodic.conf.
 
 NB. The script is off by default, thus the patch is not changing the default behavior.
 Perhaps, "/media" (or even "/media /mnt") is a better default for daily_clean_disks_prune.
 The file has mixed tabs and spaces, this might be nice to fix in a separate cosmetic
 patch.
 
 ===
 --- etc/defaults/periodic.conf.orig	2009-06-25 16:49:49.000000000 +0300
 +++ etc/defaults/periodic.conf	2009-11-17 12:28:35.000000000 +0200
 @@ -40,6 +40,8 @@
    daily_clean_disks_files="[#,]* .#* a.out *.core *.CKP .emacs_[0-9]*"
    daily_clean_disks_days=3				# If older than this
    daily_clean_disks_verbose="YES"				# Mention files deleted
 +daily_clean_disks_prune=""					# Directories to ignore
 +daily_clean_disks_ignore=""					# Files to ignore
 
    # 110.clean-tmps
    daily_clean_tmps_enable="NO"				# Delete stuff daily
 --- etc/periodic/daily/100.clean-disks.orig	2009-10-24 18:20:24.000000000 +0300
 +++ etc/periodic/daily/100.clean-disks	2009-11-17 16:15:06.000000000 +0200
 @@ -29,10 +29,18 @@
    	    echo ""
    	    echo "Cleaning disks:"
    	    set -f noglob
 -	    args="-name "`echo "$daily_clean_disks_files" |
 +	    args="( -name "`echo "$daily_clean_disks_files" |
    		sed -e 's/^[ 	]*//' \
    		    -e 's/[ 	]*$//' \
 -		    -e 's/[ 	][ 	]*/ -o -name /g'`
 +		    -e 's/[ 	][ 	]*/ -o -name /g'`" )"
 +
 +		if ! [ -z "$daily_clean_disks_ignore" ]
 +		then
 +			args="$args -a ! ( -path "`echo "$daily_clean_disks_ignore" |
 +			sed -e 's/^[ 	]*//' \
 +				-e 's/[ 	]*$//' \
 +				-e 's/[ 	][ 	]*/ -o -path /g'`" )"
 +		fi
 
    	    case "$daily_clean_disks_verbose" in
    		[Yy][Ee][Ss])
 @@ -41,9 +49,19 @@
    		    print=;;
    	    esac
 
 -	    rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
 -		\( $args \) -atime +$daily_clean_disks_days \
 -		-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
 +		if ! [ -z "$daily_clean_disks_prune" ]
 +		then
 +			prune="-o -path "`echo "$daily_clean_disks_prune" |
 +			sed -e 's/^[ 	]*//' \
 +				-e 's/[ 	]*$//' \
 +				-e 's/[ 	][ 	]*/ -o -path /g'`
 +		else
 +			prune=""
 +		fi
 +
 +	    command="find / ( ! -fstype local -o -fstype rdonly $prune ) -prune -o ( \
 +		( $args ) -atime +$daily_clean_disks_days -execdir rm -df {} ; $print )"
 +	    rc=$($command | tee /dev/stderr | wc -l)
    	    [ -z "$print" ] && rc=0
    	    [ $rc -gt 1 ] && rc=1
    	    set -f glob
 
 ===
 
 -- 
 Vladimir Chukharev
 Tampere University of Technology
State-Changed-From-To: open->closed  
State-Changed-By: brucec 
State-Changed-When: Sat Mar 13 12:24:28 UTC 2010 
State-Changed-Why:  
100.clean-disks is disabled by default, and the user needs to configure 
/etc/periodic.conf before it can be used. 

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

From: chukharev@mail.ru
To: bug-followup@freebsd.org, chukharev@mail.ru
Cc: brucec@freebsd.org
Subject: Re: conf/129697: [patch] fix misbehavior of
 periodic/daily/100.clean-disks vs. port lang/sbcl
Date: Sun, 14 Mar 2010 15:55:25 +0200

 Very weird logic in the explanation why... With this logic, all ports which need *_enable="YES"
 in rc.conf should never be fixed, which is definitely not the case.
 
 If you just want to reduce the number of open PRs, put a reference to the one left open and a
 back reference in that one. A good candidate is conf/35545. Sorry I found that and other related
 PRs too late.
 
 
 Vladimir Chukharev
State-Changed-From-To: closed->open  
State-Changed-By: brucec 
State-Changed-When: Sun Mar 14 15:16:47 UTC 2010 
State-Changed-Why:  
Re-open. 100.clean-disks should probably check that any .core files it removes 
are actually core files. 


Responsible-Changed-From-To: freebsd-bugs->brucec  
Responsible-Changed-By: brucec 
Responsible-Changed-When: Sun Mar 14 15:16:47 UTC 2010 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129697 
Responsible-Changed-From-To: brucec->freebsd-bugs 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Mon Nov 22 10:19:16 UTC 2010 
Responsible-Changed-Why:  
Back to the pool. 

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