Filesystem: fail when incorrect device mounted on mountpoint
This commit is contained in:
parent
d1593f1164
commit
fe6b2faab2
113
Filesystem-fail-when-incorrect-device-mounted-on-mou.patch
Normal file
113
Filesystem-fail-when-incorrect-device-mounted-on-mou.patch
Normal file
@ -0,0 +1,113 @@
|
||||
From 66a5308d2e8f61093716a076f4386416dc18045c Mon Sep 17 00:00:00 2001
|
||||
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
||||
Date: Mon, 22 Apr 2024 11:26:09 +0200
|
||||
Subject: [PATCH] Filesystem: fail when incorrect device mounted on mountpoint,
|
||||
and dont unmount the mountpoint in this case, or if mountpoint set to "/"
|
||||
|
||||
---
|
||||
heartbeat/Filesystem | 71 ++++++++++++++++++++++++++++++++++++--------
|
||||
1 file changed, 58 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
|
||||
index e1378f78..cec71f1a 100755
|
||||
--- a/heartbeat/Filesystem
|
||||
+++ b/heartbeat/Filesystem
|
||||
@@ -582,10 +582,16 @@ Filesystem_start()
|
||||
fi
|
||||
|
||||
# See if the device is already mounted.
|
||||
- if Filesystem_status >/dev/null 2>&1 ; then
|
||||
- ocf_log info "Filesystem $MOUNTPOINT is already mounted."
|
||||
- return $OCF_SUCCESS
|
||||
- fi
|
||||
+ Filesystem_status
|
||||
+ case "$?" in
|
||||
+ $OCF_SUCCESS)
|
||||
+ ocf_log info "Filesystem $MOUNTPOINT is already mounted."
|
||||
+ return $OCF_SUCCESS
|
||||
+ ;;
|
||||
+ $OCF_ERR_CONFIGURED)
|
||||
+ return $OCF_ERR_CONFIGURED
|
||||
+ ;;
|
||||
+ esac
|
||||
|
||||
fstype_supported || exit $OCF_ERR_INSTALLED
|
||||
|
||||
@@ -801,10 +807,42 @@ Filesystem_stop()
|
||||
#
|
||||
Filesystem_status()
|
||||
{
|
||||
- match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}"
|
||||
- if list_mounts | grep "$match_string" >/dev/null 2>&1; then
|
||||
- rc=$OCF_SUCCESS
|
||||
- msg="$MOUNTPOINT is mounted (running)"
|
||||
+ local match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}"
|
||||
+ local mounted_device=$(list_mounts | grep "$match_string" | awk '{print $1}')
|
||||
+
|
||||
+ if [ -n "$mounted_device" ]; then
|
||||
+ if [ "X$blockdevice" = "Xyes" ]; then
|
||||
+ if [ -e "$DEVICE" ] ; then
|
||||
+ local canonicalized_device="$(readlink -f "$DEVICE")"
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ ocf_exit_reason "Could not canonicalize $DEVICE because readlink failed"
|
||||
+ exit $OCF_ERR_GENERIC
|
||||
+ fi
|
||||
+ else
|
||||
+ local canonicalized_device="$DEVICE"
|
||||
+ fi
|
||||
+ if [ -e "$mounted_device" ] ; then
|
||||
+ local canonicalized_mounted_device="$(readlink -f "$mounted_device")"
|
||||
+ if [ $? -ne 0 ]; then
|
||||
+ ocf_exit_reason "Could not canonicalize $mounted_device because readlink failed"
|
||||
+ exit $OCF_ERR_GENERIC
|
||||
+ fi
|
||||
+ else
|
||||
+ local canonicalized_mounted_device="$mounted_device"
|
||||
+ fi
|
||||
+ if [ "$canonicalized_device" != "$canonicalized_mounted_device" ]; then
|
||||
+ if ocf_is_probe || [ "$__OCF_ACTION" = "stop" ]; then
|
||||
+ ocf_log debug "Another device ($mounted_device) is already mounted on $MOUNTPOINT"
|
||||
+ rc=$OCF_NOT_RUNNING
|
||||
+ else
|
||||
+ ocf_exit_reason "Another device ($mounted_device) is already mounted on $MOUNTPOINT"
|
||||
+ rc=$OCF_ERR_CONFIGURED
|
||||
+ fi
|
||||
+ fi
|
||||
+ else
|
||||
+ rc=$OCF_SUCCESS
|
||||
+ msg="$MOUNTPOINT is mounted (running)"
|
||||
+ fi
|
||||
else
|
||||
rc=$OCF_NOT_RUNNING
|
||||
msg="$MOUNTPOINT is unmounted (stopped)"
|
||||
@@ -1041,9 +1079,18 @@ else
|
||||
else
|
||||
CANONICALIZED_MOUNTPOINT="$MOUNTPOINT"
|
||||
fi
|
||||
- # At this stage, $MOUNTPOINT does not contain trailing "/" unless it is "/"
|
||||
- # TODO: / mounted via Filesystem sounds dangerous. On stop, we'll
|
||||
- # kill the whole system. Is that a good idea?
|
||||
+
|
||||
+ if echo "$CANONICALIZED_MOUNTPOINT" | grep -q "^\s*/\s*$"; then
|
||||
+ if ocf_is_probe; then
|
||||
+ ocf_log debug "/ cannot be managed in a cluster"
|
||||
+ exit $OCF_NOT_RUNNING
|
||||
+ elif [ "$__OCF_ACTION" = "start" ] || [ "$__OCF_ACTION" = "monitor" ] || [ "$__OCF_ACTION" = "status" ]; then
|
||||
+ ocf_exit_reason "/ cannot be managed in a cluster"
|
||||
+ exit $OCF_ERR_CONFIGURED
|
||||
+ elif [ "$__OCF_ACTION" = "stop" ]; then
|
||||
+ exit $OCF_SUCCESS
|
||||
+ fi
|
||||
+ fi
|
||||
fi
|
||||
|
||||
# Check to make sure the utilites are found
|
||||
@@ -1124,5 +1171,3 @@ case $OP in
|
||||
;;
|
||||
esac
|
||||
exit $?
|
||||
-
|
||||
-
|
||||
--
|
||||
2.25.1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: resource-agents
|
||||
Summary: Open Source HA Reusable Cluster Resource Scripts
|
||||
Version: 4.13.0
|
||||
Release: 20
|
||||
Release: 21
|
||||
License: GPLv2+ and LGPLv2+
|
||||
URL: https://github.com/ClusterLabs/resource-agents
|
||||
Source0: https://github.com/ClusterLabs/resource-agents/archive/v%{version}.tar.gz
|
||||
@ -25,6 +25,8 @@ Patch0016: fix-OCF_SUCESS-name-in-db2_notify.patch
|
||||
Patch0017: docs-writing-python-agents-update-required-Python-ve.patch
|
||||
Patch0018: galera-allow-joiner-to-report-non-Primary-during-ini.patch
|
||||
Patch0019: doc-writing-python-agents-add-description-of-is_prob.patch
|
||||
Patch0020: Filesystem-fail-when-incorrect-device-mounted-on-mou.patch
|
||||
|
||||
Obsoletes: heartbeat-resources <= %{version}
|
||||
Provides: heartbeat-resources = %{version}
|
||||
BuildRequires: automake autoconf pkgconfig gcc perl-interpreter perl-generators python3-devel
|
||||
@ -122,6 +124,9 @@ export CFLAGS="$(echo '%{optflags}')"
|
||||
%{_mandir}/man8/{ocf-tester.8*,ldirectord.8*}
|
||||
|
||||
%changelog
|
||||
* Mon May 06 2024 zouzhimin <zouzhimin@kylinos.cn> - 4.13.0-21
|
||||
- Filesystem: fail when incorrect device mounted on mountpoint
|
||||
|
||||
* Thu Apr 25 2024 zouzhimin <zouzhimin@kylinos.cn> - 4.13.0-20
|
||||
- doc: writing-python-agents: add description of is_probe() and distro()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user