summaryrefslogtreecommitdiff
path: root/usr.sbin/relayctl/parser.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2011-05-19 08:56:50 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2011-05-19 08:56:50 +0000
commit31b1bbafe11da6e0dead1dd433eff2ab64ae8bb6 (patch)
tree911cab636cae40f30bbaab5a11769d79cf7f41b2 /usr.sbin/relayctl/parser.c
parent1e687a712e695c6cf93da2be7c3d01ef04f587cb (diff)
Fix reload support in relayd(8) by reimplementing large parts of the
daemon infrastructure. The previous design made it fairly hard to reload the complex data structures, especially relays and protocols. One of the reasons was that the privsep'd relayd processes had two ways of getting their configuration: 1) from memory after forking from the parent process and 2) and (partially) via imsgs after reload. The new implementation first forks the privsep'd children before the parents loads the configuration and sends it via imsgs to them; so it is only like 2) before. It is based on an approach that I first implemented for iked(8) and I also fixed many bugs in the code. Thanks to many testers including dlg@ sthen@ phessler@ ok pyr@ dlg@ sthen@
Diffstat (limited to 'usr.sbin/relayctl/parser.c')
-rw-r--r--usr.sbin/relayctl/parser.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c
index a9fa3a25814..a8a80c73f2c 100644
--- a/usr.sbin/relayctl/parser.c
+++ b/usr.sbin/relayctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.24 2010/09/04 21:31:04 tedu Exp $ */
+/* $OpenBSD: parser.c,v 1.25 2011/05/19 08:56:49 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -46,7 +46,8 @@ enum token_type {
HOSTID,
TABLEID,
RDRID,
- KEYWORD
+ KEYWORD,
+ PATH
};
struct token {
@@ -65,10 +66,12 @@ static const struct token t_rdr_id[];
static const struct token t_table_id[];
static const struct token t_host_id[];
static const struct token t_log[];
+static const struct token t_load[];
static const struct token t_main[] = {
{KEYWORD, "monitor", MONITOR, NULL},
{KEYWORD, "show", NONE, t_show},
+ {KEYWORD, "load", LOAD, t_load},
{KEYWORD, "poll", POLL, NULL},
{KEYWORD, "reload", RELOAD, NULL},
{KEYWORD, "stop", SHUTDOWN, NULL},
@@ -131,6 +134,11 @@ static const struct token t_log[] = {
{ENDTOKEN, "", NONE, NULL}
};
+static const struct token t_load[] = {
+ {PATH, "", NONE, NULL},
+ {ENDTOKEN, "", NONE, NULL}
+};
+
static const struct token *match_token(const char *, const struct token *,
struct parse_result *);
static void show_valid_args(const struct token *);
@@ -228,6 +236,13 @@ match_token(const char *word, const struct token *table,
t = &table[i];
match++;
break;
+ case PATH:
+ if (!match && word != NULL && strlen(word) > 0) {
+ res->path = strdup(word);
+ match++;
+ t = &table[i];
+ }
+ break;
case ENDTOKEN:
break;
}
@@ -268,6 +283,9 @@ show_valid_args(const struct token *table)
case HOSTID:
fprintf(stderr, " <hostid>\n");
break;
+ case PATH:
+ fprintf(stderr, " <path>\n");
+ break;
case ENDTOKEN:
break;
}