diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-05 22:41:09 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-05 22:41:09 +0000 |
commit | d17098ca8f462d80cb591547dd68ab2a9007b0f0 (patch) | |
tree | 11e20d13c71fd3cfed591d35a57fbc91b7e1a5eb /sbin/isakmpd/ui.c | |
parent | 9fe49dd5198bd4a239db52c52b299b4d735b581c (diff) |
DESIGN-NOTES: Merge with EOM 1.47
conf.c: Merge with EOM 1.19
conf.h: Merge with EOM 1.10
ui.c: Merge with EOM 1.34
author: niklas
Dynamic updates of the configuration database is now possible, either through
ui, or through the new conf_* API described in DESIGN-NOTES
Diffstat (limited to 'sbin/isakmpd/ui.c')
-rw-r--r-- | sbin/isakmpd/ui.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/sbin/isakmpd/ui.c b/sbin/isakmpd/ui.c index 1cc2eaf64a6..08b9cbfb24d 100644 --- a/sbin/isakmpd/ui.c +++ b/sbin/isakmpd/ui.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ui.c,v 1.9 1999/06/02 06:29:55 niklas Exp $ */ -/* $EOM: ui.c,v 1.33 1999/05/19 22:40:13 ho Exp $ */ +/* $OpenBSD: ui.c,v 1.10 1999/08/05 22:41:08 niklas Exp $ */ +/* $EOM: ui.c,v 1.34 1999/08/05 14:58:00 niklas Exp $ */ /* * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved. @@ -115,6 +115,52 @@ ui_teardown (char *cmd) sa_delete (sa, 1); } +/* + * Call the configuration API. + * XXX Error handling! How to do multi-line transactions? Too short arbitrary + * limit on the parameters? + */ +static void +ui_config (char *cmd) +{ + char subcmd[81], section[81], tag[81], value[81]; + int override, trans = 0; + + if (sscanf (cmd, "C %80s", subcmd) != 1) + goto fail; + + trans = conf_begin (); + if (strcasecmp (subcmd, "set") == 0) + { + if (sscanf (cmd, "C %*s [%80[^]]]:%80[^=]=%80s %d", section, tag, value, + &override) != 4) + goto fail; + conf_set (trans, section, tag, value, override); + } + else if (strcasecmp (cmd, "rm") == 0) + { + if (sscanf (cmd, "C %*s [%80[^]]]:%80s", section, tag) != 2) + goto fail; + conf_remove (trans, section, tag); + } + else if (strcasecmp (cmd, "rms") == 0) + { + if (sscanf (cmd, "C %*s [%80[^]]]", section) != 1) + goto fail; + conf_remove_section (trans, section); + } + else + goto fail; + + conf_end (trans, 1); + return; + + fail: + if (trans) + conf_end (trans, 0); + log_print ("ui_config: command \"%s\" malformed", cmd); +} + static void ui_delete (char *cmd) { @@ -191,6 +237,10 @@ ui_handle_command (char *line) ui_connect (line); break; + case 'C': + ui_config (line); + break; + case 'd': ui_delete (line); break; |