diff --git a/app/src/main/java/io/xpipe/app/ext/ShellSession.java b/app/src/main/java/io/xpipe/app/ext/ShellSession.java index 8ecb81a15..1dd1f8197 100644 --- a/app/src/main/java/io/xpipe/app/ext/ShellSession.java +++ b/app/src/main/java/io/xpipe/app/ext/ShellSession.java @@ -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; } diff --git a/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java b/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java index 2da898779..711b77000 100644 --- a/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java +++ b/app/src/main/java/io/xpipe/app/pwman/BitwardenPasswordManager.java @@ -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; diff --git a/core/src/main/java/io/xpipe/core/FilePath.java b/core/src/main/java/io/xpipe/core/FilePath.java index 2b60b7760..f32c5c80e 100644 --- a/core/src/main/java/io/xpipe/core/FilePath.java +++ b/core/src/main/java/io/xpipe/core/FilePath.java @@ -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 split() { diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java index 7127edb24..1de2c7ad2 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStateManager.java @@ -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; diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStrategy.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStrategy.java index 4314260e8..8cdcc9af5 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStrategy.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/SshIdentityStrategy.java @@ -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 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();