-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcrossystem_boot_populator.sh
152 lines (140 loc) · 6.98 KB
/
crossystem_boot_populator.sh
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# crossystem.sh v3.0.0
# made by r58Playz and stackoverflow
# emulates crossystem but with static values to trick chromeos and google
# version history:
# v3.0.0 - implemented mutable crossystem values
# v2.0.0 - implemented all functionality
# v1.1.1 - hotfix for stupid crossystem
# v1.1.0 - implemented <var>?<value> functionality (searches for value in var)
# v1.0.0 - basic functionality implemented
# script gutted by rainestorme for murkmod
. /usr/share/misc/chromeos-common.sh || :
csys() {
if [ "$COMPAT" == "1" ]; then
crossystem "$@"
elif test -f "$ROOT/usr/bin/crossystem.old"; then
"$ROOT/usr/bin/crossystem.old" "$@"
else
"$ROOT/usr/bin/crossystem" "$@"
fi
}
sed_escape() {
echo -n "$1" | while read -n1 ch; do
if [[ "$ch" == "" ]]; then
echo -n "\n"
# dumbass shellcheck not expanding is the entire point
fi
echo -n "\\x$(printf %x \'"$ch")"
done
}
# the only reason this blob is still here is because i don't want to add network dependency for a boot-time script
raw_crossystem_sh() {
base64 -d <<-EOF | bunzip2 -dc
QlpoOTFBWSZTWRXa7LcAA5f/kH/+Zvh///h////frv////4AEGAL+t924LTV3srpcuYdUAAAAAGlAAEMSE0mCaADRNU/SR6j0yma
ah6j1Hkh4o09RoD9UA0PU3qj9Ub1MoGpkyCYhDTRQaeoA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S5Wzp1VpVjQSHZIAVSCFYTJiqQSGMwkJpgcSpYpgT
oQmVIZfSexkCL8rr1S3SBDBQ0RoRbQwV7CozQxC+1BkrlPcdbbeIRE0lIKk5yCzsKIkilM7CzFGpiGEiSNpnjiSV+wMAiZqI/6CP
MIsN1VpK0MmM9WntNXeys+Bu3CqtuDJeqQiEplmoz/231qK1H2GB69xrvXMwYBnANhkP1hdfWPruziGXSYr947gmhF5RSgbIPPRE
BwqdQZgDQEjajysTORCDBUB2wG412634AYpbilG77BrAvDIxNyaSO2L6DlLIlEUcxhNrSUBs7ec5pKw2iytXqbpgVA35dxkBP7WU
bzVPfi2mxFTkn/F3JFOFCQFdrstw
EOF
}
drop_crossystem_sh() {
# this weird space replacement is used because "read" has odd behaviour with spaces and newlines
# i don't need to worry about the jank because crossystem will never have user controlled data
vals=$(sed "s/ /THIS_IS_A_SPACE_DUMBASS/g" <<<"$(crossystem_values)")
raw_crossystem_sh | sed -e "s/#__SED_REPLACEME_CROSSYSTEM_VALUES#/$(sed_escape "$vals")/g" | sed -e "s/THIS_IS_A_SPACE_DUMBASS/ /g" >"$ROOT/usr/bin/crossystem"
chmod 777 "$ROOT/usr/bin/crossystem"
}
escape() {
case $1 in
'' | *[!0-9]*) echo -n "\"$1\"" ;;
*) echo -n "$1" ;;
esac
}
crossystem_values() {
readarray -t csys_lines <<<"$(csys)"
for element in "${csys_lines[@]}"; do
line_stripped=$(echo "$element" | sed -e "s/#.*//g" | sed -e 's/ .*=/=/g')
# sed 1: cuts out all chars after the #
# sed 2: cuts out all spaces before =
IFS='=' read -r -a pair <<<"$line_stripped"
key=${pair[0]}
# cut out all characters after an instance of 2 spaces in a row
val="$(echo ${pair[1]} | sed -e 's/ .*//g')"
if [ "$key" == "devsw_cur" ]; then
val=0
fi
if [ "$key" == "devsw_boot" ]; then
val=0
fi
if [ "$key" == "mainfw_type" ]; then
val="normal"
fi
if [ "$key" == "mainfw_act" ]; then
val="A"
fi
if [ "$key" == "cros_debug" ]; then
val=1
fi
if [ "$key" == "dev_boot_legacy" ]; then
val=0
fi
if [ "$key" == "dev_boot_signed_only" ]; then
val=0
fi
if [ "$key" == "dev_boot_usb" ]; then
val=0
fi
if [ "$key" == "dev_default_boot" ]; then
val="disk"
fi
if [ "$key" == "dev_enable_udc" ]; then
val=0
fi
if [ "$key" == "alt_os_enabled" ]; then
val=0
fi
if [ "$key" == "recoverysw_boot" ]; then
val=0
fi
if [ "$key" == "recoverysw_cur" ]; then
val=0
fi
echo "$key=$(escape "$val")"
done
}
mv "$ROOT/usr/bin/crossystem" "$ROOT/usr/bin/crossystem.old"
drop_crossystem_sh