Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a792fe680 | ||
|
|
69f9e9952c | ||
|
|
ed6e96b3c1 | ||
|
|
37a70edbab |
@@ -42,6 +42,30 @@ enum SSHService {
|
||||
|
||||
// MARK: - Passwort / Auto-Login
|
||||
|
||||
/// SSH-Agent-Socket für GUI-Prozesse auflösen (Finder-Apps erben SSH_AUTH_SOCK
|
||||
/// nicht, Terminal schon — ohne diesen Unterschied nutzt Terminal evtl. einen
|
||||
/// Agent-Key, während die App nach dem Passwort fragt und scheitert).
|
||||
static func agentSocket() -> String? {
|
||||
let p = Process()
|
||||
p.executableURL = URL(fileURLWithPath: "/bin/launchctl")
|
||||
p.arguments = ["getenv", "SSH_AUTH_SOCK"]
|
||||
let out = Pipe()
|
||||
let err = Pipe()
|
||||
p.standardOutput = out
|
||||
p.standardError = err
|
||||
do {
|
||||
try p.run()
|
||||
p.waitUntilExit()
|
||||
} catch {
|
||||
return nil
|
||||
}
|
||||
let path = String(data: out.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
guard !path.isEmpty,
|
||||
FileManager.default.fileExists(atPath: path) else { return nil }
|
||||
return path
|
||||
}
|
||||
|
||||
/// Gespeichertes Login-Secret: erst Profil-Passwort, dann Key-Passphrase (Keychain, nie JSON).
|
||||
static func loginSecret(for profile: ConnectionProfile, key: StoredSSHKey?) -> String? {
|
||||
if let acct = profile.passwordAccount,
|
||||
|
||||
@@ -25,6 +25,8 @@ final class PTYSession: ObservableObject {
|
||||
var executable = ""
|
||||
var arguments: [String] = []
|
||||
var customEnv: [String: String] = [:]
|
||||
/// Fingerprint der Konfiguration (TerminalManager) — bei Änderung wird neu konfiguriert.
|
||||
var configTag = ""
|
||||
|
||||
private var masterFD: Int32 = -1
|
||||
private var process: Process?
|
||||
@@ -205,12 +207,13 @@ final class PTYSession: ObservableObject {
|
||||
func send(_ string: String) {
|
||||
let fd = masterFD
|
||||
guard fd >= 0 else { return }
|
||||
guard let data = string.data(using: .utf8) else { return }
|
||||
guard let data = string.data(using: .utf8), !data.isEmpty else { return }
|
||||
ioQueue.async {
|
||||
data.withUnsafeBytes { ptr in
|
||||
guard let base = ptr.baseAddress else { return }
|
||||
var written = 0
|
||||
while written < data.count {
|
||||
let n = write(fd, ptr.baseAddress!.advanced(by: written), data.count - written)
|
||||
let n = write(fd, base.advanced(by: written), data.count - written)
|
||||
if n <= 0 { break }
|
||||
written += n
|
||||
}
|
||||
@@ -287,8 +290,27 @@ final class TerminalManager: ObservableObject {
|
||||
private var sessions: [UUID: PTYSession] = [:]
|
||||
|
||||
func session(for profile: ConnectionProfile, key: StoredSSHKey?) -> PTYSession {
|
||||
if let existing = sessions[profile.id] { return existing }
|
||||
// Fingerprint aus allem, was die Verbindung bestimmt (inkl. Secret-Wert!):
|
||||
// Ändert der User Host/Passwort/Key, wird neu konfiguriert statt stale weiterzuwählen.
|
||||
let secret = SSHService.loginSecret(for: profile, key: key)
|
||||
let tag = [profile.proto.rawValue, profile.host, "\(profile.port)", profile.username,
|
||||
profile.extraArgs, key?.privateKeyPath ?? "", secret ?? ""].joined(separator: "|")
|
||||
if let existing = sessions[profile.id] {
|
||||
// Laufende Session niemals unter den Füßen wegkonfigurieren — erst Trennen.
|
||||
if existing.isRunning || existing.configTag == tag { return existing }
|
||||
existing.stop()
|
||||
configure(existing, profile: profile, key: key, secret: secret)
|
||||
existing.configTag = tag
|
||||
return existing
|
||||
}
|
||||
let s = PTYSession()
|
||||
configure(s, profile: profile, key: key, secret: secret)
|
||||
s.configTag = tag
|
||||
sessions[profile.id] = s
|
||||
return s
|
||||
}
|
||||
|
||||
private func configure(_ s: PTYSession, profile: ConnectionProfile, key: StoredSSHKey?, secret: String?) {
|
||||
let baseExe: String
|
||||
let baseArgs: [String]
|
||||
if profile.proto == .sftp {
|
||||
@@ -298,15 +320,18 @@ final class TerminalManager: ObservableObject {
|
||||
baseExe = "/usr/bin/ssh"
|
||||
baseArgs = SSHService.sshArguments(for: profile, key: key)
|
||||
}
|
||||
// Auto-Login nur mit Keychain-Secret + sshpass, sonst interaktiver Prompt im Terminal
|
||||
// Auto-Login nur mit Keychain-Secret + sshpass, sonst interaktiver Prompt im Terminal.
|
||||
// SSH-Agent durchreichen (falls vorhanden): gleiche Keys wie in Terminal.app.
|
||||
let cfg = SSHService.sessionConfig(executable: baseExe, args: baseArgs,
|
||||
password: SSHService.loginSecret(for: profile, key: key),
|
||||
password: secret,
|
||||
sshpassPath: SSHService.findSshpass())
|
||||
s.configure(executable: cfg.executable, arguments: cfg.arguments)
|
||||
s.customEnv = cfg.extraEnv
|
||||
var env = cfg.extraEnv
|
||||
if let sock = SSHService.agentSocket() {
|
||||
env["SSH_AUTH_SOCK"] = sock
|
||||
}
|
||||
s.customEnv = env
|
||||
s.setAutoLogin(cfg.autoLogin)
|
||||
sessions[profile.id] = s
|
||||
return s
|
||||
}
|
||||
|
||||
func close(_ profile: ConnectionProfile) {
|
||||
|
||||
@@ -41,6 +41,10 @@ struct EmbeddedTerminalView: View {
|
||||
Text(lastMessage)
|
||||
.font(.caption).foregroundStyle(Dracula.foreground)
|
||||
.lineLimit(3)
|
||||
if lastMessage.localizedCaseInsensitiveContains("permission denied") {
|
||||
Text("Tipp: Passwort im Auge-Modus eingeben, Tastaturlayout prüfen. Falls Terminal.app ohne Passwort einloggt (Agent-Key: ssh-add -l), Key in der App hinterlegen oder Agent nutzen.")
|
||||
.font(.caption).foregroundStyle(Dracula.orange)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
Button("Bericht kopieren") { copyReport() }
|
||||
@@ -61,16 +65,17 @@ struct EmbeddedTerminalView: View {
|
||||
// Eingabezeile
|
||||
HStack(spacing: 6) {
|
||||
Text("❯").font(.system(.body, design: .monospaced)).foregroundStyle(Dracula.green)
|
||||
if secureInput {
|
||||
SecureField("Eingabe (versteckt, z. B. Passwort) …", text: $input, onCommit: submit)
|
||||
.textFieldStyle(.plain)
|
||||
// Gehärtetes Feld: keine macOS-Text-Ersetzungen (Passwort-Sonderzeichen!)
|
||||
ZStack(alignment: .leading) {
|
||||
if input.isEmpty {
|
||||
Text(secureInput ? "Eingabe (versteckt, z. B. Passwort) …" : "Eingabe …")
|
||||
.font(.system(.body, design: .monospaced))
|
||||
.foregroundStyle(Dracula.foreground)
|
||||
} else {
|
||||
TextField("Eingabe …", text: $input, onCommit: submit)
|
||||
.textFieldStyle(.plain)
|
||||
.font(.system(.body, design: .monospaced))
|
||||
.foregroundStyle(Dracula.foreground)
|
||||
.foregroundStyle(Dracula.comment.opacity(0.7))
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
TerminalInputField(text: $input, isSecure: secureInput, onSubmit: submit)
|
||||
.id(secureInput)
|
||||
.frame(height: 22)
|
||||
}
|
||||
Button(action: { secureInput.toggle() }) {
|
||||
Image(systemName: secureInput ? "eye.slash" : "eye")
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
/// Eingabefeld ohne macOS-Text-Ersetzungen (Anführungszeichen, Gedankenstriche,
|
||||
/// Auto-Korrektur, Punkt-Verdopplung, Vervollständigung, Links/Daten-Erkennung).
|
||||
/// Hintergrund: Normale Textfelder ersetzen still z. B. `"` durch „“ und `--`
|
||||
/// durch — (je nach Tastatur-Einstellung). Im Terminal fällt das nicht auf, aber
|
||||
/// ein Passwort mit Sonderzeichen kommt falsch bei ssh an → „Permission denied",
|
||||
/// obwohl das Passwort „stimmt" (docs/ERRORS.md #13).
|
||||
/// NSTextField kann das nicht alles abschalten, daher NSTextView-Basis.
|
||||
/// Secure-Modus nutzt NSSecureTextField (per Design ohne Ersetzungen).
|
||||
struct TerminalInputField: NSViewRepresentable {
|
||||
@Binding var text: String
|
||||
var isSecure: Bool
|
||||
var onSubmit: () -> Void
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(text: $text, onSubmit: onSubmit)
|
||||
}
|
||||
|
||||
func makeNSView(context: Context) -> NSView {
|
||||
if isSecure {
|
||||
let f = NSSecureTextField()
|
||||
f.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
|
||||
f.textColor = Dracula.nsColor(for: nil)
|
||||
f.backgroundColor = .clear
|
||||
f.isBordered = false
|
||||
f.focusRingType = .none
|
||||
f.delegate = context.coordinator
|
||||
return f
|
||||
} else {
|
||||
let tv = NSTextView()
|
||||
Self.configure(tv)
|
||||
tv.delegate = context.coordinator
|
||||
return tv
|
||||
}
|
||||
}
|
||||
|
||||
func updateNSView(_ view: NSView, context: Context) {
|
||||
context.coordinator.onSubmit = onSubmit
|
||||
// Delegat während Programm-Sets abhängen: sonst feuert textDidChange synchron
|
||||
// zurück ins SwiftUI-State — mitten im Render -> Crash ("Modifying state
|
||||
// during view update"). User-Tippen läuft weiter über den Delegaten.
|
||||
if let f = view as? NSTextField {
|
||||
if f.stringValue != text {
|
||||
f.delegate = nil
|
||||
f.stringValue = text
|
||||
f.delegate = context.coordinator
|
||||
}
|
||||
} else if let tv = view as? NSTextView, tv.string != text {
|
||||
tv.delegate = nil
|
||||
tv.string = text
|
||||
tv.delegate = context.coordinator
|
||||
}
|
||||
}
|
||||
|
||||
/// Alle Ersetzungen aus. Auch als Harness-Test nutzbar (reine Flags, headless).
|
||||
static func configure(_ tv: NSTextView) {
|
||||
tv.isRichText = false
|
||||
tv.importsGraphics = false
|
||||
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||
tv.isAutomaticDashSubstitutionEnabled = false
|
||||
tv.isAutomaticTextCompletionEnabled = false
|
||||
tv.isAutomaticSpellingCorrectionEnabled = false
|
||||
tv.isContinuousSpellCheckingEnabled = false
|
||||
tv.isAutomaticDataDetectionEnabled = false
|
||||
tv.isAutomaticLinkDetectionEnabled = false
|
||||
tv.isAutomaticTextReplacementEnabled = false
|
||||
tv.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
|
||||
tv.textColor = Dracula.nsColor(for: nil)
|
||||
tv.backgroundColor = .clear
|
||||
tv.drawsBackground = false
|
||||
tv.isVerticallyResizable = false
|
||||
tv.isHorizontallyResizable = true
|
||||
tv.textContainer?.widthTracksTextView = false
|
||||
tv.textContainer?.containerSize = NSSize(width: 100000, height: 24)
|
||||
}
|
||||
|
||||
final class Coordinator: NSObject, NSTextFieldDelegate, NSTextViewDelegate {
|
||||
var text: Binding<String>
|
||||
var onSubmit: () -> Void
|
||||
|
||||
init(text: Binding<String>, onSubmit: @escaping () -> Void) {
|
||||
self.text = text
|
||||
self.onSubmit = onSubmit
|
||||
}
|
||||
|
||||
func controlTextDidChange(_ obj: Notification) {
|
||||
if let f = obj.object as? NSTextField {
|
||||
text.wrappedValue = f.stringValue
|
||||
}
|
||||
}
|
||||
|
||||
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||
onSubmit()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func textDidChange(_ notification: Notification) {
|
||||
if let tv = notification.object as? NSTextView {
|
||||
// Einzeiler: harte Umbrüche sofort entfernen (Paste mit \n)
|
||||
let single = tv.string.replacingOccurrences(of: "\n", with: "")
|
||||
if single != tv.string { tv.string = single }
|
||||
text.wrappedValue = single
|
||||
}
|
||||
}
|
||||
|
||||
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||
onSubmit()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,10 @@ Stand: 2026-09-21 · Version 0.1.0 · macOS arm64 · Swift 5.9+ · Xcode 15+
|
||||
| 10 | 2026-09-21 | Icon-Generator (`RenderIcon.swift`) | 3 Swift-Fehler: `guard let x = f() ?? g()` (nicht optional), `Int * CGFloat`, falscher Preview-Pfad | klein | ✅ behoben |
|
||||
| 11 | 2026-09-21 | Passwort-Feature | Wunsch: Passwort + Keys speichern UND nutzen (bisher nur gespeichert, nie benutzt) | Feature | ✅ umgesetzt — Auto-Login via sshpass, sonst interaktiv |
|
||||
| 12 | 2026-09-21 | „Immer Verbindung falsch" | User-Report ohne Details (Ziel/Credentials unbekannt) | offen | ⬜ Teils: Editor-Validierung + kopierbarer Fehlerbericht; warte auf Bericht |
|
||||
| 13 | 2026-09-21 | Permission denied trotz richtigem Passwort | Text-Ersetzung im Eingabefeld verfälscht Sonderzeichen | hoch | ✅ behoben — gehärtetes Eingabefeld (alle Ersetzungen aus, 9/9 Tests) |
|
||||
| 14 | 2026-09-21 | Terminal geht, App nicht (gleiches Passwort) | SSH-Agent-Socket fehlt GUI-Prozessen → evtl. Key-Login in Terminal | hoch | ✅ App reicht Agent jetzt durch; Gegenprobe beim User offen |
|
||||
| 15 | 2026-09-21 | Crash bei Tippen + Senden | Ursache unklar (headless nicht reproduzierbar) | kritisch | ⬜ Gehärtet (v0.5.3); Crash-Log angefragt |
|
||||
| 16 | 2026-09-22 | Profil-Änderungen wirkungslos | Session-Cache ignorierte Host-/Passwort-/Key-Korrekturen | hoch | ✅ behoben — Fingerprint-Reconfig (9/9 Tests) |
|
||||
|
||||
---
|
||||
|
||||
@@ -176,3 +180,41 @@ Oder mit Token als Passwort: `git push https://<owner>:<token>@git.sysdaemon.xyz
|
||||
**Umgesetzt:** `Models/ProfileValidation.swift` (trimmen + Warnungen, Harness 7/7), Passwort direkt unter Benutzername, „Bericht kopieren" im Fehler-Banner (ohne Secrets).
|
||||
**Offen:** Bitte Banner-Text oder kopierten Bericht hierher schicken — dann steht die Ursache in einer Zeile.
|
||||
**Status:** ⬜ wartet auf Fehlerbericht.
|
||||
|
||||
## #13 — Permission denied trotz richtigem Passwort (User-Fehlerbericht)
|
||||
**Bericht:** `administrator@sysdaemon.xyz:22`, ssh fragt 3x Passwort → `Permission denied (publickey,password)`. Gleiches Passwort im Terminal.app funktioniert.
|
||||
**Ursache:** Das Terminal-Eingabefeld war ein Standard-TextField. macOS ersetzt dort je nach Einstellung still Zeichen (`"` → „“, `--` → —, Auto-Korrektur). Ein Passwort mit Sonderzeichen kommt dadurch falsch bei ssh an — im Terminal fällt nichts auf, ssh sagt nur „denied". Verifiziert: Standard-`NSTextField` hat diese Schalter an bzw. `NSTextField` kann Dash-Ersetzung gar nicht abschalten (Compiler-Beweis).
|
||||
**Fix (`Views/TerminalInputField.swift`):** Eigenes Eingabefeld auf `NSTextView`-Basis mit allen Ersetzungen explizit aus (Quotes, Dashes, Completion, Spelling, Data/Link-Erkennung, Text-Replacement, Plain-Text); Secure-Variante via `NSSecureTextField` (per Design ersetzungsfrei); Enter → Senden, Paste-Normalisierung (keine Umbrüche).
|
||||
**Verifikation:** Harness 9/9 (alle Flags aus). Hinweis: Restrisiko Tastaturlayout (Z/Y) bleibt — Banner-Tipp ergänzt.
|
||||
**Status:** ✅ behoben — bitte mit v0.5.1 erneut testen.
|
||||
|
||||
## #14 — Terminal.app loggt ein, RemminaMac nicht (gleiches Passwort)
|
||||
**Stand (User-Antworten):** v0.5.1 installiert, Passwort-Login, Terminal.app funktioniert mit denselben Daten.
|
||||
**Analyse:** App-seitig ist alles verifiziert (PTY, Fehleranzeige, Passwort-Loop mit Sonderzeichen, Eingabe-Ersetzungen aus). Gleiches Binary + gleiche Config → Unterschied muss aus der Umgebung kommen. Hauptkandidat: **SSH-Agent** — Finder-gestartete GUI-Prozesse erben `SSH_AUTH_SOCK` nicht. Nutzt Terminal unbemerkt einen Agent-Key (statt Passwort), scheitert die App mit Passwort. Verifiziert: `launchctl getenv SSH_AUTH_SOCK` liefert den Socket, Shell-Env wäre ohne Abfrage leer für GUI-Apps.
|
||||
**Fix:** `SSHService.agentSocket()` (launchctl + Existenzprüfung) → `TerminalManager` injiziert `SSH_AUTH_SOCK` ins ssh-Env (koexistiert mit SSHPASS). Banner-Tipp ergänzt.
|
||||
**Verifikation:** Harness 4/4 (Auflösung 0.07 s, Pfad existiert, `ssh -G` ok mit echtem + kaputtem Socket).
|
||||
**Gegenprobe beim User (bitte ausführen):**
|
||||
```bash
|
||||
ssh-add -l
|
||||
ssh -o IdentitiesOnly=yes administrator@sysdaemon.xyz
|
||||
```
|
||||
Zweite Zeile erzwingt Passwort-Login ohne Agent — scheitert sie auch im Terminal, war es immer der Agent-Key.
|
||||
**Status:** ✅ App-Seite umgesetzt — warte auf Gegenprobe.
|
||||
|
||||
## #15 — Crash bei Tippen + Senden (User-Report)
|
||||
**Stand:** „Sobald ich was eintippe und absende, crasht das Programm." Headless nicht reproduzierbar — alle Ebenen einzeln grün.
|
||||
**Ausgeschlossen per Test:**
|
||||
- SIGPIPE beim Schreiben (Harness: macOS liefert EIO statt Signal; `send` nach `stop()` überlebt) — Hypothese widerlegt
|
||||
- View-Schicht (echter Coordinator + NSTextView: Tippen mit Umlauten/Quotes/Paste, Enter, 200 Programm-Sets) — grün
|
||||
- PTY-Roundtrip, Refused-, Keychain-, TCP-Harness — grün
|
||||
**Gehärtet (v0.5.3, ohne Beweis dass es DER Crash war):**
|
||||
- `TerminalInputField.updateNSView`: Delegat bei Programm-Sets abgehängt — sonst feuert `textDidChange` synchron zurück ins State während SwiftUI rendert („Modifying state during view update" → Crash-Kandidat Nr. 1, genau beim Senden: Eingabe wird geleert)
|
||||
- `PTYSession.send`: Force-Unwrap `baseAddress!` → Guard, Leer-Check
|
||||
**Weiter nötig bei erneutem Crash:** Console.app → Absturzberichte → neuesten `RemminaMac`-Eintrag öffnen → `Exception Type`, `Termination Reason` und crashed Thread hierher schicken. Damit steht die Stelle fest.
|
||||
**Status:** ⬜ wartet auf Rückmeldung / Crash-Log.
|
||||
|
||||
## #16 — Profil-Änderungen wirkungslos („geht immer noch nicht")
|
||||
**Stand:** Nach mehreren Fixes meldet der User weiterhin pauschal Misserfolg. Code-Review (`TerminalManager.session`, Zeile 291): Eine einmal erstellte Session wurde für immer wiederverwendet — Host-/Passwort-/Key-Korrekturen im Editor erreichten die laufende/stale Session nie. Jede Korrektur lief ins Leere.
|
||||
**Fix:** Konfigurations-Fingerprint (Proto/Host/Port/User/ExtraArgs/Key-Pfad/Secret-Wert) pro Session. Bei Abweichung und nicht-laufender Session: stoppen + neu konfigurieren (gleiches Objekt, Tabs bleiben). Laufende Sessions werden nie unter den Füßen wegkonfiguriert ( erst Trennen).
|
||||
**Verifikation:** Harness 9/9 (Host-Wechsel reconfiguriert, Secret-Wechsel erkannt, laufende ssh-Session an Banner-lesendem Socket unangetastet).
|
||||
**Status:** ✅ behoben — bitte mit v0.5.4 erneut testen (Profil ggf. einmal neu speichern).
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
- Im Profil-Editor: Passwort eingeben + „in Keychain speichern“. Gespeichertes Passwort wird angezeigt (✓) und kann gelöscht werden. In `profiles.json` steht nur die Referenz, nie das Passwort.
|
||||
- Reihenfolge beim Verbinden: Profil-Passwort zuerst, sonst Key-Passphrase.
|
||||
- **Auto-Login ohne Tippen:** braucht `sshpass` (`brew install sshpass`). Dann loggt ssh via Keychain-Secret ein (Passwort nur im Prozess-Env `SSHPASS`, nie in Befehlszeile/Logs). Status zeigt „Auto-Login via Keychain".
|
||||
- **Ohne sshpass:** Passwort/Key-Passphrase wird interaktiv im Terminal abgefragt (Passwort-Modus: Auge-Icon).
|
||||
- **Ohne sshpass:** Passwort/Key-Passphrase wird interaktiv im Terminal abgefragt (Passwort-Modus: Auge-Icon). Bei Sonderzeichen im Passwort immer Auge-Modus nutzen (keine Text-Ersetzung).
|
||||
|
||||
## Quick-Connect
|
||||
- Mit Auswahl: verbindet direkt. Ohne Auswahl: öffnet Editor mit „Quick-Connect“-Vorlage.
|
||||
|
||||
Reference in New Issue
Block a user