Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/etc use mktemp(1) to create temporary directories, and ensur...
details: https://anonhg.NetBSD.org/src/rev/872a24b6c814
branches: trunk
changeset: 511342:872a24b6c814
user: lukem <lukem%NetBSD.org@localhost>
date: Mon Jun 18 10:54:02 2001 +0000
description:
use mktemp(1) to create temporary directories, and ensure that cleanup traps
are setup asap.
diffstat:
etc/daily | 25 ++++++++++---------------
etc/security | 20 ++++++++------------
etc/weekly | 9 ++++-----
3 files changed, 22 insertions(+), 32 deletions(-)
diffs (143 lines):
diff -r db4ceebe422f -r 872a24b6c814 etc/daily
--- a/etc/daily Mon Jun 18 10:26:33 2001 +0000
+++ b/etc/daily Mon Jun 18 10:54:02 2001 +0000
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $NetBSD: daily,v 1.35 2001/04/22 20:34:48 aymeric Exp $
+# $NetBSD: daily,v 1.36 2001/06/18 10:54:02 lukem Exp $
# @(#)daily 8.2 (Berkeley) 1/25/94
#
@@ -65,15 +65,12 @@
# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
#fi
-TMPDIR=/tmp/_daily.$$
+DAILYDIR=`mktemp -d /tmp/_daily.XXXXXX` || exit 1
-if ! mkdir $TMPDIR; then
- echo can not create $TMPDIR.
- exit 1
-fi
+trap "/bin/rm -rf $DAILYDIR ; exit 0" EXIT INT QUIT
-if ! cd $TMPDIR; then
- echo can not cd to $TMPDIR.
+if ! cd "$DAILYDIR"; then
+ echo "Can not cd to $DAILYDIR".
exit 1
fi
@@ -214,12 +211,12 @@
fi
if checkyesno run_security; then
- SECOUT=$TMPDIR/sec
- sh /etc/security 2>&1 > $SECOUT
- if [ ! -s $SECOUT ]; then
- echo "Nothing to report on $date" > $SECOUT
+ SECOUT="$DAILYDIR/sec"
+ sh /etc/security 2>&1 > "$SECOUT"
+ if [ ! -s "$SECOUT" ]; then
+ echo "Nothing to report on $date" > "$SECOUT"
fi
- mail -s "$host daily insecurity output for $date" $MAILTO < $SECOUT
+ mail -s "$host daily insecurity output for $date" $MAILTO < "$SECOUT"
fi
if checkyesno run_skeyaudit; then
@@ -233,5 +230,3 @@
echo "Running /etc/daily.local:"
. /etc/daily.local
fi
-
-rm -rf $TMPDIR
diff -r db4ceebe422f -r 872a24b6c814 etc/security
--- a/etc/security Mon Jun 18 10:26:33 2001 +0000
+++ b/etc/security Mon Jun 18 10:54:02 2001 +0000
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $NetBSD: security,v 1.55 2001/06/14 07:50:07 lukem Exp $
+# $NetBSD: security,v 1.56 2001/06/18 10:54:02 lukem Exp $
# from: @(#)security 8.1 (Berkeley) 6/9/93
#
@@ -19,23 +19,21 @@
. /etc/security.conf
fi
-SECUREDIR=/tmp/_securedir.$$
-if ! mkdir $SECUREDIR; then
- echo can not create $SECUREDIR.
- exit 1
-fi
+SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
-if ! cd $SECUREDIR; then
- echo can not chdir to $SECUREDIR.
+trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT
+
+if ! cd "$SECUREDIR"; then
+ echo "Can not cd to $SECUREDIR".
exit 1
fi
if [ -z "$max_loginlen" ];then
- max_loginlen=8
+ max_loginlen=8
fi
if [ -z "$max_grouplen" ]; then
- max_grouplen=8
+ max_grouplen=8
fi
ERR=secure1.$$
@@ -47,8 +45,6 @@
OUTPUT=secure7.$$
LABELS=secure8.$$
-trap '/bin/rm -rf $SECUREDIR ; exit 0' EXIT INT QUIT
-
# Handle backup_dir not being set in .conf file
backup_dir=${backup_dir:-/var/backups}
diff -r db4ceebe422f -r 872a24b6c814 etc/weekly
--- a/etc/weekly Mon Jun 18 10:26:33 2001 +0000
+++ b/etc/weekly Mon Jun 18 10:54:02 2001 +0000
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $NetBSD: weekly,v 1.16 2000/10/15 17:32:38 kim Exp $
+# $NetBSD: weekly,v 1.17 2001/06/18 10:54:02 lukem Exp $
# from: @(#)weekly 8.2 (Berkeley) 1/2/94
#
@@ -37,14 +37,14 @@
#then
# echo ""
# echo "Looking for checked out files:"
-# TDIR=/tmp/_checkout$$
#
-# mkdir $TDIR
+# TDIR=`mktemp -d /tmp/_checkout.XXXXXX` || exit 1
+# trap "/bin/rm -rf $TDIR ; exit 0" EXIT INT QUIT
# for file in `find -f /usr/src ! -fstype local -prune -or \
# -name 'p.*' -print | egrep 'SCCS/p\.'`; do
# owner=`awk '{ print $3 }' $file`
# echo "$owner $file"
-# echo $file >> $TDIR/$owner
+# echo $file >> "$TDIR/$owner"
# done | sed -e 's,SCCS/p.,,'
# if test -n "`ls $TDIR`"; then
# for file in $TDIR/*; do
@@ -52,7 +52,6 @@
# Mail -s 'checked out files' ${file##*/}
# done
# fi
-# rm -rf $TDIR
#fi
if checkyesno clean_uucp && [ -f /usr/libexec/uucp/clean.weekly ]; then
Home |
Main Index |
Thread Index |
Old Index