From 1831e433a03fa0e6c5be6b6a87af4550688f1c49 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sat, 16 Feb 2013 00:48:36 -0600 Subject: bootmisc: Skip cleaning /var/run or tmp directories if they are tmpfs Reported-by: walter@pratyeka.org X-Gentoo-Bug: 454338 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=454338 --- init.d/bootmisc.in | 55 +++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index 6dabdfd..4fdb433 100644 --- a/init.d/bootmisc.in +++ b/init.d/bootmisc.in @@ -59,6 +59,34 @@ cleanup_tmp_dir() fi } +cleanup_var_run_dir() +{ + ebegin "Cleaning /var/run" + for x in $(find /var/run ! -type d ! -name utmp \ + ! -name random-seed ! -name dev.db \ + ! -name ld-elf.so.hints ! -name ld.so.hints); + do + # Clean stale sockets + if [ -S "$x" ]; then + if type fuser >/dev/null 2>&1; then + fuser "$x" >/dev/null 2>&1 || rm -- "$x" + else + rm -- "$x" + fi + fi + [ ! -f "$x" ] && continue + # Do not remove pidfiles of already running daemons + case "$x" in + *.pid) + start-stop-daemon --test --quiet \ + --stop --pidfile "$x" && continue + ;; + esac + rm -f -- "$x" + done + eend 0 +} + mkutmp() { : >"$1" @@ -138,36 +166,13 @@ start() [ -e /var/log/wtmp ] || mkutmp /var/log/wtmp eend 0 - ebegin "Cleaning /var/run" - for x in $(find /var/run ! -type d ! -name utmp \ - ! -name random-seed ! -name dev.db \ - ! -name ld-elf.so.hints ! -name ld.so.hints); - do - # Clean stale sockets - if [ -S "$x" ]; then - if type fuser >/dev/null 2>&1; then - fuser "$x" >/dev/null 2>&1 || rm -- "$x" - else - rm -- "$x" - fi - fi - [ ! -f "$x" ] && continue - # Do not remove pidfiles of already running daemons - case "$x" in - *.pid) - start-stop-daemon --test --quiet \ - --stop --pidfile "$x" && continue - ;; - esac - rm -f -- "$x" - done - eend 0 + mountinfo -q -f tmpfs /var/run || cleanup_var_run_dir fi # Clean up /tmp directories local tmp= for tmp in ${clean_tmp_dirs:-${wipe_tmp_dirs-/tmp}}; do - cleanup_tmp_dir "$tmp" + mountinfo -q -f tmpfs "$tmp" || cleanup_tmp_dir "$tmp" done if checkpath -W /tmp; then -- cgit v1.2.3