diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-31 21:30:06 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-31 21:30:06 -0500 |
commit | 011f7069677c77ee3039d94aef7bc25030ab3309 (patch) | |
tree | 0ac1ae8a99d8f8d58ebb47efb6481289aa570f79 /hscript/disk.cc | |
parent | 1342fe0f855d72642c250c7c4be3509fb2257d7b (diff) | |
download | horizon-011f7069677c77ee3039d94aef7bc25030ab3309.tar.gz horizon-011f7069677c77ee3039d94aef7bc25030ab3309.tar.bz2 horizon-011f7069677c77ee3039d94aef7bc25030ab3309.tar.xz horizon-011f7069677c77ee3039d94aef7bc25030ab3309.zip |
hscript: Implement Encrypt, add tests
Diffstat (limited to 'hscript/disk.cc')
-rw-r--r-- | hscript/disk.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index 05fb6d2..ad253b3 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -233,6 +233,37 @@ bool DiskLabel::execute(ScriptOptions options) const { } +Key *Encrypt::parseFromData(const std::string &data, int lineno, int *errors, + int *) { + std::string::size_type sep = data.find(' '); + std::string dev, pass; + + if(sep == std::string::npos) { + dev = data; + } else { + dev = data.substr(0, sep); + pass = data.substr(sep + 1); + } + + if(dev.size() < 6 || dev.compare(0, 5, "/dev/")) { + if(errors) *errors += 1; + output_error("installfile:" + std::to_string(lineno), + "encrypt: expected path to block device"); + return nullptr; + } + + return new Encrypt(lineno, dev, pass); +} + +bool Encrypt::validate(ScriptOptions) const { + return true; +} + +bool Encrypt::execute(ScriptOptions) const { + return false; +} + + /*! Parse a size string into a size and type. * @param in_size (in) The string to parse. * @param out_size (out) Where to which to write the size in bytes or %. |