From 9851352f87a7dbbc9b4e032c86420f93b407e6a9 Mon Sep 17 00:00:00 2001 From: Vrganj Date: Sun, 17 Jan 2021 15:44:40 +0000 Subject: [PATCH] Move runuser to execute --- lxc/execute | 2 +- lxc/executors/awk | 2 +- lxc/executors/bash | 6 ++---- lxc/executors/brainfuck | 6 ++---- lxc/executors/c | 8 +++----- lxc/executors/cpp | 8 +++----- lxc/executors/csharp | 8 +++----- lxc/executors/deno | 6 ++---- lxc/executors/elixir | 6 ++---- lxc/executors/emacs | 6 ++---- lxc/executors/go | 10 ++++------ lxc/executors/haskell | 10 ++++------ lxc/executors/java | 10 +++------- lxc/executors/jelly | 6 ++---- lxc/executors/julia | 6 ++---- lxc/executors/kotlin | 10 ++++------ lxc/executors/lua | 6 ++---- lxc/executors/nasm | 10 ++++------ lxc/executors/nasm64 | 10 ++++------ lxc/executors/node | 6 ++---- lxc/executors/paradoc | 6 ++---- lxc/executors/perl | 6 ++---- lxc/executors/php | 6 ++---- lxc/executors/python2 | 6 ++---- lxc/executors/python3 | 6 ++---- lxc/executors/ruby | 6 ++---- lxc/executors/rust | 8 +++----- lxc/executors/swift | 6 ++---- lxc/executors/typescript | 14 ++++++-------- lxc/start | 2 +- 30 files changed, 76 insertions(+), 132 deletions(-) diff --git a/lxc/execute b/lxc/execute index 29c445b..d7e5b22 100755 --- a/lxc/execute +++ b/lxc/execute @@ -41,7 +41,7 @@ exec 200>&- # runner timeout -s KILL 20 \ lxc-attach --clear-env -n piston -- \ - /bin/bash -l -c "bash /exec/$lang $newinc $epoch" + /bin/bash -l -c "runuser runner$newinc /exec/$lang $newinc $epoch" # process janitor lxc-attach --clear-env -n piston -- \ diff --git a/lxc/executors/awk b/lxc/executors/awk index 26723b3..67cdee8 100755 --- a/lxc/executors/awk +++ b/lxc/executors/awk @@ -1,4 +1,4 @@ cd /tmp/$2 timeout -s KILL 2 sed "/___code___/Q" code.code > code.stdin timeout -s KILL 2 sed "1,/___code___/d" code.code > code.awk -runuser runner$1 -c "cd /tmp/$2 ; timeout -s KILL 3 awk -f code.awk < code.stdin" +timeout -s KILL 3 awk -f code.awk < code.stdin diff --git a/lxc/executors/bash b/lxc/executors/bash index 04ebb1c..6aeb899 100755 --- a/lxc/executors/bash +++ b/lxc/executors/bash @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - xargs -a args.args -d '\n' timeout -s KILL 3 bash code.code < stdin.stdin -" +cd /tmp/$2 +xargs -a args.args -d '\n' timeout -s KILL 3 bash code.code < stdin.stdin diff --git a/lxc/executors/brainfuck b/lxc/executors/brainfuck index 0503bcf..7ec1bfe 100755 --- a/lxc/executors/brainfuck +++ b/lxc/executors/brainfuck @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' brainfuck code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' brainfuck code.code < stdin.stdin diff --git a/lxc/executors/c b/lxc/executors/c index 8d60422..096b1d9 100755 --- a/lxc/executors/c +++ b/lxc/executors/c @@ -1,7 +1,5 @@ #!/usr/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - gcc -std=c11 -o binary -x c code.code - timeout -s KILL 3 xargs -a args.args ./binary < stdin.stdin -" +cd /tmp/$2 +gcc -std=c11 -o binary -x c code.code +timeout -s KILL 3 xargs -a args.args ./binary < stdin.stdin diff --git a/lxc/executors/cpp b/lxc/executors/cpp index 8602962..5f7008b 100755 --- a/lxc/executors/cpp +++ b/lxc/executors/cpp @@ -1,7 +1,5 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - g++ -std=c++17 -o binary -x c++ code.code - timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin -" +cd /tmp/$2 +g++ -std=c++17 -o binary -x c++ code.code +timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/csharp b/lxc/executors/csharp index 4946e27..f35c876 100755 --- a/lxc/executors/csharp +++ b/lxc/executors/csharp @@ -1,7 +1,5 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary - timeout -s KILL 3 xargs -a args.args -d '\n' mono binary < stdin.stdin -" +cd /tmp/$2 +mcs $(echo code.code | sed 's/\///') -nowarn:0219 -out:binary +timeout -s KILL 3 xargs -a args.args -d '\n' mono binary < stdin.stdin diff --git a/lxc/executors/deno b/lxc/executors/deno index a18c647..31132fa 100755 --- a/lxc/executors/deno +++ b/lxc/executors/deno @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' deno run code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' deno run code.code < stdin.stdin diff --git a/lxc/executors/elixir b/lxc/executors/elixir index 0343cf1..49bfb78 100755 --- a/lxc/executors/elixir +++ b/lxc/executors/elixir @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' elixir code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' elixir code.code < stdin.stdin diff --git a/lxc/executors/emacs b/lxc/executors/emacs index 3a64ecc..ab41624 100755 --- a/lxc/executors/emacs +++ b/lxc/executors/emacs @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' emacs -Q --script code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' emacs -Q --script code.code < stdin.stdin diff --git a/lxc/executors/go b/lxc/executors/go index a9aa4fd..09c1e68 100755 --- a/lxc/executors/go +++ b/lxc/executors/go @@ -1,8 +1,6 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - cp code.code interim.go - go build interim.go - timeout -s KILL 3 xargs -a args.args -d '\n' ./interim < stdin.stdin -" +cd /tmp/$2 +cp code.code interim.go +go build interim.go +timeout -s KILL 3 xargs -a args.args -d '\n' ./interim < stdin.stdin diff --git a/lxc/executors/haskell b/lxc/executors/haskell index bc13034..df517d9 100755 --- a/lxc/executors/haskell +++ b/lxc/executors/haskell @@ -1,8 +1,6 @@ #!/bin/bash -runuser runner$1 -c "\ - cd /tmp/$2 - cp code.code code.hs - ghc -dynamic -o binary code.hs > /dev/null 2>&1 - timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin -" +cd /tmp/$2 +cp code.code code.hs +ghc -dynamic -o binary code.hs > /dev/null 2>&1 +timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/java b/lxc/executors/java index 12ac347..52f4cf0 100755 --- a/lxc/executors/java +++ b/lxc/executors/java @@ -2,10 +2,6 @@ cd /tmp/$2 name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface)\s+\K([^\/\\\n\s{]+)" code.code) - -runuser runner$1 -c " - cd /tmp/$2 - cp code.code $name.java - javac $name.java - timeout -s KILL 3 xargs -a args.args -d '\n' java $name < stdin.stdin -" +cp code.code $name.java +javac $name.java +timeout -s KILL 3 xargs -a args.args -d '\n' java $name < stdin.stdin diff --git a/lxc/executors/jelly b/lxc/executors/jelly index 0c1b343..945444e 100755 --- a/lxc/executors/jelly +++ b/lxc/executors/jelly @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' jelly fu code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' jelly fu code.code < stdin.stdin diff --git a/lxc/executors/julia b/lxc/executors/julia index 4350335..e8b4ea5 100755 --- a/lxc/executors/julia +++ b/lxc/executors/julia @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' julia code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' julia code.code < stdin.stdin diff --git a/lxc/executors/kotlin b/lxc/executors/kotlin index efd00e0..c304575 100755 --- a/lxc/executors/kotlin +++ b/lxc/executors/kotlin @@ -1,8 +1,6 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - cp code.code code.kt - kotlinc code.kt -include-runtime -d code.jar - timeout -s KILL 3 xargs -a args.args -d '\n' java -jar code.jar < stdin.stdin -" +cd /tmp/$2 +cp code.code code.kt +kotlinc code.kt -include-runtime -d code.jar +timeout -s KILL 3 xargs -a args.args -d '\n' java -jar code.jar < stdin.stdin diff --git a/lxc/executors/lua b/lxc/executors/lua index c318a87..4caa4b6 100755 --- a/lxc/executors/lua +++ b/lxc/executors/lua @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' lua code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' lua code.code < stdin.stdin diff --git a/lxc/executors/nasm b/lxc/executors/nasm index f48e5bc..ffe8fd0 100755 --- a/lxc/executors/nasm +++ b/lxc/executors/nasm @@ -1,8 +1,6 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - nasm -f elf32 -o binary.o code.code - ld -m elf_i386 binary.o -o binary - timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin -" +cd /tmp/$2 +nasm -f elf32 -o binary.o code.code +ld -m elf_i386 binary.o -o binary +timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/nasm64 b/lxc/executors/nasm64 index 23ad450..98c2aab 100755 --- a/lxc/executors/nasm64 +++ b/lxc/executors/nasm64 @@ -1,8 +1,6 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - nasm -f elf64 -o binary.o code.code - ld -m elf_x86_64 binary.o -o binary - timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin -" +cd /tmp/$2 +nasm -f elf64 -o binary.o code.code +ld -m elf_x86_64 binary.o -o binary +timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/node b/lxc/executors/node index b43fff0..3262b53 100755 --- a/lxc/executors/node +++ b/lxc/executors/node @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' node code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' node code.code < stdin.stdin diff --git a/lxc/executors/paradoc b/lxc/executors/paradoc index 08e6e2c..be58dad 100755 --- a/lxc/executors/paradoc +++ b/lxc/executors/paradoc @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 python3 -m paradoc code.code < args.args -" +cd /tmp/$2 +timeout -s KILL 3 python3 -m paradoc code.code < args.args diff --git a/lxc/executors/perl b/lxc/executors/perl index 8657564..8b65855 100755 --- a/lxc/executors/perl +++ b/lxc/executors/perl @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' perl code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' perl code.code < stdin.stdin diff --git a/lxc/executors/php b/lxc/executors/php index 2acacb9..9f21f7b 100755 --- a/lxc/executors/php +++ b/lxc/executors/php @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' php code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' php code.code < stdin.stdin diff --git a/lxc/executors/python2 b/lxc/executors/python2 index ab90f29..5fa1c3e 100755 --- a/lxc/executors/python2 +++ b/lxc/executors/python2 @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' python code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' python code.code < stdin.stdin diff --git a/lxc/executors/python3 b/lxc/executors/python3 index a944242..6cb93f8 100755 --- a/lxc/executors/python3 +++ b/lxc/executors/python3 @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' python3.8 code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' python3.8 code.code < stdin.stdin diff --git a/lxc/executors/ruby b/lxc/executors/ruby index 9407d75..ebb9b06 100755 --- a/lxc/executors/ruby +++ b/lxc/executors/ruby @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' ruby code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' ruby code.code < stdin.stdin diff --git a/lxc/executors/rust b/lxc/executors/rust index 9dc32ea..137dffa 100755 --- a/lxc/executors/rust +++ b/lxc/executors/rust @@ -1,7 +1,5 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - rustc -o binary code.code - timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin -" +cd /tmp/$2 +rustc -o binary code.code +timeout -s KILL 3 xargs -a args.args -d '\n' ./binary < stdin.stdin diff --git a/lxc/executors/swift b/lxc/executors/swift index 6e0565d..a8327f7 100755 --- a/lxc/executors/swift +++ b/lxc/executors/swift @@ -1,6 +1,4 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - timeout -s KILL 3 xargs -a args.args -d '\n' swift code.code < stdin.stdin -" +cd /tmp/$2 +timeout -s KILL 3 xargs -a args.args -d '\n' swift code.code < stdin.stdin diff --git a/lxc/executors/typescript b/lxc/executors/typescript index 20a382f..8c1873d 100755 --- a/lxc/executors/typescript +++ b/lxc/executors/typescript @@ -1,10 +1,8 @@ #!/bin/bash -runuser runner$1 -c " - cd /tmp/$2 - mv code.code interim.ts - tsc interim.ts - rm -f interim.ts - mv interim.js code.code - xargs -a args.args -d '\n' timeout -s KILL 3 node code.code < stdin.stdin -" +cd /tmp/$2 +mv code.code interim.ts +tsc interim.ts +rm -f interim.ts +mv interim.js code.code +timeout -s KILL 3 xargs -a args.args -d '\n' node code.code < stdin.stdin diff --git a/lxc/start b/lxc/start index 6c13c98..fec7aef 100755 --- a/lxc/start +++ b/lxc/start @@ -3,7 +3,7 @@ mkdir -p /var/lib/lxc/piston/rootfs/exec rm -f /var/lib/lxc/piston/rootfs/exec/* cp -f executors/* /var/lib/lxc/piston/rootfs/exec -chmod 700 /var/lib/lxc/piston/rootfs/exec/* +chmod 555 /var/lib/lxc/piston/rootfs/exec/* chown -R root:root /var/lib/lxc/piston/rootfs/exec lxc-start -n piston -d