Skip to content
  • Marc Vertes's avatar
    feature: restrict symbols which can exit the interpreter process · b3766509
    Marc Vertes authored
    * feature: restrict symbols which can exit the interpreter process
    
    Some symbols such as os.Exit or log.Fatal, which make the current process
    to exit, are now restricted. They are replaced by a version which panics
    instead of exiting, as panics are recovered by Eval.
    
    The restricted os.FindProcess version is identical to the original
    except it errors when trying to return the self process, in order to
    forbid killing or signaling the interpreter process from script.
    
    The os/exec symbols are available only through unrestricted package.
    
    The original symbols are stored in an unrestricted package, which
    requires an explicit Use, as for unsafe and syscall packages.
    
    The Use() interpreter method has been slightly modified to allow inplace
    updating of package symbols, allowing to replace some symbols but not
    the entire imported package.
    
    A command line option -unrestricted has been added to yaegi CLI to use
    the unrestricted symbols.
    
    Fixes #486.
    
    * fix: lint
    b3766509