Skip to content

Commit 7c38c6a

Browse files
authored
Merge branch 'contour-terminal:master' into master
2 parents ab084c1 + 864e725 commit 7c38c6a

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

metainfo.xml

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
<li>Fixes missing dependencies for release .deb packages (#1397).</li>
116116
<li>Fixes legacy keyboard input protocol not reporting non-Alt modifier (#1411).</li>
117117
<li>Digitally sign MacOS release binaries using a valid Apple ID.</li>
118+
<li>Add support for authenticating to SSH servers with a private key without a password and without requesting for one - also allow password retry (#1425).</li>
119+
<li>Default history limit is now 1000 lines rather than 0 lines.</li>
118120
</ul>
119121
</description>
120122
</release>

src/contour/Config.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -1770,14 +1770,16 @@ namespace
17701770
logger()("Invalid render_mode \"{}\" in configuration.", strValue);
17711771

17721772
auto intValue = LineCount();
1773-
tryLoadChildRelative(usedKeys, profile, basePath, "history.limit", intValue, logger);
1774-
// value -1 is used for infinite grid
1775-
if (unbox(intValue) == -1)
1776-
terminalProfile.maxHistoryLineCount = Infinite();
1777-
else if (unbox(intValue) > -1)
1778-
terminalProfile.maxHistoryLineCount = LineCount(intValue);
1779-
else
1780-
terminalProfile.maxHistoryLineCount = LineCount(0);
1773+
if (tryLoadChildRelative(usedKeys, profile, basePath, "history.limit", intValue, logger))
1774+
{
1775+
// value -1 is used for infinite grid
1776+
if (unbox(intValue) == -1)
1777+
terminalProfile.maxHistoryLineCount = Infinite();
1778+
else if (unbox(intValue) > -1)
1779+
terminalProfile.maxHistoryLineCount = LineCount(intValue);
1780+
else
1781+
terminalProfile.maxHistoryLineCount = LineCount(0);
1782+
}
17811783

17821784
tryLoadChildRelative(
17831785
usedKeys, profile, basePath, "option_as_alt", terminalProfile.optionKeyAsAlt, logger);

src/contour/Config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ struct TerminalProfile
173173
vtbackend::PageSize terminalSize = { vtbackend::LineCount(10), vtbackend::ColumnCount(40) };
174174
vtbackend::VTType terminalId = vtbackend::VTType::VT525;
175175

176-
vtbackend::MaxHistoryLineCount maxHistoryLineCount;
176+
vtbackend::MaxHistoryLineCount maxHistoryLineCount = vtbackend::LineCount(1000);
177177
vtbackend::LineCount historyScrollMultiplier = vtbackend::LineCount(3);
178178
ScrollBarPosition scrollbarPosition = ScrollBarPosition::Right;
179179
vtbackend::StatusDisplayPosition statusDisplayPosition = vtbackend::StatusDisplayPosition::Bottom;

src/vtpty/SshSession.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,16 @@ void SshSession::processState()
431431
break;
432432
}
433433
case State::AuthenticatePrivateKeyStart:
434+
_walkIndex = 0;
435+
// authenticateWithPrivateKey() is taking the password from _injectedWrite
436+
_injectedWrite = "";
437+
authenticateWithPrivateKey();
438+
break;
439+
case State::AuthenticatePrivateKeyRequest: {
434440
setState(State::AuthenticatePrivateKeyWaitForInput);
435441
injectRead("\U0001F511 Private key password: ");
436442
[[fallthrough]];
443+
}
437444
case State::AuthenticatePrivateKeyWaitForInput:
438445
// See handlePreAuthenticationPasswordInput()
439446
return;
@@ -1172,7 +1179,17 @@ void SshSession::authenticateWithPrivateKey()
11721179

11731180
if (rc != LIBSSH2_ERROR_NONE)
11741181
{
1175-
logError("Private key based authentication failed. {}", libssl2ErrorString(rc));
1182+
// Only log error if we havee tried to authenticate with password,
1183+
// as the first attempt is always with an empty password.
1184+
if (_walkIndex != 0)
1185+
logError("Private key based authentication failed. {}", libssl2ErrorString(rc));
1186+
1187+
if (_walkIndex <= MaxPasswordTries)
1188+
{
1189+
setState(State::AuthenticatePrivateKeyRequest);
1190+
++_walkIndex;
1191+
return;
1192+
}
11761193
setState(State::AuthenticatePasswordStart);
11771194
_walkIndex = 0;
11781195
return;

src/vtpty/SshSession.h

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class SshSession final: public Pty
8080
VerifyHostKey, // verify host key against known_hosts file
8181
AuthenticateAgent, // authenticate with SSH agent
8282
AuthenticatePrivateKeyStart, // start private key authentication
83+
AuthenticatePrivateKeyRequest, // request private key's password
8384
AuthenticatePrivateKeyWaitForInput, // wait for private key's password (user input))
8485
AuthenticatePrivateKey, // authenticate with private key
8586
AuthenticatePasswordStart, // start password authentication
@@ -173,6 +174,7 @@ struct fmt::formatter<vtpty::SshSession::State>: fmt::formatter<std::string_view
173174
case vtpty::SshSession::State::VerifyHostKey: name = "VerifyHostKey"; break;
174175
case vtpty::SshSession::State::AuthenticateAgent: name = "AuthenticateAgent"; break;
175176
case vtpty::SshSession::State::AuthenticatePrivateKeyStart: name = "AuthenticatePrivateKeyStart"; break;
177+
case vtpty::SshSession::State::AuthenticatePrivateKeyRequest: name = "AuthenticatePrivateKeyRequest"; break;
176178
case vtpty::SshSession::State::AuthenticatePrivateKeyWaitForInput: name = "AuthenticatePrivateKeyWaitForInput"; break;
177179
case vtpty::SshSession::State::AuthenticatePrivateKey: name = "AuthenticatePrivateKey"; break;
178180
case vtpty::SshSession::State::AuthenticatePasswordStart: name = "AuthenticatePasswordStart"; break;

0 commit comments

Comments
 (0)