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

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/mkdir.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 mkdir
 
10
#=DESCRIPTION mkdir() and rmdir() test
 
11
 
 
12
pwd=`dirname $0`
 
13
pwd=`cd $pwd ; /bin/pwd`
 
14
 
 
15
bin=$pwd
 
16
 
 
17
. $bin/prologue.inc
 
18
 
 
19
dir=$tmpdir/tmpdir/
 
20
perms=w
 
21
excess_perms=wl
 
22
badperms=r
 
23
 
 
24
# mkdir TEST
 
25
 
 
26
# null profile, verify mkdir/rmdir fail
 
27
genprofile
 
28
 
 
29
runchecktest "MKDIR (confined - no perms)" fail mkdir $dir
 
30
 
 
31
# yeah, looks like NOP, but pass/fail of first shouldn't affect second
 
32
# use || : to avoid shell trap error if dir doesn't exist
 
33
/bin/rmdir $dir 2> /dev/null || :
 
34
/bin/mkdir $dir
 
35
 
 
36
runchecktest "RMDIR (confined - no perms)" fail rmdir $dir
 
37
 
 
38
# profile with read-only permissions, fail
 
39
 
 
40
genprofile $dir:$badperms
 
41
 
 
42
/bin/rmdir $dir 2> /dev/null || :
 
43
runchecktest "MKDIR (confined read-only)" fail mkdir $dir
 
44
 
 
45
# yeah, looks like NOP, but pass/fail of first shouldn't affect second
 
46
/bin/rmdir $dir 2> /dev/null || :
 
47
/bin/mkdir $dir
 
48
 
 
49
runchecktest "RMDIR (confined read-only)" fail rmdir $dir
 
50
 
 
51
# profile with permissions, shouldn't fail
 
52
 
 
53
genprofile $dir:$perms
 
54
 
 
55
/bin/rmdir $dir 2> /dev/null || :
 
56
runchecktest "MKDIR (confined)" pass mkdir $dir
 
57
 
 
58
# yeah, looks like NOP, but pass/fail of first shouldn't affect second
 
59
/bin/rmdir $dir 2> /dev/null || :
 
60
/bin/mkdir $dir
 
61
 
 
62
runchecktest "RMDIR (confined)" pass rmdir $dir
 
63
 
 
64
# profile with excess permissions, shouldn't fail
 
65
 
 
66
genprofile $dir:$excess_perms
 
67
 
 
68
/bin/rmdir $dir 2> /dev/null || :
 
69
runchecktest "MKDIR (confined +l)" pass mkdir $dir
 
70
 
 
71
# yeah, looks like NOP, but pass/fail of first shouldn't affect second
 
72
/bin/rmdir $dir 2> /dev/null || :
 
73
/bin/mkdir $dir
 
74
 
 
75
runchecktest "RMDIR (confined +l)" pass rmdir $dir