summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-18 19:41:28 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-18 19:41:28 -0500
commit918125404fdf222caef16f8cf3798e20266ae662 (patch)
tree19df60cf84f58d0fd26809598910c046f561d002 /hscript
parent1f64481933503f9ee12603a2ef076e5e1e987abe (diff)
downloadhorizon-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')
-rw-r--r--hscript/user.cc18
-rw-r--r--hscript/user.hh1
2 files changed, 14 insertions, 5 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 {
diff --git a/hscript/user.hh b/hscript/user.hh
index b8d5386..d29944f 100644
--- a/hscript/user.hh
+++ b/hscript/user.hh
@@ -36,7 +36,6 @@ private:
StringKey(_line, name) {}
public:
static Key *parseFromData(const std::string &, int, int*, int*);
- bool validate(ScriptOptions) const override;
bool execute(ScriptOptions) const override;
};