Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 198eaa6

Browse files
Fixed Catalina support, added Big Sur Beta support, reworked installer app downloads
-Fixed Catalina support -Added Big Sur support -Added SIP detection -Reworked Installer app download window -The app will now start with a password prompt, either graphical or via terminal -Added diagnostics mode with administrator privileges -Password prompt is no longer mandatory for the diagnostics mode -Improovements to the installer app detection system and added support to BIg Sur -Imoprooved drive detection system -Added root users detection and optimizations (when the app is running as root there will be some optimizations to the way scripts are handled) -various code optimization and improovements -Commenetd the bootfiles replacement code which will be remooved in the future -The readme which is created on installer drives has been rewritten
1 parent 08e8c9e commit 198eaa6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+863
-918
lines changed

TINU.xcodeproj/project.pbxproj

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
C6B74D0C20BA2A79001CAD4D /* EFIPartitionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6B74D0B20BA2A79001CAD4D /* EFIPartitionManager.swift */; };
6666
C6C1820D1FE7605300617DC2 /* ChooseSideViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6C1820C1FE7605300617DC2 /* ChooseSideViewController.swift */; };
6767
C6C2EAA72030710A0033EF85 /* SettingsSectionItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6C2EAA62030710A0033EF85 /* SettingsSectionItem.swift */; };
68+
C6C8A8B1249E9C8A009C3D6E /* SIPManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6C8A8B0249E9C8A009C3D6E /* SIPManager.swift */; };
69+
C6C8A8B3249EB2C2009C3D6E /* DebugScriptSudo.sh in Resources */ = {isa = PBXBuildFile; fileRef = C6C8A8B2249EB2C2009C3D6E /* DebugScriptSudo.sh */; };
6870
C6CB670A217756BE00746A84 /* CreateMediaWithAuth.sh in Resources */ = {isa = PBXBuildFile; fileRef = C6CB6709217756B300746A84 /* CreateMediaWithAuth.sh */; };
6971
C6D82A6A20D802E700A5B5BE /* OtherOptionsObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6D82A6920D802E700A5B5BE /* OtherOptionsObject.swift */; };
7072
C6D82A6C20D80C7600A5B5BE /* OtherOptionsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6D82A6B20D80C7600A5B5BE /* OtherOptionsManager.swift */; };
@@ -167,10 +169,13 @@
167169
C6B74D0B20BA2A79001CAD4D /* EFIPartitionManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EFIPartitionManager.swift; sourceTree = "<group>"; };
168170
C6C1820C1FE7605300617DC2 /* ChooseSideViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseSideViewController.swift; sourceTree = "<group>"; };
169171
C6C2EAA62030710A0033EF85 /* SettingsSectionItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsSectionItem.swift; sourceTree = "<group>"; };
172+
C6C8A8B0249E9C8A009C3D6E /* SIPManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SIPManager.swift; sourceTree = "<group>"; };
173+
C6C8A8B2249EB2C2009C3D6E /* DebugScriptSudo.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = DebugScriptSudo.sh; sourceTree = "<group>"; };
170174
C6CB6709217756B300746A84 /* CreateMediaWithAuth.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = CreateMediaWithAuth.sh; sourceTree = "<group>"; };
171175
C6D82A6920D802E700A5B5BE /* OtherOptionsObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtherOptionsObject.swift; sourceTree = "<group>"; };
172176
C6D82A6B20D80C7600A5B5BE /* OtherOptionsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtherOptionsManager.swift; sourceTree = "<group>"; };
173177
C6D9EE58210AED4700019818 /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
178+
C6DE523A247EB6EA00FBD2E1 /* TINU.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TINU.entitlements; sourceTree = "<group>"; };
174179
C6DF04621F4F33C500D200B1 /* TINU.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TINU.app; sourceTree = BUILT_PRODUCTS_DIR; };
175180
C6DF04651F4F33C500D200B1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
176181
C6DF046C1F4F33C500D200B1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -243,8 +248,9 @@
243248
C60C40B720CC9E4800258574 /* IconsManager.swift */,
244249
C60C40C320CCACB600258574 /* PlistXMLManager.swift */,
245250
C6D9EE58210AED4700019818 /* Reachability.swift */,
246-
C6F68E8A20D0277B00F7A0F4 /* SmallManagers.swift */,
247251
C65B5EFE1F72099F0061F1A3 /* ScriptsManager.swift */,
252+
C6C8A8B0249E9C8A009C3D6E /* SIPManager.swift */,
253+
C6F68E8A20D0277B00F7A0F4 /* SmallManagers.swift */,
248254
C65B5F021F720D680061F1A3 /* SudoManager.swift */,
249255
C63DD0272265D921007944A5 /* TaskKillManager.swift */,
250256
C60C40B920CCA24000258574 /* TextsManager.swift */,
@@ -335,6 +341,7 @@
335341
children = (
336342
C6553A921F5F83770048965D /* License.rtf */,
337343
C65B5EFB1F71FAB10061F1A3 /* DebugScript.sh */,
344+
C6C8A8B2249EB2C2009C3D6E /* DebugScriptSudo.sh */,
338345
C6CB6709217756B300746A84 /* CreateMediaWithAuth.sh */,
339346
);
340347
name = Resources;
@@ -372,6 +379,7 @@
372379
C6DF04641F4F33C500D200B1 /* TINU */ = {
373380
isa = PBXGroup;
374381
children = (
382+
C6DE523A247EB6EA00FBD2E1 /* TINU.entitlements */,
375383
C6DF046E1F4F33C500D200B1 /* Info.plist */,
376384
C691BFED1F6DEEA800589EF8 /* Assets.xcassets */,
377385
C6DF046B1F4F33C500D200B1 /* Main.storyboard */,
@@ -513,6 +521,20 @@
513521
DevelopmentTeam = 9RSH5734GY;
514522
LastSwiftMigration = 0900;
515523
ProvisioningStyle = Manual;
524+
SystemCapabilities = {
525+
com.apple.ApplicationGroups.Mac = {
526+
enabled = 0;
527+
};
528+
com.apple.HardenedRuntime = {
529+
enabled = 1;
530+
};
531+
com.apple.Keychain = {
532+
enabled = 0;
533+
};
534+
com.apple.Sandbox = {
535+
enabled = 0;
536+
};
537+
};
516538
};
517539
C6DF04721F4F33C500D200B1 = {
518540
CreatedOnToolsVersion = 8.3.1;
@@ -558,6 +580,7 @@
558580
C65B5EFD1F7201D10061F1A3 /* DebugScript.sh in Resources */,
559581
C647B3AF211D18950024B9A1 /* EFIPartitionMounterTool.storyboard in Resources */,
560582
C6DF046D1F4F33C500D200B1 /* Main.storyboard in Resources */,
583+
C6C8A8B3249EB2C2009C3D6E /* DebugScriptSudo.sh in Resources */,
561584
C691BFEE1F6DEEA800589EF8 /* Assets.xcassets in Resources */,
562585
C6553A931F5F83770048965D /* License.rtf in Resources */,
563586
C6CB670A217756BE00746A84 /* CreateMediaWithAuth.sh in Resources */,
@@ -692,6 +715,7 @@
692715
C615B817216B0B8900913BFF /* MediaCreationManagerErrorChecking.swift in Sources */,
693716
C64E563B1F522854007B8CEE /* InstallingViewController.swift in Sources */,
694717
C61A3654205DA3F400350BE9 /* DownloadAppViewController.swift in Sources */,
718+
C6C8A8B1249E9C8A009C3D6E /* SIPManager.swift in Sources */,
695719
C65AA6241F4F4C3400C43223 /* ChoseDriveViewController.swift in Sources */,
696720
DD01EBEF1F71BD2A00C94D9B /* LogManager.swift in Sources */,
697721
C66411052077A80100454292 /* OtherWindowsControllers.swift in Sources */,
@@ -868,12 +892,14 @@
868892
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
869893
ASSETCATALOG_COMPILER_OPTIMIZATION = space;
870894
CLANG_ENABLE_MODULES = YES;
895+
CODE_SIGN_ENTITLEMENTS = TINU/TINU.entitlements;
871896
CODE_SIGN_IDENTITY = "Developer ID Application";
872897
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES;
873898
CODE_SIGN_STYLE = Manual;
874899
COMBINE_HIDPI_IMAGES = YES;
875900
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
876901
DEVELOPMENT_TEAM = 9RSH5734GY;
902+
ENABLE_HARDENED_RUNTIME = YES;
877903
GCC_OPTIMIZATION_LEVEL = s;
878904
INFOPLIST_FILE = TINU/Info.plist;
879905
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
@@ -883,7 +909,7 @@
883909
PRODUCT_NAME = "$(TARGET_NAME)";
884910
PROVISIONING_PROFILE = "";
885911
PROVISIONING_PROFILE_SPECIFIER = "";
886-
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG useEFIReplacement skipChooseCustomization TINU";
912+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG useEFIReplacement skipChooseCustomization TINU sudoStartup";
887913
SWIFT_COMPILATION_MODE = wholemodule;
888914
SWIFT_ENFORCE_EXCLUSIVE_ACCESS = on;
889915
SWIFT_OBJC_BRIDGING_HEADER = "";
@@ -899,11 +925,13 @@
899925
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
900926
ASSETCATALOG_COMPILER_OPTIMIZATION = space;
901927
CLANG_ENABLE_MODULES = YES;
928+
CODE_SIGN_ENTITLEMENTS = TINU/TINU.entitlements;
902929
CODE_SIGN_IDENTITY = "Developer ID Application";
903930
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES;
904931
CODE_SIGN_STYLE = Manual;
905932
COMBINE_HIDPI_IMAGES = YES;
906933
DEVELOPMENT_TEAM = 9RSH5734GY;
934+
ENABLE_HARDENED_RUNTIME = YES;
907935
ENABLE_TESTABILITY = YES;
908936
GCC_OPTIMIZATION_LEVEL = s;
909937
INFOPLIST_FILE = TINU/Info.plist;
@@ -914,7 +942,7 @@
914942
PRODUCT_NAME = "$(TARGET_NAME)";
915943
PROVISIONING_PROFILE = "";
916944
PROVISIONING_PROFILE_SPECIFIER = "";
917-
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "useEFIReplacement skipChooseCustomization TINU";
945+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "useEFIReplacement skipChooseCustomization TINU sudoStartup";
918946
SWIFT_COMPILATION_MODE = wholemodule;
919947
SWIFT_ENFORCE_EXCLUSIVE_ACCESS = on;
920948
SWIFT_OBJC_BRIDGING_HEADER = "";

TINU/AppDelegate.swift

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import Cocoa
1010

1111
@NSApplicationMain
1212
class AppDelegate: NSObject, NSApplicationDelegate {
13-
@IBOutlet weak var verboseItem: NSMenuItem!
13+
@IBOutlet weak var verboseItemSudo: NSMenuItem!
14+
@IBOutlet weak var verboseItem: NSMenuItem!
1415
//@IBOutlet weak var vibrantButton: NSMenuItem!
1516
@IBOutlet weak var tinuRelated: NSMenuItem!
1617
@IBOutlet weak var otherApps: NSMenuItem!
@@ -30,6 +31,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
3031
@IBOutlet weak var toolsMenuItem: NSMenuItem!
3132
@IBOutlet weak var efiMounterMenuItem: NSMenuItem!
3233

34+
func getVerboseItem(isSudo: Bool) -> NSMenuItem!{
35+
if isSudo{
36+
return verboseItemSudo
37+
}else{
38+
return verboseItem
39+
}
40+
}
41+
3342
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
3443
return true
3544
}
@@ -72,6 +81,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
7281
tinuRelated .isEnabled = !sharedIsOnRecovery
7382
otherApps .isEnabled = !sharedIsOnRecovery
7483
verboseItem .isEnabled = !sharedIsOnRecovery
84+
verboseItemSudo .isEnabled = !sharedIsOnRecovery
7585
FAQItem .isEnabled = !sharedIsOnRecovery
7686
getMacOSApp .isEnabled = !sharedIsOnRecovery
7787
wMSDIND .isEnabled = !sharedIsOnRecovery
@@ -98,6 +108,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
98108
sharedShowLicense = true
99109
print("License agreement file found")
100110
}
111+
112+
#if demo
113+
demoMacroEnabled = true
114+
#endif
101115

102116
}
103117

@@ -259,65 +273,56 @@ class AppDelegate: NSObject, NSApplicationDelegate {
259273

260274
@IBAction func openVerbose(_ sender: Any) {
261275
if !(CreateinstallmediaSmallManager.shared.sharedIsCreationInProgress || CreateinstallmediaSmallManager.shared.sharedIsPreCreationInProgress || sharedIsOnRecovery){
262-
/*
263-
if let b = Bundle.main.resourcePath{
264-
let f = b + "/DebugScript.sh"
265-
if FileManager.default.fileExists(atPath: f){
266-
print("Trying to fix script permitions")
267-
if let e = getOutWithSudo(cmd: "chmod -R 771 \"" + f + "\""){
268-
if e == "" || e == "Password:\n" || e == "Password:" {
269-
print("Script permitions fixed with success")
270-
print("Restarting app with log in the terminal")
271-
NSWorkspace.shared().openFile(f, withApplication: "Terminal")
272-
NSApplication.shared().terminate(self)
273-
}else{
274-
print("Script permitions fix failed")
275-
print("Application not opened: " + e)
276-
}
277-
}else{
278-
print("Script permitions not fixed, switch to diagnostics mode aborted")
279-
msgBox("Impossible to switch mode!", "The needed script to run TINU in diagnostics mode is not usable, try to downlaod again the app", .warning)
280-
}
281-
}else{
282-
283-
if !dialogYesNoWarning(question: "Diagnostics mode script missing", text: "The needed script to run TINU in diagnoistics mode is missing, do you want to create a new one?", style: .warning){
284-
do {
285-
try verboseScript.write(toFile: f, atomically: true, encoding: .utf8)
286-
return openVerbose(_: sender)
287-
}catch{
288-
msgBox("Impossible to switch mode!", "The needed script to run TINU in diagnostics mode can't be written, try to downlaod again the app", .warning)
289-
}
290-
}
291-
292-
/*
293-
verboseItem.isEnabled = false
294-
msgBox("Impossible to switch mode!", "The needed script to run TINU in diagnostics mode is missing, try to downlaod again the app", .warning)
295-
*/
296-
}
297-
}*/
298276

299277
print("trying to use diagnostics mode")
300-
if let scriptPath = Bundle.main.url(forResource: "DebugScript", withExtension: "sh") {
301-
let theScript = "do shell script \"chmod -R 771 \'" + scriptPath.path + "\'\" with administrator privileges"
278+
279+
let isSudo = (sender as? NSMenuItem) == verboseItemSudo
280+
281+
let resourceName = isSudo ? "DebugScriptSudo" : "DebugScript"
282+
283+
if let scriptPath = Bundle.main.url(forResource: resourceName, withExtension: "sh")?.path {
302284

303-
print(theScript)
285+
var val: Int16 = 1;
304286

305-
let appleScript = NSAppleScript(source: theScript)
287+
do{
288+
if let perm = (try FileManager.default.attributesOfItem(atPath: scriptPath)[FileAttributeKey.posixPermissions] as? NSNumber)?.int16Value{
289+
val = perm
290+
}
291+
292+
}catch let err{
293+
print(err)
294+
}
306295

307-
if let eventResult = appleScript?.executeAndReturnError(nil){
308-
if let result = eventResult.stringValue{
309-
if result.isEmpty || result == "\n" || result == "Password:"{
310-
NSWorkspace.shared().openFile(scriptPath.path, withApplication: "Terminal")
311-
NSApplication.shared().terminate(self)
312-
}else{
313-
print("error with the script output: " + result)
314-
msgBoxWarning("Impossible to use diagnostics mode", "Something went wrong when preparing TINU to be run in diagnostics mode.\n\n[error code: 0]\n\nScript output: \(result)")
296+
if val != 0o771{
297+
298+
let theScript = "do shell script \"chmod -R 771 \'" + scriptPath + "\'\" with administrator privileges"
299+
300+
print(theScript)
301+
302+
let appleScript = NSAppleScript(source: theScript)
303+
304+
if let eventResult = appleScript?.executeAndReturnError(nil){
305+
if let result = eventResult.stringValue{
306+
if result.isEmpty || result == "\n" || result == "Password:"{
307+
val = 0;
308+
}else{
309+
print("error with the script output: " + result)
310+
msgBoxWarning("Impossible to use diagnostics mode", "Something went wrong when preparing TINU to be run in diagnostics mode.\n\n[error code: 0]\n\nScript output: \(result)")
311+
}
315312
}
313+
}else{
314+
print("impossible to execute the apple script to prepare the app")
315+
316+
msgBoxWarning("Impossible to use diagnostics mode", "Impossible to prepare TINU to run in diagnostics mode.\n\n[error code: 1]")
316317
}
317-
}else{
318-
print("impossible to execute the apple script to prepare the app")
319318

320-
msgBoxWarning("Impossible to use diagnostics mode", "Impossible to prepare TINU to run in diagnostics mode.\n\n[error code: 1]")
319+
}else{
320+
val = 0
321+
}
322+
323+
if val == 0{
324+
NSWorkspace.shared().openFile(scriptPath, withApplication: "Terminal")
325+
NSApplication.shared().terminate(self)
321326
}
322327
}else{
323328
print("no debug file found!")

TINU/AppManager.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ public func checkAppMode(){
6868

6969
//checks if teh app is running in a normal user level environment or in a root user inside the mac os recovery or installer, so it's sufficient to call it only once during the startup of the app
7070
public func checkUser(){
71-
let u = NSUserName()
7271
if sharedIsReallyOnRecovery{
7372
print("Running on the root user on a mac os recovery")
7473
sharedIsOnRecovery = true
7574
}else{
7675
sharedIsOnRecovery = false
77-
print("Running on this user: " + u)
76+
print("Running on this user: " + NSUserName())
7877

7978
if simulateRecovery{
8079
print("Recovery mode simulation activated")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "Yosemite.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"filename" : "Yosemite-1.png",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "universal",
15+
"filename" : "Yosemite-2.png",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}
Loading
Loading
Loading

0 commit comments

Comments
 (0)