53 lines
1.6 KiB
Diff
53 lines
1.6 KiB
Diff
|
From bfbc99003ebd96d79bbf8ad50be0b5e714a92fd7 Mon Sep 17 00:00:00 2001
|
||
|
From: ytakeshita <y.takeshita0311@gmail.com>
|
||
|
Date: Fri, 7 Jun 2019 15:20:52 +0900
|
||
|
Subject: [PATCH] Medium: Filesystem: Prevents to all root user processes are
|
||
|
killed when bind mounting a directory on rootfs.
|
||
|
|
||
|
if a directory is bound mounting on rootfs and "force_umount" is not set "safe", change "force_umount" to "safe".
|
||
|
---
|
||
|
heartbeat/Filesystem | 23 +++++++++++++++++++++++
|
||
|
1 file changed, 23 insertions(+)
|
||
|
|
||
|
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
|
||
|
index c46ec3cca..1b29a08b3 100755
|
||
|
--- a/heartbeat/Filesystem
|
||
|
+++ b/heartbeat/Filesystem
|
||
|
@@ -314,6 +314,24 @@ bind_kernel_check() {
|
||
|
[ $? -ne 0 ] &&
|
||
|
ocf_log warn "kernel `uname -r` cannot handle read only bind mounts"
|
||
|
}
|
||
|
+
|
||
|
+bind_rootfs_check() {
|
||
|
+ local SOURCE
|
||
|
+ local TARGET
|
||
|
+ local ROOTFS
|
||
|
+
|
||
|
+ SOURCE=$1
|
||
|
+ TARGET=$(df --output=target $SOURCE | tail -n 1)
|
||
|
+
|
||
|
+ ROOTFS=$(list_mounts | grep -w rootfs | cut -d' ' -f 2)
|
||
|
+
|
||
|
+ if [ "${TARGET}" = "${ROOTFS}" ]; then
|
||
|
+ return 1
|
||
|
+ else
|
||
|
+ return 0
|
||
|
+ fi
|
||
|
+}
|
||
|
+
|
||
|
bind_mount() {
|
||
|
if is_bind_mount && [ "$options" != "-o bind" ]
|
||
|
then
|
||
|
@@ -476,6 +494,11 @@ get_pids()
|
||
|
local procs
|
||
|
local mmap_procs
|
||
|
|
||
|
+ if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_rootfs_check "$DEVICE"; then
|
||
|
+ ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'"
|
||
|
+ FORCE_UNMOUNT=safe
|
||
|
+ fi
|
||
|
+
|
||
|
if ocf_is_true "$FORCE_UNMOUNT"; then
|
||
|
if [ "X${HOSTOS}" = "XOpenBSD" ];then
|
||
|
fstat | grep $dir | awk '{print $3}'
|