commit - 137b80e403bf357dbddb90881630808cf83a4f83
commit + e1ccda6ce491da869dab6ce6297ca7a805369171
blob - c37f393e960ed08f9185909559aa8a0b289e46c5
blob + c4d1e1fad4add26b371a08609689fe243cdd6866
--- identity.c
+++ identity.c
{ "generate", cmd_generate, "[-t type] name" },
{ "remove", cmd_remove, "name" },
{ "import", cmd_import, "-C cert [-K key] name" },
- { "export", cmd_export, "-C cert name path" },
+ { "export", cmd_export, "-C cert name" },
{ "list", cmd_list, "" },
{ "mappings", cmd_mappings, "" },
{ "use", cmd_use, "name host[:port][/path]" },
return (cmd->fn(cmd, argc, argv));
}
+ warnx("unknown command: %s", argv[0]);
usage();
}
static int
cmd_mappings(const struct cmd *cmd, int argc, char **argv)
{
- struct ccert *ccert;
+ struct ccert *c;
+ const char *id = NULL;
int ch, defport;
size_t i;
}
argc -= optind;
argv += optind;
+ if (argc == 1) {
+ if ((id = ccert(*argv)) == NULL)
+ errx(1, "unknown identity %s", *argv);
+ argc--, argv++;
+ }
if (argc != 0)
cmd_usage(cmd);
for (i = 0; i < cert_store.len; ++i) {
- ccert = &cert_store.certs[i];
+ c = &cert_store.certs[i];
+
+ if (id && strcmp(id, c->cert) != 0)
+ continue;
- defport = !strcmp(ccert->port, "1965");
+ defport = !strcmp(c->port, "1965");
- printf("%s\t%s%s%s%s\n", ccert->host, ccert->host,
- defport ? "" : ":", defport ? "" : ccert->port,
- ccert->path);
+ printf("%s\t%s%s%s%s\n", c->cert, c->host,
+ defport ? "" : ":", defport ? "" : c->port,
+ c->path);
}
return (0);