Skip to content

anomit/loki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

As it might be already clear from the small description, I’m trying to create a full fledged online judge. On a personal level, I’m doing it to get a better idea about programming in the linux environment.

Getting Started

The web interface

Dump the whole ‘judge’ directory in your apache document root directory. Keep in mind though that the document root direcotry should be within the chroot jail, otherwise the backend can’t access the saved files.

You’ll also need the Smarty templating system installed. To change the path where you have installed Smarty look in the config.php file. I’ve included the only template file used so far now, index.tpl with the code. I hope someone will take up the work on the template and beautify it so that I don’t have to bother with the design :)

Also create a mysql database named judge and import the sql provided.

The php script that accepts the source code sumbmissions(submit.php) has to write them to a file within the ‘files’ subdir under the ‘judge’ dir. So you’d need to give the apache server’s username and group ownership of this directory (yeah 777 you’d say, but it’s too dangerous). For Ubuntu/Debian based installations, it is `chown www-data:www-data files`. If you’ve better ideas about doing this, please tell me.

The backend

You need to specify the mysql username, password in the backend/main.c file.

Also look in the main.c file to change the location of the chroot_jail and also where the submitted files and executables can be found.

Installing

All these done, go to the backend dir and type in

make judge

to get the executable file ‘judge’. Now run it as root.

TODOs and Issues

Right now this is offers a very basic level of functionality and a lot of things need to be added. I have TODO-ed them within the source code but still I’ll list a few things that deserve immediate attention:

  • Make a whitelist(or blacklist?) of system calls that’ll be intercepted by ptrace() in exec.c (Work in progress. Suggestions are more than welcome)
  • This currently compiles and executes only C code. Make pluggable modules for source codes submitted in different languages maybe?
  • Improve the web interface that drives the system. Right now it offers basically nothing.
  • Make a conf file parser to make the system more customizable. No one wants to hack the code to get it running.
  • Right now the backend is asynchronous, to use a fancy term. Running it in an infinite loop doesn’t make any sense. I’m sure it’d crash the system when it doesn’t have anything to do like fetch something from the database and process. But a perfectly synchronous backend can’t be a solution as well. At least I don’t know how responding to each code submission would have an effect on the system (another fancy term: scaling). A middle ground needs to be adopted, like some kinda messaging system between the php script and the backend where the backend swings into action after applying a smart algorithm to the pending requests. Suggestions are more than welcome regarding this part.
  • Redirect the STDIN and STDOUT to the problem input file and an output file in the forked child (exec.c)
  • Work on the design of the web interface as well as adding a lot of other actions like checking scores for submitted code and history of code submissions, both on an individual as well as public scale.
  • Get the system to run in a chroot jail. This now runs inside a chroot jail, specifically on a debootstrap installation on which I have tested.

Dependencies

If you are indeed trying this out, you are sure to run into some problems and miss some libraries that are not listed here. Please contact me so that I can update this list.

  • mysqlclient library
  • Smarty templating system
  • The usual LAMP stack

About

An attempt at making an automated online judge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published