diff options
Diffstat (limited to 'src/add.c')
-rw-r--r-- | src/add.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -204,7 +204,7 @@ static int add_transaction_try(DB *db, const AddOpt * const opt, const char *hom } static int link_config(const AddOpt *opt, const char* newPath) { - hLOG("Linking %s -> %s\n", newPath, opt->confPath); + hLOG("Linking %s -> %s", newPath, opt->confPath); if (util_symlink_file(newPath, opt->confPath) != 0) { ERR("Could not link file."); return -1; @@ -222,7 +222,7 @@ static int move_config(const AddOpt *opt, char *progDir, char *ret) { return -1; } strcpy(ret, newPath); - hLOG("Moving %s -> %s\n", opt->confPath, newPath); + hLOG("Moving %s -> %s", opt->confPath, newPath); if (util_move_file(opt->confPath, newPath) != 0) { ERR("Could not move file."); return -1; @@ -230,7 +230,7 @@ static int move_config(const AddOpt *opt, char *progDir, char *ret) { return 0; } -static AddOpt add_make_options(cklist *args) { +static AddOpt add_make_options(cklist *args, DB *db) { list_rewind(args); /* since we are here, the first two arguments must exist */ AddOpt addOpt = { @@ -254,6 +254,10 @@ static AddOpt add_make_options(cklist *args) { while (list_next(args)) { if (strcmp(list_get(args), "-s") == 0 && addOpt.secret == 0) { + if (!secret_enabled(db)) { + addOpt.err = ADD_ERR_NO_SECRET; + return addOpt; + } addOpt.secret = 1; } else if (strcmp(list_get(args), "-p") == 0 && addOpt.prime == 0) { addOpt.prime = 1; @@ -304,10 +308,13 @@ int run_ADD(UserOpt * opt, Conf *conf) { if (open_DB(&db, opt)) { return -1; } - AddOpt addOpt = add_make_options(opt->args); + AddOpt addOpt = add_make_options(opt->args, &db); switch (addOpt.err) { case ADD_NO_ERR: break; + case ADD_ERR_NO_SECRET: + ERR("Secret is not enabled for this ck instance."); + goto error; case ADD_ERR_LINK_CONFIG: ERR("%s is a link.", addOpt.confPath); goto error; |