WIP
This commit is contained in:
parent
6bb9fd376f
commit
a3b5ccbc3d
|
@ -23,6 +23,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
|
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
|
||||||
return SocketController(path: path)
|
return SocketController(path: path)
|
||||||
}()
|
}()
|
||||||
|
private lazy var fakeFile: PublicKeyStandinFileStoreController = {
|
||||||
|
PublicKeyStandinFileStoreController(secrets: storeList.stores.flatMap({ $0.secrets }))
|
||||||
|
}()
|
||||||
private var updateSink: AnyCancellable?
|
private var updateSink: AnyCancellable?
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
|
@ -35,6 +38,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
guard let update = update else { return }
|
guard let update = update else { return }
|
||||||
self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
||||||
}
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
print(self.fakeFile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
import Foundation
|
||||||
|
import SecretKit
|
||||||
|
|
||||||
|
public class PublicKeyStandinFileStoreController {
|
||||||
|
|
||||||
|
var files: [PublicKeyStandinFileController] = []
|
||||||
|
|
||||||
|
public init(secrets: [AnySecret]) {
|
||||||
|
let directory = NSHomeDirectory().appending("/PublicKeys")
|
||||||
|
try? FileManager.default.removeItem(at: URL(fileURLWithPath: directory))
|
||||||
|
try? FileManager.default.createDirectory(at: URL(fileURLWithPath: directory), withIntermediateDirectories: false, attributes: nil)
|
||||||
|
// TODO: TEST
|
||||||
|
files = secrets.filter({ $0.name == "Git Signature"})
|
||||||
|
/*files = secrets*/.map { PublicKeyStandinFileController(secret: $0, path: directory.appending("/").appending("test") )}
|
||||||
|
print("Done")
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Constants {
|
||||||
|
static var standinExtension = "secretive-public-key"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PublicKeyStandinFileController {
|
||||||
|
|
||||||
|
private var fileHandle: FileHandle?
|
||||||
|
private let secret: AnySecret
|
||||||
|
private let keyWriter = OpenSSHKeyWriter()
|
||||||
|
|
||||||
|
public init(secret: AnySecret, path: String) {
|
||||||
|
self.secret = secret
|
||||||
|
resetHandle(path: path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func resetHandle(path: String) {
|
||||||
|
try? FileManager.default.removeItem(atPath: path)
|
||||||
|
let fifo = mkfifo(UnsafePointer(Array(path.utf8CString)), S_IRWXU)
|
||||||
|
assert(fifo == 0)
|
||||||
|
fileHandle = nil
|
||||||
|
fileHandle = FileHandle(forWritingAtPath: path)
|
||||||
|
fileHandle?.writeabilityHandler = { [self] handle in
|
||||||
|
try! handle.write(contentsOf: keyWriter.openSSHString(secret: secret).data(using: .utf8)!)
|
||||||
|
try! fileHandle?.close()
|
||||||
|
// self.resetHandle(path: path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,6 +49,7 @@
|
||||||
506838A32415EA5D00F55094 /* AnySecretStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506838A22415EA5D00F55094 /* AnySecretStore.swift */; };
|
506838A32415EA5D00F55094 /* AnySecretStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 506838A22415EA5D00F55094 /* AnySecretStore.swift */; };
|
||||||
506AB87E2412334700335D91 /* SecretAgent.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 50A3B78A24026B7500D209EA /* SecretAgent.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
506AB87E2412334700335D91 /* SecretAgent.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 50A3B78A24026B7500D209EA /* SecretAgent.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
5079BA0F250F29BF00EA86F4 /* StoreListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5079BA0E250F29BF00EA86F4 /* StoreListView.swift */; };
|
5079BA0F250F29BF00EA86F4 /* StoreListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5079BA0E250F29BF00EA86F4 /* StoreListView.swift */; };
|
||||||
|
507CBBC92744AE4E00A0D79A /* PublicKeyStandinFileController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507CBBC82744AE4E00A0D79A /* PublicKeyStandinFileController.swift */; };
|
||||||
507CE4ED2420A3C70029F750 /* Agent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A3B79F24026B9900D209EA /* Agent.swift */; };
|
507CE4ED2420A3C70029F750 /* Agent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A3B79F24026B9900D209EA /* Agent.swift */; };
|
||||||
507CE4EE2420A3CA0029F750 /* SocketController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A3B79D24026B9900D209EA /* SocketController.swift */; };
|
507CE4EE2420A3CA0029F750 /* SocketController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A3B79D24026B9900D209EA /* SocketController.swift */; };
|
||||||
507CE4F02420A4C50029F750 /* SigningWitness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507CE4EF2420A4C50029F750 /* SigningWitness.swift */; };
|
507CE4F02420A4C50029F750 /* SigningWitness.swift in Sources */ = {isa = PBXBuildFile; fileRef = 507CE4EF2420A4C50029F750 /* SigningWitness.swift */; };
|
||||||
|
@ -269,6 +270,7 @@
|
||||||
506838A02415EA5600F55094 /* AnySecret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySecret.swift; sourceTree = "<group>"; };
|
506838A02415EA5600F55094 /* AnySecret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySecret.swift; sourceTree = "<group>"; };
|
||||||
506838A22415EA5D00F55094 /* AnySecretStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySecretStore.swift; sourceTree = "<group>"; };
|
506838A22415EA5D00F55094 /* AnySecretStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnySecretStore.swift; sourceTree = "<group>"; };
|
||||||
5079BA0E250F29BF00EA86F4 /* StoreListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreListView.swift; sourceTree = "<group>"; };
|
5079BA0E250F29BF00EA86F4 /* StoreListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreListView.swift; sourceTree = "<group>"; };
|
||||||
|
507CBBC82744AE4E00A0D79A /* PublicKeyStandinFileController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicKeyStandinFileController.swift; sourceTree = "<group>"; };
|
||||||
507CE4EF2420A4C50029F750 /* SigningWitness.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningWitness.swift; sourceTree = "<group>"; };
|
507CE4EF2420A4C50029F750 /* SigningWitness.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningWitness.swift; sourceTree = "<group>"; };
|
||||||
507CE4F32420A8C10029F750 /* SigningRequestProvenance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningRequestProvenance.swift; sourceTree = "<group>"; };
|
507CE4F32420A8C10029F750 /* SigningRequestProvenance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningRequestProvenance.swift; sourceTree = "<group>"; };
|
||||||
507CE4F52420A96F0029F750 /* SigningRequestTracer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningRequestTracer.swift; sourceTree = "<group>"; };
|
507CE4F52420A96F0029F750 /* SigningRequestTracer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningRequestTracer.swift; sourceTree = "<group>"; };
|
||||||
|
@ -610,6 +612,7 @@
|
||||||
5099A06E240242BA0062B6F2 /* SecretAgentKit.h */,
|
5099A06E240242BA0062B6F2 /* SecretAgentKit.h */,
|
||||||
5099A089240242C20062B6F2 /* SSHAgentProtocol.swift */,
|
5099A089240242C20062B6F2 /* SSHAgentProtocol.swift */,
|
||||||
50A3B79D24026B9900D209EA /* SocketController.swift */,
|
50A3B79D24026B9900D209EA /* SocketController.swift */,
|
||||||
|
507CBBC82744AE4E00A0D79A /* PublicKeyStandinFileController.swift */,
|
||||||
507CE4EF2420A4C50029F750 /* SigningWitness.swift */,
|
507CE4EF2420A4C50029F750 /* SigningWitness.swift */,
|
||||||
507CE4F52420A96F0029F750 /* SigningRequestTracer.swift */,
|
507CE4F52420A96F0029F750 /* SigningRequestTracer.swift */,
|
||||||
50A3B79F24026B9900D209EA /* Agent.swift */,
|
50A3B79F24026B9900D209EA /* Agent.swift */,
|
||||||
|
@ -1102,6 +1105,7 @@
|
||||||
5099A08A240242C20062B6F2 /* SSHAgentProtocol.swift in Sources */,
|
5099A08A240242C20062B6F2 /* SSHAgentProtocol.swift in Sources */,
|
||||||
507CE4ED2420A3C70029F750 /* Agent.swift in Sources */,
|
507CE4ED2420A3C70029F750 /* Agent.swift in Sources */,
|
||||||
507CE4F02420A4C50029F750 /* SigningWitness.swift in Sources */,
|
507CE4F02420A4C50029F750 /* SigningWitness.swift in Sources */,
|
||||||
|
507CBBC92744AE4E00A0D79A /* PublicKeyStandinFileController.swift in Sources */,
|
||||||
507CE4F62420A96F0029F750 /* SigningRequestTracer.swift in Sources */,
|
507CE4F62420A96F0029F750 /* SigningRequestTracer.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|
Loading…
Reference in New Issue