File tree 1 file changed +25
-8
lines changed
1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -86,23 +86,40 @@ setup_flashable() {
86
86
}
87
87
88
88
ensure_bb () {
89
- [ -o standalone ] && return
90
- set -o standalone 2> /dev/null && return
89
+ if set -o | grep -q standalone; then
90
+ # We are definitely in busybox ash
91
+ set -o standalone
92
+ return
93
+ fi
91
94
92
- # At this point, we are not running in BusyBox ash
93
95
# Find our busybox binary
94
- local BUSYBOX
96
+ local bb
95
97
if [ -f $TMPDIR /busybox ]; then
96
- BUSYBOX =$TMPDIR /busybox
98
+ bb =$TMPDIR /busybox
97
99
elif [ -f $MAGISKBIN /busybox ]; then
98
- BUSYBOX =$MAGISKBIN /busybox
100
+ bb =$MAGISKBIN /busybox
99
101
else
100
102
abort " ! Cannot find BusyBox"
101
103
fi
104
+ chmod 755 $bb
105
+
106
+ # Find our current arguments
107
+ # Run in busybox environment to ensure consistent results
108
+ # /proc/<pid>/cmdline shall be <interpreter> <script> <arguments...>
109
+ local cmds=$( $bb sh -o standalone -c "
110
+ tr '\0' '\n' < /proc/$$ /cmdline | (while read -r arg; do
111
+ if [ -z \"\$ cmds\" ]; then
112
+ # Skip the first argument as we want to change the interpreter
113
+ cmds=\" sh -o standalone\"
114
+ else
115
+ cmds=\"\$ cmds '\$ arg'\"
116
+ fi
117
+ done
118
+ echo \$ cmds)" )
102
119
103
120
# Re-exec our script
104
- chmod 755 $BUSYBOX
105
- exec $BUSYBOX sh -o standalone $0 " $@ "
121
+ echo $cmds | $bb xargs $bb
122
+ exit
106
123
}
107
124
108
125
recovery_actions () {
You can’t perform that action at this time.
0 commit comments