2
# $Id: openat.sh 441 2007-03-14 20:53:10Z steve-beattie $
4
# Copyright (C) 2002-2007 Novell/SUSE
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
13
# Verify that the openat syscall is correctly managed for confined profiles.
17
pwd=`cd $pwd ; /bin/pwd`
27
filepath=${dir}/${file}
33
rm -rf ${dir}/${subdir} ${dir}/${otherdir}
34
mkdir ${dir}/${subdir}
39
runchecktest "OPENAT unconfined RW (create) " pass $dir $file
41
# PASS TEST (the file shouldn't exist, so open should create it
43
genprofile ${dir}:r ${filepath}:$okperm
44
runchecktest "OPENAT RW (create) " pass $dir $file
49
genprofile ${dir}:r ${filepath}:$okperm
50
runchecktest "OPENAT RW (exists)" pass $dir $file
55
genprofile ${dir}:r ${filepath}:$badperm1
56
runchecktest "OPENAT R" fail $dir $file
61
genprofile ${dir}:r ${filepath}:$badperm2
62
runchecktest "OPENAT W (exists)" fail $dir $file
66
genprofile ${dir}:r ${filepath}:$badperm1 cap:dac_override
67
runchecktest "OPENAT R+dac_override" fail $dir $file
70
# This is testing for bug: https://bugs.wirex.com/show_bug.cgi?id=2885
71
# When we open O_CREAT|O_RDWR, we are (were?) allowing only write access
74
genprofile ${dir}:r ${filepath}:$badperm2
75
runchecktest "OPENAT W (create)" fail $dir $file
77
# PASS rename of directory in between opendir/openat
79
genprofile ${dir}/${subdir}:rw ${dir}/otherdir:w ${dir}/otherdir/file:rw
80
runchecktest "OPENAT RW (rename/newpath)" pass --rename ${dir}/otherdir ${dir}/${subdir} file
82
# PASS rename of directory in between opendir/openat - file exists
85
genprofile ${dir}/${subdir}:rw ${dir}/otherdir:w ${dir}/otherdir/file:rw
86
runchecktest "OPENAT RW (rename/newpath)" pass --rename ${dir}/otherdir ${dir}/${subdir} file
88
# FAIL rename of directory in between opendir/openat - use old name
90
genprofile ${dir}/${subdir}:rw ${dir}/otherdir:w ${dir}/${subdir}/file:rw
91
runchecktest "OPENAT RW (rename/newpath)" fail --rename ${dir}/otherdir ${dir}/${subdir} file
94
# FAIL rename of directory in between opendir/openat - use old name, file exists
97
genprofile ${dir}/${subdir}:rw ${dir}/otherdir:w ${dir}/${subdir}/file:rw
98
runchecktest "OPENAT RW (rename/newpath)" fail --rename ${dir}/otherdir ${dir}/${subdir} file