From 90025fbec30a78e84794585bf93604d56b392267 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 7 Oct 2019 17:48:21 -0500 Subject: hscript: Implement key validity test --- hscript/script.cc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'hscript/script.cc') diff --git a/hscript/script.cc b/hscript/script.cc index 3196d9e..e53154b 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -13,6 +13,8 @@ #include #include #include +#include + #include "script.hh" #include "disk.hh" #include "meta.hh" @@ -23,6 +25,26 @@ #define LINE_MAX 512 + +const std::set valid_keys = { + "network", "hostname", "pkginstall", "rootpw", + "language", "keymap", "firmware", + "netaddress", "nameserver", "netssid", + "timezone", "repository", "signingkey", + "username", "useralias", "userpw", "usericon", "usergroups", + "diskid", "disklabel", "partition", "lvm_pv", "lvm_vg", "lvm_lv", + "encrypt", "fs", "mount" +}; + + +/*! Determines if the specified +key+ has been defined in this version of + * HorizonScript. + */ +inline bool is_key(const std::string key) { + return valid_keys.find(key) != valid_keys.end(); +} + + namespace Horizon { struct Script::ScriptPrivate { @@ -53,13 +75,6 @@ const Script *Script::load(const std::string path, const ScriptOptions opts) { return Script::load(file, opts); } -/*! Determines if the specified +key+ has been defined in this version of - * HorizonScript. - */ -bool is_key(std::string key) { - return true; -} - #define PARSER_ERROR(err_str) \ errors++;\ output_error("installfile:" + std::to_string(lineno),\ -- cgit v1.2.3-60-g2f50