When a Launchd job should not be cleaned up when managedsoftwareupdate exits, do not use a Munki-managed temp directory; use a temp direcotry created under /private/tmp

This commit is contained in:
Greg Neagle
2025-11-10 10:50:07 -08:00
parent 069e7e45da
commit 7ee04f1435

View File

@@ -110,9 +110,16 @@ class LaunchdJob {
// need to use a different tmpdir than the shared one,
// which will get cleaned up when managedsoftwareupdate
// exits
tmpdir = TempDir().path
tmpdir = "/private/tmp/munki-\(UUID().uuidString)"
if let tmpdir {
do {
try FileManager.default.createDirectory(atPath: tmpdir, withIntermediateDirectories: true)
} catch {
// will be dealt with later when we check for existence of the tmpdir
}
}
}
guard let tmpdir else {
guard let tmpdir, pathExists(tmpdir) else {
throw MunkiError("Could not allocate temp dir for launchd job")
}
// label this job