From 8b3af4ea3647832046e7f140c78181986429aea9 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 28 Jun 2007 23:03:45 +0200 Subject: [PATCH] Implemented a limit on number of submits of a single task part. --- TODO | 1 - submit/commands.c | 7 +++++++ submit/config | 4 ++++ submit/submitd.c | 4 +++- submit/submitd.h | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 6364c45..f31fbe3 100644 --- a/TODO +++ b/TODO @@ -18,7 +18,6 @@ Installer: New submitter: - Checking of contest time (and per-contestant exceptions) -- Remember hashes - contest: override failed check - contest: local history - contest: task status cache diff --git a/submit/commands.c b/submit/commands.c index cf4ace6..bee9549 100644 --- a/submit/commands.c +++ b/submit/commands.c @@ -207,6 +207,13 @@ cmd_submit(struct conn *c) struct odes *tasko = task_status_find_task(c, task, 1); struct odes *parto = task_status_find_part(tasko, pname, 1); uns current_ver = obj_find_anum(parto, 'V', 0); + if (current_ver >= max_versions) + { + err(c, "Maximum number of submits of this task exceeded"); + bclose(fb); + task_unlock_status(c, 0); + return; + } uns last_ver = 0; uns replaced_ver = 0; for (struct oattr *a = obj_find_attr(parto, 'V' + OBJ_ATTR_SON); a; a=a->same) diff --git a/submit/config b/submit/config index 1b00f46..578c856 100644 --- a/submit/config +++ b/submit/config @@ -21,6 +21,10 @@ MaxRequestSize 4K # This is a default, which can be overriden in task definitions. MaxAttachSize 256K +# Maximum number of versions of a single task part a contestant is allowed +# to submit (0=unlimited) +MaxVersions 50 + # Number of bits for the Diffie-Hellman key exchange DHBits 1024 diff --git a/submit/submitd.c b/submit/submitd.c index 9160cf9..f373618 100644 --- a/submit/submitd.c +++ b/submit/submitd.c @@ -30,6 +30,7 @@ static uns port = 8888; static uns dh_bits = 1024; static uns max_conn = 10; static uns session_timeout; +uns max_versions; static byte *ca_cert_name = "?"; static byte *server_cert_name = "?"; static byte *server_key_name = "?"; @@ -68,6 +69,7 @@ static struct cf_section submitd_conf = { CF_UNS("SessionTimeout", &session_timeout), CF_UNS("MaxRequestSize", &max_request_size), CF_UNS("MaxAttachSize", &max_attachment_size), + CF_UNS("MaxVersions", &max_versions), CF_STRING("CACert", &ca_cert_name), CF_STRING("ServerCert", &server_cert_name), CF_STRING("ServerKey", &server_key_name), @@ -167,7 +169,7 @@ tls_new_session(int sk) int err; err = gnutls_init(&s, GNUTLS_SERVER); TLS_CHECK(gnutls_init); - err = gnutls_set_default_priority(s); TLS_CHECK(gnutls_set_default_priority); // FIXME + err = gnutls_set_default_priority(s); TLS_CHECK(gnutls_set_default_priority); gnutls_credentials_set(s, GNUTLS_CRD_CERTIFICATE, cert_cred); gnutls_certificate_server_set_request(s, GNUTLS_CERT_REQUEST); gnutls_dh_set_prime_bits(s, dh_bits); diff --git a/submit/submitd.h b/submit/submitd.h index 42a8e53..6078eb9 100644 --- a/submit/submitd.h +++ b/submit/submitd.h @@ -50,6 +50,7 @@ struct conn { }; extern uns max_request_size, max_attachment_size, trace_commands; +extern uns max_versions; extern byte *history_format; /* submitd.c */ -- 2.39.5