diff options
author | Eric Blake <ebb9@byu.net> | 2009-10-28 14:36:09 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-10-28 21:12:41 -0600 |
commit | 1c59bb3cefff73c532033863e60e9130892a50dd (patch) | |
tree | 42f89ad649d5be625ac200f044c3f7acd5ee5e08 /tests/misc/nohup | |
parent | 536a1fbe5ff47078d515a41ea4b45c4e0d794da2 (diff) | |
download | coreutils-1c59bb3cefff73c532033863e60e9130892a50dd.tar.xz |
nice, nohup, su: detect write failure to stderr
These programs can print non-fatal diagnostics to stderr prior to
exec'ing a subsidiary program. However, if we thought the situation
warranted a diagnostic, we insist that the diagnostic be printed
without error, rather than blindly exec, as it may be a security risk.
For an example, try 'nice -n -1 nice 2>/dev/full'. Failure to raise
priority (by lowering niceness) is not fatal, but failure to inform
the user about failure to change priority is dangerous.
* src/nice.c (main): Declare failure if writing advisory message
to stderr fails.
* src/nohup.c (main): Likewise.
* src/su.c (main): Likewise.
* tests/misc/nice: Test this.
* tests/misc/nohup: Likewise.
* NEWS: Document this.
Diffstat (limited to 'tests/misc/nohup')
-rwxr-xr-x | tests/misc/nohup | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/misc/nohup b/tests/misc/nohup index ad04a1cb0..96810588e 100755 --- a/tests/misc/nohup +++ b/tests/misc/nohup @@ -64,6 +64,21 @@ test -f nohup.out && fail=1 rm -f nohup.out err # ---------------------- +# Bug present through coreutils 8.0: failure to print advisory message +# to stderr must be fatal. Requires stdout to be terminal. +if test -w /dev/full && test -c /dev/full; then +( + exec >/dev/tty + test -t 1 || exit 0 + nohup echo hi 2> /dev/full + test $? = 125 || fail=1 + test -f nohup.out || fail=1 + test -s nohup.out && fail=1 + rm -f nohup.out + exit $fail +) || fail=1 +fi + nohup no-such-command 2> err errno=$? if test -t 1; then |