implement secretstore config

Sun, 08 Aug 2021 11:45:36 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 08 Aug 2021 11:45:36 +0200
changeset 730
83f832e345e0
parent 729
5433f0f3dd48
child 731
e0358fa1a3b1

implement secretstore config

dav/config.c file | annotate | diff | comparison | revisions
dav/config.h file | annotate | diff | comparison | revisions
--- a/dav/config.c	Sun Aug 08 11:38:55 2021 +0200
+++ b/dav/config.c	Sun Aug 08 11:45:36 2021 +0200
@@ -65,7 +65,8 @@
 
 static PwdStore *pstore;
 
-
+static char *secretstore_unlock_cmd;
+static char *secretstore_lock_cmd;
 
 int check_config_dir(void) {
     char *file = util_concat_path(ENV_HOME, ".dav");
@@ -146,7 +147,10 @@
                 ret = load_proxy(ctx->https_proxy, node, HTTPS_PROXY);
             } else if (xstreq(node->name, "namespace")) {
                 ret = load_namespace(node);
-            } /* else {
+            } else if (xstreq(node->name, "secretstore")) {
+                ret = load_secretstore(node);
+            } 
+            /* else {
                 fprintf(stderr, "Unknown config element: %s\n", node->name);
                 ret = 1;
             } */
@@ -567,6 +571,28 @@
     return dav_add_namespace(context, prefix, uri);
 }
 
+int load_secretstore(const xmlNode *node) {
+    // currently only one secretstore is supported
+    
+    node = node->children;
+    int error = 0;
+    while(node) {
+        if(node->type == XML_ELEMENT_NODE) {
+            char *value = util_xml_get_text(node);
+            if(value) {
+                if(xstreq(node->name, "unlock-command")) {
+                    secretstore_unlock_cmd = strdup(value);
+                } else if(xstreq(node->name, "lock-command")) {
+                    secretstore_lock_cmd = strdup(value);
+                }
+            }
+        }
+        node = node->next;
+    }
+    
+    return error;
+}
+
 Repository* get_repository(sstr_t name) {
     if(!name.ptr) {
         return NULL;
--- a/dav/config.h	Sun Aug 08 11:38:55 2021 +0200
+++ b/dav/config.h	Sun Aug 08 11:45:36 2021 +0200
@@ -82,6 +82,7 @@
 int load_proxy(DavProxy*, const xmlNode *proxynode, int type);
 sstr_t load_key_file(char *filename);
 int load_namespace(const xmlNode *node);
+int load_secretstore(const xmlNode *node);
 
 Repository* repository_new(void);
 

mercurial