List Info

Thread: Use of /tmp in /etc/{daily,weekly,monthly,security}




Use of /tmp in /etc/{daily,weekly,monthly,security}
country flaguser name
Sweden
2007-06-05 01:12:18
Inspired by misc/35544, any objections if I commit this?

Martti



Index: daily
============================================================
=======
RCS file: /cvsroot/src/etc/daily,v
retrieving revision 1.69
diff -u -r1.69 daily
--- daily	17 Dec 2006 23:24:09 -0000	1.69
+++ daily	5 Jun 2007 06:09:04 -0000
 -38,8
+38,8 
  #
  #echo ""
  #echo "Removing scratch and junk files:"
-#if [ -d /tmp -a ! -h /tmp ]; then
-#	cd /tmp && {
+#if [ -d ${TMPDIR:="/tmp"} -a ! -h
${TMPDIR:="/tmp"} ]; then
+#	cd ${TMPDIR:="/tmp"} && {
  #	find . -type f -atime +3 -exec rm -f -- {} ;
  #	find . ! -name . -type d -mtime +1 -exec rmdir -- {} ;

  #	    >/dev/null 2>&1; }
 -66,7
+66,7 
  #	find . ! -name . -mtime +7 -exec rm -f -- {} ; ; }
  #fi

-DAILYDIR=`mktemp -d /tmp/_daily.XXXXXX` || exit 1
+DAILYDIR=`mktemp -d
${TMPDIR:="/tmp"}/_daily.XXXXXX` || exit 1

  trap "/bin/rm -rf $DAILYDIR ; exit 0" EXIT INT
QUIT

Index: monthly
============================================================
=======
RCS file: /cvsroot/src/etc/monthly,v
retrieving revision 1.10
diff -u -r1.10 monthly
--- monthly	9 Apr 2004 17:35:21 -0000	1.10
+++ monthly	5 Jun 2007 06:09:04 -0000
 -19,7
+19,7 
  echo "Subject: $host monthly output for $date"
  echo ""

-MONTHLYDIR=`mktemp -d /tmp/_monthly.XXXXXX` || exit 1
+MONTHLYDIR=`mktemp -d
${TMPDIR:="/tmp"}/_monthly.XXXXXX` || exit 1

  trap "/bin/rm -rf $MONTHLYDIR ; exit 0" EXIT INT
QUIT PIPE

Index: security
============================================================
=======
RCS file: /cvsroot/src/etc/security,v
retrieving revision 1.101
diff -u -r1.101 security
--- security	27 Mar 2007 08:37:58 -0000	1.101
+++ security	5 Jun 2007 06:09:05 -0000
 -40,7
+40,7 
  	mkdir -p "$work_dir"
  fi

-SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
+SECUREDIR=`mktemp -d
${TMPDIR:="/tmp"}/_securedir.XXXXXX` || exit 1

  trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT
QUIT PIPE

Index: weekly
============================================================
=======
RCS file: /cvsroot/src/etc/weekly,v
retrieving revision 1.22
diff -u -r1.22 weekly
--- weekly	15 Feb 2007 23:04:10 -0000	1.22
+++ weekly	5 Jun 2007 06:09:05 -0000
 -26,7
+26,7 
  	exit 1;
  fi

-WEEKLYDIR=`mktemp -d /tmp/_weekly.XXXXXX` || exit 1
+WEEKLYDIR=`mktemp -d
${TMPDIR:="/tmp"}/_weekly.XXXXXX` || exit 1

  trap "/bin/rm -rf $WEEKLYDIR ; exit 0" EXIT INT
QUIT PIPE

 -50,7
+50,7 
  #	echo ""
  #	echo "Looking for checked out files:"
  #
-#	TDIR=`mktemp -d /tmp/_checkout.XXXXXX` || exit 1
+#	TDIR=`mktemp -d
${TMPDIR:="/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

Re: Use of /tmp in /etc/{daily,weekly,monthly,security}
country flaguser name
Japan
2007-06-05 01:23:07
In message <Pine.NEB.4.64.0706050910580.17699p130.piuha.net>
	on Tue, 5 Jun 2007 09:12:18 +0300 (EEST),
	Martti Kuparinen <martti.kuparineniki.fi> wrote:
> Inspired by misc/35544, any objections if I commit
this?
Basically, I agree.

> Index: daily
>
============================================================
=======
> RCS file: /cvsroot/src/etc/daily,v
> retrieving revision 1.69
> diff -u -r1.69 daily
> --- daily	17 Dec 2006 23:24:09 -0000	1.69
> +++ daily	5 Jun 2007 06:09:04 -0000
>  -38,8 +38,8 
>   #
>   #echo ""
>   #echo "Removing scratch and junk files:"
> -#if [ -d /tmp -a ! -h /tmp ]; then
> -#	cd /tmp && {
> +#if [ -d ${TMPDIR:="/tmp"} -a ! -h
${TMPDIR:="/tmp"} ]; then
> +#	cd ${TMPDIR:="/tmp"} && {
Though this is comment-outed part, I think that this change
assumes
TMPDIR is defined for all processes.  If setting TMPDIR in
/etc/daily.conf only, "/tmp" still used other
processes and need to be
cleaned.

Of course, it is about minor details.  

-- 
Takahiro Kambe <tacaback-street.net>

Re: Use of /tmp in /etc/{daily,weekly,monthly,security}
country flaguser name
Sweden
2007-06-05 01:30:51
Takahiro Kambe wrote:

>> --- daily	17 Dec 2006 23:24:09 -0000	1.69
>> +++ daily	5 Jun 2007 06:09:04 -0000
>>  -38,8 +38,8 
>>   #
>>   #echo ""
>>   #echo "Removing scratch and junk
files:"
>> -#if [ -d /tmp -a ! -h /tmp ]; then
>> -#	cd /tmp && {
>> +#if [ -d ${TMPDIR:="/tmp"} -a ! -h
${TMPDIR:="/tmp"} ]; then
>> +#	cd ${TMPDIR:="/tmp"} && {

> Though this is comment-outed part, I think that this
change assumes
> TMPDIR is defined for all processes.  If setting TMPDIR
in

You are right, I removed these changed.

Re: Use of /tmp in /etc/{daily,weekly,monthly,security}
country flaguser name
Sweden
2007-06-06 01:24:40
On Tue, 5 Jun 2007, Christos Zoulas wrote:

> Isn't that simpler to write as:
>
> WEEKLYDIR=$(mktemp -d -t _weekly) || exit 1

You are right, here's a new version. Any other issues with
this?

Index: daily
============================================================
=======
RCS file: /cvsroot/src/etc/daily,v
retrieving revision 1.69
diff -u -r1.69 daily
--- daily	17 Dec 2006 23:24:09 -0000	1.69
+++ daily	6 Jun 2007 06:23:48 -0000
 -66,7
+66,7 
  #	find . ! -name . -mtime +7 -exec rm -f -- {} ; ; }
  #fi

-DAILYDIR=`mktemp -d /tmp/_daily.XXXXXX` || exit 1
+DAILYDIR=$(mktemp -d -t _daily) || exit 1

  trap "/bin/rm -rf $DAILYDIR ; exit 0" EXIT INT
QUIT

Index: monthly
============================================================
=======
RCS file: /cvsroot/src/etc/monthly,v
retrieving revision 1.10
diff -u -r1.10 monthly
--- monthly	9 Apr 2004 17:35:21 -0000	1.10
+++ monthly	6 Jun 2007 06:23:48 -0000
 -19,7
+19,7 
  echo "Subject: $host monthly output for $date"
  echo ""

-MONTHLYDIR=`mktemp -d /tmp/_monthly.XXXXXX` || exit 1
+MONTHLYDIR=$(mktemp -d -t _monthly) || exit 1

  trap "/bin/rm -rf $MONTHLYDIR ; exit 0" EXIT INT
QUIT PIPE

Index: security
============================================================
=======
RCS file: /cvsroot/src/etc/security,v
retrieving revision 1.101
diff -u -r1.101 security
--- security	27 Mar 2007 08:37:58 -0000	1.101
+++ security	6 Jun 2007 06:23:48 -0000
 -40,7
+40,7 
  	mkdir -p "$work_dir"
  fi

-SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
+SECUREDIR=$(mktemp -d -t _securedir) || exit 1

  trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT
QUIT PIPE

Index: weekly
============================================================
=======
RCS file: /cvsroot/src/etc/weekly,v
retrieving revision 1.22
diff -u -r1.22 weekly
--- weekly	15 Feb 2007 23:04:10 -0000	1.22
+++ weekly	6 Jun 2007 06:23:48 -0000
 -26,7
+26,7 
  	exit 1;
  fi

-WEEKLYDIR=`mktemp -d /tmp/_weekly.XXXXXX` || exit 1
+WEEKLYDIR=$(mktemp -d -t _weekly) || exit 1

  trap "/bin/rm -rf $WEEKLYDIR ; exit 0" EXIT INT
QUIT PIPE

 -50,7
+50,7 
  #	echo ""
  #	echo "Looking for checked out files:"
  #
-#	TDIR=`mktemp -d /tmp/_checkout.XXXXXX` || exit 1
+#	TDIR=$(mktemp -d -t _checkout) || 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

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )