From owner-svn-src-all@FreeBSD.ORG Tue Apr 20 22:52:29 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 580631065686; Tue, 20 Apr 2010 22:52:29 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 461AC8FC19; Tue, 20 Apr 2010 22:52:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3KMqTlU069093; Tue, 20 Apr 2010 22:52:29 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3KMqTjk069088; Tue, 20 Apr 2010 22:52:29 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201004202252.o3KMqTjk069088@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 20 Apr 2010 22:52:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206950 - in stable/8: bin/sh tools/regression/bin/sh/parameters X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2010 22:52:29 -0000 Author: jilles Date: Tue Apr 20 22:52:28 2010 New Revision: 206950 URL: http://svn.freebsd.org/changeset/base/206950 Log: MFC r203576,r203677: sh: Don't stat() $MAIL/$MAILPATH if not interactive. These may be NFS mounted, and we should not touch them unless we are going to do something useful with the information. Added: stable/8/tools/regression/bin/sh/parameters/mail1.0 - copied unchanged from r203576, head/tools/regression/bin/sh/parameters/mail1.0 stable/8/tools/regression/bin/sh/parameters/mail2.0 - copied, changed from r203576, head/tools/regression/bin/sh/parameters/mail2.0 Modified: stable/8/bin/sh/main.c stable/8/bin/sh/var.c Directory Properties: stable/8/bin/sh/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/main.c ============================================================================== --- stable/8/bin/sh/main.c Tue Apr 20 22:52:13 2010 (r206949) +++ stable/8/bin/sh/main.c Tue Apr 20 22:52:28 2010 (r206950) @@ -157,6 +157,8 @@ main(int argc, char *argv[]) out2str("sh: cannot determine working directory\n"); if (getpwd() != NULL) setvar ("PWD", getpwd(), VEXPORT); + if (iflag) + chkmail(1); if (argv[0] && argv[0][0] == '-') { state = 1; read_profile("/etc/profile"); Modified: stable/8/bin/sh/var.c ============================================================================== --- stable/8/bin/sh/var.c Tue Apr 20 22:52:13 2010 (r206949) +++ stable/8/bin/sh/var.c Tue Apr 20 22:52:28 2010 (r206950) @@ -335,8 +335,13 @@ setvareq(char *s, int flags) /* * We could roll this to a function, to handle it as * a regular variable function callback, but why bother? + * + * Note: this assumes iflag is not set to 1 initially. + * As part of init(), this is called before arguments + * are looked at. */ - if (vp == &vmpath || (vp == &vmail && ! mpathset())) + if ((vp == &vmpath || (vp == &vmail && ! mpathset())) && + iflag == 1) chkmail(1); if ((vp->flags & VEXPORT) && localevar(s)) { change_env(s, 1); Copied: stable/8/tools/regression/bin/sh/parameters/mail1.0 (from r203576, head/tools/regression/bin/sh/parameters/mail1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parameters/mail1.0 Tue Apr 20 22:52:28 2010 (r206950, copy of r203576, head/tools/regression/bin/sh/parameters/mail1.0) @@ -0,0 +1,15 @@ +# $FreeBSD$ +# Test that a non-interactive shell does not access $MAIL. + +goodfile=/var/empty/sh-test-goodfile +mailfile=/var/empty/sh-test-mailfile +T=$(mktemp sh-test.XXXXXX) || exit +MAIL=$mailfile ktrace -i -f "$T" sh -c "[ -s $goodfile ]" 2>/dev/null +if ! grep -q $goodfile "$T"; then + # ktrace problem + rc=0 +elif ! grep -q $mailfile "$T"; then + rc=0 +fi +rm "$T" +exit ${rc:-3} Copied and modified: stable/8/tools/regression/bin/sh/parameters/mail2.0 (from r203576, head/tools/regression/bin/sh/parameters/mail2.0) ============================================================================== --- head/tools/regression/bin/sh/parameters/mail2.0 Sat Feb 6 22:57:24 2010 (r203576, copy source) +++ stable/8/tools/regression/bin/sh/parameters/mail2.0 Tue Apr 20 22:52:28 2010 (r206950) @@ -4,7 +4,7 @@ goodfile=/var/empty/sh-test-goodfile mailfile=/var/empty/sh-test-mailfile T=$(mktemp sh-test.XXXXXX) || exit -MAIL=$mailfile ktrace -i -f "$T" sh +m -i /dev/null 2>&1 +ENV=$goodfile MAIL=$mailfile ktrace -i -f "$T" sh +m -i /dev/null 2>&1 if ! grep -q $goodfile "$T"; then # ktrace problem rc=0