Date: Sat, 6 Feb 2010 22:57:24 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203576 - in head: bin/sh tools/regression/bin/sh/parameters Message-ID: <201002062257.o16MvOsj063794@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sat Feb 6 22:57:24 2010 New Revision: 203576 URL: http://svn.freebsd.org/changeset/base/203576 Log: sh: Do not stat() $MAIL/$MAILPATH in non-interactive shells. These may be NFS mounted, and we should not touch them unless we are going to do something useful with the information. Added: head/tools/regression/bin/sh/parameters/mail1.0 (contents, props changed) head/tools/regression/bin/sh/parameters/mail2.0 (contents, props changed) Modified: head/bin/sh/main.c head/bin/sh/var.c Modified: head/bin/sh/main.c ============================================================================== --- head/bin/sh/main.c Sat Feb 6 22:50:50 2010 (r203575) +++ head/bin/sh/main.c Sat Feb 6 22:57:24 2010 (r203576) @@ -157,6 +157,8 @@ main(int argc, char *argv[]) out2fmt_flush("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: head/bin/sh/var.c ============================================================================== --- head/bin/sh/var.c Sat Feb 6 22:50:50 2010 (r203575) +++ head/bin/sh/var.c Sat Feb 6 22:57:24 2010 (r203576) @@ -337,8 +337,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); Added: head/tools/regression/bin/sh/parameters/mail1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parameters/mail1.0 Sat Feb 6 22:57:24 2010 (r203576) @@ -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} Added: head/tools/regression/bin/sh/parameters/mail2.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parameters/mail2.0 Sat Feb 6 22:57:24 2010 (r203576) @@ -0,0 +1,15 @@ +# $FreeBSD$ +# Test that an interactive shell accesses $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 +m -i </dev/null >/dev/null 2>&1 +if ! grep -q $goodfile "$T"; then + # ktrace problem + rc=0 +elif grep -q $mailfile "$T"; then + rc=0 +fi +rm "$T" +exit ${rc:-3}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002062257.o16MvOsj063794>