From 7eb0a44bce50f7241f82cfe08fd6b9b4017276c9 Mon Sep 17 00:00:00 2001 From: pvalchev <> Date: Sat, 8 Feb 2003 10:19:30 +0000 Subject: [PATCH] When creating > 1 files with mktemp(1), make sure that if the creation of the n'th (n>1) file fails, the previous ones get removed before exit(1) Idea by jason; ok millert deraadt --- src/etc/daily | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/etc/daily b/src/etc/daily index dc6f8a87..933352e3 100644 --- a/src/etc/daily +++ b/src/etc/daily @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: daily,v 1.41 2002/12/07 20:16:19 millert Exp $ +# $OpenBSD: daily,v 1.42 2003/02/08 10:19:30 pvalchev Exp $ # From: @(#)daily 8.2 (Berkeley) 1/25/94 # PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin @@ -13,7 +13,10 @@ if [ -f /etc/daily.local ]; then fi TMP=`mktemp /tmp/_daily.XXXXXX` || exit 1 -OUT=`mktemp /tmp/_security.XXXXXX` || exit 1 +OUT=`mktemp /tmp/_security.XXXXXX` || { + rm -f ${TMP} + exit 1 +} trap 'rm -f $TMP $OUT' 0 1 15