buffet: Read privet options from buffet.conf
Privet code is part of buffet, so it does not need separate config.
BUG=brillo:1213
TEST=`FEATURES=test emerge-gizmo buffet`
Change-Id: I8b2ecb4143aa5d50555fcdc45c3708992187db4d
Reviewed-on: https://chromium-review.googlesource.com/277706
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/main.cc b/buffet/main.cc
index 3971abb..128d8e1 100644
--- a/buffet/main.cc
+++ b/buffet/main.cc
@@ -85,6 +85,7 @@
options.state_path = base::FilePath{FLAGS_state_path};
options.test_definitions_path = base::FilePath{FLAGS_test_definitions_path};
options.xmpp_enabled = FLAGS_enable_xmpp;
+ options.privet.config_path = base::FilePath{FLAGS_config_path};
options.privet.disable_privet = FLAGS_disable_privet;
options.privet.disable_security = FLAGS_disable_security;
options.privet.enable_ping = FLAGS_enable_ping;
diff --git a/buffet/privet/privet_manager.cc b/buffet/privet/privet_manager.cc
index 7b23326..2ae9c8a 100644
--- a/buffet/privet/privet_manager.cc
+++ b/buffet/privet/privet_manager.cc
@@ -49,7 +49,6 @@
using libwebserv::Request;
using libwebserv::Response;
-const char kDefaultConfigFilePath[] = "/etc/privetd/privetd.conf";
const char kDefaultStateFilePath[] = "/var/lib/privetd/privetd.state";
std::string GetFirstHeader(const Request& request, const std::string& name) {
@@ -74,16 +73,15 @@
disable_security_ = options.disable_security;
// TODO(vitalybuka): switch to BuffetConfig.
- base::FilePath config_path{privetd::kDefaultConfigFilePath};
base::FilePath state_path{privetd::kDefaultStateFilePath};
state_store_.reset(new DaemonState(state_path));
parser_.reset(new PrivetdConfigParser);
chromeos::KeyValueStore config_store;
- if (!config_store.Load(config_path)) {
+ if (!config_store.Load(options.config_path)) {
LOG(ERROR) << "Failed to read privetd config file from "
- << config_path.value();
+ << options.config_path.value();
} else {
CHECK(parser_->Parse(config_store)) << "Failed to read configuration file.";
}
diff --git a/buffet/privet/privet_manager.h b/buffet/privet/privet_manager.h
index 25ff43b..c54b6f0 100644
--- a/buffet/privet/privet_manager.h
+++ b/buffet/privet/privet_manager.h
@@ -54,6 +54,7 @@
bool disable_security{false};
bool enable_ping{false};
std::set<std::string> device_whitelist;
+ base::FilePath config_path;
};
Manager();