From 666374d17401aee8fefbfa99e64b3f2b08b9d012 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sun, 12 Nov 2023 11:30:49 -0800 Subject: [PATCH] Testing home directory --- Sources/SecretAgent/AppDelegate.swift | 13 +++++++++++-- Sources/SecretAgent/SecretAgent.entitlements | 2 ++ Sources/Secretive.xcodeproj/project.pbxproj | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Sources/SecretAgent/AppDelegate.swift b/Sources/SecretAgent/AppDelegate.swift index e21587f..387e44b 100644 --- a/Sources/SecretAgent/AppDelegate.swift +++ b/Sources/SecretAgent/AppDelegate.swift @@ -16,14 +16,23 @@ class AppDelegate: NSObject, NSApplicationDelegate { list.add(store: SmartCard.Store()) return list }() + private static var homeDirectory: String { +// if UserDefaults.standard.bool(forKey: "usehomedirectory") { + let folder = "/Users/max/.secretive" + try? FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: false) + return folder +// } else { +// return FileManager.default.homeDirectoryForCurrentUser.path +// } + } private let updater = Updater(checkOnLaunch: false) private let notifier = Notifier() - private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: NSHomeDirectory()) + private let publicKeyFileStoreController = PublicKeyFileStoreController(homeDirectory: homeDirectory) private lazy var agent: Agent = { Agent(storeList: storeList, witness: notifier) }() private lazy var socketController: SocketController = { - let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String + let path = (AppDelegate.homeDirectory as NSString).appendingPathComponent("socket.ssh") as String return SocketController(path: path) }() private var updateSink: AnyCancellable? diff --git a/Sources/SecretAgent/SecretAgent.entitlements b/Sources/SecretAgent/SecretAgent.entitlements index 895fc77..aed9f49 100644 --- a/Sources/SecretAgent/SecretAgent.entitlements +++ b/Sources/SecretAgent/SecretAgent.entitlements @@ -8,6 +8,8 @@ com.apple.security.smartcard + com.apple.security.temporary-exception.files.home-relative-path.read-write + keychain-access-groups $(AppIdentifierPrefix)com.maxgoedjen.Secretive diff --git a/Sources/Secretive.xcodeproj/project.pbxproj b/Sources/Secretive.xcodeproj/project.pbxproj index fe78151..3dcdbcb 100644 --- a/Sources/Secretive.xcodeproj/project.pbxproj +++ b/Sources/Secretive.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -878,6 +878,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = SecretAgent/SecretAgent.entitlements; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_ASSET_PATHS = "\"SecretAgent/Preview Content\"";