Various fixes

This commit is contained in:
crschnick
2025-08-20 11:47:51 +00:00
parent 3a6c95e352
commit da863a690a
5 changed files with 29 additions and 9 deletions

View File

@@ -83,8 +83,8 @@ public class ShellSession extends Session {
return true;
}
// Don't run commands while in exit
if (shellControl.isExiting()) {
// Don't run commands while in startup / exit
if (shellControl.isInitializing() || shellControl.isExiting()) {
return true;
}

View File

@@ -65,7 +65,7 @@ public class BitwardenPasswordManager implements PasswordManager {
return null;
}
if (!sc.view().getEnvironmentVariable("BW_SESSION").isEmpty() && r[1].contains("Vault is locked")) {
if (r[1].contains("Vault is locked")) {
var pw = AskpassAlert.queryRaw("Unlock vault with your Bitwarden master password", null, false);
if (pw.getSecret() == null) {
return null;

View File

@@ -189,8 +189,8 @@ public final class FilePath {
return r;
}
public FilePath resolveTildeHome(String dir) {
return value.startsWith("~") ? FilePath.of(value.replace("~", dir)) : this;
public FilePath resolveTildeHome(FilePath dir) {
return value.startsWith("~") ? FilePath.of(value.replace("~", dir.toString())) : this;
}
public List<String> split() {

View File

@@ -223,7 +223,7 @@ public class SshIdentityStateManager {
if (socket == null) {
socket = AppPrefs.get().defaultSshAgentSocket().getValue();
}
checkLocalAgentIdentities(socket != null ? socket.toString() : null);
checkLocalAgentIdentities(socket != null ? socket.resolveTildeHome(sc.view().userHome()).toString() : null);
}
runningAgent = RunningAgent.SSH_AGENT;

View File

@@ -118,8 +118,28 @@ public interface SshIdentityStrategy {
}
}
@Override
public void buildCommand(CommandBuilder builder) {}
public void buildCommand(CommandBuilder builder) {
builder.environment("SSH_AUTH_SOCK", sc -> {
if (sc.getOsType() == OsType.WINDOWS) {
return null;
}
if (AppPrefs.get() != null) {
var socket = AppPrefs.get().sshAgentSocket().getValue();
if (socket == null) {
socket = AppPrefs.get().defaultSshAgentSocket().getValue();
}
if (socket != null) {
return socket.resolveTildeHome(sc.view().userHome()).toString();
}
}
return null;
});
}
@Override
public List<KeyValue> configOptions(ShellControl parent) throws Exception {
@@ -308,7 +328,7 @@ public interface SshIdentityStrategy {
var s = file.toAbsoluteFilePath(parent);
// The ~ is supported on all platforms, so manually replace it here for Windows
if (s.startsWith("~")) {
s = s.resolveTildeHome(parent.view().userHome().toString());
s = s.resolveTildeHome(parent.view().userHome());
}
var resolved = parent.getShellDialect()
.evaluateExpression(parent, s.toString())
@@ -374,7 +394,7 @@ public interface SshIdentityStrategy {
var s = file.toAbsoluteFilePath(sc);
// The ~ is supported on all platforms, so manually replace it here for Windows
if (s.startsWith("~")) {
s = s.resolveTildeHome(sc.view().userHome().toString());
s = s.resolveTildeHome(sc.view().userHome());
}
var resolved =
sc.getShellDialect().evaluateExpression(sc, s.toString()).readStdoutOrThrow();