]> mj.ucw.cz Git - eval.git/blobdiff - submit/submitd.c
Added command-line clients for remote submit and status.
[eval.git] / submit / submitd.c
index 22be143b6aad69f635c0dec767fc7306fa5493d1..b3c39280614d0e12ae8399b40ae0dd83dbace72e 100644 (file)
@@ -7,6 +7,7 @@
 /*
  *  FIXME:
  *     - competition timeout & per-contestant exceptions
+ *     - open-data problems
  */
 
 #undef LOCAL_DEBUG
@@ -54,15 +55,7 @@ static struct cf_section access_conf = {
   }
 };
 
-static byte *
-config_init(void)
-{
-  clist_init(&access_rules);
-  return NULL;
-}
-
 static struct cf_section submitd_conf = {
-  CF_INIT(config_init),
   CF_ITEMS {
     CF_UNS("Port", &port),
     CF_UNS("DHBits", &dh_bits),
@@ -105,6 +98,8 @@ conn_new(void)
 static void
 conn_free(struct conn *c)
 {
+  xfree(c->ip_string);
+  xfree(c->cert_name);
   clist_remove(&c->n);
   num_conn--;
   xfree(c);
@@ -249,9 +244,9 @@ tls_log_params(struct conn *c)
     proto, kx, cert, comp, cipher, mac);
 }
 
-/*** SOCKET FASTBUFS ***/
+/*** FASTBUFS OVER SOCKETS AND TLS ***/
 
-void NONRET
+void NONRET                            // Fatal protocol violation
 client_error(char *msg, ...)
 {
   va_list args;
@@ -353,6 +348,7 @@ sigalrm_handler(int sig UNUSED)
 static void
 client_loop(struct conn *c)
 {
+  setproctitle("submitd: client %s", c->ip_string);
   log_pid = c->id;
   init_sk_fastbufs(c);
 
@@ -387,12 +383,15 @@ client_loop(struct conn *c)
   if (!process_init(c))
     log(L_ERROR, "Protocol handshake failed");
   else
-    for (;;)
-      {
-       alarm(session_timeout);
-       if (!process_command(c))
-         break;
-      }
+    {
+      setproctitle("submitd: client %s (%s)", c->ip_string, c->user);
+      for (;;)
+       {
+         alarm(session_timeout);
+         if (!process_command(c))
+           break;
+       }
+    }
 
   if (c->tls)
     gnutls_bye(c->tls, GNUTLS_SHUT_WR);
@@ -493,6 +492,7 @@ sk_accept(void)
        (rule->plain_text ? "plain-text" : "TLS"),
        (rule->allow_admin ? "admin" : "user"));
   c->ip = addr;
+  c->ip_string = xstrdup(ipbuf);
   c->sk = sk;
   c->rule = rule;
 
@@ -531,6 +531,7 @@ int main(int argc, char **argv)
   setproctitle_init(argc, argv);
   cf_def_file = "config";
   cf_declare_section("SubmitD", &submitd_conf, 0);
+  cf_declare_section("Tasks", &tasks_conf, 0);
 
   int opt;
   if ((opt = cf_getopt(argc, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL)) >= 0)
@@ -551,6 +552,7 @@ int main(int argc, char **argv)
 
   for (;;)
     {
+      setproctitle("submitd: %d connections", num_conn);
       int status;
       pid_t pid = waitpid(-1, &status, WNOHANG);
       if (pid > 0)