mirror of
https://github.com/engineer-man/piston.git
synced 2025-06-08 03:06:26 +02:00
handle network, run code as different user than compilation
This commit is contained in:
parent
c94c7577fb
commit
7891b676eb
17 changed files with 30 additions and 24 deletions
|
@ -15,14 +15,13 @@ lang=$1
|
|||
epoch=$(date +%s%3N)
|
||||
basepath="/var/lib/lxc/piston/rootfs"
|
||||
filepath="/tmp/$epoch/code.code"
|
||||
file=$(basename $2)
|
||||
argpath="/tmp/$epoch/args.args"
|
||||
arg=$(basename $argpath)
|
||||
|
||||
# write arg file
|
||||
mkdir -p $basepath/tmp/$epoch
|
||||
chmod 777 $basepath/tmp/$epoch
|
||||
cat $file > $basepath$filepath
|
||||
cat $2 > $basepath$filepath
|
||||
echo "${@:3}" > $basepath$argpath
|
||||
|
||||
bin=
|
||||
|
@ -69,7 +68,6 @@ case "$lang" in
|
|||
esac
|
||||
|
||||
lxc-attach -n piston -- \
|
||||
/bin/su ubuntu \
|
||||
-c "bash /home/ubuntu/$bin $epoch 2>&1 | head -c 65536"
|
||||
/bin/bash -c "PATH=/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin bash /exec/$bin $epoch 2>&1 | head -c 65536"
|
||||
|
||||
rm -rf $basepath/tmp/$epoch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue