The safe mode option lets you run scripts in a protected environment where potentially harmful system commands are inherently disabled.
This feature is available in the 2020b R1 release.
The following restrictions are in place when script safe mode is on:
- The commands system, read, write, cp, mv, rm, del, and python are disabled
- The mpi executable of resources cannot be changed using setresource
Certain format of files can still be written in safe mode, and the formats include ".txt", ".dat", ".bsdf" and ".sdf".
Running disabled commands in safe mode will result in an error, which contains a link to this page. You can use try/catch to handle errors related to safe mode.
To turn on and off safe mode, you can use the “Safe-mode” checkbox in the products:
The product configuration file will remember the status of the safe mode checkbox, and it will initiate the project file accordingly when it is created.
Safe mode is turned on by default. Users can also turn it on and off from the command line by using the "-safe-mode" flag and "-trust-script" flag:
-safe-mode
to turn on the safe mode, and
-trust-script
to turn off the safe mode.
Note that the command line flag does not affect the configuration file value. More details on how to use these command line options can be found here.