2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 /* TODO: make these customizable */
28 #define KD_CONF_FILE "/etc/kamid.conf"
29 #define KD_USER "_kamid"
30 #define KD_SOCKET "/var/run/kamid.sock"
32 #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
34 #define MIN(a, b) ((a) < (b) ? (a) : (b))
38 void (*handler)(int, short, void *);
62 struct kd_options_conf {
72 char t_name[LINE_MAX];
73 enum table_type t_type;
74 char t_path[PATH_MAX];
76 struct table_backend *t_backend;
79 struct table_backend {
81 int (*open)(struct table *);
82 int (*add)(struct table *, const char *, const char *);
83 int (*lookup)(struct table *, const char *, char **);
84 void (*close)(struct table *);
88 extern struct table_backend table_static;
92 struct kd_listen_conf {
93 SIMPLEQ_ENTRY(kd_listen_conf) entry;
99 struct table *auth_table;
106 SIMPLEQ_ENTRY(kd_pki_conf) entry;
112 struct tls_config *tlsconf;
115 struct kd_tables_conf {
116 SIMPLEQ_ENTRY(kd_tables_conf) entry;
121 struct kd_options_conf kd_options;
122 SIMPLEQ_HEAD(kd_pki_conf_head, kd_pki_conf) pki_head;
123 SIMPLEQ_HEAD(kd_tables_conf_head, kd_tables_conf) table_head;
124 SIMPLEQ_HEAD(kd_listen_conf_head, kd_listen_conf) listen_head;
135 * The message itself is len bytes long (counting the whole header
138 struct np_msg_header {
144 /* useful constants */
145 #define NOTAG ((uint16_t)~0U)
146 #define NOFID ((uint32_t)~0U)
149 /* 9p message types */
157 Terror = 106, /* illegal */
182 * plan9ports' include/fcall.h also has a
187 * which it's not mentioned in the 9p "rfc" over at
188 * 9p.cat-v.org. Ignoring that for now.
194 int main_imsg_compose_listener(int, int, uint32_t, const void *, uint16_t);
195 void merge_config(struct kd_conf *, struct kd_conf *);
196 void imsg_event_add(struct imsgev *);
197 int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t,
198 int, const void *, uint16_t);
200 struct kd_conf *config_new_empty(void);
201 void config_clear(struct kd_conf *);
204 struct kd_conf *parse_config(const char *);
205 int cmdline_symset(char *);