diff --git a/alethzero/NatspecHandler.cpp b/alethzero/NatspecHandler.cpp index 6ed9f2b10..dc4a219ab 100644 --- a/alethzero/NatspecHandler.cpp +++ b/alethzero/NatspecHandler.cpp @@ -38,7 +38,7 @@ NatspecHandler::NatspecHandler() { string path = Defaults::dbPath(); fs::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); ldb::Options o; o.create_if_missing = true; ldb::DB::Open(o, path + "/natspec", &m_db); diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 5c501fde7..3c3b08845 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -128,7 +128,7 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDe s.write(reinterpret_cast(_data.data()), _data.size()); if (!s) BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); - fs::permissions(_file, fs::owner_read|fs::owner_write); + DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write)); } } diff --git a/libdevcore/TransientDirectory.cpp b/libdevcore/TransientDirectory.cpp index 31a826c24..cd91bd0e4 100644 --- a/libdevcore/TransientDirectory.cpp +++ b/libdevcore/TransientDirectory.cpp @@ -41,7 +41,7 @@ TransientDirectory::TransientDirectory(std::string const& _path): BOOST_THROW_EXCEPTION(FileError()); fs::create_directories(m_path); - fs::permissions(m_path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(m_path, fs::owner_all)); } TransientDirectory::~TransientDirectory() diff --git a/libdevcrypto/SecretStore.cpp b/libdevcrypto/SecretStore.cpp index 266f3735a..39f421f3e 100644 --- a/libdevcrypto/SecretStore.cpp +++ b/libdevcrypto/SecretStore.cpp @@ -148,7 +148,7 @@ void SecretStore::save(string const& _keysPath) { fs::path p(_keysPath); fs::create_directories(p); - fs::permissions(p, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(p, fs::owner_all)); for (auto& k: m_keys) { string uuid = toUUID(k.first); @@ -170,7 +170,7 @@ void SecretStore::load(string const& _keysPath) { fs::path p(_keysPath); fs::create_directories(p); - fs::permissions(p, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(p, fs::owner_all)); for (fs::directory_iterator it(p); it != fs::directory_iterator(); ++it) if (fs::is_regular_file(it->path())) readKey(it->path().string(), true); diff --git a/libdevcrypto/SecretStore.h b/libdevcrypto/SecretStore.h index fbc4c0bec..0fcb18734 100644 --- a/libdevcrypto/SecretStore.h +++ b/libdevcrypto/SecretStore.h @@ -70,6 +70,9 @@ public: /// Returns the uuids of all stored keys. std::vector keys() const { return keysOf(m_keys); } + /// @returns true iff we have the given key stored. + bool contains(h128 const& _k) const { return m_keys.count(_k); } + /// Clears all cached decrypted keys. The passwords have to be supplied in order to retrieve /// secrets again after calling this function. void clearCache() const; diff --git a/libethcore/KeyManager.cpp b/libethcore/KeyManager.cpp index 08892e453..8f3cd5e85 100644 --- a/libethcore/KeyManager.cpp +++ b/libethcore/KeyManager.cpp @@ -95,8 +95,11 @@ bool KeyManager::load(string const& _pass) { h128 uuid(i[1]); Address addr(i[0]); - m_addrLookup[addr] = uuid; - m_keyInfo[uuid] = KeyInfo(h256(i[2]), string(i[3])); + if (m_store.contains(uuid)) + { + m_addrLookup[addr] = uuid; + m_keyInfo[uuid] = KeyInfo(h256(i[2]), string(i[3])); + } // cdebug << toString(addr) << toString(uuid) << toString((h256)i[2]) << (string)i[3]; } diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 230eb39eb..b38db9c8b 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -180,7 +180,7 @@ unsigned BlockChain::openDatabase(std::string const& _path, WithExisting _we) string extrasPath = chainPath + "/" + toString(c_databaseVersion); fs::create_directories(extrasPath); - fs::permissions(extrasPath, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(extrasPath, fs::owner_all)); bytes status = contents(extrasPath + "/minor"); unsigned lastMinor = c_minorProtocolVersion; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 8329ff485..b7367a64f 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -83,7 +83,7 @@ OverlayDB State::openDB(std::string const& _basePath, h256 const& _genesisHash, path += "/" + toHex(_genesisHash.ref().cropped(0, 4)) + "/" + toString(c_databaseVersion); boost::filesystem::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); ldb::Options o; o.max_open_files = 256; diff --git a/libethereum/Utility.cpp b/libethereum/Utility.cpp index f34f66463..ac407999c 100644 --- a/libethereum/Utility.cpp +++ b/libethereum/Utility.cpp @@ -114,13 +114,13 @@ void dev::eth::upgradeDatabase(std::string const& _basePath, h256 const& _genesi if (!fs::exists(chainPath + "/blocks")) { fs::create_directories(chainPath); - fs::permissions(chainPath, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(chainPath, fs::owner_all)); fs::rename(path + "/blocks", chainPath + "/blocks"); if (!fs::exists(extrasPath + "/extras")) { fs::create_directories(extrasPath); - fs::permissions(extrasPath, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(extrasPath, fs::owner_all)); fs::rename(path + "/details", extrasPath + "/extras"); fs::rename(path + "/state", extrasPath + "/state"); writeFile(extrasPath + "/minor", rlp(minorProtocolVersion)); diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 627f18d38..b5d8dc35f 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -59,7 +59,7 @@ WebThreeStubServer::WebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, { auto path = getDataDir() + "/.web3"; fs::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); ldb::Options o; o.create_if_missing = true; ldb::DB::Open(o, path, &m_db); diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 39d0629a7..ba3691a26 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -34,7 +34,7 @@ WhisperDB::WhisperDB(string const& _type) m_readOptions.verify_checksums = true; string path = dev::getDataDir("shh"); fs::create_directories(path); - fs::permissions(path, fs::owner_all); + DEV_IGNORE_EXCEPTIONS(fs::permissions(path, fs::owner_all)); path += "/" + _type; leveldb::Options op; op.create_if_missing = true;