@@ -59,7 +59,7 @@ func getVersionGeneric(executablePath string, args ...string) (string, error) {
5959 logging .Debugf ("failed to run executable %s: %v" , executablePath , err )
6060 return "" , err
6161 }
62- parsedOutput := strings .Split (stdOut , ": " )
62+ parsedOutput := strings .Split (stdOut , " " )
6363 if len (parsedOutput ) < 2 {
6464 logging .Debugf ("failed to parse version information for %s: %s" , executablePath , stdOut )
6565 return "" , fmt .Errorf ("Unable to parse the version information of %s" , executablePath )
@@ -144,7 +144,45 @@ func (c *Cache) cacheExecutable() error {
144144 if err != nil {
145145 return err
146146 }
147+ if c .GetExecutableName () == constants .KrunkitCommand {
148+ err = signKrunkit (finalExecutablePath )
149+ if err != nil {
150+ return err
151+ }
152+ }
153+ }
154+ return nil
155+ }
156+
157+ func signKrunkit (executablePath string ) error {
158+ const krunkitEntitlements = `<?xml version="1.0" encoding="UTF-8"?>
159+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
160+ <plist version="1.0">
161+ <dict>
162+ <key>com.apple.security.cs.disable-library-validation</key>
163+ <true/>
164+ <key>com.apple.security.hypervisor</key>
165+ <true/>
166+ </dict>
167+ </plist>
168+ `
169+ tmpFile , err := os .CreateTemp ("" , "krunkit-entitlements-*.plist" )
170+ if err != nil {
171+ return fmt .Errorf ("failed to create temp entitlements file: %w" , err )
172+ }
173+ defer os .Remove (tmpFile .Name ())
174+
175+ if _ , err := tmpFile .WriteString (krunkitEntitlements ); err != nil {
176+ tmpFile .Close ()
177+ return fmt .Errorf ("failed to write entitlements: %w" , err )
178+ }
179+ tmpFile .Close ()
180+
181+ _ , _ , err = crcos .RunWithDefaultLocale ("codesign" , "-s" , "-" , "--entitlements" , tmpFile .Name (), "--force" , executablePath )
182+ if err != nil {
183+ return err
147184 }
185+ logging .Debugf ("Signed %s" , executablePath )
148186 return nil
149187}
150188
@@ -183,7 +221,7 @@ func (c *Cache) CheckVersion() error {
183221}
184222
185223func isTarball (filename string ) bool {
186- tarballExtensions := []string {".tar" , ".tar.gz" , ".tar.xz" , ".zip" , ".tar.bz2" , ".crcbundle" }
224+ tarballExtensions := []string {".tar" , ".tar.gz" , ".tar.xz" , ".zip" , ".tar.bz2" , ".crcbundle" , ".tgz" }
187225 for _ , extension := range tarballExtensions {
188226 if strings .HasSuffix (strings .ToLower (filename ), extension ) {
189227 return true
0 commit comments