about summary refs log tree commit diff
path: root/src/libutil/config.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-04-13T14·31+0200
committerEelco Dolstra <edolstra@gmail.com>2017-04-13T14·31+0200
commit0bf34de43b2fc4c9c3104b986eaea5c5cc856b83 (patch)
treea68787051d9a77fa2ed694f4be50a33d1239ca8a /src/libutil/config.cc
parent1860070548db119fc5f958febff3a087f21d5c83 (diff)
Validate Boolean settings better
Diffstat (limited to 'src/libutil/config.cc')
-rw-r--r--src/libutil/config.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libutil/config.cc b/src/libutil/config.cc
index 2f9f988607..893cdccce3 100644
--- a/src/libutil/config.cc
+++ b/src/libutil/config.cc
@@ -90,7 +90,12 @@ template<> std::string Setting<int>::to_string()
 
 template<> void Setting<bool>::set(const std::string & str)
 {
-    value = str == "true" || str == "1";
+    if (str == "true" || str == "yes" || str == "1")
+        value = true;
+    else if (str == "false" || str == "no" || str == "0")
+        value = false;
+    else
+        throw UsageError("Boolean setting '%s' has invalid value '%s'", name, str);
 }
 
 template<> std::string Setting<bool>::to_string()