Auto merge of #2013 - str4d:2002-require-zcash-conf, r=ebfull

Require zcash.conf to start zcashd

Closes #2002.
This commit is contained in:
zkbot 2017-01-16 23:09:38 +00:00
commit 6abf7adc14
3 changed files with 23 additions and 1 deletions

View File

@ -97,6 +97,24 @@ bool AppInit(int argc, char* argv[])
try
{
ReadConfigFile(mapArgs, mapMultiArgs);
} catch (const missing_zcash_conf& e) {
fprintf(stderr,
(_("Before starting zcashd, you need to create a configuration file:\n"
"%s\n"
"It can be completely empty! That indicates you are happy with the default\n"
"configuration of zcashd. But requiring a configuration file to start ensures\n"
"that zcashd won't accidentally compromise your privacy if there was a default\n"
"option you needed to change.\n"
"\n"
"You can look at the example configuration file for suggestions of default\n"
"options that you may want to change. It should be in one of these locations,\n"
"depending on how you installed Zcash:\n") +
_("- Source code: %s\n"
"- .deb package: %s\n")).c_str(),
GetConfigFile().string().c_str(),
"contrib/DEBIAN/examples/zcash.conf",
"/usr/share/doc/zcash/examples/zcash.conf");
return false;
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;

View File

@ -534,7 +534,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
{
boost::filesystem::ifstream streamConfig(GetConfigFile());
if (!streamConfig.good())
return; // No zcash.conf file is OK
throw missing_zcash_conf();
set<string> setOptions;
setOptions.insert("*");

View File

@ -127,6 +127,10 @@ boost::filesystem::path GetConfigFile();
boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
class missing_zcash_conf : public std::runtime_error {
public:
missing_zcash_conf() : std::runtime_error("Missing zcash.conf") { }
};
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);