mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-06-28 19:10:57 +12:00
Ssh key file fixes
This commit is contained in:
parent
09a419f628
commit
aa71a72f58
|
@ -165,7 +165,7 @@ public class SentryErrorHandler implements ErrorHandler {
|
|||
atts.forEach(attachment -> s.addAttachment(attachment));
|
||||
}
|
||||
|
||||
s.setTag("hasLicense", String.valueOf(LicenseProvider.get().hasLicense()));
|
||||
s.setTag("hasLicense", String.valueOf(LicenseProvider.get().hasPaidLicense()));
|
||||
s.setTag("updatesEnabled", AppPrefs.get() != null ? AppPrefs.get().automaticallyUpdate().getValue().toString() : "unknown");
|
||||
s.setTag("initError", String.valueOf(OperationMode.isInStartup()));
|
||||
s.setTag(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.xpipe.app.storage;
|
||||
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.process.ShellControl;
|
||||
import io.xpipe.core.store.FileNames;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -42,17 +42,23 @@ public class ContextualFileReference {
|
|||
}
|
||||
|
||||
var ns = normalized(s.trim());
|
||||
// Replacement order is important
|
||||
var replaced = ns.replace("<DATA>", getDataDir())
|
||||
.replace("~", normalized(System.getProperty("user.home")));
|
||||
|
||||
String replaced;
|
||||
var withHomeResolved = ns.replace("~", normalized(System.getProperty("user.home")));
|
||||
// Only replace ~ if it is part of data dir, otherwise keep it raw
|
||||
if (withHomeResolved.startsWith(getDataDir())) {
|
||||
replaced = withHomeResolved.replace("<DATA>", getDataDir());
|
||||
} else {
|
||||
replaced = ns.replace("<DATA>", getDataDir());
|
||||
}
|
||||
return new ContextualFileReference(normalized(replaced));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private final String path;
|
||||
|
||||
public String toString() {
|
||||
return path.replaceAll("/", Matcher.quoteReplacement(OsType.getLocal().getFileSystemSeparator()));
|
||||
public String toFilePath(ShellControl sc) {
|
||||
return path.replaceAll("/", Matcher.quoteReplacement(sc != null ? sc.getOsType().getFileSystemSeparator() : "/"));
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
|
|
|
@ -46,4 +46,6 @@ public abstract class LicenseProvider {
|
|||
public abstract void init();
|
||||
|
||||
public abstract Comp<?> overviewPage();
|
||||
|
||||
public abstract boolean hasPaidLicense();
|
||||
}
|
||||
|
|
|
@ -124,12 +124,12 @@ public class ScriptHelper {
|
|||
return file;
|
||||
}
|
||||
|
||||
public static String createAskPassScript(SecretValue pass, ShellControl parent, boolean forceExecutable)
|
||||
public static String createAskpassScript(SecretValue pass, ShellControl parent, boolean forceExecutable, String errorMessage)
|
||||
throws Exception {
|
||||
return createAskPassScript(pass != null ? List.of(pass) : List.of(), parent, forceExecutable);
|
||||
return createAskpassScript(pass != null ? List.of(pass) : List.of(), parent, forceExecutable, errorMessage);
|
||||
}
|
||||
|
||||
public static String createAskPassScript(List<SecretValue> pass, ShellControl parent, boolean forceExecutable)
|
||||
public static String createAskpassScript(List<SecretValue> pass, ShellControl parent, boolean forceExecutable, String errorMessage)
|
||||
throws Exception {
|
||||
var scriptType = parent.getShellDialect();
|
||||
|
||||
|
@ -138,10 +138,10 @@ public class ScriptHelper {
|
|||
scriptType = parent.getOsType().equals(OsType.WINDOWS) ? ShellDialects.CMD : ShellDialects.SH;
|
||||
}
|
||||
|
||||
return createAskPassScript(pass, parent, scriptType);
|
||||
return createAskpassScript(pass, parent, scriptType, errorMessage);
|
||||
}
|
||||
|
||||
private static String createAskPassScript(List<SecretValue> pass, ShellControl parent, ShellDialect type)
|
||||
private static String createAskpassScript(List<SecretValue> pass, ShellControl parent, ShellDialect type, String errorMessage)
|
||||
throws Exception {
|
||||
var fileName = "exec-" + getScriptId() + "." + type.getScriptFileEnding();
|
||||
var temp = parent.getSubTemporaryDirectory();
|
||||
|
@ -154,7 +154,7 @@ public class ScriptHelper {
|
|||
file,
|
||||
pass.stream()
|
||||
.map(secretValue -> secretValue.getSecretValue())
|
||||
.toList());
|
||||
.toList(), errorMessage);
|
||||
return createExecScript(sub.getShellDialect(), sub, file, content);
|
||||
}
|
||||
} else {
|
||||
|
@ -164,7 +164,7 @@ public class ScriptHelper {
|
|||
file,
|
||||
pass.stream()
|
||||
.map(secretValue -> secretValue.getSecretValue())
|
||||
.toList());
|
||||
.toList(), errorMessage);
|
||||
return createExecScript(parent.getShellDialect(), parent, file, content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public interface SecretRetrievalStrategy {
|
|||
|
||||
@Override
|
||||
public boolean isLocalAskpassCompatible() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,25 +125,6 @@ public interface SecretRetrievalStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
@JsonTypeName("dynamicPrompt")
|
||||
class DynamicPrompt implements SecretRetrievalStrategy {
|
||||
|
||||
@Override
|
||||
public SecretValue retrieve(String displayName, UUID id, int sub) {
|
||||
return AskpassAlert.query(displayName, UUID.randomUUID(), id, sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCache() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalAskpassCompatible() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonTypeName("passwordManager")
|
||||
@Builder
|
||||
@Jacksonized
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.xpipe.core.process;
|
||||
|
||||
import io.xpipe.core.store.ShellStore;
|
||||
import io.xpipe.core.store.StatefulDataStore;
|
||||
import io.xpipe.core.util.*;
|
||||
import lombok.NonNull;
|
||||
|
@ -16,6 +17,10 @@ import java.util.function.Predicate;
|
|||
|
||||
public interface ShellControl extends ProcessControl {
|
||||
|
||||
Optional<ShellStore> getSourceStore();
|
||||
|
||||
ShellControl withSourceStore(ShellStore store);
|
||||
|
||||
List<ScriptSnippet> getInitCommands();
|
||||
|
||||
ShellControl withTargetTerminalShellDialect(ShellDialect d);
|
||||
|
@ -44,6 +49,8 @@ public interface ShellControl extends ProcessControl {
|
|||
|
||||
ShellControl onInit(FailableConsumer<ShellControl, Exception> pc);
|
||||
|
||||
ShellControl onPreInit(FailableConsumer<ShellControl, Exception> pc);
|
||||
|
||||
default <T extends ShellStoreState> ShellControl withShellStateInit(StatefulDataStore<T> store) {
|
||||
return onInit(shellControl -> {
|
||||
var s = store.getState();
|
||||
|
@ -169,6 +176,10 @@ public interface ShellControl extends ProcessControl {
|
|||
|
||||
ShellControl additionalTimeout(int ms);
|
||||
|
||||
default ShellControl disableTimeout() {
|
||||
return additionalTimeout(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
FailableSupplier<SecretValue> getElevationPassword();
|
||||
|
||||
default ShellControl subShell(@NonNull ShellDialect type) {
|
||||
|
|
|
@ -129,7 +129,7 @@ public interface ShellDialect {
|
|||
|
||||
String getScriptPermissionsCommand(String file);
|
||||
|
||||
String prepareAskpassContent(ShellControl sc, String fileName, List<String> s) throws Exception;
|
||||
String prepareAskpassContent(ShellControl sc, String fileName, List<String> s, String errorMessage) throws Exception;
|
||||
|
||||
String getSetEnvironmentVariableCommand(String variable, String value);
|
||||
|
||||
|
|
Loading…
Reference in a new issue