# HG changeset patch # User Olaf Wintermann # Date 1628427542 -7200 # Node ID a7883961b5f4d86afea19eee71be91743eff758a # Parent b0eb645cd26e622c58173d9af0fd3cf330bc2fc7 add set-master-password command diff -r b0eb645cd26e -r a7883961b5f4 dav/main.c --- a/dav/main.c Sun Aug 08 14:40:26 2021 +0200 +++ b/dav/main.c Sun Aug 08 14:59:02 2021 +0200 @@ -232,6 +232,8 @@ ret = cmd_remove_user(args); } else if(!strcasecmp(cmd, "edit-user")) { ret = cmd_edit_user(args); + } else if(!strcasecmp(cmd, "set-master-password") || !strcasecmp(cmd, "set-master-pw")) { + ret = cmd_set_master_password(args); } else if(!strcasecmp(cmd, "version") || !strcasecmp(cmd, "-version") || !strcasecmp(cmd, "--version")) { fprintf(stderr, "dav %s\n", DAV_VERSION); @@ -333,7 +335,7 @@ fprintf(stderr, " versioncontrol list-versions checkout checkin uncheckout\n\n"); fprintf(stderr, "Config commands:\n"); fprintf(stderr, " add-repository remove-repository list-repositories repository-url\n"); - fprintf(stderr, " add-user remove-user edit-user list-users\n"); + fprintf(stderr, " add-user remove-user edit-user list-users set-master-password\n"); fprintf(stderr, " check-config\n"); fprintf(stderr, "\n"); fprintf(stderr, @@ -3171,6 +3173,24 @@ } +static int cmd_ss_set_master_pw(CmdArgs *args, PwdStore *secrets, void *ud) { + char *new_master_pw = util_password_input("New master password: "); + int ret = pwdstore_setpassword(secrets, new_master_pw); + if(ret) { + fprintf(stderr, "Error: failed to set new master password\n"); + } + + ret = pwdstore_save(secrets); + if(ret) { + fprintf(stderr, "Error: saving srcrets store failed.\n"); + } + return ret; +} + +int cmd_set_master_password(CmdArgs *args) { + return secretstore_cmd(args, FALSE, NULL, cmd_ss_set_master_pw, NULL); +} + static char** read_args_from_stdin(int *argc) { // read stdin into buffer UcxBuffer *in = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); diff -r b0eb645cd26e -r a7883961b5f4 dav/main.h --- a/dav/main.h Sun Aug 08 14:40:26 2021 +0200 +++ b/dav/main.h Sun Aug 08 14:59:02 2021 +0200 @@ -137,6 +137,8 @@ int cmd_remove_user(CmdArgs *args); int cmd_edit_user(CmdArgs *args); +int cmd_set_master_password(CmdArgs *args); + int cmd_complete(CmdArgs *args); int shell_completion(char *cmd, CmdArgs *args, int index);