mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
More elevation fixes
This commit is contained in:
parent
6f4712934e
commit
4320040c9a
9 changed files with 67 additions and 34 deletions
|
@ -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);
|
||||
|
|
|
@ -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<SecretQuery> suppliers, SecretQuery fallback, CountDown countDown) {
|
||||
var p = new SecretQueryProgress(request, storeId, suppliers, fallback, countDown);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package io.xpipe.core.process;
|
||||
|
||||
public class AskpassSetup {}
|
|
@ -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();
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package io.xpipe.core.process;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class ElevationResult {
|
||||
String value;
|
||||
boolean promptsUserInput;
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -16,7 +16,9 @@ import java.util.function.Function;
|
|||
|
||||
public interface ShellControl extends ProcessControl {
|
||||
|
||||
UUID getElevationSecretId();
|
||||
ElevationHandler getElevationHandler();
|
||||
|
||||
void setElevationHandler(ElevationHandler ref);
|
||||
|
||||
List<UUID> getExitUuids();
|
||||
|
||||
|
|
|
@ -10,13 +10,10 @@ public interface ShellDialectAskpass {
|
|||
String prepareFixedContent(ShellControl sc, String fileName, List<String> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue