jcrodriguez-dis / vpl-jail-system

Execution/jail server for VPL
GNU General Public License v3.0
23 stars 22 forks source link

Node.Js incomplete compatibility #29

Closed guiga-zalu closed 1 year ago

guiga-zalu commented 5 years ago

The jail server can successfully execute a .js file with nodejs. I altered an installation file to install some modules (as globals, via npm), and it installed them successfully. But I can't import them when an script is executed.

jcrodriguez-dis commented 5 years ago

Hello Guiga-Zalu,

please, detail how can I reproduce the problem to try to spot a solution.

Best regards, Juan Carlos.

guiga-zalu commented 5 years ago

Well, for the installation of the npm modules, I altered install-vpl-sh and added lines (right after the vpl_install "Valgrind tool" valgrind) with content like this:

# Processamento Numérico
vpl_install_npm "big.js" big.js
vpl_install_npm "BigNumber.js" bignumber.js
vpl_install_npm "decimal.js" decimal.js
vpl_install_npm "vectorious" vectorious

In total, 14 modules were installed. The shell showed no installation errors for 13 of them, failing only with opencv4nodejs, which was not crucial.

So, to try out the modules, I submitted, saved and executed a file (test.js) like that:

const BN = require('bignumber.js');
console.dir(BN);

But the module could not be found.

jcrodriguez-dis commented 5 years ago

Hello guiga-zalu, I have not been able to install globally the modules and run the test.js code. I am using Ubuntu 18 it seems that some modules are deprecated. what O.S. are you using?

Best regards, Juan Carlos.

alphonse92 commented 5 years ago

I think is b/c when the student/teacher code is executed its running in another isolated context. In few words, you installed that dependencies for the host, but not to the isolated context. Maybe related: https://github.com/jcrodriguez-dis/vpl-xmlrpc-jail/issues/32

alphonse92 commented 5 years ago

I think i resolved your bug. You need adjust the prisoner environment.

https://github.com/jcrodriguez-dis/vpl-xmlrpc-jail/blob/ef6786fb203a315eb76278f444d21583afacf44a/vpl-jail-system.initd#L27-L35

That is the folder structure to the prisoner process. @jcrodriguez-dis Let me know if im wrong.

jcrodriguez-dis commented 5 years ago

Sorry, Alejandro, this is an outdated comment. The correct comment must be

# Jail filesystem structure $JAILPATH overlayfs of / with nosuid by default
# $JAILPATH____ dev #Real dir by mount --bind 
#          |     |___ pts #Real dir by mount --bind
#          |     |___ shm #New tmpfs
#          |___ etc      #Replaced passwd and group 
#          |___ home  #Relaced dir to create suitable prisoner home dir 
#          |___ proc    #Real dir by mount --bind 
#          |___ run      #Real dir by mount --bind 
#          |     |___ lock #Real dir by mount --bind 
alphonse92 commented 5 years ago

@jcrodriguez-dis thanks for your clarification. But related to the @guiga-zalu issue, i mean the problem is the context that the process prisoner for a vpl execution. Global node modules exists in another context, not in the prisoner context. @jcrodriguez-dis Maybe, could u add a way to customize the prisoner file system?

The steps to modify the prisoner context is:

Warning always that you restart your jail process you should repeat the next steps:

  1. Locate /jail
  2. That folder contains the schema to construct the prisoner filesystem
  3. Add your node modules global packages there
  4. The prisoners CANT resolve hosts, so, maybe you need to add some hosts to /jail/etc/hosts

Enjoy!

@jcrodriguez-dis let me know if im right

jcrodriguez-dis commented 5 years ago

Apologize for my ignorance about the Docker contexts, but I think that the approach of installing the software at each service start is slow and requires knowing the set of packages to install. About the limitations of access to the DNS service from the student code, I think that is related to the firewall configuration managed from VPL (that may be wrong), and I believe that the use of the /etc/hosts file is a not general solution requiring manual intervention. About the @guiga-zalu issue, I did not get to install and use the nodejs modules to run outside VPL, this is the first step to resolve problems of running code inside VPL.

Best regards, Juan Carlos.

alphonse92 commented 5 years ago

Of course, that process gets slowly, but i recommend to node js users to avoid to use another dependencies. Just keep mocha and unit testing libraries.

Dont worry, i was not talking about docker context. I was talking about the file system that the jail mounts every time that create a execution process