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

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/swap.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 swap
 
10
#=DESCRIPTION 
 
11
# Confined processes are prohibited from executing certain system calls 
 
12
# entirely, including swapon(2) swapoff (2).  This test verifies that 
 
13
# unconfined processes can call these syscalls but confined processes cannot.
 
14
#=END
 
15
 
 
16
# I made this a seperate test script because of the need to make a
 
17
# swapfile before the tests run.
 
18
 
 
19
pwd=`dirname $0`
 
20
pwd=`cd $pwd ; /bin/pwd`
 
21
 
 
22
bin=$pwd
 
23
 
 
24
. $bin/prologue.inc
 
25
 
 
26
##
 
27
## A. SWAP
 
28
##
 
29
 
 
30
swap_file=$tmpdir/swapfile
 
31
 
 
32
dd if=/dev/zero of=${swap_file} bs=1024 count=512 2> /dev/null
 
33
/sbin/mkswap -f ${swap_file} > /dev/null
 
34
 
 
35
# TEST 1.  Make sure can enable and disable swap unconfined
 
36
 
 
37
runchecktest "SWAPON (unconfined)" pass on ${swap_file}
 
38
runchecktest "SWAPOFF (unconfined)" pass off ${swap_file}
 
39
 
 
40
# TEST A2.  confine SWAPON
 
41
 
 
42
genprofile
 
43
runchecktest "SWAPON (confined)" fail on ${swap_file}
 
44
 
 
45
# TEST A3.  confine SWAPOFF
 
46
 
 
47
/sbin/swapon ${swap_file} 
 
48
 
 
49
runchecktest "SWAPOFF (confined)" fail off ${swap_file}
 
50
 
 
51
# cleanup, turn off swap
 
52
 
 
53
/sbin/swapoff ${swap_file}