Rework shell license check

This commit is contained in:
crschnick 2024-11-21 11:23:36 +00:00
parent 3211896045
commit 66b6fae017
7 changed files with 11 additions and 13 deletions

View file

@ -32,9 +32,6 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
default ShellSession newSession() throws Exception {
var func = shellFunction();
var c = func.control();
if (!isInStorage()) {
c.withoutLicenseCheck();
}
return new ShellSession(this, () -> c);
}

View file

@ -974,6 +974,6 @@ public abstract class DataStorage {
}
public DataStoreEntry local() {
return getStoreEntryIfPresent(LOCAL_ID).orElse(null);
return getStoreEntryIfPresent(LOCAL_ID).orElseThrow(() -> new IllegalStateException("Missing local machine connection"));
}
}

View file

@ -43,7 +43,6 @@ public class LocalShell {
localPowershell = ProcessControlProvider.get()
.createLocalProcessControl(false)
.subShell(ShellDialects.POWERSHELL)
.withoutLicenseCheck()
.start();
} catch (ProcessOutputException ex) {
throw ProcessOutputException.withPrefix("Failed to start local powershell process", ex);

View file

@ -143,7 +143,7 @@ class ScanDialog extends DialogComp {
ThreadHelper.runFailableAsync(() -> {
BooleanScope.executeExclusive(busy, () -> {
var sc = entry.get().getStore().getOrStartSession().withoutLicenseCheck();
var sc = entry.get().getStore().getOrStartSession();
var a = applicable.apply(entry.get().get(), sc);
Platform.runLater(() -> {
if (a == null) {

View file

@ -54,8 +54,6 @@ public interface ShellControl extends ProcessControl {
ShellControl getMachineRootSession();
ShellControl withoutLicenseCheck();
String getOsName();
boolean isLicenseCheck();
@ -106,6 +104,8 @@ public interface ShellControl extends ProcessControl {
ShellControl withErrorFormatter(Function<String, String> formatter);
void checkLicenseOrThrow();
String prepareIntermediateTerminalOpen(
TerminalInitFunction content, TerminalInitScriptConfig config, WorkingDirectoryFunction workingDirectory)
throws Exception;

View file

@ -106,11 +106,6 @@ public class WrapperShellControl implements ShellControl {
return parent.getMachineRootSession();
}
@Override
public ShellControl withoutLicenseCheck() {
return parent.withoutLicenseCheck();
}
@Override
public String getOsName() {
return parent.getOsName();
@ -262,6 +257,11 @@ public class WrapperShellControl implements ShellControl {
return parent.withErrorFormatter(formatter);
}
@Override
public void checkLicenseOrThrow() {
parent.checkLicenseOrThrow();
}
@Override
public String prepareIntermediateTerminalOpen(
TerminalInitFunction content, TerminalInitScriptConfig config, WorkingDirectoryFunction workingDirectory)

View file

@ -50,6 +50,8 @@ public class ConnectionFileSystem implements FileSystem {
"Shell has a PTY allocated and as a result does not support file system operations");
}
shellControl.checkLicenseOrThrow();
return this;
}