commit b061976216b9147d74f0e6da6686891d983e6c6f Author: Elan Ruusamäe <g...@delfi.ee> Date: Mon Sep 28 11:22:20 2015 +0300
use tempdir for work files lftp GET by default fails to download overwrite file, so just create secure tempdir get-path.patch | 30 +++++++++++++++++++----------- nagios-plugin-check_ftp_fully.spec | 3 ++- 2 files changed, 21 insertions(+), 12 deletions(-) --- diff --git a/nagios-plugin-check_ftp_fully.spec b/nagios-plugin-check_ftp_fully.spec index c52f623..763fc45 100644 --- a/nagios-plugin-check_ftp_fully.spec +++ b/nagios-plugin-check_ftp_fully.spec @@ -3,7 +3,7 @@ Summary: Nagios plugin to check FTP transfers Summary(pl.UTF-8): Wtyczka Nagiosa sprawdzająca ... Name: nagios-plugin-%{plugin} Version: 0.1 -Release: 2 +Release: 3 License: GPL v2+ Group: Networking Source0: http://www.deathwing00.org/nagios/check_ftp_fully @@ -14,6 +14,7 @@ Patch1: bashisms.patch Patch2: get-path.patch URL: http://exchange.nagios.org/directory/Plugins/Network-Protocols/FTP/check_ftp_fully/details Requires: lftp +Requires: mktemp >= 1.5 Requires: nagios-common BuildArch: noarch BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) diff --git a/get-path.patch b/get-path.patch index 39dd226..f3e2c20 100644 --- a/get-path.patch +++ b/get-path.patch @@ -1,18 +1,26 @@ specify path where to download, otherwise it will download relative to execution path and from nagios execution path is "/", thus GET operation will fail -also use more secure mktemp rather predictable filename from date ---- nagios-plugin-check_ftp_fully-0.1/check_ftp_fully~ 2015-09-25 17:22:08.216836469 +0300 -+++ nagios-plugin-check_ftp_fully-0.1/check_ftp_fully 2015-09-25 17:25:29.783974165 +0300 -@@ -32,15 +32,16 @@ +use more secure mktemp to make the temp dir + +--- nagios-plugin-check_ftp_fully-0.1/check_ftp_fully 2015-09-25 17:25:29.783974165 +0300 ++++ nagios-plugin-check_ftp_fully-0.1/check_ftp_fully 2015-09-25 18:01:30.332890552 +0300 +@@ -30,17 +30,21 @@ + # 2 if the ftp transactions do not work correctly + # 3 if the number of arguments is incorrect or the executable cannot be found - # Name of the file to use for testing - FILEDIR="/tmp/" +-# Name of the file to use for testing +-FILEDIR="/tmp/" -FILENAME=".fspftpcheck."$(/bin/date +%s) -FILEPATH=${FILEDIR}${FILENAME} -+FILEPATH=$(mktemp -p $FILEDIR .fspftpcheck.XXXXX) || exit 1 -+TEMPGET=$(mktemp -p $FILEDIR .fspftpcheck.XXXXX) || exit 1 -+FILENAME=$(basename $FILEPATH) ++# Test is performed inside FILEDIR. ++# ++# Files inside the dir may be predictable, but we use something random so that ++# failure from previous test could not affect current test. ++FILEDIR=$(mktemp -d -p ${TMPDIR:-/tmp} .fspftpcheck.XXXXX) || exit 1 ++FILENAME=$(basename $FILEDIR) || exit 1 ++FILEPATH=$FILEDIR/$FILENAME ++TEMPGET=$FILEDIR/$FILENAME.tmp setup() { echo $(/bin/date) > ${FILEPATH} @@ -20,11 +28,11 @@ also use more secure mktemp rather predictable filename from date teardown() { - /bin/rm -f ${FILEPATH} -+ /bin/rm -f ${FILEPATH} ${TEMPGET} ++ /bin/rm -r ${FILEDIR} } f_ok() { -@@ -102,7 +103,7 @@ +@@ -102,7 +106,7 @@ fi # Get test ================================================================ ---- gitweb: http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_ftp_fully.git/commitdiff/b061976216b9147d74f0e6da6686891d983e6c6f _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit