~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/environ.sh

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/bash
 
2
#       Copyright (C) 2002-2005 Novell/SUSE
 
3
#
 
4
#       This program is free software; you can redistribute it and/or
 
5
#       modify it under the terms of the GNU General Public License as
 
6
#       published by the Free Software Foundation, version 2 of the
 
7
#       License.
 
8
 
 
9
#=NAME environ
 
10
#=DESCRIPTION
 
11
# verify bprm_unsafe filtering occurs for Px and Ux.
 
12
#
 
13
#=END
 
14
 
 
15
pwd=`dirname $0`
 
16
pwd=`cd $pwd ; /bin/pwd`
 
17
 
 
18
bin=$pwd
 
19
 
 
20
. $bin/prologue.inc
 
21
 
 
22
helper=$pwd/env_check
 
23
setuid_helper=${tmpdir}/env_check
 
24
helper_sh=$pwd/env_check.sh
 
25
 
 
26
# TEST environment filtering on elf binaries
 
27
genprofile $helper:ux
 
28
runchecktest "ENVIRON (elf): ux & regular env" pass $helper FOO=BAR
 
29
runchecktest "ENVIRON (elf): ux & sensitive env" pass $helper LD_LIBRARY_PATH=.
 
30
 
 
31
genprofile $helper:Ux
 
32
runchecktest "ENVIRON (elf): Ux & regular env" pass $helper FOO=BAR
 
33
runchecktest "ENVIRON (elf): Ux & sensitive env" fail $helper LD_LIBRARY_PATH=.
 
34
 
 
35
genprofile $helper:rix
 
36
runchecktest "ENVIRON (elf): ix & regular env" pass $helper FOO=BAR
 
37
runchecktest "ENVIRON (elf): ix & sensitive env" pass $helper LD_LIBRARY_PATH=.
 
38
 
 
39
genprofile $helper:px -- image=$helper
 
40
runchecktest "ENVIRON (elf): px & regular env" pass $helper FOO=BAR
 
41
runchecktest "ENVIRON (elf): px & sensitive env" pass $helper LD_LIBRARY_PATH=.
 
42
 
 
43
genprofile $helper:Px -- image=$helper
 
44
runchecktest "ENVIRON (elf): Px & regular env" pass $helper FOO=BAR
 
45
runchecktest "ENVIRON (elf): Px & sensitive env" fail $helper LD_LIBRARY_PATH=.
 
46
 
 
47
genprofile image=$helper
 
48
runchecktest "ENVIRON (elf): unconfined --> confined & regular env" pass $helper FOO=BAR
 
49
runchecktest "ENVIRON (elf): unconfined --> confined & sensitive env" pass $helper LD_LIBRARY_PATH=.
 
50
 
 
51
genprofile -C
 
52
runchecktest "ENVIRON (elf): confined/complain & regular env" pass $helper FOO=BAR
 
53
runchecktest "ENVIRON (elf): confined/complain & sensitive env" pass $helper LD_LIBRARY_PATH=.
 
54
 
 
55
# TEST environment filtering on shell scripts
 
56
genprofile ${helper_sh}:ux
 
57
runchecktest "ENVIRON (shell script): ux & regular env" pass ${helper_sh} FOO=BAR
 
58
runchecktest "ENVIRON (shell script): ux & sensitive env" pass ${helper_sh} LD_LIBRARY_PATH=.
 
59
 
 
60
genprofile ${helper_sh}:Ux
 
61
runchecktest "ENVIRON (shell script): Ux & regular env" pass ${helper_sh} FOO=BAR
 
62
runchecktest "ENVIRON (shell script): Ux & sensitive env" fail ${helper_sh} LD_LIBRARY_PATH=.
 
63
 
 
64
genprofile ${helper_sh}:px -- image=${helper_sh} /bin/bash:rix "/lib*/lib*:mr"
 
65
runchecktest "ENVIRON (shell script): px & regular env" pass ${helper_sh} FOO=BAR
 
66
runchecktest "ENVIRON (shell script): px & sensitive env" pass ${helper_sh} LD_LIBRARY_PATH=.
 
67
 
 
68
genprofile ${helper_sh}:Px -- image=${helper_sh} /bin/bash:rix "/lib*/lib*:mr"
 
69
runchecktest "ENVIRON (shell script): Px & regular env" pass ${helper_sh} FOO=BAR
 
70
runchecktest "ENVIRON (shell script): Px & sensitive env" fail ${helper_sh} LD_LIBRARY_PATH=.
 
71
 
 
72
genprofile ${helper_sh}:rix /bin/bash:rix "/lib*/lib*:mr"
 
73
runchecktest "ENVIRON (shell script): ix & regular env" pass ${helper_sh} FOO=BAR
 
74
runchecktest "ENVIRON (shell script): ix & sensitive env" pass ${helper_sh} LD_LIBRARY_PATH=.
 
75
 
 
76
genprofile image=${helper_sh} /bin/bash:rix "/lib*/lib*:mr"
 
77
runchecktest "ENVIRON (shell script): unconfined --> confined & regular env" pass ${helper_sh} FOO=BAR
 
78
runchecktest "ENVIRON (shell script): unconfined --> confined & sensitive env" pass ${helper_sh} LD_LIBRARY_PATH=.
 
79
 
 
80
genprofile -C
 
81
runchecktest "ENVIRON (shell script): confined/complain & regular env" pass ${helper_sh} FOO=BAR
 
82
runchecktest "ENVIRON (shell script): confined/complain & sensitive env" pass ${helper_sh} LD_LIBRARY_PATH=.
 
83
 
 
84
# TEST environment filtering still works on setuid apps
 
85
removeprofile
 
86
 
 
87
cp $helper ${setuid_helper}
 
88
chown nobody ${setuid_helper}
 
89
chmod u+s ${setuid_helper}
 
90
runchecktest "ENVIRON (elf): unconfined setuid helper" pass ${setuid_helper} FOO=BAR
 
91
runchecktest "ENVIRON (elf): unconfined setuid helper" fail ${setuid_helper} LD_LIBRARY_PATH=.