~ubuntu-branches/ubuntu/raring/apparmor/raring

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/rw.sh

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-03-23 16:42:01 UTC
  • Revision ID: james.westby@ubuntu.com-20070323164201-jkax6f0oku087b7l
Tags: upstream-2.0.1+510.dfsg
ImportĀ upstreamĀ versionĀ 2.0.1+510.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/bash
 
2
# $Id: rw.sh 61 2006-05-19 18:32:14Z steve-beattie $
 
3
 
 
4
#       Copyright (C) 2002-2005 Novell/SUSE
 
5
#
 
6
#       This program is free software; you can redistribute it and/or
 
7
#       modify it under the terms of the GNU General Public License as
 
8
#       published by the Free Software Foundation, version 2 of the
 
9
#       License.
 
10
 
 
11
#=NAME rw
 
12
#=DESCRIPTION 
 
13
# This test verifies read/write operation.   AppArmor caches a successful open 
 
14
# but checks (on read/write) to see if a confined processes profile has been 
 
15
# replaced asynchronously. If it has, access is reevaluated.  The test waits 
 
16
# for a signal at which point it reattempts to write, read and verify data. The
 
17
# controlling script performs a profile replacement before sending the signal 
 
18
# for the test to reattempt the io.
 
19
#=END
 
20
 
 
21
pwd=`dirname $0`
 
22
pwd=`cd $pwd ; /bin/pwd`
 
23
 
 
24
bin=$pwd
 
25
 
 
26
. $bin/prologue.inc
 
27
 
 
28
file=$tmpdir/src
 
29
okperm=rw
 
30
badperm=r
 
31
 
 
32
# PASS TEST (pt 1)
 
33
 
 
34
genprofile $file:$okperm 
 
35
 
 
36
runtestbg "READ/WRITE pass" pass $file
 
37
 
 
38
sleep 2
 
39
 
 
40
# PASS TEST (pt 2)
 
41
 
 
42
kill -USR1 $_pid
 
43
 
 
44
checktestbg
 
45
 
 
46
rm -f $file
 
47
 
 
48
# FAILURE TEST (pt 1)
 
49
 
 
50
genprofile $file:$okperm
 
51
 
 
52
runtestbg "READ/WRITE fail" fail $file
 
53
 
 
54
sleep 2
 
55
 
 
56
# FAILURE TEST (pt 2)
 
57
 
 
58
genprofile $file:$badperm
 
59
 
 
60
# problem the shell and the test program are racing, after profile replacement
 
61
# if the shell runs immediately after profile replacement instead of the
 
62
# test program it will will.  We insert a small sleep to make this unlikely
 
63
 
 
64
sleep 1
 
65
 
 
66
kill -USR1 $_pid
 
67
 
 
68
checktestbg