apparmor/tests/regression/subdomain/unix_fd_server.sh
Steve Beattie 6d3e74907d Import the rest of the core functionality of the internal apparmor
development tree (trunk branch). From svn repo version 6381.
2006-04-11 21:52:54 +00:00

70 lines
1.8 KiB
Bash
Executable file

#! /bin/bash
# $Id:$
# Copyright (C) 2002-2005 Novell/SUSE
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, version 2 of the
# License.
#=NAME fd_over_unix
#=DESCRIPTION
# This tests passing a file descriptor over a unix domain socket. The server
# opens a socket, forks a client with it's own profile, passes the file
# descriptor to it over the socket, and sees what happens.
#=END
pwd=`dirname $0`
pwd=`cd $pwd ; /bin/pwd`
bin=$pwd
. $bin/prologue.inc
file=${tmpdir}/file
socket=${tmpdir}/unix_fd_test
fd_client=$PWD/unix_fd_client
okperm=rw
badperm=w
# Content generated with:
# dd if=/dev/urandom bs=32 count=4 2> /dev/null | od -x | head -8 | sed -e 's/^[[:xdigit:]]\{7\}//g' -e 's/ //g'
cat > ${file} << EOM
aabcc2739c621194a00b6cb7875dcdeb
72f485a783219817c81c65f3e1b2bc80
4366ba09e881286c834e67b34ae6f186
ccc2c402fcc6e66d5cfaa0c68b94211c
163f7beeb9a320ab859189a82d695713
175797a8cf2e2435dd98551385e96d8f
05f82e8e0e146be0d4655d4681cb08b6
ed15ad1d4fb9959008589e589206ee13
EOM
# lets just be on the safe side
rm -f ${socket}
# PASS - unconstrained client
genprofile $file:$okperm $socket:rw $fd_client:ux
runchecktest "fd passing; unconstrained client" pass $file $socket $fd_client
sleep 1
rm -f ${socket}
# PASS - constrained client, rw access to the file
genprofile $file:$okperm $socket:rw $fd_client:px -- image=$fd_client $file:$okperm $socket:rw
runchecktest "fd passing; constrained client w/ rw" pass $file $socket $fd_client
sleep 1
rm -f ${socket}
# FAIL - constrained client, w access to the file
genprofile $file:$okperm $socket:rw $fd_client:px -- image=$fd_client $file:$badperm $socket:rw
runchecktest "fd passing; constrained client w/ w only" fail $file $socket $fd_client
sleep 1
rm -f ${socket}