summaryrefslogtreecommitdiff
path: root/python/runner/terminator.c
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-14 17:57:09 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-14 17:57:09 +0200
commit520420556ad9f2871cd8c5910645193508cb4082 (patch)
tree08efd34b6c9d3cc071b6c5345b213ec9f7f59dd5 /python/runner/terminator.c
parent7ae2d8824ab59dfbda6eaf7f621b6d3bfdec56e7 (diff)
Use sandbox for testing Python programs
Use interpreter.py for running tests as well as interactive sessions. Signals are now sent with "sandbox <user> kill", so terminator is not needed anymore.
Diffstat (limited to 'python/runner/terminator.c')
-rw-r--r--python/runner/terminator.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/python/runner/terminator.c b/python/runner/terminator.c
deleted file mode 100644
index 9eaca83..0000000
--- a/python/runner/terminator.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-int main(int argc, char* argv[])
-{
- if (argc < 4) {
- fprintf(stderr, "usage: %s USERNAME PID SIGNAL\n", argv[0]);
- return 1;
- }
-
- // switch user (requires root or "setcap cap_setuid,cap_setgid+ep")
- char const* username = argv[1];
- struct passwd const* pw = getpwnam(username);
- if (!pw) {
- fprintf(stderr, "no such user: %s\n", username);
- return 1;
- }
- int ret = 0;
- if ((ret = setgid(pw->pw_gid)) != 0)
- fprintf(stderr, "setgid returned %d\n", ret);
- if ((ret = setuid(pw->pw_uid)) != 0)
- fprintf(stderr, "setuid returned %d\n", ret);
-
- pid_t pid = atol(argv[2]);
- int signum = atoi(argv[3]);
- kill(pid, signum);
- return 0;
-}