Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<!-- Report execution statistics as azure-pipelien -->
<sysproperty key="tlc2.TLC.ide" value="azure-pipeline"/>
<sysproperty key="util.ExecutionStatisticsCollector.id" value="01ed03e40ba44f278a934849dd2b1038"/>
<sysproperty key="tlc2.overrides.IOUtils.enableExec" value="true"/>

<arg value="-fp"/>
<arg value="1"/>
Expand Down
4 changes: 4 additions & 0 deletions modules/IOUtils.tla
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
(* perform side effects when executed by TLC with the Java overrides. *)
(***************************************************************************)

\* The external-process operators IOExec, IOEnvExec, IOExecTemplate and
\* IOEnvExecTemplate are disabled by default. Set the system property
\* -Dtlc2.overrides.IOUtils.enableExec=true to allow TLC to run OS commands.

LOCAL INSTANCE TLC
LOCAL INSTANCE Integers
LOCAL INSTANCE Sequences
Expand Down
3 changes: 3 additions & 0 deletions modules/tlc2/overrides/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ private static Value runProcess(final Map<String, String> env, final String[] co

private static Value runProcess(final ProcessBuilder processBuilder)
throws IOException, InterruptedException {
if (!Boolean.getBoolean("tlc2.overrides.IOUtils.enableExec")) {
throw new EvalException(EC.GENERAL, "IOUtils exec is disabled by default. Evaluating an IOUtils exec operator such as IOExec runs an OS command. Set -Dtlc2.overrides.IOUtils.enableExec=true to allow it.");
}
// 3. Run command-line and receive its output.
final Process process = processBuilder/* .inheritIO() */.start();

Expand Down
2 changes: 1 addition & 1 deletion tests/IOUtilsUnixTests.tla
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ASSUME PrintT("IOUtilsUnixTests!C!d")
\* Run TLC with some spec depending on CommunityModules and CM on the classpath.
\* Pass an environment variable to the nested spec.
ASSUME(LET ret == IOEnvExec([SOME_NESTED_VAR |-> "SOME_VAL", B |-> "23"],
<<"java", "-cp", "modules:build/deps:build/modules:tlc/tla2tools.jar", "tlc2.TLC",
<<"java", "-cp", "modules:build/deps:build/modules:tlc/tla2tools.jar", "-Dtlc2.overrides.IOUtils.enableExec=true", "tlc2.TLC",
"-config", "Counter.cfg", "tests/nested/CounterCM">>)
IN /\ PrintT(ret)
/\ ret.exitValue = 0
Expand Down