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

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/unix_fd_server.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
 
# $Id: unix_fd_server.sh 430 2007-03-08 21:23:17Z 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 fd_over_unix
12
 
#=DESCRIPTION 
13
 
# This tests passing a file descriptor over a unix domain socket.  The server 
14
 
# opens a socket, forks a client with it's own profile, passes the file 
15
 
# descriptor to it over the socket, and sees what happens.
16
 
#=END
17
 
 
18
 
pwd=`dirname $0`
19
 
pwd=`cd $pwd ; /bin/pwd`
20
 
 
21
 
bin=$pwd
22
 
 
23
 
. $bin/prologue.inc
24
 
 
25
 
file=${tmpdir}/file
26
 
socket=${tmpdir}/unix_fd_test
27
 
fd_client=$PWD/unix_fd_client
28
 
okperm=rw
29
 
badperm=w
30
 
 
31
 
# Content generated with:
32
 
# dd if=/dev/urandom bs=32 count=4 2> /dev/null | od -x | head -8 | sed -e 's/^[[:xdigit:]]\{7\}//g' -e 's/ //g'
33
 
cat > ${file} << EOM
34
 
aabcc2739c621194a00b6cb7875dcdeb
35
 
72f485a783219817c81c65f3e1b2bc80
36
 
4366ba09e881286c834e67b34ae6f186
37
 
ccc2c402fcc6e66d5cfaa0c68b94211c
38
 
163f7beeb9a320ab859189a82d695713
39
 
175797a8cf2e2435dd98551385e96d8f
40
 
05f82e8e0e146be0d4655d4681cb08b6
41
 
ed15ad1d4fb9959008589e589206ee13
42
 
EOM
43
 
 
44
 
# lets just be on the safe side
45
 
rm -f ${socket}
46
 
 
47
 
# PASS - unconfined client
48
 
 
49
 
genprofile $file:$okperm $socket:rw $fd_client:ux
50
 
 
51
 
runchecktest "fd passing; unconfined client" pass $file $socket $fd_client
52
 
 
53
 
sleep 1
54
 
rm -f ${socket}
55
 
 
56
 
# PASS - confined client, rw access to the file
57
 
 
58
 
genprofile $file:$okperm $socket:rw $fd_client:px -- image=$fd_client $file:$okperm $socket:rw
59
 
runchecktest "fd passing; confined client w/ rw" pass $file $socket $fd_client
60
 
 
61
 
sleep 1
62
 
rm -f ${socket}
63
 
# FAIL - confined client, w access to the file
64
 
 
65
 
genprofile $file:$okperm $socket:rw $fd_client:px -- image=$fd_client $file:$badperm $socket:rw
66
 
runchecktest "fd passing; confined client w/ w only" fail $file $socket $fd_client
67
 
 
68
 
sleep 1
69
 
rm -f ${socket}
70