summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2006-11-30 11:24:50 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2006-11-30 11:24:50 +0000
commit7f575d4ac4bfa545ba21f61b8c888a06118a1540 (patch)
tree4b3618d1362ff7c6df2c2e6db50f607d7dd058e2
parentc0a03e1d970493a9d25a8e407046f05d8c8a09ff (diff)
new ui command 'rmv': removes an entry from a list, thus reversing an
'add' operation; ok ho, hshoexer, jmc eVS: ----------------------------------------------------------------------
-rw-r--r--sbin/isakmpd/isakmpd.814
-rw-r--r--sbin/isakmpd/ui.c42
2 files changed, 53 insertions, 3 deletions
diff --git a/sbin/isakmpd/isakmpd.8 b/sbin/isakmpd/isakmpd.8
index ba48b524f0c..82365d2194b 100644
--- a/sbin/isakmpd/isakmpd.8
+++ b/sbin/isakmpd/isakmpd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: isakmpd.8,v 1.98 2006/11/29 19:44:50 jmc Exp $
+.\" $OpenBSD: isakmpd.8,v 1.99 2006/11/30 11:24:49 markus Exp $
.\" $EOM: isakmpd.8,v 1.23 2000/05/02 00:30:23 niklas Exp $
.\"
.\" Copyright (c) 1998, 1999, 2000, 2001 Niklas Hallqvist.
@@ -311,6 +311,14 @@ Available commands are:
.Sm on
.Xc
.It Xo
+.Ic C rmv
+.Sm off
+.Op Ic section
+.No :
+.Ic tag No = Ic value
+.Sm on
+.Xc
+.It Xo
.Ic C rm
.Sm off
.Op Ic section
@@ -355,6 +363,10 @@ unless the value is already in the list.
removes a tag in a section.
.Sq rms
removes an entire section.
+.Sq rmv
+removes an entry from a list, thus reversing an
+.Sq add
+operation.
.Pp
NOTE: Sending
.Nm
diff --git a/sbin/isakmpd/ui.c b/sbin/isakmpd/ui.c
index 40cf43cd847..75a39a8f32a 100644
--- a/sbin/isakmpd/ui.c
+++ b/sbin/isakmpd/ui.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ui.c,v 1.51 2006/11/28 09:27:09 markus Exp $ */
+/* $OpenBSD: ui.c,v 1.52 2006/11/30 11:24:49 markus Exp $ */
/* $EOM: ui.c,v 1.43 2000/10/05 09:25:12 niklas Exp $ */
/*
@@ -224,7 +224,7 @@ ui_config(char *cmd)
struct conf_list_node *vnode;
char subcmd[81], section[81], tag[81], value[81], tmp[81];
char *v, *nv;
- int trans = 0, items, skip = 0;
+ int trans = 0, items, skip = 0, ret;
FILE *fp;
if (sscanf(cmd, "C %80s", subcmd) != 1)
@@ -294,6 +294,44 @@ ui_config(char *cmd)
(strcasecmp(tag, "Connections") == 0 ||
strcasecmp(tag, "Passive-connections") == 0))
ui_conn_reinit();
+ } else if (strcasecmp(subcmd, "rmv") == 0) {
+ items = sscanf(cmd, "C %*s [%80[^]]]:%80[^=]=%80s %80s",
+ section, tag, value, tmp);
+ if (!(items == 3 || items == 4))
+ goto fail;
+ vlist = conf_get_list(section, tag);
+ if (vlist) {
+ nv = v = NULL;
+ for (vnode = TAILQ_FIRST(&vlist->fields);
+ vnode;
+ vnode = TAILQ_NEXT(vnode, link)) {
+ if (strcmp(vnode->field, value) == 0)
+ continue;
+ ret = v ?
+ asprintf(&nv, "%s,%s", v, vnode->field) :
+ asprintf(&nv, "%s", vnode->field);
+ if (v)
+ free(v);
+ if (ret == -1) {
+ log_error("ui_config: malloc() failed");
+ if (trans)
+ conf_end(trans, 0);
+ return;
+ }
+ v = nv;
+ }
+ conf_free_list(vlist);
+ if (nv) {
+ conf_set(trans, section, tag, nv, 1, 0);
+ free(nv);
+ } else {
+ conf_remove(trans, section, tag);
+ }
+ }
+ if (strcasecmp(section, "Phase 2") == 0 &&
+ (strcasecmp(tag, "Connections") == 0 ||
+ strcasecmp(tag, "Passive-connections") == 0))
+ ui_conn_reinit();
} else if (strcasecmp(subcmd, "rm") == 0) {
if (sscanf(cmd, "C %*s [%80[^]]]:%80s", section, tag) != 2)
goto fail;