diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-18 19:41:28 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-18 19:41:28 -0500 |
commit | 918125404fdf222caef16f8cf3798e20266ae662 (patch) | |
tree | 19df60cf84f58d0fd26809598910c046f561d002 /hscript/user.cc | |
parent | 1f64481933503f9ee12603a2ef076e5e1e987abe (diff) | |
download | horizon-918125404fdf222caef16f8cf3798e20266ae662.tar.gz horizon-918125404fdf222caef16f8cf3798e20266ae662.tar.bz2 horizon-918125404fdf222caef16f8cf3798e20266ae662.tar.xz horizon-918125404fdf222caef16f8cf3798e20266ae662.zip |
hscript: Implement some Username logic, add tests
Diffstat (limited to 'hscript/user.cc')
-rw-r--r-- | hscript/user.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/hscript/user.cc b/hscript/user.cc index 92fed4e..40a8022 100644 --- a/hscript/user.cc +++ b/hscript/user.cc @@ -107,11 +107,21 @@ bool RootPassphrase::execute(ScriptOptions options) const { Key *Username::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { - return nullptr; -} + if(data.find_first_of(' ') != std::string::npos) { + if(errors) *errors += 1; + output_error("installfile:" + std::to_string(lineno), + "username: invalid username specified"); + return nullptr; + } -bool Username::validate(ScriptOptions) const { - return false; + if(system_names.find(data) != system_names.end()) { + if(errors) *errors += 1; + output_error("installfile:" + std::to_string(lineno), + "username: " + data + " is a reserved system username"); + return nullptr; + } + + return new Username(lineno, data); } bool Username::execute(ScriptOptions) const { |