]> mj.ucw.cz Git - eval.git/blob - submit/submitd.h
Improved formatting of login tickets.
[eval.git] / submit / submitd.h
1 /*
2  *  The Submit Daemon
3  *
4  *  (c) 2007 Martin Mares <mj@ucw.cz>
5  */
6
7 #ifndef _SUBMITD_H
8 #define _SUBMITD_H
9
10 #include "lib/clists.h"
11 #include "lib/ipaccess.h"
12 #include "lib/fastbuf.h"
13
14 #include <gnutls/gnutls.h>
15 #include <gnutls/x509.h>
16
17 struct ip_node {
18   cnode n;
19   struct ip_addrmask addrmask;
20 };
21
22 struct access_rule {
23   cnode n;
24   clist ip_list;
25   uns allow_admin;
26   uns plain_text;
27   uns max_conn;
28 };
29
30 struct conn {
31   // Set up by the master process
32   cnode n;
33   u32 ip;
34   byte *ip_string;                      // (xmalloced)
35   pid_t pid;
36   uns id;
37   struct access_rule *rule;             // Rule matched by this connection
38   int sk;                               // Client socket
39   byte *cert_name;                      // Client name from the certificate (NULL if no TLS) (xmalloced)
40
41   // Used by the child process
42   gnutls_session_t tls;                 // TLS session
43   struct fastbuf rx_fb, tx_fb;          // Fastbufs for communication with the client (either plain-text or TLS)
44   struct mempool *pool;
45   struct odes *request;
46   struct odes *reply;
47   struct odes *task_status;
48   int task_lock_fd;
49   byte *user;
50 };
51
52 extern uns max_request_size, max_attachment_size, trace_commands;
53 extern uns max_versions;
54 extern byte *history_format;
55
56 /* submitd.c */
57
58 void NONRET client_error(char *msg, ...);
59
60 /* commands.c */
61
62 int process_init(struct conn *c);
63 int process_command(struct conn *c);
64
65 /* tasks.c */
66
67 struct task {
68   cnode n;
69   byte *name;
70   uns open_data;        // Number of parts for open-data tasks
71   uns max_size;         // Maximum size (0=use global default)
72   clist parts;          // List of parts of this task (simp_nodes)
73   clist *extensions;    // List of allowed extensions for this task (simp_nodes)
74 };
75
76 extern clist task_list;
77 extern struct cf_section tasks_conf;
78
79 struct task *task_find(byte *name);
80 int part_exists_p(struct task *t, byte *name);
81 int user_exists_p(byte *user);
82 int ext_exists_p(struct task *t, byte *ext);
83
84 void task_lock_status(struct conn *c);
85 void task_unlock_status(struct conn *c, uns write_back);
86 void task_load_status(struct conn *c);
87
88 struct odes *task_status_find_task(struct conn *c, struct task *t, uns create);
89 struct odes *task_status_find_part(struct odes *t, byte *part, uns create);
90
91 void task_submit_part(byte *user, byte *task, byte *part, byte *ext, uns version, struct fastbuf *fb);
92 void task_delete_part(byte *user, byte *task, byte *part, byte *ext, uns version);
93
94 #endif