dav/config.c

changeset 470
6bf798ad3aec
parent 405
6b85d745e402
child 472
08d2d1263429
--- a/dav/config.c	Thu Sep 06 12:51:37 2018 +0200
+++ b/dav/config.c	Sat Sep 15 11:56:36 2018 +0200
@@ -34,6 +34,7 @@
 #include <errno.h>
 #include <libxml/tree.h>
 
+#include "pwd.h"
 #include "config.h"
 #include "main.h"
 #include <libidav/utils.h>
@@ -62,6 +63,8 @@
 static UcxMap *repos;
 static UcxMap *keys;
 
+static PwdStore *pstore;
+
 int check_config_dir(void) {
     char *file = util_concat_path(ENV_HOME, ".dav");
     int ret = 0;
@@ -100,6 +103,10 @@
     repos = ucx_map_new(16);
     keys = ucx_map_new(16);
     
+    char *pwfile = util_concat_path(ENV_HOME, ".dav/pw.crypt");
+    pstore = pwdstore_open(pwfile);
+    free(pwfile);
+    
     char *file = util_concat_path(ENV_HOME, ".dav/config.xml");
     
     struct stat s;
@@ -216,6 +223,8 @@
         repo->user = strdup(value);
     } else if(xstreq(key, "password")) {
         repo->password = util_base64decode(value);
+    } else if(xstreq(key, "stored-user")) {
+        repo->stored_user = strdup(value);
     } else if(xstreq(key, "default-key")) {
         repo->default_key = strdup(value);
     } else if(xstreq(key, "full-encryption")) {
@@ -751,3 +760,14 @@
     }
     return list;
 }
+
+PwdStore* get_pwdstore(void) {
+    return pstore;
+}
+
+int pwdstore_save(PwdStore *pwdstore) {
+    char *pwfile = util_concat_path(ENV_HOME, ".dav/pw.crypt");
+    int ret = pwdstore_store(pwdstore, pwfile);
+    free(pwfile);
+    return ret; 
+}

mercurial