Subject: misc/29144: /etc/rc.d/cleartmp attempts to delete /tmp/ifile (on LFS)
To: None <,,>
From: None <>
List: netbsd-bugs
Date: 01/28/2005 14:03:00
>Number:         29144
>Category:       misc
>Synopsis:       /etc/rc.d/cleartmp attempts to delete /tmp/ifile (on LFS)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 28 14:03:00 +0000 2005
>Originator:     Geert Hendrickx
>Release:        NetBSD 2.0
Universiteit Antwerpen
NetBSD 2.0 NetBSD 2.0 (GENERIC) #0: Wed Dec  1 10:58:25 UTC 2004  builds@build:/big/builds/ab/netbsd-2-0-RELEASE/i386/200411300000Z-obj/big/builds/ab/netbsd-2-0-RELEASE/src/sys/arch/i386/compile/GENERIC i386

When /tmp is on a separate partition using the log-structured filesystem (LFS), it contains a file /tmp/ifile which cannot be removed.  However, when clear_tmp is set to YES in rc.conf (YES is the default), /etc/rc.d/cleartmp tries to delete /tmp/ifile, and returns an error: "rm: /tmp/ifile: Operation not permitted", which is ugly and unnecessary.  
Put /tmp on a log-structured filesystem, and don't have clear_tmp=NO in /etc/rc.conf.  Reboot.  
The patch below avoids the (attempted) removal of /tmp/ifile.  

Another solution (not LFS specific) would be to simply newfs the /tmp partition (if /tmp is on a seperate partition, of course), instead of rm'ing all files.  This is faster, but would require a few more rc.conf variables (e.g. to specify newfs parameters, user quotas, ...).  

--- /etc/rc.d/cleartmp  2002-03-22 05:33:58.000000000 +0100
+++ cleartmp    2005-01-28 13:35:19.000000000 +0100
@@ -19,12 +19,13 @@
        echo "Clearing /tmp."
        #       Prune quickly with one rm, then use find to clean up
-       #       /tmp/[lq]* (this is not needed with mfs /tmp, but
+       #       /tmp/[ilq]* (this is not needed with mfs /tmp, but
        #       doesn't hurt anything).
-       (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
+       (cd /tmp && rm -rf [a-hjkm-pr-zA-Z]* &&
            find -x . ! -name . ! -name lost+found ! -name quota.user \
-               ! -name -exec rm -rf -- {} \; -type d -prune)
+               ! -name ! -name ifile \
+               -exec rm -rf -- {} \; -type d -prune)
 load_rc_config $name