~apparmor-dev/apparmor/master

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/readdir.sh

  • Committer: Steve Beattie
  • Date: 2019-02-19 09:38:13 UTC
  • Revision ID: sbeattie@ubuntu.com-20190219093813-ud526ee6hwn8nljz
The AppArmor project has been converted to git and is now hosted on
gitlab.

To get the converted repository, please do
  git clone https://gitlab.com/apparmor/apparmor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/bash
2
 
#       Copyright (C) 2002-2005 Novell/SUSE
3
 
#       Copyright (C) 2017 Canonical, Ltd.
4
 
#
5
 
#       This program is free software; you can redistribute it and/or
6
 
#       modify it under the terms of the GNU General Public License as
7
 
#       published by the Free Software Foundation, version 2 of the
8
 
#       License.
9
 
 
10
 
#=NAME readdir
11
 
#=DESCRIPTION 
12
 
# AppArmor requires 'r' permission on a directory in order for a confined task
13
 
# to be able to read the directory contents.  This test verifies this.
14
 
#=END
15
 
 
16
 
pwd=`dirname $0`
17
 
pwd=`cd $pwd ; /bin/pwd`
18
 
 
19
 
bin=$pwd
20
 
 
21
 
. $bin/prologue.inc
22
 
 
23
 
dir=$tmpdir/tmpdir
24
 
# x is not really needed, see chdir.sh
25
 
okperm=rix
26
 
badperm=ix
27
 
 
28
 
mkdir $dir
29
 
 
30
 
# The readdir utility expects the return value to be passed as the
31
 
# second argument and returns success if the succeeding or failing calls
32
 
# match the expected value. It will fail the test if they don't, so for
33
 
# example the result differs acrorss getdents() and getdents64() this
34
 
# will be detected.
35
 
 
36
 
# READDIR TEST
37
 
genprofile $dir/:$okperm
38
 
runchecktest "READDIR" pass $dir 0
39
 
 
40
 
EACCES=13
41
 
# READDIR TEST (no perm)
42
 
genprofile $dir/:$badperm
43
 
runchecktest "READDIR (no perm)" pass $dir ${EACCES}
44
 
 
45
 
# READDIR TEST (write perm) - ensure write perm isn't sufficient
46
 
genprofile $dir/:w
47
 
runchecktest "READDIR (write perm)" pass $dir ${EACCES}
48
 
 
49
 
# this test is to make sure the raw 'file' rule allows access
50
 
# to directories
51
 
genprofile file
52
 
runchecktest "READDIR 'file' dir" pass $dir 0
53
 
 
54
 
# this test is to make sure the raw 'file' rule allows access
55
 
# to '/'
56
 
genprofile file
57
 
runchecktest "READDIR 'file' '/'" pass '/' 0