d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#! /usr/bin/ksh
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# This file and its contents are supplied under the terms of the
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# Common Development and Distribution License ("CDDL"), version 1.0.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# You may only use this file in accordance with the terms of version
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# 1.0 of the CDDL.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# A full copy of the text of the CDDL should have accompanied this
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# source. A copy of the CDDL is also available via the Internet at
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# http://www.illumos.org/license/CDDL.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe# Copyright 2015, Richard Lowe.
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe#
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecd /tmp;
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecleanup() {
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe rm /tmp/output.$$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe rm /tmp/expected.$$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe}
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowetrap cleanup EXIT
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecat > /tmp/expected.$$ <<EOF
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe^psecflags\(0x[0-9A-F]+, PSF_INHERIT, \{ PROC_SEC_ASLR, 0x0, 0x0, B_FALSE \}\) = 0$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard LoweEOF
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowetruss -t psecflags /usr/bin/psecflags -s current,aslr -e ls \
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe >/dev/null 2>output.$$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Loweif ! grep -qEf /tmp/expected.$$ /tmp/output.$$; then
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe echo "truss: failed"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe echo "output:"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe sed -e 's/^/ /' output.$$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe echo "should match:"
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe sed -e 's/^/ /' expected.$$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe exit 1;
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowefi
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Loweexit 0