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

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/changehat.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 changehat
 
10
#=DESCRIPTION 
 
11
# Verifies basic file access permission checks for a parent profile and one 
 
12
# subprofile/hat
 
13
#=END
 
14
 
 
15
pwd=`dirname $0`
 
16
pwd=`cd $pwd ; /bin/pwd`
 
17
 
 
18
bin=$pwd
 
19
 
 
20
. $bin/prologue.inc
 
21
 
 
22
file=$tmpdir/file
 
23
subfile=$tmpdir/file2
 
24
okperm=rw
 
25
 
 
26
subtest=sub
 
27
subtest2=sub2
 
28
subtest3=sub3
 
29
 
 
30
touch $file $subfile
 
31
 
 
32
# CHANGEHAT UNCONFINED
 
33
runchecktest "CHANGEHAT (unconfined - nochange)" pass nochange $file
 
34
runchecktest_errno EPERM "CHANGEHAT (unconfined)" fail $subtest $file
 
35
 
 
36
# NO CHANGEHAT TEST
 
37
genprofile $file:$okperm
 
38
 
 
39
runchecktest "NO CHANGEHAT (access parent file)" pass nochange $file
 
40
runchecktest "NO CHANGEHAT (access sub file)" fail nochange $subfile
 
41
 
 
42
# CHANGEHAT NO HATS TEST
 
43
runchecktest "CHAGEHAT (no hats, nochange)" pass nochange $file
 
44
runchecktest_errno ECHILD "CHANGEHAT (no hats, $file)" fail $subtest $file
 
45
runchecktest_errno ECHILD "CHANGEHAT (no hats, $subfile)" fail $subtest $subfile
 
46
 
 
47
# CHANGEHAT TEST
 
48
 
 
49
genprofile $file:$okperm hat:$subtest $subfile:$okperm
 
50
 
 
51
runchecktest "CHANGEHAT (access parent file)" fail $subtest $file
 
52
runchecktest "CHANGEHAT (access sub file)" pass $subtest $subfile
 
53
 
 
54
# CHANGEHAT TEST -- multiple subprofiles
 
55
 
 
56
genprofile $file:$okperm hat:$subtest $subfile:$okperm hat:$subtest2 $subfile:$okperm hat:$subtest3 $subfile:$okperm
 
57
 
 
58
runchecktest "CHANGEHAT (access parent file)" fail $subtest $file
 
59
runchecktest "CHANGEHAT (access sub file)" pass $subtest $subfile
 
60
runchecktest "CHANGEHAT (access sub file)" pass $subtest2 $subfile
 
61
runchecktest "CHANGEHAT (access sub file)" pass $subtest3 $subfile
 
62