Add sudo cache

This commit is contained in:
crschnick
2025-09-15 06:58:24 +00:00
parent 9f5dc8cf1e
commit dc1e1bda91
4 changed files with 28 additions and 3 deletions
@@ -271,4 +271,6 @@ public interface ShellControl extends ProcessControl {
CommandControl command(CommandBuilder builder);
void exitAndWait() throws IOException;
SudoCache getSudoCache();
}
@@ -0,0 +1,12 @@
package io.xpipe.app.process;
import io.xpipe.core.FilePath;
public interface SudoCache {
void setRequiresPassword();
boolean requiresPassword() throws Exception;
FilePath getSudoExecutable() throws Exception;
}
@@ -364,4 +364,9 @@ public class WrapperShellControl implements ShellControl {
public void exitAndWait() throws IOException {
parent.exitAndWait();
}
@Override
public SudoCache getSudoCache() {
return parent.getSudoCache();
}
}
@@ -88,12 +88,18 @@ public class SecretManager {
return r;
}
public static synchronized void completeRequest(UUID request) {
if (progress.removeIf(
secretQueryProgress -> secretQueryProgress.getRequestId().equals(request))) {
public static synchronized List<SecretQueryProgress> completeRequest(UUID request) {
var found = progress.stream().filter(
secretQueryProgress -> secretQueryProgress.getRequestId().equals(request))
.toList();
if (progress.removeAll(found)) {
TrackEvent.withTrace("Completed secret request")
.tag("uuid", request)
.handle();
return found;
} else {
return List.of();
}
}