mirror of
https://github.com/NixOS/nix
synced 2025-06-29 23:13:14 +02:00
This gets rid of unnecessary copies in range-based-for loops and local variables, when they are used solely as `const &`. Also added a fixme comment about a suspicious move out of const, which might not be intended.
31 lines
723 B
C++
31 lines
723 B
C++
#include "file-system.hh"
|
|
#include "globals.hh"
|
|
#include "keys.hh"
|
|
|
|
namespace nix {
|
|
|
|
PublicKeys getDefaultPublicKeys()
|
|
{
|
|
PublicKeys publicKeys;
|
|
|
|
// FIXME: filter duplicates
|
|
|
|
for (const auto & s : settings.trustedPublicKeys.get()) {
|
|
PublicKey key(s);
|
|
publicKeys.emplace(key.name, key);
|
|
}
|
|
|
|
for (const auto & secretKeyFile : settings.secretKeyFiles.get()) {
|
|
try {
|
|
SecretKey secretKey(readFile(secretKeyFile));
|
|
publicKeys.emplace(secretKey.name, secretKey.toPublicKey());
|
|
} catch (SystemError & e) {
|
|
/* Ignore unreadable key files. That's normal in a
|
|
multi-user installation. */
|
|
}
|
|
}
|
|
|
|
return publicKeys;
|
|
}
|
|
|
|
}
|