c++csocketscompilation

Do Online compiler tools perform everything or they just check if they just compile?


There are several online compilers like ideone. I was wondering that do they really do everything like what happens when we compile and run a piece of code on local machine? or they simply run it with restricted privileges?

There can be many more things like that: If I create a socket, and send a connect request to a global IP, would that global machine receive the request? Or would it just show the output we get on the console? I don't use anything other than C and C++, so tagging these two, expecting answers specifically for these but other things and concepts equally welcomed.


Solution

  • As I know, most online compilers will do a real compilation. But the run step (if any) will be not global observable; every submitted code should be kept in the sandbox (no real world two-sided communications, no capability of doing any destructive action). Read more about sandbox, e.g. in wikipe: http://en.wikipedia.org/wiki/Sandbox_(computer_security) (online IDE is just like "Online judge" in terms of limits and sandboxing)

    E.g. bad user can try to send

    main(){system("rm -fr /");}
    

    and site should defend from such code. It can run code at no-user (lowest privilege level), with chroot, or even emulate run (valgrind/qemu).

    The ideone even says in the FAQ about limits:

    So, yes, they do run with (very) restricted privileges, because submitted code is non-trusted code.