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

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/rw.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 rw
 
10
#=DESCRIPTION 
 
11
# This test verifies read/write operation.   AppArmor caches a successful open 
 
12
# but checks (on read/write) to see if a confined processes profile has been 
 
13
# replaced asynchronously. If it has, access is reevaluated.  The test waits 
 
14
# for a signal at which point it reattempts to write, read and verify data. The
 
15
# controlling script performs a profile replacement before sending the signal 
 
16
# for the test to reattempt the io.
 
17
#=END
 
18
 
 
19
pwd=`dirname $0`
 
20
pwd=`cd $pwd ; /bin/pwd`
 
21
 
 
22
bin=$pwd
 
23
 
 
24
. $bin/prologue.inc
 
25
 
 
26
file=$tmpdir/src
 
27
okperm=rw
 
28
badperm=r
 
29
 
 
30
# PASS TEST (pt 1)
 
31
 
 
32
genprofile $file:$okperm 
 
33
 
 
34
runtestbg "READ/WRITE pass" pass $file
 
35
 
 
36
sleep 2
 
37
 
 
38
# PASS TEST (pt 2)
 
39
 
 
40
kill -USR1 $_pid
 
41
 
 
42
checktestbg
 
43
 
 
44
rm -f $file
 
45
 
 
46
# FAILURE TEST (pt 1)
 
47
 
 
48
genprofile $file:$okperm
 
49
 
 
50
runtestbg "READ/WRITE fail" fail $file
 
51
 
 
52
sleep 2
 
53
 
 
54
# FAILURE TEST (pt 2)
 
55
 
 
56
genprofile $file:$badperm
 
57
 
 
58
# problem the shell and the test program are racing, after profile replacement
 
59
# if the shell runs immediately after profile replacement instead of the
 
60
# test program it will will.  We insert a small sleep to make this unlikely
 
61
 
 
62
sleep 1
 
63
 
 
64
kill -USR1 $_pid
 
65
 
 
66
checktestbg