Skip to content

Commit aeded84

Browse files
committed
main: Put the new stub in Reduced Security mode before reboot
This avoids the Apple call-home step and lets us work with firmwares Apple no longer signs. Signed-off-by: Hector Martin <[email protected]>
1 parent 1f542db commit aeded84

1 file changed

Lines changed: 33 additions & 12 deletions

File tree

src/main.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,35 @@ def choose_ipsw(self):
182182

183183
return ipsw
184184

185+
def set_reduced_security(self):
186+
print( "We are about to prepare your new stub OS for booting in")
187+
print( "Reduced Security mode. Please enter your macOS credentials")
188+
print( "when prompted.")
189+
print()
190+
print( "Press enter to continue.")
191+
input()
192+
193+
while True:
194+
try:
195+
subprocess.run(["bputil", "-g", "-v", self.ins.osi.vgid], check=True)
196+
break
197+
except subprocess.CalledProcessError:
198+
print("Failed to run bputil. Press enter to try again.")
199+
input()
200+
201+
print()
202+
185203
def step2(self):
186204
is_1tr = self.sysinfo.boot_mode == "one true recoveryOS"
187205
is_recovery = "recoveryOS" in self.sysinfo.boot_mode
188206
bootpicker_works = split_ver(self.sysinfo.macos_ver) >= split_ver(self.ipsw.min_macos)
189207

190208
if is_1tr and self.is_sfr_recovery and self.ipsw.paired_sfr:
191-
self.startup_disk(recovery=True)
192209
subprocess.run([self.ins.step2_sh], check=True)
210+
self.startup_disk(recovery=True, volume_blessed=True, reboot=True)
193211
elif is_recovery:
194-
self.startup_disk(recovery=True)
212+
self.set_reduced_security()
213+
self.startup_disk(recovery=True, volume_blessed=True)
195214
self.step2_indirect()
196215
elif bootpicker_works:
197216
self.startup_disk()
@@ -262,9 +281,10 @@ def step2_old_macos(self):
262281
print(f"/Volumes/{shlex.quote(self.part.label)}/step2.sh")
263282
print()
264283

265-
def startup_disk(self, recovery=False):
284+
def startup_disk(self, recovery=False, volume_blessed=False, reboot=False):
266285
print(f"When the Startup Disk screen appears, choose '{self.part.label}', then click Restart.")
267-
print( "You will have to authenticate yourself.")
286+
if not volume_blessed:
287+
print( "You will have to authenticate yourself.")
268288
print()
269289
print( "Press enter to continue.")
270290
input()
@@ -288,16 +308,17 @@ def startup_disk(self, recovery=False):
288308
cur_vol = self.sysinfo.default_boot
289309

290310
# This race is tight... I hate this.
291-
while self.sysinfo.default_boot == cur_vol:
292-
self.sysinfo.get_nvram_data()
311+
if not reboot:
312+
while self.sysinfo.default_boot == cur_vol:
313+
self.sysinfo.get_nvram_data()
293314

294-
if recovery:
295-
sd.kill()
296-
else:
297-
os.system("killall -9 StartupDiskPrefPaneService 'System Preferences' 2>/dev/null")
298-
sd.wait()
315+
if recovery:
316+
sd.kill()
317+
else:
318+
os.system("killall -9 StartupDiskPrefPaneService 'System Preferences' 2>/dev/null")
319+
sd.wait()
299320

300-
print()
321+
print()
301322

302323
def main(self):
303324
print()

0 commit comments

Comments
 (0)