diff --git a/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java index 4f8c65922..af31f7bab 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StandardStoreEntryComp.java @@ -33,6 +33,7 @@ public class StandardStoreEntryComp extends StoreEntryComp { var nameCC = new ColumnConstraints(); nameCC.setMinWidth(100); nameCC.setHgrow(Priority.ALWAYS); + nameCC.setPrefWidth(100); grid.getColumnConstraints().addAll(nameCC); grid.add(createInformation(), 2, 0, 1, 2); diff --git a/app/src/main/java/io/xpipe/app/util/SecretManager.java b/app/src/main/java/io/xpipe/app/util/SecretManager.java index 20c542547..d2fb3ba80 100644 --- a/app/src/main/java/io/xpipe/app/util/SecretManager.java +++ b/app/src/main/java/io/xpipe/app/util/SecretManager.java @@ -28,18 +28,6 @@ public class SecretManager { .findFirst(); } - public static synchronized SecretQueryProgress expectElevationPrompt( - UUID request, UUID secretId, CountDown countDown, boolean askIfNeeded) { - var p = new SecretQueryProgress( - request, - secretId, - List.of(askIfNeeded ? SecretQuery.elevation(secretId) : SecretQuery.prompt(true)), - SecretQuery.prompt(false), - countDown); - progress.add(p); - return p; - } - public static synchronized SecretQueryProgress expectAskpass( UUID request, UUID storeId, List suppliers, SecretQuery fallback, CountDown countDown) { var p = new SecretQueryProgress(request, storeId, suppliers, fallback, countDown); diff --git a/app/src/main/java/io/xpipe/app/util/SecretQuery.java b/app/src/main/java/io/xpipe/app/util/SecretQuery.java index 3d30dfe3b..502888cbf 100644 --- a/app/src/main/java/io/xpipe/app/util/SecretQuery.java +++ b/app/src/main/java/io/xpipe/app/util/SecretQuery.java @@ -4,11 +4,18 @@ import io.xpipe.app.prefs.AppPrefs; import io.xpipe.core.util.SecretReference; import java.util.Optional; -import java.util.UUID; public interface SecretQuery { - static SecretQuery elevation(UUID secretId) { + static SecretQuery confirmElevationIfNeeded(SecretQuery original, boolean needed) { + if (!needed) { + return original; + } + + return confirmElevation(original); + } + + static SecretQuery confirmElevation(SecretQuery original) { return new SecretQuery() { @Override @@ -30,7 +37,13 @@ public interface SecretQuery { @Override public SecretQueryResult query(String prompt) { - return AskpassAlert.queryRaw(prompt, null); + var r = original.query(prompt); + if (r.isCancelled()) { + return r; + } + + var inPlace = r.getSecret().inPlace(); + return AskpassAlert.queryRaw(prompt, inPlace); } @Override diff --git a/core/src/main/java/io/xpipe/core/process/AskpassSetup.java b/core/src/main/java/io/xpipe/core/process/AskpassSetup.java deleted file mode 100644 index 4af327031..000000000 --- a/core/src/main/java/io/xpipe/core/process/AskpassSetup.java +++ /dev/null @@ -1,3 +0,0 @@ -package io.xpipe.core.process; - -public class AskpassSetup {} diff --git a/core/src/main/java/io/xpipe/core/process/ElevationHandler.java b/core/src/main/java/io/xpipe/core/process/ElevationHandler.java new file mode 100644 index 000000000..2a5db7d6a --- /dev/null +++ b/core/src/main/java/io/xpipe/core/process/ElevationHandler.java @@ -0,0 +1,29 @@ +package io.xpipe.core.process; + +import io.xpipe.core.util.SecretReference; + +import java.util.UUID; + +public interface ElevationHandler { + + default ElevationHandler orElse(ElevationHandler other) { + return new ElevationHandler() { + + @Override + public boolean handleRequest(UUID requestId, CountDown countDown, boolean confirmIfNeeded) { + var r = ElevationHandler.this.handleRequest(requestId, countDown, confirmIfNeeded); + return r || other.handleRequest(requestId, countDown, confirmIfNeeded); + } + + @Override + public SecretReference getSecretRef() { + var r = ElevationHandler.this.getSecretRef(); + return r != null ? r : other.getSecretRef(); + } + }; + } + + boolean handleRequest(UUID requestId, CountDown countDown, boolean confirmIfNeeded); + + SecretReference getSecretRef(); +} diff --git a/core/src/main/java/io/xpipe/core/process/ElevationResult.java b/core/src/main/java/io/xpipe/core/process/ElevationResult.java deleted file mode 100644 index 71c148c60..000000000 --- a/core/src/main/java/io/xpipe/core/process/ElevationResult.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.xpipe.core.process; - -import lombok.Value; - -@Value -public class ElevationResult { - String value; - boolean promptsUserInput; -} diff --git a/core/src/main/java/io/xpipe/core/process/ParentSystemAccess.java b/core/src/main/java/io/xpipe/core/process/ParentSystemAccess.java index a28108308..67f08f969 100644 --- a/core/src/main/java/io/xpipe/core/process/ParentSystemAccess.java +++ b/core/src/main/java/io/xpipe/core/process/ParentSystemAccess.java @@ -4,6 +4,11 @@ public interface ParentSystemAccess { static ParentSystemAccess none() { return new ParentSystemAccess() { + @Override + public boolean supportsSameUsers() { + return false; + } + @Override public boolean supportsFileSystemAccess() { return false; @@ -33,6 +38,10 @@ public interface ParentSystemAccess { static ParentSystemAccess identity() { return new ParentSystemAccess() { + @Override + public boolean supportsSameUsers() { + return true; + } @Override public boolean supportsFileSystemAccess() { @@ -63,6 +72,10 @@ public interface ParentSystemAccess { static ParentSystemAccess combine(ParentSystemAccess a1, ParentSystemAccess a2) { return new ParentSystemAccess() { + @Override + public boolean supportsSameUsers() { + return a1.supportsSameUsers() && a2.supportsSameUsers(); + } @Override public boolean supportsFileSystemAccess() { @@ -95,6 +108,8 @@ public interface ParentSystemAccess { return supportsFileSystemAccess(); } + boolean supportsSameUsers(); + boolean supportsFileSystemAccess(); boolean supportsExecutables(); 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 a99ec3b64..fae426f70 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellControl.java +++ b/core/src/main/java/io/xpipe/core/process/ShellControl.java @@ -16,7 +16,9 @@ import java.util.function.Function; public interface ShellControl extends ProcessControl { - UUID getElevationSecretId(); + ElevationHandler getElevationHandler(); + + void setElevationHandler(ElevationHandler ref); List getExitUuids(); diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialectAskpass.java b/core/src/main/java/io/xpipe/core/process/ShellDialectAskpass.java index 70e7eb761..5a8575bc1 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialectAskpass.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialectAskpass.java @@ -10,13 +10,10 @@ public interface ShellDialectAskpass { String prepareFixedContent(ShellControl sc, String fileName, List s) throws Exception; String elevateDumbCommand( - ShellControl shellControl, - CommandConfiguration command, - UUID requestId, - CountDown countDown, - String message) + ShellControl shellControl, UUID requestId, ElevationHandler handler, CountDown countDown, String message, CommandConfiguration command + ) throws Exception; - String elevateTerminalCommandWithPreparedAskpass(ShellControl shellControl, String command, String prefix) + String elevateTerminalCommandWithPreparedAskpass(ShellControl shellControl, ElevationHandler handler, String command, String prefix) throws Exception; }