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

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/open.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-2007 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 open
 
10
#=DESCRIPTION 
 
11
# Verify that the open syscall is correctly managed for confined profiles.  
 
12
#=END
 
13
 
 
14
pwd=`dirname $0`
 
15
pwd=`cd $pwd ; /bin/pwd`
 
16
 
 
17
bin=$pwd
 
18
 
 
19
. $bin/prologue.inc
 
20
 
 
21
file=$tmpdir/file
 
22
okperm=rw
 
23
badperm1=r
 
24
badperm2=w
 
25
 
 
26
# PASS UNCONFINED
 
27
runchecktest "OPEN unconfined RW (create) " pass $file
 
28
 
 
29
# PASS TEST (the file shouldn't exist, so open should create it
 
30
rm -f ${file}
 
31
genprofile $file:$okperm
 
32
runchecktest "OPEN RW (create) " pass $file
 
33
 
 
34
# PASS TEST
 
35
genprofile $file:$okperm
 
36
runchecktest "OPEN RW" pass $file
 
37
 
 
38
# FAILURE TEST (1)
 
39
genprofile $file:$badperm1
 
40
runchecktest "OPEN R" fail $file
 
41
 
 
42
# FAILURE TEST (2)
 
43
genprofile $file:$badperm2
 
44
runchecktest "OPEN W" fail $file
 
45
 
 
46
# FAILURE TEST (3)
 
47
genprofile $file:$badperm1 cap:dac_override
 
48
runchecktest "OPEN R+dac_override" fail $file
 
49
 
 
50
# FAILURE TEST (4)
 
51
# This is testing for bug: https://bugs.wirex.com/show_bug.cgi?id=2885
 
52
# When we open O_CREAT|O_RDWR, we are (were?) allowing only write access
 
53
# to be required.
 
54
rm -f ${file}
 
55
genprofile $file:$badperm2
 
56
runchecktest "OPEN W (create)" fail $file