diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-03-23 14:42:42 -0400 |
---|---|---|
committer | William Hubbs <williamh@gentoo.org> | 2011-03-25 11:25:25 -0500 |
commit | 7c1a2defb6fdec4190a2256bd023857e30ecb7a7 (patch) | |
tree | e79a3abf055b5c466eaff6e0f23aad5a629f5e35 /init.d | |
parent | 1d63e85794ad850752eec95fa077e5895295f3b7 (diff) |
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
Diffstat (limited to 'init.d')
-rw-r--r-- | init.d/bootmisc.in | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index 320e7e82..37f187bb 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -26,14 +26,15 @@ cleanup_tmp_dir() fi dir_writeable "$dir" || return 1 chmod a+rwt "$dir" 2> /dev/null - cd "$dir" + cd "$dir" || return 1 if yesno $wipe_tmp; then ebegin "Wiping $dir directory" - local startopts="-x . -depth" - [ "$RC_UNAME" = Linux ] && startopts=". -xdev -depth" - # Faster than find - rm -rf -- [^ajlq\.]* + # 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 # pam_mktemp creates a .private directory within which # each user gets a private directory with immutable @@ -41,27 +42,23 @@ cleanup_tmp_dir() # remove it. [ -d /tmp/.private ] && chattr -R -a /tmp/.private 2> /dev/null - find $startopts ! -name . \ - ! -path "./lost+found" \ - ! -path "./lost+found/*" \ - ! -path "./quota.user" \ - ! -path "./quota.user/*" \ - ! -path "./aquota.user" \ - ! -path "./aquota.user/*" \ - ! -path "./quota.group" \ - ! -path "./quota.group/*" \ - ! -path "./aquota.group" \ - ! -path "./aquota.group/*" \ - ! -path "./journal" \ - ! -path "./journal/*" \ - -exec rm -rf {} \; + # 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" - rm -rf -- "$dir"/.X*-lock "$dir"/esrv* "$dir"/kio* \ - "$dir"/jpsock.* "$dir"/.fam* "$dir"/.esd* \ - "$dir"/orbit-* "$dir"/ssh-* "$dir"/ksocket-* \ - "$dir"/.*-unix + rm -rf -- .X*-lock esrv* kio* \ + jpsock.* .fam* .esd* \ + orbit-* ssh-* ksocket-* \ + .*-unix eend 0 fi } |