swanctl: Be more verbose while loading connections and credentials
authorMartin Willi <martin@revosec.ch>
Mon, 24 Feb 2014 12:28:24 +0000 (13:28 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 7 May 2014 13:48:15 +0000 (15:48 +0200)
src/swanctl/commands/load_conns.c
src/swanctl/commands/load_creds.c

index 68ed3cd..0208196 100644 (file)
@@ -214,6 +214,10 @@ static bool load_conn(vici_conn_t *conn, settings_t *cfg,
                                section, vici_find_str(res, "", "errmsg"));
                ret = FALSE;
        }
+       else
+       {
+               printf("loaded connection '%s'\n", section);
+       }
        vici_free_res(res);
        return ret;
 }
index dcfc6fe..52cdfb9 100644 (file)
@@ -55,6 +55,10 @@ static bool load_cert(vici_conn_t *conn, bool raw, char *dir,
                                dir, vici_find_str(res, "", "errmsg"));
                ret = FALSE;
        }
+       else
+       {
+               printf("loaded %s certificate '%s'\n", type, dir);
+       }
        vici_free_res(res);
        return ret;
 }
@@ -124,6 +128,10 @@ static bool load_key(vici_conn_t *conn, bool raw, char *dir,
                                dir, vici_find_str(res, "", "errmsg"));
                ret = FALSE;
        }
+       else
+       {
+               printf("loaded %s key '%s'\n", type, dir);
+       }
        vici_free_res(res);
        return ret;
 }
@@ -274,6 +282,7 @@ static bool load_secret(vici_conn_t *conn, char *type, char *owners,
        vici_req_t *req;
        vici_res_t *res;
        chunk_t data;
+       char *owner;
        bool ret = TRUE;
 
        req = vici_begin("load-shared");
@@ -281,9 +290,9 @@ static bool load_secret(vici_conn_t *conn, char *type, char *owners,
        vici_add_key_valuef(req, "type", "%s", type);
        vici_begin_list(req, "owners");
        enumerator = enumerator_create_token(owners, " ", " ");
-       while (enumerator->enumerate(enumerator, &owners))
+       while (enumerator->enumerate(enumerator, &owner))
        {
-               vici_add_list_itemf(req, "%s", owners);
+               vici_add_list_itemf(req, "%s", owner);
        }
        enumerator->destroy(enumerator);
        vici_end_list(req);
@@ -319,6 +328,17 @@ static bool load_secret(vici_conn_t *conn, char *type, char *owners,
                                vici_find_str(res, "", "errmsg"));
                ret = FALSE;
        }
+       else
+       {
+               printf("loaded %s secret for: ", type);
+               enumerator = enumerator_create_token(owners, " ", " ");
+               while (enumerator->enumerate(enumerator, &owner))
+               {
+                       printf("'%s' ", owner);
+               }
+               enumerator->destroy(enumerator);
+               printf("\n");
+       }
        vici_free_res(res);
        return ret;
 }