if (ishex) {
count = dbctx->fetch_key_id(dbctx, keyid, &publickey,
false);
- } else if (isfp) {
+ } else if (isfp && exact) {
+ count = dbctx->fetch_key(dbctx, fingerprint,
+ &publickey, false);
+ } else if (isfp && !exact) {
count = dbctx->fetch_key_fp(dbctx, fingerprint,
&publickey, false);
} else {
char *end = NULL;
uint64_t keyid = 0;
int i;
+ bool exact = false;
bool ishex = false;
bool isfp = false;
bool update = false;
struct onak_dbctx *dbctx;
struct openpgp_fingerprint fingerprint;
- while ((optchar = getopt(argc, argv, "bc:fsuv")) != -1 ) {
+ while ((optchar = getopt(argc, argv, "bc:efsuv")) != -1 ) {
switch (optchar) {
case 'b':
binary = true;
break;
case 'c':
+ if (configfile != NULL) {
+ free(configfile);
+ }
configfile = strdup(optarg);
break;
+ case 'e':
+ exact = true;
+ break;
case 'f':
dispfp = true;
break;
logthing(LOGTHING_INFO, "Finished reading %d keys.",
result);
- result = cleankeys(&keys, config.clean_policies);
+ dbctx = config.dbinit(config.backend, false);
+ result = cleankeys(dbctx, &keys,
+ config.clean_policies);
logthing(LOGTHING_INFO, "%d keys cleaned.",
result);
- dbctx = config.dbinit(config.backend, false);
logthing(LOGTHING_NOTICE, "Got %d new keys.",
dbctx->update_keys(dbctx, &keys,
- false));
+ &config.blacklist,
+ (config.clean_policies &
+ ONAK_CLEAN_UPDATE_ONLY),
+ false));
if (keys != NULL && update) {
flatten_publickey(keys,
&packets,
logthing(LOGTHING_NOTICE, "No changes.");
}
} else if (!strcmp("clean", argv[optind])) {
+ dbctx = config.dbinit(config.backend, true);
if (binary) {
result = read_openpgp_stream(stdin_getchar, NULL,
&packets, 0);
result);
if (keys != NULL) {
- result = cleankeys(&keys,
+ result = cleankeys(dbctx, &keys,
config.clean_policies);
logthing(LOGTHING_INFO, "%d keys cleaned.",
result);
free_publickey(keys);
keys = NULL;
}
+ dbctx->cleanupdb(dbctx);
} else if (!strcmp("dumpconfig", argv[optind])) {
if ((argc - optind) == 2) {
writeconfig(argv[optind + 1]);
if (!strcmp("index", argv[optind])) {
find_keys(dbctx, search, keyid, &fingerprint, ishex,
isfp, dispfp, skshash,
- false, false);
+ exact, false);
} else if (!strcmp("vindex", argv[optind])) {
find_keys(dbctx, search, keyid, &fingerprint, ishex,
isfp, dispfp, skshash,
- false, true);
+ exact, true);
} else if (!strcmp("getphoto", argv[optind])) {
if (!ishex) {
puts("Can't get a key on uid text."
&fingerprint);
dbctx->delete_key(dbctx, &fingerprint,
false);
+ free_publickey(keys);
+ keys = NULL;
}
} else
dbctx->delete_key(dbctx, &fingerprint, false);
if (dbctx->fetch_key_id(dbctx, keyid, &keys, true)) {
get_fingerprint(keys->publickey, &fingerprint);
dbctx->delete_key(dbctx, &fingerprint, true);
- cleankeys(&keys, config.clean_policies);
+ cleankeys(dbctx, &keys, config.clean_policies);
dbctx->store_key(dbctx, keys, true, false);
} else {
puts("Key not found");