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 Lowe/usr/bin/psecflags -s aslr -e sleep 100000 &
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowepid=$!
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowecleanup() {
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe kill $pid
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$pid: sleep 100000
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe E: aslr
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe I: aslr
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard LoweEOF
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe/usr/bin/psecflags $pid | grep -v '[LU]:' > /tmp/output.$$
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Loweif ! diff -u /tmp/expected.$$ /tmp/output.$$; then
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe exit 1;
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowefi
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Loweexit 0