diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2013-02-16 00:48:36 -0600 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2013-02-16 02:06:26 -0600 |
commit | 1831e433a03fa0e6c5be6b6a87af4550688f1c49 (patch) | |
tree | e7bb276fdde63cd09bb58d91a458bf1b62464022 /init.d | |
parent | b46747f9981337470353014bfa34e9f9f8bace34 (diff) |
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
Diffstat (limited to 'init.d')
-rw-r--r-- | init.d/bootmisc.in | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in index 6dabdfd6..4fdb4338 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 |