diff --git a/conf.d/bootmisc b/conf.d/bootmisc index dd5b08e01..a7d58e258 100644 --- a/conf.d/bootmisc +++ b/conf.d/bootmisc @@ -1,4 +1,6 @@ -# List of /tmp directories we should clean up +# List of /tmp-like directories we should clean up. tmpfs mounts are ignored +# since they will be empty at boot. +# Use of tmpfs for /tmp itself is strongly recommended if possible. clean_tmp_dirs="/tmp" # Should we wipe the tmp paths completely or just selectively remove known diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index b1a849a37..6394db2f2 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -25,7 +25,8 @@ cleanup_tmp_dir() local dir="$1" if ! [ -d "$dir" ]; then - mkdir -p "$dir" || return $? + mkdir -p "$dir" + return $? fi checkpath -W "$dir" || return 1 chmod a+rwt "$dir" 2> /dev/null @@ -33,11 +34,8 @@ cleanup_tmp_dir() if yesno $wipe_tmp; then ebegin "Wiping $dir directory" - # Faster than raw find - if ! rm -rf -- [!ajlq\.]* 2>/dev/null ; then - # Blah, too many files - find . -maxdepth 1 -name '[!ajlq\.]*' -exec rm -rf -- {} + - fi + find "${dir}" -depth -xdev ! -type d -exec rm -- {} + + find "${dir}" -depth -xdev -type d -empty -exec rmdir -- {} + # pam_mktemp creates a .private directory within which # each user gets a private directory with immutable @@ -45,16 +43,6 @@ cleanup_tmp_dir() # remove it. [ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null - # Prune the paths that are left - find . -maxdepth 1 \ - ! -name . \ - ! -name lost+found \ - ! -name quota.user \ - ! -name aquota.user \ - ! -name quota.group \ - ! -name aquota.group \ - ! -name journal \ - -exec rm -rf -- {} + eend 0 else ebegin "Cleaning $dir directory"