Improvements for proxmox connections

This commit is contained in:
crschnick 2024-11-19 10:15:11 +00:00
parent b1d8ec2de9
commit 3be6f70272
5 changed files with 21 additions and 6 deletions

View file

@ -199,7 +199,7 @@ public class SentryErrorHandler implements ErrorHandler {
options.setProguardUuid(AppProperties.get().getBuildUuid().toString());
options.setTag("os", System.getProperty("os.name"));
options.setTag("osVersion", System.getProperty("os.version"));
options.setTag("arch", System.getProperty("os.arch"));
options.setTag("arch", AppProperties.get().getArch());
options.setDist(XPipeDistributionType.get().getId());
options.setTag("staging", String.valueOf(AppProperties.get().isStaging()));
options.setSendModules(false);

View file

@ -2,6 +2,7 @@ package io.xpipe.app.util;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.storage.DataStoreEntry;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.util.FailableSupplier;
@ -10,6 +11,15 @@ import java.util.Optional;
public class CommandSupport {
public static boolean isRoot(ShellControl shellControl) throws Exception {
if (shellControl.getOsType() == OsType.WINDOWS) {
return false;
}
var isRoot = shellControl.executeSimpleBooleanCommand("test \"${EUID:-$(id -u)}\" -eq 0");
return isRoot;
}
public static Optional<String> findProgram(ShellControl processControl, String name) throws Exception {
var out = processControl
.command(processControl.getShellDialect().getWhichCommand(name))

View file

@ -199,6 +199,14 @@ public interface ShellControl extends ProcessControl {
return sc;
}
default ShellControl elevateIfNeeded(ElevationFunction function) throws Exception {
if (function.apply(this)) {
return identicalSubShell().elevated(ElevationFunction.elevated(function.getPrefix()));
} else {
return new StubShellControl(this);
}
}
default <T> T enforceDialect(@NonNull ShellDialect type, FailableFunction<ShellControl, T, Exception> sc)
throws Exception {
if (isRunning() && getShellDialect().equals(type)) {

View file

@ -1,6 +1,4 @@
package io.xpipe.app.ext;
import io.xpipe.core.process.ShellControl;
package io.xpipe.core.process;
public class StubShellControl extends WrapperShellControl {

View file

@ -1,6 +1,5 @@
package io.xpipe.app.ext;
package io.xpipe.core.process;
import io.xpipe.core.process.*;
import io.xpipe.core.store.DataStore;
import io.xpipe.core.store.FilePath;
import io.xpipe.core.util.FailableConsumer;