File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -336,7 +336,15 @@ enum DatabaseDriverFactory {
336336
337337 private static func resolvePassword( for connection: DatabaseConnection ) -> String {
338338 if connection. usePgpass {
339- return " "
339+ let pgpassHost = connection. additionalFields [ " pgpassOriginalHost " ] ?? connection. host
340+ let pgpassPort = connection. additionalFields [ " pgpassOriginalPort " ]
341+ . flatMap ( Int . init) ?? connection. port
342+ return PgpassReader . resolve (
343+ host: pgpassHost. isEmpty ? " localhost " : pgpassHost,
344+ port: pgpassPort,
345+ database: connection. database,
346+ username: connection. username
347+ ) ?? " "
340348 }
341349 return ConnectionStorage . shared. loadPassword ( for: connection. id) ?? " "
342350 }
Original file line number Diff line number Diff line change @@ -440,6 +440,12 @@ final class DatabaseManager {
440440 tunnelSSL. clientKeyPath = " "
441441 }
442442
443+ var effectiveFields = connection. additionalFields
444+ if connection. usePgpass {
445+ effectiveFields [ " pgpassOriginalHost " ] = connection. host
446+ effectiveFields [ " pgpassOriginalPort " ] = String ( connection. port)
447+ }
448+
443449 return DatabaseConnection (
444450 id: connection. id,
445451 name: connection. name,
@@ -450,7 +456,7 @@ final class DatabaseManager {
450456 type: connection. type,
451457 sshConfig: SSHConfiguration ( ) ,
452458 sslConfig: tunnelSSL,
453- additionalFields: connection . additionalFields
459+ additionalFields: effectiveFields
454460 )
455461 }
456462
You can’t perform that action at this time.
0 commit comments