Subject: /etc/daily fubar if daily.local changes FWD
To: None <tech-userlevel@NetBSD.org>
From: Hubert Feyrer <hubert@feyrer.de>
List: tech-userlevel
Date: 12/12/2006 02:12:31
Hi,

trying to do some filtering with /var/log/messages, I've found that
/etc/daily breaks if /etc/daily.local changes the current working 
directory. Paraphrasing /etc/daily:

line1:		cd $somedir
line2:		TMP=relative_path
line3:		. /etc/daily.local >$TMP
line4:		if [ -s $TMP ]; then ...

In the above example, line3 creates creates $somedir/relative_path,
but if daily.local uses 'cd' to change the current working directory, the 
if-test in line4 will fail.

To solve this, I suggest running daily.local in a subshell:

 	( . /etc/daily.local ) >$TMP 2>&1

Does that make sense? Do I miss something substantial here?
Any comments about (not) committing the patch below?

Thanks!


  - Hubert


Index: daily
===================================================================
RCS file: /cvsroot/src/etc/daily,v
retrieving revision 1.68
diff -u -r1.68 daily
--- daily	12 Nov 2006 01:22:57 -0000	1.68
+++ daily	12 Dec 2006 01:01:49 -0000
@@ -268,7 +268,7 @@
  fi

  if [ -f /etc/daily.local ]; then
-	. /etc/daily.local > $TMP 2>&1
+	( . /etc/daily.local ) >$TMP 2>&1
  	if [ -s $TMP ] ; then
  		printf "\nRunning /etc/daily.local:\n"
  		cat $TMP