-1

I'd like to create an auto-testing/grading script for students on a Linux system such that:

  • Any student user can initiate the script at any time.
  • A separate script (with root privileges) copies student code to a non-student-accessible file space, using non-student-accessible unit tests, etc.
  • The user receives limited feedback in the form of a text file generated by the grading script.

In short, I'm looking to create something similar to programming contest submission systems, but allowing richer feedback without revealing all teacher unit testing.

I would imagine that a spooling behavior between one initiating script and one root-permission cron script might be in order. Are there any models/examples of how one might best structure communication between a user-initiated script and a separate root-initiated script for such purposes?

ProfPlum
  • 129
  • 1
  • 8

2 Answers2

0

There are many options.

The things I would mention at the first line:

  • Don't use su; use sudo; there are several reasons for it, and the main reason, that to use su you need the password of the user you want to be and with sudo — you don't;
  • Scripts can't be suid, you must use binaries or just a normal script that will be started using sudo (of course students must have sudoers entry that allows them to use the script);
  • Cron is not that fast, as you may theoretically need; cron runs tasks every minute; please consider inotify usage;
  • To communicate between components of your system you need something that will react in realtime; there are many opensource components/libraries/frameworks that could help you, but I would recommend you to take a look at ZeroMQ and Redis;
  • Results of the scripts' executions/tests can be written either to a filesystem (I think it would be better), or to a DBMS.
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
  • I'm not sure that I understand your response. I certainly don't want students doing sudo. The point here is to separate the student initiated submission script with the privileged testing/evaluation script. This would facilitate encapsulation and hiding of the tests, etc. – ProfPlum Jan 14 '14 at 21:26
0

If you want to stick to shell scripting, the method I suggest for communicating between processes would be to have the root script continually check a named pipe for input (i.e. keep opening it after each eof) and send each input through whatever various tests must be done. Have part of the input be a 'return address' - where to send the result.

This should allow the tests to be performed in a privileged space without exposing any control over the privileged space to the students. The students don't need sudo, and you don't need to pull in libraries. Just have the students pipe their code into a non-privileged script that adds the return address and whatever other markup you may need, which then gives it to the named pipe.

  • Thanks. This sounds like something akin to what I'm looking to do, but I have no experience with writing to or reading from named pipes. Are there tutorials or model examples you would recommend? – ProfPlum Jan 14 '14 at 21:27
  • I've come to understand that named pipes allow communication on the same machine, but not across machines sharing a file system, so named pipes won't work for this purpose. Thanks for the suggestion, though! – ProfPlum Jan 15 '14 at 21:41
  • 1
    Look into using a socket instead of a named pipe in this case. They work almost exactly the same. You could convert a simple client/server 'hello world' into something that invokes your checking system. [Here's a bit on using sockets over a network in linux](http://www.linuxhowtos.org/C_C++/socket.htm) – 1337 on Tuesdays Jan 16 '14 at 04:45
  • Also, if you don't want to use Linux's C interface, other languages such as Python have a library to use sockets. – 1337 on Tuesdays Jan 16 '14 at 04:51
  • Just thought of another strategy: you could use netcat to do the communication, with a root-level script that listens (also using netcat) on the privileged machine. [Netcat](http://en.wikipedia.org/wiki/Netcat) – 1337 on Tuesdays Jan 16 '14 at 04:56