From: Marius Gavrilescu Date: Mon, 10 Feb 2014 09:23:17 +0000 (+0200) Subject: Support getting infiles/okfiles from the filesystem X-Git-Tag: 5999.000_002~6 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=8a8d1a82a2a778c546569ea1e6745be4594a0ff5;p=gruntmaster-daemon.git Support getting infiles/okfiles from the filesystem --- diff --git a/lib/Gruntmaster/Daemon.pm b/lib/Gruntmaster/Daemon.pm index 7166a42..9a02adb 100644 --- a/lib/Gruntmaster/Daemon.pm +++ b/lib/Gruntmaster/Daemon.pm @@ -63,6 +63,7 @@ sub process{ my %files = exists $meta->{files} ? %{$meta->{files}} : (); $meta = { %$meta, + problem => $_, (defined problem_generator() ? (generator => problem_generator) : ()), (defined problem_runner() ? (runner => problem_runner) : ()), (defined problem_judge() ? (judge => problem_judge) : ()), diff --git a/lib/Gruntmaster/Daemon/Generator/File.pm b/lib/Gruntmaster/Daemon/Generator/File.pm index 601ea99..fb1dc5e 100644 --- a/lib/Gruntmaster/Daemon/Generator/File.pm +++ b/lib/Gruntmaster/Daemon/Generator/File.pm @@ -4,6 +4,7 @@ use 5.014000; use strict; use warnings; +use File::Copy qw/copy/; use File::Slurp qw/write_file/; use Log::Log4perl qw/get_logger/; @@ -14,7 +15,11 @@ our $VERSION = "5999.000_001"; sub generate{ my ($test, $meta) = @_; get_logger->trace("Generating test $test ..."); - write_file 'input', $meta->{infile}[$test - 1] + if (exists $meta->{infile}) { + write_file 'input', $meta->{infile}[$test - 1] + } else { + copy "/var/lib/gruntmasterd/pb/$meta->{problem}/$test.in", 'input' + } } 1; diff --git a/lib/Gruntmaster/Daemon/Runner/File.pm b/lib/Gruntmaster/Daemon/Runner/File.pm index 6fc66c2..34ea04d 100644 --- a/lib/Gruntmaster/Daemon/Runner/File.pm +++ b/lib/Gruntmaster/Daemon/Runner/File.pm @@ -17,7 +17,12 @@ sub run{ get_logger->trace("Running on test $test..."); $meta->{files}{prog}{run}->($meta->{files}{prog}{name}, fds => [qw/0 input 1 >output/], map {defined $meta->{$_} ? ($_ => $meta->{$_}) : () } qw/timeout olimit mlimit/); my $out = slurp 'output'; - my $ok = $meta->{okfile}[$test - 1]; + my $ok; + if (exists $meta->{okfile}) { + $ok = $meta->{okfile}[$test - 1] + } else { + $ok = slurp "/var/lib/gruntmasterd/pb/$meta->{problem}/$test.ok" + } $out =~ s/^\s+//; $ok =~ s/^\s+//; diff --git a/selinux/gruntmasterd.fc b/selinux/gruntmasterd.fc index f011981..f867ea4 100644 --- a/selinux/gruntmasterd.fc +++ b/selinux/gruntmasterd.fc @@ -3,4 +3,5 @@ /usr/(local/)?bin/gruntmaster-exec gen_context(system_u:object_r:gruntmaster_job_exec_t, s0) /usr/(local/)?bin/gruntmaster-paged gen_context(system_u:object_r:gruntmaster_paged_exec_t, s0) /etc/gruntmasterd(/.*)? gen_context(system_u:object_r:gruntmasterd_etc_t, s0) +/var/lib/gruntmasterd(/.*)? gen_context(system_u:object_r:gruntmasterd_var_lib_t, s0) /var/log/gruntmasterd gen_context(system_u:object_r:gruntmasterd_log_t, s0) diff --git a/selinux/gruntmasterd.te b/selinux/gruntmasterd.te index ed878da..9bcba33 100644 --- a/selinux/gruntmasterd.te +++ b/selinux/gruntmasterd.te @@ -26,6 +26,7 @@ type gruntmasterd_etc_t; type gruntmasterd_exec_t; type gruntmasterd_log_t; type gruntmasterd_tmp_t; +type gruntmasterd_var_lib_t; type gruntmaster_job_t; type gruntmaster_job_exec_t; type gruntmaster_compile_t; @@ -54,6 +55,7 @@ type_transition gruntmasterd_t gruntmaster_job_exec_t : process gruntmaster_job_ type_transition gruntmasterd_t tmp_t : dir gruntmasterd_tmp_t; files_type(gruntmasterd_tmp_t) files_type(gruntmasterd_etc_t) +files_type(gruntmasterd_var_lib_t) # Daemon permissions allow gruntmasterd_t { gruntmaster_compile_t gruntmaster_job_t } : process { sigkill siginh rlimitinh transition }; @@ -71,6 +73,7 @@ allow gruntmasterd_t tmp_t : dir { getattr write search add_name }; gruntmaster_read(bin_t) gruntmaster_read(gruntmaster_compile_exec_t) gruntmaster_read(gruntmasterd_etc_t) +gruntmaster_read(gruntmasterd_var_lib_t) gruntmaster_read(gruntmaster_job_exec_t) gruntmaster_read(httpd_sys_content_t) gruntmaster_read(lib_t)