diff --git a/app/src/main/java/io/xpipe/app/update/AppInstaller.java b/app/src/main/java/io/xpipe/app/update/AppInstaller.java index 6ca9f4468..fd2838047 100644 --- a/app/src/main/java/io/xpipe/app/update/AppInstaller.java +++ b/app/src/main/java/io/xpipe/app/update/AppInstaller.java @@ -42,7 +42,7 @@ public class AppInstaller { targetFile = localFile.toString(); } else { targetFile = FileNames.join( - s.getTemporaryDirectory(), localFile.getFileName().toString()); + s.getSubTemporaryDirectory(), localFile.getFileName().toString()); try (InputStream in = Files.newInputStream(localFile)) { in.transferTo(s.getShellDialect().createStreamFileWriteCommand(s, targetFile).startExternalStdin()); } diff --git a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java index bb6054f9c..c62b793b3 100644 --- a/app/src/main/java/io/xpipe/app/util/ScriptHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ScriptHelper.java @@ -10,7 +10,6 @@ import io.xpipe.core.process.ShellDialects; import io.xpipe.core.util.SecretValue; import lombok.SneakyThrows; -import java.util.Collections; import java.util.List; import java.util.Random; @@ -84,7 +83,7 @@ public class ScriptHelper { @SneakyThrows public static String getExecScriptFile(ShellControl processControl, String fileEnding) { var fileName = "exec-" + getScriptId(); - var temp = processControl.getTemporaryDirectory(); + var temp = processControl.getSubTemporaryDirectory(); var file = FileNames.join(temp, fileName + "." + fileEnding); return file; } @@ -93,7 +92,7 @@ public class ScriptHelper { public static String createExecScript(ShellControl processControl, String content) { var fileName = "exec-" + getScriptId(); ShellDialect type = processControl.getShellDialect(); - var temp = processControl.getTemporaryDirectory(); + var temp = processControl.getSubTemporaryDirectory(); var file = FileNames.join(temp, fileName + "." + type.getScriptFileEnding()); return createExecScript(processControl, file, content); } @@ -122,6 +121,11 @@ public class ScriptHelper { public static String createAskPassScript(SecretValue pass, ShellControl parent, boolean forceExecutable) throws Exception { + return createAskPassScript(pass != null ? List.of(pass) : List.of(), parent, forceExecutable); + } + + public static String createAskPassScript(List pass, ShellControl parent, boolean forceExecutable) + throws Exception { var scriptType = parent.getShellDialect(); // Fix for powershell as there are permission issues when executing a powershell askpass script @@ -132,23 +136,23 @@ public class ScriptHelper { return createAskPassScript(pass, parent, scriptType); } - private static String createAskPassScript(SecretValue pass, ShellControl parent, ShellDialect type) + private static String createAskPassScript(List pass, ShellControl parent, ShellDialect type) throws Exception { var fileName = "askpass-" + getScriptId() + "." + type.getScriptFileEnding(); - var temp = parent.getTemporaryDirectory(); + var temp = parent.getSubTemporaryDirectory(); var file = FileNames.join(temp, fileName); if (type != parent.getShellDialect()) { try (var sub = parent.subShell(type).start()) { var content = sub.getShellDialect() .prepareAskpassContent( - sub, file, pass != null ? Collections.singletonList(pass.getSecretValue()) : List.of()); + sub, file, pass.stream().map(secretValue -> secretValue.getSecretValue()).toList()); var exec = createExecScript(sub, file, content); return exec; } } else { var content = parent.getShellDialect() .prepareAskpassContent( - parent, file, pass != null ? Collections.singletonList(pass.getSecretValue()) : List.of()); + parent, file, pass.stream().map(secretValue -> secretValue.getSecretValue()).toList()); var exec = createExecScript(parent, file, content); return exec; } diff --git a/core/src/main/java/io/xpipe/core/process/ShellControl.java b/core/src/main/java/io/xpipe/core/process/ShellControl.java index 41b0c54e9..e5107feea 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -33,7 +33,9 @@ public interface ShellControl extends ProcessControl { String prepareIntermediateTerminalOpen(String content, String displayName) throws Exception; - String getTemporaryDirectory() throws Exception; + String getSystemTemporaryDirectory(); + + String getSubTemporaryDirectory(); public void checkRunning() throws Exception; diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialect.java b/core/src/main/java/io/xpipe/core/process/ShellDialect.java index bf47df806..cf3460204 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialect.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialect.java @@ -110,7 +110,7 @@ public interface ShellDialect { String prepareTerminalInitFileOpenCommand(ShellDialect parentDialect, ShellControl sc, String file) throws Exception; - String runScript(String file); + String runScript(ShellControl parent, String file); String sourceScript(String file); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java index e924cd9b9..12f0e3d15 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/RunAction.java @@ -61,6 +61,6 @@ public class RunAction extends MultiExecuteAction { @Override protected String createCommand(ShellControl sc, OpenFileSystemModel model, BrowserEntry entry) { - return sc.getShellDialect().runScript(entry.getFileName()); + return sc.getShellDialect().runScript(sc, entry.getFileName()); } }