bootmisc: clean up tmpdir cleaning
Make sure that the `cd` into the $dir actually happened. This we don't have to worry about relative paths deleting stuff it shouldn't. This step shouldn't fail, but who knows, and better to be sane than to wipe out someone's valuables. When wiping, automatically fall back to a dedicated `find` if the initial `rm` failed on us. This should help with the speed issues related to the later `find`. Have the later find only search the top level allowing `rm` to walk the directory contents. This means that -xdev no longer applies, but since the earlier `rm` wasn't doing -xdev either and no one has complained thus far, let's assume it isn't an issue. Also convert to the -exec...+ form so that we don't have to worry about long argument lists, and add -- to the `rm` that was previously missing. In practice, this shouldn't matter as we've already deleted all those files, but better safe than sorry. When cleaning, since we've already done a `cd` into the $dir, no point in prefixing all the paths with $dir too. Go with the relative loving. Signed-off-by: Mike Frysinger <vapier@gentoo.org> X-Gentoo-Bug: 359831 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=359831
This commit is contained in:
parent
1d63e85794
commit
7c1a2defb6
@ -26,14 +26,15 @@ cleanup_tmp_dir()
|
|||||||
fi
|
fi
|
||||||
dir_writeable "$dir" || return 1
|
dir_writeable "$dir" || return 1
|
||||||
chmod a+rwt "$dir" 2> /dev/null
|
chmod a+rwt "$dir" 2> /dev/null
|
||||||
cd "$dir"
|
cd "$dir" || return 1
|
||||||
if yesno $wipe_tmp; then
|
if yesno $wipe_tmp; then
|
||||||
ebegin "Wiping $dir directory"
|
ebegin "Wiping $dir directory"
|
||||||
local startopts="-x . -depth"
|
|
||||||
[ "$RC_UNAME" = Linux ] && startopts=". -xdev -depth"
|
|
||||||
|
|
||||||
# Faster than find
|
# Faster than raw find
|
||||||
rm -rf -- [^ajlq\.]*
|
if ! rm -rf -- [^ajlq\.]* 2>/dev/null ; then
|
||||||
|
# Blah, too many files
|
||||||
|
find . -maxdepth 1 -name '[^ajlq\.]*' -exec rm -rf -- {} +
|
||||||
|
fi
|
||||||
|
|
||||||
# pam_mktemp creates a .private directory within which
|
# pam_mktemp creates a .private directory within which
|
||||||
# each user gets a private directory with immutable
|
# each user gets a private directory with immutable
|
||||||
@ -41,27 +42,23 @@ cleanup_tmp_dir()
|
|||||||
# remove it.
|
# remove it.
|
||||||
[ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null
|
[ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null
|
||||||
|
|
||||||
find $startopts ! -name . \
|
# Prune the paths that are left
|
||||||
! -path "./lost+found" \
|
find . -maxdepth 1 \
|
||||||
! -path "./lost+found/*" \
|
! -name . \
|
||||||
! -path "./quota.user" \
|
! -name lost+found \
|
||||||
! -path "./quota.user/*" \
|
! -name quota.user \
|
||||||
! -path "./aquota.user" \
|
! -name aquota.user \
|
||||||
! -path "./aquota.user/*" \
|
! -name quota.group \
|
||||||
! -path "./quota.group" \
|
! -name aquota.group \
|
||||||
! -path "./quota.group/*" \
|
! -name journal \
|
||||||
! -path "./aquota.group" \
|
-exec rm -rf -- {} +
|
||||||
! -path "./aquota.group/*" \
|
|
||||||
! -path "./journal" \
|
|
||||||
! -path "./journal/*" \
|
|
||||||
-exec rm -rf {} \;
|
|
||||||
eend 0
|
eend 0
|
||||||
else
|
else
|
||||||
ebegin "Cleaning $dir directory"
|
ebegin "Cleaning $dir directory"
|
||||||
rm -rf -- "$dir"/.X*-lock "$dir"/esrv* "$dir"/kio* \
|
rm -rf -- .X*-lock esrv* kio* \
|
||||||
"$dir"/jpsock.* "$dir"/.fam* "$dir"/.esd* \
|
jpsock.* .fam* .esd* \
|
||||||
"$dir"/orbit-* "$dir"/ssh-* "$dir"/ksocket-* \
|
orbit-* ssh-* ksocket-* \
|
||||||
"$dir"/.*-unix
|
.*-unix
|
||||||
eend 0
|
eend 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user