xref: /illumos-gate/usr/src/test/os-tests/tests/secflags/secflags_limits.sh (revision c5bab7026b8e0ac44b25ee08507ea360f177d844)
1#! /usr/bin/ksh
2#
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright 2015, Richard Lowe.
16#
17
18mkdir /tmp/secflags-test.$$
19cd /tmp/secflags-test.$$
20
21cleanup() {
22    kill $pid >/dev/null 2>&1
23    cd /
24    rm -fr /tmp/secflags-test.$$
25}
26
27trap cleanup EXIT
28
29# Check that lower implies setting of inheritable
30echo "Setting lower also adds to inheritable"
31/usr/bin/psecflags -s L=aslr $$
32
33cat > expected <<EOF
34	I:	aslr
35EOF
36/usr/bin/psecflags $$ | grep 'I:' > output
37
38diff -u expected output || exit 1
39
40echo "Setting in lower cannot be removed from inheritable"
41/usr/bin/psecflags -s I=current,-aslr $$ 2>/dev/null && exit 1
42
43echo "Setting in lower cannot be removed"
44/usr/bin/psecflags -s L=current,-aslr $$ 2>/dev/null && exit 1
45
46
47echo "Setting in lower cannot be removed from upper"
48/usr/bin/psecflags -s U=current,-aslr $$ 2>/devlnull && exit 1
49
50/usr/bin/psecflags -s U=current,-noexecstack $$
51
52echo "Setting in default cannot exceed upper"
53/usr/bin/psecflags -s I=noexecstack $$ 2>/dev/null && exit 1
54
55echo "Setting cannot ever be added to upper"
56/usr/bin/psecflags -s U=current,+noexecstack $$ 2>/dev/null && exit 1
57
58exit 0
59
60
61