actions: list secrets
This commit is contained in:
parent
9ead59dbad
commit
86d3afc213
|
@ -180,6 +180,32 @@ int action_rename (bool yes,
|
||||||
int action_list_sec (bool nice_fingerprint, const std::string&filter,
|
int action_list_sec (bool nice_fingerprint, const std::string&filter,
|
||||||
keyring&KR)
|
keyring&KR)
|
||||||
{
|
{
|
||||||
|
for (keyring::keypair_storage::iterator
|
||||||
|
i = KR.pairs.begin(), e = KR.pairs.end();
|
||||||
|
i != e; ++i) {
|
||||||
|
|
||||||
|
if (!keyspec_matches (filter, i->second.pub.name, i->first) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!nice_fingerprint)
|
||||||
|
out ("keypair\t"
|
||||||
|
<< i->second.pub.alg << '\t'
|
||||||
|
<< '@' << i->first.substr (0, 22) << "...\t"
|
||||||
|
<< "\"" << i->second.pub.name << "\"");
|
||||||
|
else {
|
||||||
|
out ("key pair with algorithm " << i->second.pub.alg
|
||||||
|
<< ", name `" << i->second.pub.name << "'");
|
||||||
|
|
||||||
|
std::cout << " fingerprint ";
|
||||||
|
for (size_t j = 0; j < i->first.length(); ++j) {
|
||||||
|
std::cout << i->first[j];
|
||||||
|
if (! ( (j + 1) % 4) &&
|
||||||
|
j < i->first.length() - 1)
|
||||||
|
std::cout << ':';
|
||||||
|
}
|
||||||
|
std::cout << std::endl << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ bool algorithm_name_matches (const std::string& search,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool key_matches (const std::string&search,
|
bool keyspec_matches (const std::string&search,
|
||||||
const std::string&name,
|
const std::string&name,
|
||||||
const std::string&keyid)
|
const std::string&keyid)
|
||||||
{
|
{
|
||||||
if (!search.length() ) return true;
|
if (!search.length() ) return true;
|
||||||
if (search[0] == '@') { //match for keyID
|
if (search[0] == '@') { //match for keyID
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
bool algorithm_name_matches (const std::string& search,
|
bool algorithm_name_matches (const std::string& search,
|
||||||
const std::string&name);
|
const std::string&name);
|
||||||
|
|
||||||
bool key_matches (const std::string&search,
|
bool keyspec_matches (const std::string&search,
|
||||||
const std::string&name,
|
const std::string&name,
|
||||||
const std::string&keyid);
|
const std::string&keyid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue