From 918125404fdf222caef16f8cf3798e20266ae662 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Fri, 18 Oct 2019 19:41:28 -0500 Subject: hscript: Implement some Username logic, add tests --- hscript/user.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'hscript/user.cc') 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 { -- cgit v1.2.3-70-g09d2