Safe mode: Difference between revisions

Line 39:
 
However, not all REXXes support this option.
 
Regina REXX supports a '''--restricted''' command line option, and embedded interpreters can also be set to run restricted. Many commands are disabled in this mode, including most access to hosted services. The intrinsic '''FUNCTION REXX()''' extension in GnuCOBOL defaults to restricted mode, and programmers must explicitly use '''FUNCTION REXX-UNRESTRICTED(script, args...)''' for access to the full REXX programming environment from that [[COBOL]] implementation.
 
<lang cobol> identification division.
program-id. rexxtrial.
 
environment division.
configuration section.
repository.
function all intrinsic.
 
data division.
working-storage section.
 
procedure division.
*> First attempt fails and return statement does not execute
display rexx("ADDRESS SYSTEM; 'ls rexxtrial.cob'; return 'fail'")
display "Exception: " exception-status
 
*> Second is allowed and succeeds
display "Try with rexx-unrestricted"
display rexx-unrestricted(
"ADDRESS SYSTEM; 'ls -l rexxtrial.cob'; return 'success'")
display "No exception raised: " exception-status
goback.
end program rexxtrial.</lang>
 
{{out}}
<pre>$ cobc -xj rexxtrial.cob
1 +++ 'ls rexxtrial.cob'
Error 95 running "gnucobol", line 1: [Restricted feature used in "safe" mode]
Error 95.5: [Running external commands invalid in "safe" mode]
 
Exception: EC-IMP-SCRIPT
Try with rexx-unrestricted
-rw-rw-r--. 1 btiffin btiffin 727 Feb 19 04:26 rexxtrial.cob
success
No exception raised:</pre>
Anonymous user