diff --git a/SOURCES/bz1817439-use-safe-temp-file-location.patch b/SOURCES/bz1817439-use-safe-temp-file-location.patch
new file mode 100644
index 0000000..0149d72
--- /dev/null
+++ b/SOURCES/bz1817439-use-safe-temp-file-location.patch
@@ -0,0 +1,44 @@
+diff -uNr a/heartbeat/ClusterMon b/heartbeat/ClusterMon
+--- a/heartbeat/ClusterMon 2018-06-29 14:05:02.000000000 +0200
++++ b/heartbeat/ClusterMon 2020-03-27 12:09:23.636845893 +0100
+@@ -86,7 +86,7 @@
+ PID file location to ensure only one instance is running
+
+ PID file
+-
++
+
+
+
+@@ -94,7 +94,7 @@
+ Location to write HTML output to.
+
+ HTML output
+-
++
+
+
+
+@@ -233,8 +233,8 @@
+ fi
+
+ : ${OCF_RESKEY_update:="15000"}
+-: ${OCF_RESKEY_pidfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid"}
+-: ${OCF_RESKEY_htmlfile:="/tmp/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"}
++: ${OCF_RESKEY_pidfile:="${HA_RSCTMP}/ClusterMon_${OCF_RESOURCE_INSTANCE}.pid"}
++: ${OCF_RESKEY_htmlfile:="${HA_RSCTMP}/ClusterMon_${OCF_RESOURCE_INSTANCE}.html"}
+
+ OCF_RESKEY_update=`expr $OCF_RESKEY_update / 1000`
+
+diff -uNr a/heartbeat/sapdb-nosha.sh b/heartbeat/sapdb-nosha.sh
+--- a/heartbeat/sapdb-nosha.sh 2018-06-29 14:05:02.000000000 +0200
++++ b/heartbeat/sapdb-nosha.sh 2020-03-27 12:07:16.183958164 +0100
+@@ -740,5 +740,5 @@
+ }
+
+ # Set a tempfile and make sure to clean it up again
+-TEMPFILE="/tmp/SAPDatabase.$$.tmp"
+-trap trap_handler INT TERM
+\ No newline at end of file
++TEMPFILE="${HA_RSCTMP}/SAPDatabase.$$.tmp"
++trap trap_handler INT TERM
diff --git a/SPECS/resource-agents-sap.spec b/SPECS/resource-agents-sap.spec
index 0e932e4..f8e1184 100644
--- a/SPECS/resource-agents-sap.spec
+++ b/SPECS/resource-agents-sap.spec
@@ -28,7 +28,7 @@
Name: resource-agents-sap
Summary: SAP cluster resource agents
Version: 4.1.1
-Release: 29%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
+Release: 30%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
License: GPLv2+
URL: https://github.com/ClusterLabs/resource-agents
%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel}
@@ -41,6 +41,7 @@ Source1: %{sap_script_prefix}-%{sap_script_hash}.tar.gz
Patch0: bz1751949-1-SAPInstance-add-reload-action.patch
Patch1: bz1751949-2-SAPInstance-improve-profile-detection.patch
Patch2: bz1751949-3-SAPInstance-metadata-improvements.patch
+Patch3: bz1817439-use-safe-temp-file-location.patch
BuildArch: noarch
@@ -66,6 +67,7 @@ SAP instances to be managed in a cluster environment.
%patch0 -p1
%patch1 -p1
%patch2 -p1
+%patch3 -p1
%build
if [ ! -f configure ]; then
@@ -130,6 +132,11 @@ rm -rf %{buildroot}
%exclude /usr/src
%changelog
+* Fri Apr 17 2020 Oyvind Albrigtsen - 4.1.1-30
+- use safe temp file location
+
+ Resolves: rhbz#1817439
+
* Thu Jan 23 2020 Oyvind Albrigtsen - 4.1.1-29
- SAPInstance: add reload-action