ia64/xen-unstable

view tools/security/getlabel.sh @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children 06d84bf87159
line source
1 #!/bin/sh
2 # *
3 # * getlabel
4 # *
5 # * Copyright (C) 2005 IBM Corporation
6 # *
7 # * Authors:
8 # * Stefan Berger <stefanb@us.ibm.com>
9 # *
10 # * This program is free software; you can redistribute it and/or
11 # * modify it under the terms of the GNU General Public License as
12 # * published by the Free Software Foundation, version 2 of the
13 # * License.
14 # *
15 # * 'getlabel' tries to find the labels corresponding to the ssidref
16 # *
17 # * 'getlabel -?' shows the usage of the program
18 # *
19 # * 'getlabel -sid <ssidref> [<policy name>]' lists the label corresponding
20 # * to the given ssidref.
21 # *
22 # * 'getlabel -dom <domain id> [<policy name>]' lists the label of the
23 # * domain with given id
24 # *
25 #
27 if [ -z "$runbash" ]; then
28 runbash="1"
29 export runbash
30 exec sh -c "bash $0 $*"
31 fi
34 export PATH=$PATH:.
35 source labelfuncs.sh
37 usage ()
38 {
39 echo "Usage: $0 -sid <ssidref> [<policy name>] or"
40 echo " $0 -dom <domid> [<policy name>] "
41 echo ""
42 echo "policy name : the name of the policy, i.e. 'chwall'"
43 echo " If the policy name is omitted, the grub.conf"
44 echo " entry of the running system is tried to be read"
45 echo " and the policy name determined from there."
46 echo "ssidref : an ssidref in hex or decimal format, i.e., '0x00010002'"
47 echo " or '65538'"
48 echo "domid : id of the domain, i.e., '1'; Use numbers from the 2nd"
49 echo " column shown when invoking 'xm list'"
50 echo ""
51 }
55 if [ "$1" == "-?" ]; then
56 mode="usage"
57 elif [ "$1" == "-dom" ]; then
58 mode="domid"
59 shift
60 elif [ "$1" == "-sid" ]; then
61 mode="sid"
62 shift
63 elif [ "$1" == "" ]; then
64 usage
65 exit -1
66 fi
69 if [ "$mode" == "usage" ]; then
70 usage
71 elif [ "$mode" == "domid" ]; then
72 if [ "$2" == "" ]; then
73 findGrubConf
74 ret=$?
75 if [ $ret -eq 0 ]; then
76 echo "Could not find grub.conf"
77 exit -1;
78 fi
79 findPolicyInGrub $grubconf
80 if [ "$policy" != "" ]; then
81 echo "Assuming policy to be '$policy'.";
82 else
83 echo "Could not find policy."
84 exit -1;
85 fi
86 else
87 policy=$2
88 fi
89 findMapFile $policy
90 res=$?
91 if [ "$res" != "0" ]; then
92 getSSIDUsingSecpolTool $1
93 res=$?
94 if [ "$res" != "0" ]; then
95 translateSSIDREF $ssid $mapfile
96 else
97 echo "Could not determine the SSID of the domain."
98 fi
99 else
100 echo "Could not find map file for policy '$policy'."
101 fi
102 elif [ "$mode" == "sid" ]; then
103 if [ "$2" == "" ]; then
104 findGrubConf
105 ret=$?
106 if [ $ret -eq 0 ]; then
107 echo "Could not find grub.conf"
108 exit -1;
109 fi
110 findPolicyInGrub $grubconf
111 if [ "$policy" != "" ]; then
112 echo "Assuming policy to be '$policy'.";
113 else
114 echo "Could not find policy."
115 exit -1;
116 fi
117 else
118 policy=$2
119 fi
120 findMapFile $policy
121 res=$?
122 if [ "$res" != "0" ]; then
123 translateSSIDREF $1 $mapfile
124 else
125 echo "Could not find map file for policy '$policy'."
126 fi
128 else
129 usage
130 fi