Skip to content

Commit 07984ac

Browse files
committed
v2.1
1 parent 24bd354 commit 07984ac

7 files changed

Lines changed: 34 additions & 30 deletions

File tree

Sentinel.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
343343
CODE_SIGN_STYLE = Manual;
344344
COMBINE_HIDPI_IMAGES = YES;
345-
CURRENT_PROJECT_VERSION = 11;
345+
CURRENT_PROJECT_VERSION = 12;
346346
DEAD_CODE_STRIPPING = YES;
347347
DEVELOPMENT_ASSET_PATHS = "";
348348
DEVELOPMENT_TEAM = "";
@@ -358,7 +358,7 @@
358358
"@executable_path/../Frameworks",
359359
);
360360
MACOSX_DEPLOYMENT_TARGET = 12.0;
361-
MARKETING_VERSION = 2.0;
361+
MARKETING_VERSION = 2.1;
362362
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Sentinel;
363363
PRODUCT_NAME = "$(TARGET_NAME)";
364364
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -378,7 +378,7 @@
378378
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
379379
CODE_SIGN_STYLE = Manual;
380380
COMBINE_HIDPI_IMAGES = YES;
381-
CURRENT_PROJECT_VERSION = 11;
381+
CURRENT_PROJECT_VERSION = 12;
382382
DEAD_CODE_STRIPPING = YES;
383383
DEVELOPMENT_ASSET_PATHS = "";
384384
DEVELOPMENT_TEAM = "";
@@ -394,7 +394,7 @@
394394
"@executable_path/../Frameworks",
395395
);
396396
MACOSX_DEPLOYMENT_TARGET = 12.0;
397-
MARKETING_VERSION = 2.0;
397+
MARKETING_VERSION = 2.1;
398398
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Sentinel;
399399
PRODUCT_NAME = "$(TARGET_NAME)";
400400
PROVISIONING_PROFILE_SPECIFIER = "";

Sentinel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

Sentinel.xcodeproj/xcuserdata/alin.xcuserdatad/xcschemes/Sentinel - No GH.xcscheme

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@
4949
ReferencedContainer = "container:Sentinel.xcodeproj">
5050
</BuildableReference>
5151
</BuildableProductRunnable>
52-
<EnvironmentVariables>
53-
<EnvironmentVariable
54-
key = "OS_ACTIVITY_MODE"
55-
value = "disable"
56-
isEnabled = "YES">
57-
</EnvironmentVariable>
58-
</EnvironmentVariables>
5952
</LaunchAction>
6053
<ProfileAction
6154
buildConfiguration = "Release"

Sentinel/About Window/AboutCommand.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import SwiftUI
22
import AlinFoundation
33

44
struct AboutCommand: Commands {
5+
@State private var windowController = WindowManager()
56
let appState: AppState
67
let updater: Updater
78
init(appState: AppState, updater: Updater) {
@@ -25,6 +26,13 @@ struct AboutCommand: Commands {
2526
}
2627
.keyboardShortcut("u", modifiers: .command)
2728

29+
Button {
30+
windowController.open(with: ConsoleView(), width: 600, height: 400)
31+
} label: {
32+
Text("Debug Console")
33+
}
34+
.keyboardShortcut("d", modifiers: .command)
35+
2836
}
2937
}
3038
}

Sentinel/Dashboard.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ struct DropQuarantine: DropDelegate {
211211
}
212212
Task
213213
{
214-
_ = await CmdRunDrop(cmd: "xattr -rd com.apple.quarantine \(url.path)", type: "quarantine", appState: appState)
214+
_ = await CmdRunDrop(cmd: "xattr -rd com.apple.quarantine", path: url.path, type: "quarantine", appState: appState)
215215
}
216216

217217
}
@@ -248,7 +248,7 @@ struct DropSign: DropDelegate {
248248
}
249249
Task
250250
{
251-
_ = await CmdRunDrop(cmd: "codesign -f -s - --deep \(url.path)", type: "sign", appState: appState)
251+
_ = await CmdRunDrop(cmd: "codesign -f -s - --deep", path: url.path, type: "sign", appState: appState)
252252
}
253253

254254
}

Sentinel/Utilities/Commands.swift

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ func getGatekeeperState(appState: AppState) {
9393
}
9494
}
9595

96-
func CmdRunDrop(cmd: String, type: String, sudo: Bool = false, appState: AppState) async {
96+
func CmdRunDrop(cmd: String, path: String, type: String, sudo: Bool = false, appState: AppState) async {
97+
let fullCMD = "\(cmd) '\(path)'"
9798
let source = """
98-
set the_script to "\(cmd)"
99+
set the_script to "\(fullCMD)"
99100
set the_result to do shell script the_script
100101
return the_result
101102
"""
102103
let sourceSudo = """
103-
set the_script to "\(cmd)"
104+
set the_script to "\(fullCMD)"
104105
set the_result to do shell script the_script with prompt "Sentinel requires elevated privileges" with administrator privileges
105106
return the_result
106107
"""
@@ -111,7 +112,7 @@ func CmdRunDrop(cmd: String, type: String, sudo: Bool = false, appState: AppStat
111112
switch type {
112113
case "quarantine":
113114
// Check if the quarantine attribute is removed
114-
let removed = await checkQuarantineRemoved(cmd: cmd)
115+
let removed = await checkQuarantineRemoved(path: path)
115116
if removed {
116117
updateOnMain {
117118
appState.status = "App has been removed from quarantine"
@@ -121,7 +122,7 @@ func CmdRunDrop(cmd: String, type: String, sudo: Bool = false, appState: AppStat
121122
updateOnMain {
122123
appState.status = "Retrying with elevated privileges"
123124
}
124-
_ = await CmdRunDrop(cmd: cmd, type: "quarantine", sudo: true, appState: appState)
125+
_ = await CmdRunDrop(cmd: cmd, path: path, type: "quarantine", sudo: true, appState: appState)
125126
} else {
126127
printOS(out.standardError)
127128
updateOnMain {
@@ -131,7 +132,8 @@ func CmdRunDrop(cmd: String, type: String, sudo: Bool = false, appState: AppStat
131132

132133
case "sign":
133134
// Check if the app was self-signed successfully
134-
let signed = await checkAppSigned(cmd: cmd)
135+
let signed = await checkAppSigned(path: path)
136+
135137
if signed {
136138
updateOnMain {
137139
appState.status = "App has been successfully self-signed"
@@ -141,7 +143,7 @@ func CmdRunDrop(cmd: String, type: String, sudo: Bool = false, appState: AppStat
141143
updateOnMain {
142144
appState.status = "Retrying with elevated privileges"
143145
}
144-
_ = await CmdRunDrop(cmd: cmd, type: "sign", sudo: true, appState: appState)
146+
_ = await CmdRunDrop(cmd: cmd, path: path, type: "sign", sudo: true, appState: appState)
145147
} else {
146148
printOS(out.standardError)
147149
updateOnMain {
@@ -159,9 +161,9 @@ func CmdRunDrop(cmd: String, type: String, sudo: Bool = false, appState: AppStat
159161
}
160162

161163

162-
func checkQuarantineRemoved(cmd: String) async -> Bool {
164+
func checkQuarantineRemoved(path: String) async -> Bool {
163165
// Adjust command to check for quarantine attribute, e.g., `xattr`
164-
let checkCmd = "xattr -p com.apple.quarantine \(cmd)"
166+
let checkCmd = "xattr -p com.apple.quarantine '\(path)'"
165167
let source = """
166168
set the_script to "\(checkCmd)"
167169
set the_result to do shell script the_script
@@ -171,10 +173,11 @@ func checkQuarantineRemoved(cmd: String) async -> Bool {
171173
return !out.standardOutput.contains("com.apple.quarantine")
172174
}
173175

174-
func checkAppSigned(cmd: String) async -> Bool {
176+
func checkAppSigned(path: String) async -> Bool {
175177
// Adjust the command to extract the path from the original command if necessary
176-
let path = extractPathFromCmd(cmd)
177-
let checkCmd = "codesign -v \(path)"
178+
// let path = extractPathFromCmd(cmd)
179+
print(path)
180+
let checkCmd = "codesign -v '\(path)'"
178181
let source = """
179182
set the_script to "\(checkCmd)"
180183
set the_result to do shell script the_script
@@ -184,10 +187,10 @@ func checkAppSigned(cmd: String) async -> Bool {
184187
return out.standardError.isEmpty // If there's no error, the app is correctly signed
185188
}
186189

187-
func extractPathFromCmd(_ cmd: String) -> String {
188-
// Extract the path from the provided command (assumes path is the last argument)
189-
return cmd.components(separatedBy: " ").last ?? ""
190-
}
190+
//func extractPathFromCmd(_ cmd: String) -> String {
191+
// // Extract the path from the provided command (assumes path is the last argument)
192+
// return cmd.components(separatedBy: " ").last ?? ""
193+
//}
191194

192195

193196
func runShellCommand(_ command: String) -> TerminalOutput {

0 commit comments

Comments
 (0)