summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
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;
};