NetBSD Problem Report #37376
From eric@duke.efjohnson.com Tue Nov 13 15:29:48 2007
Return-Path: <eric@duke.efjohnson.com>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 7FE9563B8D7
for <gnats-bugs@gnats.NetBSD.org>; Tue, 13 Nov 2007 15:29:48 +0000 (UTC)
Message-Id: <20071113152947.ABD1049918@duke.efjohnson.com>
Date: Tue, 13 Nov 2007 09:29:47 -0600 (CST)
From: eschnoebelen@efjohnson.com
Reply-To: eric@cirr.com
To: gnats-bugs@NetBSD.org
Subject: /etc/{daily,weekly,montly} shouldn't try to "dot in" {}.local
X-Send-Pr-Version: 3.95
>Number: 37376
>Category: bin
>Synopsis: /etc/{daily,weekly,monthly} attempt to "dot in" {}.local
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 13 15:30:00 +0000 2007
>Last-Modified: Tue Nov 13 19:35:00 +0000 2007
>Originator: Eric Schnoebelen
>Release: NetBSD 4.99.34
>Organization:
Eric Schnoebelen eschnoebelen@efjohnson.com eric@cirr.com
"He made a lot of mistakes. But he made mistakes in good directions, so
eventually he got to the right answers. I tried to imitate him, but I
found out that it is very difficult to make good mistakes." -- Goro Simura
>Environment:
System: NetBSD duke 4.99.34 NetBSD 4.99.34 (GENERIC.MP) #17: Sat Nov 3 07:24:10 CDT 2007 eric@egsner.cirr.com:/work/eric/NetBSD-current/obj/amd64/sys/arch/amd64/compile/GENERIC.MP amd64
Architecture: x86_64
Machine: amd64
>Description:
The administrative scripts /etc/{daily,weekly,monthly} contain the following
construct:
. /etc/weekly.local > $TMP 2>&1
Which doesn't work, as the "." (dot) operator doesn't allow/permit
redirection of it's output.. So, trying to run the local scripts failes.
>How-To-Repeat:
Write a /etc/daily.local script (doesn't have to do much) and wonder why
it doesn't run overnight..
>Fix:
remove the attempts to use the bourne shell's dot operator to execute
the script as part of the current shell.
Alternatively, if it is felt essential that the local scripts execute in
the current shell's environment, use sh(1) exec magic to redirect
standard output and standard error. eg:
[...]
if [ -f /etc/daily.local ] ; then
# stash away stdout/err, then put them on log file
exec 1>&10 2>&11 1> $TMP 2>&1
. /etc/daily.local
# put everything back.
exec 10>&1 11>&2 10>&- 11>&-
if [ -s "${TMP}" ] ; then
[...]
--- /var/backups/etc/daily.current 2007-10-09 03:16:40.000000000 -0500
+++ /etc/daily 2007-11-13 09:13:51.000000000 -0600
@@ -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
--- /var/backups/etc/weekly.current 2007-11-13 03:15:58.000000000 -0600
+++ /etc/weekly 2007-11-13 09:13:30.000000000 -0600
@@ -90,7 +90,7 @@
fi
if [ -f /etc/weekly.local ]; then
- . /etc/weekly.local > $TMP 2>&1
+ /etc/weekly.local > $TMP 2>&1
if [ -s $TMP ] ; then
printf "\nRunning /etc/weekly.local:\n"
cat $TMP
--- /var/backups/etc/monthly.current 2007-10-09 03:16:40.000000000 -0500
+++ /etc/monthly 2007-11-13 09:18:26.000000000 -0600
@@ -35,7 +35,7 @@
# ac -p | sort -nr +1
if [ -f /etc/monthly.local ]; then
- . /etc/monthly.local > $TMP 2>&1
+ /etc/monthly.local > $TMP 2>&1
if [ -s $TMP ] ; then
printf "\nRunning /etc/monthly.local:\n"
cat $TMP
>Audit-Trail:
From: "Jeremy C. Reed" <reed@reedmedia.net>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/37376: /etc/{daily,weekly,montly} shouldn't try to "dot in"
{}.local
Date: Tue, 13 Nov 2007 09:44:02 -0600 (CST)
On Tue, 13 Nov 2007, eschnoebelen@efjohnson.com wrote:
> also present on 4.0_BETA?/RC?, 3.X.
I do not have this problem on multiple 3.1 systems where I use a
/etc/daily.local file. My /etc/daily.local files are not executable.
I also can't reproduce this problem on my 4.99.27 system.
From: eric@cirr.com (Eric Schnoebelen)
To: gnats-bugs@NetBSD.org
Cc: netbsd-bugs@NetBSD.org
Subject: Re: bin/37376: /etc/{daily,weekly,montly} shouldn't try to "dot in" {}.local
Date: Tue, 13 Nov 2007 11:24:05 -0600
"Jeremy C. Reed" writes:
- The following reply was made to PR bin/37376; it has been noted by GNATS.
-
- From: "Jeremy C. Reed" <reed@reedmedia.net>
- To: gnats-bugs@NetBSD.org
- Cc:
- Subject: Re: bin/37376: /etc/{daily,weekly,montly} shouldn't try to "dot in
- "
- {}.local
- Date: Tue, 13 Nov 2007 09:44:02 -0600 (CST)
-
- On Tue, 13 Nov 2007, eschnoebelen@efjohnson.com wrote:
-
- > also present on 4.0_BETA?/RC?, 3.X.
-
- I do not have this problem on multiple 3.1 systems where I use a
- /etc/daily.local file. My /etc/daily.local files are not executable.
-
- I also can't reproduce this problem on my 4.99.27 system.
I've been seeing it regularly with my weekly script.
What I've really been seeing is a lack of output from my .local
scripts (notably weekly.local), and the appearance of it not
running.
However, after investigation, the real issue may be that ${TMP}
is a relative path in /etc/weekly, and my weekly.local changes
directories (it's primary task is to update the pkgsrc tree and
rebuild.)
Perhaps the the {daily,weekly,monthly,security} scripts should
use absolute path names for their temporary files?
--
Eric Schnoebelen eric@cirr.com http://www.cirr.com
Artificial Intelligence is neither -- it consists of quite
natural people programming computers to do dumb things.
- Bob Spitzer
From: "Jeremy C. Reed" <reed@reedmedia.net>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/37376: /etc/{daily,weekly,montly} shouldn't try to "dot in"
{}.local
Date: Tue, 13 Nov 2007 13:32:34 -0600 (CST)
On Tue, 13 Nov 2007, Eric Schnoebelen wrote:
> However, after investigation, the real issue may be that ${TMP}
> is a relative path in /etc/weekly, and my weekly.local changes
> directories (it's primary task is to update the pkgsrc tree and
> rebuild.)
>
> Perhaps the the {daily,weekly,monthly,security} scripts should
> use absolute path names for their temporary files?
That makes sense.
Some ideas:
1) So for weekly use:
TMP=${WEEKLYDIR}/weekly.$$
or something like that.
Note that it creates and cd's into that temporary directory for any work
it does.
2) Maybe just have your weekly.local script cd to the WEEKLYDIR when done?
3) Or maybe this should be done:
. /etc/weekly.local > $TMP 2>&1
+ cd ${WEEKLYDIR}
if [ -s $TMP ] ; then
Jeremy C. Reed
>Unformatted:
also present on 4.0_BETA?/RC?, 3.X.
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.