0

我正在编写一个像 spoj.pl 这样的在线编码 jude 网站,并且我正在创建一个用于编译和执行程序的监狱。我写了一个脚本,它采用 c/c++ 源代码,编译并运行代码。我需要在 debootstrap 创建的监狱中执行此程序,但我必须限制对我的脚本的权限并允许二进制文件仅读取原始 /home/ubuntu 系统中存在的输入/输出文件。

可能吗 ?

Linux system:
/home/ubuntu:
   This folder has 
   online_judge/scripts.py ...
   input_output/input*.txt,output*.txt

/Jail 
    submissions/code.c
    submissions/code.cpp

我需要使用受限的监狱用户在监狱中调用 /home/ubuntu 的 scripts.py,编译代码并运行二进制文件。Jail 用户永远不能访问任何 /home/ubuntu 文件,除了 input_output/input*txt 我可以授予然后执行权限

4

2 回答 2

0

You need to use debootstrap you can download the necessary compiling toolchains. so instead of trying using existing systems toolchain use from debootstrap's provided toolchain or also you can download toolchain via apt-get from the jail inside. If all fails, then try using scratchbox (www.scratchbox.org), it contains all the compiling toolchain you need also an execution environment. Hope it'll help!

于 2013-08-11T06:52:44.033 回答
0

我需要使用受限的监狱用户在监狱中调用 /home/ubuntu 的 scripts.py,

你说scripts.py 位于/home/ubuntu/online_judge,它不在/Jail 中。因此,无论您是否将监狱用户限制为 /Jail。如果受限制的监狱用户应该执行 online_judge/scripts.py,你必须让它在 /Jail 下的某个地方可以访问。

Jail 用户永远不能访问任何 /home/ubuntu 文件,除了 input_output/input*txt 我可以授予然后执行权限

硬链接可能会有所帮助,例如“ln /home/ubuntu/online_judge/scripts.py /Jail/scripts.py”,现在受限制的监狱用户可以通过 /Jail/scripts.py 访问 scripts.py。一定要限制对该文件的写访问,否则他/她会修改两个“副本”。

于 2013-08-11T00:20:42.897 回答