tst.execfail.ksh revision 14ea49401f3c8c61422aefbda43809e275f60c6c
44be2a82d1be2bebf786473e4b09142e64020bd6vboxsync#
44be2a82d1be2bebf786473e4b09142e64020bd6vboxsync# CDDL HEADER START
44be2a82d1be2bebf786473e4b09142e64020bd6vboxsync#
44be2a82d1be2bebf786473e4b09142e64020bd6vboxsync# The contents of this file are subject to the terms of the
27efd9329f6a90f7cacf840031e5305f98975960vboxsync# Common Development and Distribution License (the "License").
27efd9329f6a90f7cacf840031e5305f98975960vboxsync# You may not use this file except in compliance with the License.
03d95f0cb2f0d5150afe682f9b2e3fda29dc9cbbvboxsync#
03d95f0cb2f0d5150afe682f9b2e3fda29dc9cbbvboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
03d95f0cb2f0d5150afe682f9b2e3fda29dc9cbbvboxsync# or http://www.opensolaris.org/os/licensing.
03d95f0cb2f0d5150afe682f9b2e3fda29dc9cbbvboxsync# See the License for the specific language governing permissions
27efd9329f6a90f7cacf840031e5305f98975960vboxsync# and limitations under the License.
27efd9329f6a90f7cacf840031e5305f98975960vboxsync#
7aaee03c1ea56a523fe64f674a5ff3da31c27c48vboxsync# When distributing Covered Code, include this CDDL HEADER in each
7aaee03c1ea56a523fe64f674a5ff3da31c27c48vboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aaee03c1ea56a523fe64f674a5ff3da31c27c48vboxsync# If applicable, add the following below this CDDL HEADER, with the
7aaee03c1ea56a523fe64f674a5ff3da31c27c48vboxsync# fields enclosed by brackets "[]" replaced with your own identifying
7aaee03c1ea56a523fe64f674a5ff3da31c27c48vboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
7aaee03c1ea56a523fe64f674a5ff3da31c27c48vboxsync#
460ec25fd6142d040369ba8a86b928936e7da08cvboxsync# CDDL HEADER END
460ec25fd6142d040369ba8a86b928936e7da08cvboxsync#
460ec25fd6142d040369ba8a86b928936e7da08cvboxsync
460ec25fd6142d040369ba8a86b928936e7da08cvboxsync#
460ec25fd6142d040369ba8a86b928936e7da08cvboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
460ec25fd6142d040369ba8a86b928936e7da08cvboxsync# Use is subject to license terms.
b5c54fea3b0b605abd04782cc858e1f030ff4a29vboxsync#
98b57301cf15ff5f95eaf7bc8b81e57750026b8evboxsync# ident "%Z%%M% %I% %E% SMI"
f3dd47993f29190065ac0cdaa4a0800642825822vboxsync
98b57301cf15ff5f95eaf7bc8b81e57750026b8evboxsync#
365b40dec2ed01d9983d29e276e7431c5a4a9c18vboxsync# This script tests that -- if a exec(2) fails -- the proc:::exec probe fires,
98b57301cf15ff5f95eaf7bc8b81e57750026b8evboxsync# followed by the proc:::exec-success probe (in a successful exec(2)). To
ed9e399bf577a6863708163e88c4ba19b673e246vboxsync# circumvent any potential shell cleverness, this script generates exec
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync# failure by generating a file with a bogus interpreter. (It seems unlikely
f3dd47993f29190065ac0cdaa4a0800642825822vboxsync# that a shell -- regardless of how clever it claims to be -- would bother to
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync# validate the interpreter before exec'ing.)
104ee9b130538e40654d7732282799493cdd5e7dvboxsync#
# If this fails, the script will run indefinitely; it relies on the harness
# to time it out.
#
script()
{
$dtrace -s /dev/stdin <<EOF
proc:::exec
/curpsinfo->pr_ppid == $child && args[0] == "$badexec"/
{
self->exec = 1;
}
proc:::exec-failure
/self->exec/
{
exit(0);
}
EOF
}
sleeper()
{
while true; do
/usr/bin/sleep 1
$badexec
done
}
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
badexec=/tmp/execfail.ksh.$$
dtrace=$1
cat > $badexec <<EOF
#!/this_is_a_bogus_interpreter
EOF
chmod +x $badexec
sleeper &
child=$!
script
status=$?
kill $child
rm $badexec
exit $status