From 068a3be616df91a033c7bad0a00b57a15eb98682 Mon Sep 17 00:00:00 2001 From: Kabir Oberai Date: Wed, 14 May 2025 12:02:12 +0530 Subject: [PATCH] Fix ADI permissions --- Sources/XKit/GrandSlam/Anisette/XADIProvider.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/XKit/GrandSlam/Anisette/XADIProvider.swift b/Sources/XKit/GrandSlam/Anisette/XADIProvider.swift index faef03e7..107c83fc 100644 --- a/Sources/XKit/GrandSlam/Anisette/XADIProvider.swift +++ b/Sources/XKit/GrandSlam/Anisette/XADIProvider.swift @@ -129,6 +129,15 @@ public actor XADIProvider: RawADIProvider { } }) let file = adiDirectory.appending(path: "adi.pb") + // adi saves the file as 0o034 (group wx, public r) by default + // which is a... strange choice that prevents us from reading + // or writing by default. Since we're the owner, we can easily + // change this though. + try FileManager.default.setAttributes( + // rw for owner + [.posixPermissions: 0o600], + ofItemAtPath: file.path + ) return try Data(contentsOf: file) } } @@ -148,9 +157,6 @@ public actor XADIProvider: RawADIProvider { let adiDirectory = directory.appending(path: "adi") try? FileManager.default.createDirectory(at: adiDirectory, withIntermediateDirectories: true) let adiFile = adiDirectory.appending(path: "adi.pb") - // this file may be saved as write-protected, but we can still remove it - // and then overwrite it. - try? FileManager.default.removeItem(at: adiFile) try provisioningInfo.write(to: adiFile) try check(xadi_OTPRequest(