@@ -440,8 +440,24 @@ class Injector: ObservableObject {
440
440
let entitlementDownloadURL = injectConfiguration. generateInjectToolDownloadURL ( name: entitlements)
441
441
let downloadIntoTmpPath = try ? FileManager . default. url ( for: . itemReplacementDirectory, in: . userDomainMask, appropriateFor: URL ( fileURLWithPath: " / " ) , create: true )
442
442
let entitlementsPath = downloadIntoTmpPath? . appendingPathComponent ( entitlements) . path
443
- let downloadCommand = " curl -L -o \( entitlementsPath!) \( entitlementDownloadURL!) "
444
- shells. append ( ( downloadCommand, false ) )
443
+ // let downloadCommand = "curl -L -o \(entitlementsPath!) \(entitlementDownloadURL!)"
444
+
445
+ let semaphore = DispatchSemaphore ( value: 0 )
446
+
447
+ let task = URLSession . shared. downloadTask ( with: entitlementDownloadURL!) { ( location, response, error) in
448
+ if let location = location {
449
+ try ? FileManager . default. moveItem ( at: location, to: URL ( fileURLWithPath: entitlementsPath!) )
450
+ print ( " [*] Download Entitlements Success: \( entitlementDownloadURL!) " )
451
+ } else {
452
+ print ( " [*] Download Entitlements Failed: \( entitlementDownloadURL!) " )
453
+ shells. append ( ( " echo Download Entitlements Failed: \( entitlementDownloadURL!) && exit 1 " , false ) )
454
+ }
455
+ semaphore. signal ( )
456
+ }
457
+
458
+ task. resume ( )
459
+ semaphore. wait ( )
460
+
445
461
sign_prefix_with_deep += " --entitlements \( entitlementsPath!) "
446
462
}
447
463
@@ -486,7 +502,24 @@ class Injector: ObservableObject {
486
502
try ? FileManager . default. createDirectory ( at: extraShellDir, withIntermediateDirectories: true , attributes: nil )
487
503
}
488
504
let downloadPath = downloadIntoTmpPath. appendingPathComponent ( extraShell) . path
489
- let downloadCommand = " curl -L -o \( downloadPath) \( getToolDownloadURL) "
505
+ // let downloadCommand = "curl -L -o \(downloadPath) \(getToolDownloadURL)"
506
+ // 创建信号量,等待下载完成
507
+
508
+ let semaphore = DispatchSemaphore ( value: 0 )
509
+
510
+ let task = URLSession . shared. downloadTask ( with: getToolDownloadURL) { ( location, response, error) in
511
+ if let location = location {
512
+ try ? FileManager . default. moveItem ( at: location, to: URL ( fileURLWithPath: downloadPath) )
513
+ print ( " [*] Download Extra Shell Success: \( getToolDownloadURL) " )
514
+ } else {
515
+ print ( " [*] Download Extra Shell Failed: \( getToolDownloadURL) " )
516
+ shells. append ( ( " echo Download Extra Shell Failed: \( getToolDownloadURL) && exit 1 " , false ) )
517
+ }
518
+ semaphore. signal ( )
519
+ }
520
+
521
+ task. resume ( )
522
+ semaphore. wait ( )
490
523
491
524
let dest = self . genSourcePath ( for: . bash)
492
525
@@ -519,8 +552,9 @@ class Injector: ObservableObject {
519
552
" sed -i '' 's| \( from) | \" \( to) \" |g' \( downloadPath) "
520
553
}
521
554
522
- shells. append ( ( downloadCommand, false ) )
523
- shells. append ( ( " chmod +x \( downloadPath) " , false ) )
555
+ // shells.append((downloadCommand, false))
556
+ shells. append ( ( " sudo chmod -R 777 \( downloadPath) " , true ) )
557
+ shells. append ( ( " chmod +x \( downloadPath) " , true ) )
524
558
if !replaceCommands. isEmpty {
525
559
shells. append ( contentsOf: replaceCommands. map { ( $0, false ) } )
526
560
}
0 commit comments