-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlocalfuncs
87 lines (82 loc) · 2.51 KB
/
localfuncs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
POLICY_LOCATION="/home/swift/Development/Centralized/hardened-refpolicy/";
# sefindif - Find interface definitions that have a string that matches the
# given regular expression
sefindif() {
REGEXP="$1";
if [ -d ${POLICY_LOCATION}/policy/modules ];
then
pushd ${POLICY_LOCATION}/policy/modules > /dev/null 2>&1;
elif [ -d ${POLICY_LOCATION}/include ];
then
pushd ${POLICY_LOCATION}/include > /dev/null 2>&1;
else
echo "Variable POLICY_LOCATION is not properly defined.";
return 1;
fi
for FILE in */*.if;
do
awk "BEGIN { P=1 } /(interface\(|template\()/ { NAME=\$0; P=0 }; /${REGEXP}/ { if (P==0) {P=1; print NAME}; if (NAME!=\$0) print };" ${FILE} | sed -e "s:^:${FILE}\: :g";
done
popd > /dev/null 2>&1;
}
# seshowif - Show the interface definition
seshowif() {
INTERFACE="$1";
if [ -d ${POLICY_LOCATION}/policy/modules ];
then
pushd ${POLICY_LOCATION}/policy/modules > /dev/null 2>&1;
elif [ -d ${POLICY_LOCATION}/include ];
then
pushd ${POLICY_LOCATION}/include > /dev/null 2>&1;
else
echo "Variable POLICY_LOCATION is not properly defined.";
return 1;
fi
for FILE in */*.if;
do
grep -A 9999 "\(interface(\`${INTERFACE}'\|template(\`${INTERFACE}'\)" ${FILE} | grep -B 9999 -m 1 "^')";
done
popd > /dev/null 2>&1;
}
# sefinddef - Find macro definitions that have a string that matches the given
# regular expression
sefinddef() {
REGEXP="$1";
if [ -d ${POLICY_LOCATION}/policy/support ];
then
pushd ${POLICY_LOCATION}/policy/support > /dev/null 2>&1;
elif [ -d ${POLICY_LOCATION}/include/support ];
then
pushd ${POLICY_LOCATION}/include/support > /dev/null 2>&1;
else
echo "Variable POLICY_LOCATION is not properly defined.";
return 1;
fi
for FILE in *;
do
awk "BEGIN { P=1; } /(define\(\`[^\`]*\`$)/ { NAME=\$0; P=0 }; /${REGEXP}/ { if (P==0) {P=1; print NAME}; if (NAME!=\$0) print };" ${FILE};
done
popd > /dev/null 2>&1;
}
# seshowdef - Show the macro definition
seshowdef() {
MACRONAME="$1";
if [ -d ${POLICY_LOCATION}/policy/support ];
then
pushd ${POLICY_LOCATION}/policy/support > /dev/null 2>&1;
elif [ -d ${POLICY_LOCATION}/include/support ];
then
pushd ${POLICY_LOCATION}/include/support > /dev/null 2>&1;
else
echo "Variable POLICY_LOCATION is not properly defined.";
return 1;
fi
for FILE in *.spt;
do
grep -A 9999 "define(\`${MACRONAME}'" ${FILE} | grep -B 999 -m 1 "')";
done
popd > /dev/null 2>&1;
}
sepathdecode() {
python -c "import base64; print(base64.b16decode(\"${1}\"));";
}