@@ -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
193196func runShellCommand( _ command: String ) -> TerminalOutput {
0 commit comments