]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
vici: Return authentication rounds with unique names
authorMartin Willi <martin@revosec.ch>
Fri, 27 Feb 2015 13:28:47 +0000 (14:28 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 18 Mar 2015 12:59:14 +0000 (13:59 +0100)
To simplify handling of authentication rounds in dictionaries/hashtables on the
client side, we assign unique names to each authentication round when listing
connection.

src/libcharon/plugins/vici/vici_query.c
src/swanctl/commands/list_conns.c

index 7e4e241b20c39aeaa8da6d5c1171785cc33e61c3..84fc23c6a343e6a369c5b233d0b2825ab18a4a8e 100644 (file)
@@ -508,11 +508,14 @@ static void build_auth_cfgs(peer_cfg_t *peer_cfg, bool local, vici_builder_t *b)
                certificate_t *cert;
                char *str;
        } v;
+       char buf[32];
+       int i = 0;
 
        enumerator = peer_cfg->create_auth_cfg_enumerator(peer_cfg, local);
        while (enumerator->enumerate(enumerator, &auth))
        {
-               b->begin_section(b, local ? "local" : "remote");
+               snprintf(buf, sizeof(buf), "%s-%d", local ? "local" : "remote", ++i);
+               b->begin_section(b, buf);
 
                rules = auth->create_enumerator(auth);
                while (rules->enumerate(rules, &rule, &v))
index 31ab9c40a8627fc99bce284affee594fc8394a3f..019c88888479c2c3cca28169fc38d796c8b198b8 100644 (file)
@@ -103,7 +103,7 @@ CALLBACK(conn_sn, int,
        {
                return vici_parse_cb(res, children_sn, NULL, NULL, NULL);
        }
-       if (streq(name, "local") || streq(name, "remote"))
+       if (strpfx(name, "local") || strpfx(name, "remote"))
        {
                hashtable_t *auth;
 
@@ -112,7 +112,8 @@ CALLBACK(conn_sn, int,
                if (ret == 0)
                {
                        printf("  %s %s authentication:\n",
-                               name, auth->get(auth, "class") ?: "unspecified");
+                               strpfx(name, "local") ? "local" : "remote",
+                               auth->get(auth, "class") ?: "unspecified");
                        if (auth->get(auth, "id"))
                        {
                                printf("    id: %s\n", auth->get(auth, "id"));