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 { default ShellSession newSession() throws Exception {
var func = shellFunction(); var func = shellFunction();
var c = func.control(); var c = func.control();
if (!isInStorage()) {
c.withoutLicenseCheck();
}
return new ShellSession(this, () -> c); return new ShellSession(this, () -> c);
} }

View file

@ -974,6 +974,6 @@ public abstract class DataStorage {
} }
public DataStoreEntry local() { 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() localPowershell = ProcessControlProvider.get()
.createLocalProcessControl(false) .createLocalProcessControl(false)
.subShell(ShellDialects.POWERSHELL) .subShell(ShellDialects.POWERSHELL)
.withoutLicenseCheck()
.start(); .start();
} catch (ProcessOutputException ex) { } catch (ProcessOutputException ex) {
throw ProcessOutputException.withPrefix("Failed to start local powershell process", ex); throw ProcessOutputException.withPrefix("Failed to start local powershell process", ex);

View file

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

View file

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

View file

@ -106,11 +106,6 @@ public class WrapperShellControl implements ShellControl {
return parent.getMachineRootSession(); return parent.getMachineRootSession();
} }
@Override
public ShellControl withoutLicenseCheck() {
return parent.withoutLicenseCheck();
}
@Override @Override
public String getOsName() { public String getOsName() {
return parent.getOsName(); return parent.getOsName();
@ -262,6 +257,11 @@ public class WrapperShellControl implements ShellControl {
return parent.withErrorFormatter(formatter); return parent.withErrorFormatter(formatter);
} }
@Override
public void checkLicenseOrThrow() {
parent.checkLicenseOrThrow();
}
@Override @Override
public String prepareIntermediateTerminalOpen( public String prepareIntermediateTerminalOpen(
TerminalInitFunction content, TerminalInitScriptConfig config, WorkingDirectoryFunction workingDirectory) 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"); "Shell has a PTY allocated and as a result does not support file system operations");
} }
shellControl.checkLicenseOrThrow();
return this; return this;
} }