Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conf.d/bootmisc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 4 additions & 16 deletions init.d/bootmisc.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,24 @@ 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
cd "$dir" || return 1
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
# bit set; remove the immutable bit before trying to
# 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"
Expand Down