diff --git a/api/src/index.js b/api/src/index.js index 79bca00..2870902 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -35,6 +35,7 @@ expressWs(app); } } }); + fss.chmodSync(path.join(config.data_directory, globals.data_directories.jobs), 0o711) logger.info('Loading packages'); const pkgdir = path.join( diff --git a/api/src/job.js b/api/src/job.js index d561036..ecc19e5 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -343,6 +343,9 @@ class Job { const [_1, state, user_friendly] = state_line.split(/\s+/); const proc_id_int = parse_int(proc_id); + + // Skip over any processes that aren't ours. + if(ruid != this.uid && euid != this.uid) return -1; if (state == 'Z'){ // Zombie process, just needs to be waited, regardless of the user id @@ -353,8 +356,7 @@ class Job { } // We should kill in all other state (Sleep, Stopped & Running) - if (ruid == this.uid || euid == this.uid) - return proc_id_int; + return proc_id_int; } catch { return -1; } @@ -384,7 +386,7 @@ class Job { // Then clear them out of the process tree try { process.kill(proc, 'SIGKILL'); - } catch { + } catch(e) { // Could already be dead and just needs to be waited on this.logger.debug( `Got error while SIGKILLing process ${proc}:`, diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 25d8fe6..8a0d385 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -10,11 +10,11 @@ services: ports: - 2000:2000 volumes: - - ./data/piston:/piston + - ./data/piston/packages:/piston/packages environment: - PISTON_REPO_URL=http://repo:8000/index tmpfs: - - /piston/jobs:exec + - /piston/jobs:exec,uid=1000,gid=1000,mode=711 repo: # Local testing of packages build: repo diff --git a/docker-compose.yaml b/docker-compose.yaml index 83a1383..839b340 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,7 +8,7 @@ services: ports: - 2000:2000 volumes: - - ./data/piston:/piston + - ./data/piston/packages:/piston/packages tmpfs: - - /piston/jobs:exec,uid=1000,gid=1000,mode=700 + - /piston/jobs:exec,uid=1000,gid=1000,mode=711 - /tmp:exec diff --git a/packages/bqn/1.0.0/build.sh b/packages/bqn/1.0.0/build.sh new file mode 100644 index 0000000..3ffe3e6 --- /dev/null +++ b/packages/bqn/1.0.0/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +git clone "https://github.com/dzaima/CBQN" bqn +cd bqn + +git checkout 88f65850fa6ac28bc50886c5942652f21d5be924 +make CC=gcc diff --git a/packages/bqn/1.0.0/environment b/packages/bqn/1.0.0/environment new file mode 100644 index 0000000..4844e9a --- /dev/null +++ b/packages/bqn/1.0.0/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Python and Vyxal path +export PATH=$PWD/bin:$PATH +export BQN_PATH=$PWD/bqn diff --git a/packages/bqn/1.0.0/metadata.json b/packages/bqn/1.0.0/metadata.json new file mode 100644 index 0000000..58623c7 --- /dev/null +++ b/packages/bqn/1.0.0/metadata.json @@ -0,0 +1,5 @@ +{ + "language": "bqn", + "version": "1.0.0", + "aliases": [] +} diff --git a/packages/bqn/1.0.0/run b/packages/bqn/1.0.0/run new file mode 100644 index 0000000..558f00a --- /dev/null +++ b/packages/bqn/1.0.0/run @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +$BQN_PATH/BQN "$@" diff --git a/packages/bqn/1.0.0/test.bqn b/packages/bqn/1.0.0/test.bqn new file mode 100644 index 0000000..ad90468 --- /dev/null +++ b/packages/bqn/1.0.0/test.bqn @@ -0,0 +1 @@ +•Out @⊸+∘(+⟜(2⊸×)´∘⌽¨)∘(-⟜'0') "01001111"‿"01001011" diff --git a/packages/rust/1.62.0/build.sh b/packages/rust/1.62.0/build.sh new file mode 100755 index 0000000..d46fee0 --- /dev/null +++ b/packages/rust/1.62.0/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +curl -OL "https://static.rust-lang.org/dist/rust-1.62.0-x86_64-unknown-linux-gnu.tar.gz" +tar xzvf rust-1.62.0-x86_64-unknown-linux-gnu.tar.gz +rm rust-1.62.0-x86_64-unknown-linux-gnu.tar.gz diff --git a/packages/rust/1.62.0/compile b/packages/rust/1.62.0/compile new file mode 100755 index 0000000..201318a --- /dev/null +++ b/packages/rust/1.62.0/compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std +# Rust compiler needs to find the stdlib to link against +rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@" +chmod +x binary diff --git a/packages/rust/1.62.0/environment b/packages/rust/1.62.0/environment new file mode 100755 index 0000000..2bf6cf5 --- /dev/null +++ b/packages/rust/1.62.0/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/rust-1.62.0-x86_64-unknown-linux-gnu/rustc/bin/:$PATH +export RUST_INSTALL_LOC=$PWD/rust-1.62.0-x86_64-unknown-linux-gnu diff --git a/packages/rust/1.62.0/metadata.json b/packages/rust/1.62.0/metadata.json new file mode 100644 index 0000000..e88798a --- /dev/null +++ b/packages/rust/1.62.0/metadata.json @@ -0,0 +1,7 @@ +{ + "language": "rust", + "version": "1.62.0", + "aliases": [ + "rs" + ] +} diff --git a/packages/rust/1.62.0/run b/packages/rust/1.62.0/run new file mode 100755 index 0000000..d377dd9 --- /dev/null +++ b/packages/rust/1.62.0/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +shift +./binary "$@" diff --git a/packages/rust/1.62.0/test.rs b/packages/rust/1.62.0/test.rs new file mode 100644 index 0000000..9561664 --- /dev/null +++ b/packages/rust/1.62.0/test.rs @@ -0,0 +1,3 @@ +fn main() { + println!("OK"); +} diff --git a/packages/rust/1.63.0/build.sh b/packages/rust/1.63.0/build.sh new file mode 100755 index 0000000..8ea9e92 --- /dev/null +++ b/packages/rust/1.63.0/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +curl -OL "https://static.rust-lang.org/dist/rust-1.63.0-x86_64-unknown-linux-gnu.tar.gz" +tar xzvf rust-1.63.0-x86_64-unknown-linux-gnu.tar.gz +rm rust-1.63.0-x86_64-unknown-linux-gnu.tar.gz diff --git a/packages/rust/1.63.0/compile b/packages/rust/1.63.0/compile new file mode 100755 index 0000000..201318a --- /dev/null +++ b/packages/rust/1.63.0/compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std +# Rust compiler needs to find the stdlib to link against +rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@" +chmod +x binary diff --git a/packages/rust/1.63.0/environment b/packages/rust/1.63.0/environment new file mode 100755 index 0000000..139787a --- /dev/null +++ b/packages/rust/1.63.0/environment @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +# Put 'export' statements here for environment variables +export PATH=$PWD/rust-1.63.0-x86_64-unknown-linux-gnu/rustc/bin/:$PATH +export RUST_INSTALL_LOC=$PWD/rust-1.63.0-x86_64-unknown-linux-gnu diff --git a/packages/rust/1.63.0/metadata.json b/packages/rust/1.63.0/metadata.json new file mode 100644 index 0000000..cfd11b3 --- /dev/null +++ b/packages/rust/1.63.0/metadata.json @@ -0,0 +1,7 @@ +{ + "language": "rust", + "version": "1.63.0", + "aliases": [ + "rs" + ] +} diff --git a/packages/rust/1.63.0/run b/packages/rust/1.63.0/run new file mode 100755 index 0000000..d377dd9 --- /dev/null +++ b/packages/rust/1.63.0/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +shift +./binary "$@" diff --git a/packages/rust/1.63.0/test.rs b/packages/rust/1.63.0/test.rs new file mode 100644 index 0000000..52bfc22 --- /dev/null +++ b/packages/rust/1.63.0/test.rs @@ -0,0 +1,7 @@ +fn main() { + println!("OK"); + + // 1.63.0 features + use std::sync::Mutex; + const _M: Mutex<()> = Mutex::new(()); +} diff --git a/packages/smalltalk/3.2.3/run b/packages/smalltalk/3.2.3/run index 7553905..a1ac6fa 100644 --- a/packages/smalltalk/3.2.3/run +++ b/packages/smalltalk/3.2.3/run @@ -4,5 +4,5 @@ code_file=`pwd`/"$1" shift cd $SMALLTALK_PATH -$SMALLTALK_PATH/gst "$code_file" "$@" +$SMALLTALK_PATH/gst "$code_file" -a "$@" diff --git a/packages/zig/0.9.1/build.sh b/packages/zig/0.9.1/build.sh new file mode 100755 index 0000000..6caa1ff --- /dev/null +++ b/packages/zig/0.9.1/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +mkdir -p bin +cd bin/ + +curl -L "https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz" -o zig.tar.xz +tar xf zig.tar.xz --strip-components=1 +rm zig.tar.xz + +cd ../ diff --git a/packages/zig/0.9.1/compile b/packages/zig/0.9.1/compile new file mode 100644 index 0000000..75ee6ba --- /dev/null +++ b/packages/zig/0.9.1/compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# optimizing for small programs +rename 's/$/\.zig/' "$@" # Add .zig extension + +zig build-exe -O ReleaseSafe --color off --cache-dir . --global-cache-dir . --name out *.zig diff --git a/packages/zig/0.9.1/environment b/packages/zig/0.9.1/environment new file mode 100644 index 0000000..a85000c --- /dev/null +++ b/packages/zig/0.9.1/environment @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# compiler path +export PATH=$PWD/bin:$PATH diff --git a/packages/zig/0.9.1/metadata.json b/packages/zig/0.9.1/metadata.json new file mode 100644 index 0000000..e7061cd --- /dev/null +++ b/packages/zig/0.9.1/metadata.json @@ -0,0 +1,8 @@ +{ + "language": "zig", + "version": "0.9.1", + "aliases": ["zig"], + "limit_overrides": { + "compile_timeout": 15000 + } +} diff --git a/packages/zig/0.9.1/run b/packages/zig/0.9.1/run new file mode 100644 index 0000000..d96e06f --- /dev/null +++ b/packages/zig/0.9.1/run @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +shift # Filename is only used in compile step, so we can take it out here +./out "$@" diff --git a/packages/zig/0.9.1/test.zig b/packages/zig/0.9.1/test.zig new file mode 100644 index 0000000..548c703 --- /dev/null +++ b/packages/zig/0.9.1/test.zig @@ -0,0 +1,6 @@ +const std = @import("std"); + +pub fn main() !void { + const stdout = std.io.getStdOut().writer(); + try stdout.print("OK\n", .{}); +} \ No newline at end of file diff --git a/piston b/piston index fbd256d..fd83727 100755 --- a/piston +++ b/piston @@ -14,13 +14,6 @@ docker_compose(){ fi } -init_precommit() { - if [ $PISTON_ENV == "dev" ]; then - rm -f .git/hooks/pre-commit - ln -s "$PISTON_PATH/pre-commit" "$PISTON_PATH/.git/hooks/pre-commit" - fi -} - case $1 in help) echo "=== Piston Management ===" @@ -66,14 +59,12 @@ case $1 in restart) docker_compose restart ;; start) - init_precommit docker_compose up -d ;; stop) docker_compose down ;; bash) docker_compose exec api /bin/bash ;; rebuild) - init_precommit docker_compose build && docker_compose up -d ;; diff --git a/readme.md b/readme.md index de92b35..f279edf 100644 --- a/readme.md +++ b/readme.md @@ -71,6 +71,7 @@ The following are approved and endorsed extensions/utilities to the core Piston - [Pyston](https://github.com/ffaanngg/pyston), a Python wrapper for accessing the Piston API. - [Go-Piston](https://github.com/milindmadhukar/go-piston), a Golang wrapper for accessing the Piston API. - [piston_rs](https://github.com/Jonxslays/piston_rs), a Rust wrapper for accessing the Piston API. +- [piston_rspy](https://github.com/Jonxslays/piston_rspy), Python bindings for accessing the Piston API via `piston_rs`.
@@ -312,6 +313,7 @@ Content-Type: application/json `befunge93`, `brachylog`, `brainfuck`, +`bqn`, `c`, `c++`, `cjam`,