diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-02 16:09:44 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-02 16:09:44 -0500 |
commit | 3dbe0982a10c823a2793a3d125beba2edf75f1f7 (patch) | |
tree | daaa08bbe9a31318e0e8c5c083afecfb7b5f5e1b /hscript | |
parent | 26849aa92e046b15d1c80c623b20f20f89e52b65 (diff) | |
download | horizon-3dbe0982a10c823a2793a3d125beba2edf75f1f7.tar.gz horizon-3dbe0982a10c823a2793a3d125beba2edf75f1f7.tar.bz2 horizon-3dbe0982a10c823a2793a3d125beba2edf75f1f7.tar.xz horizon-3dbe0982a10c823a2793a3d125beba2edf75f1f7.zip |
hscript: Filesystem::execute: null-terminate argv, pass environ
Diffstat (limited to 'hscript')
-rw-r--r-- | hscript/disk.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index 1aaf45f..35936ac 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -482,6 +482,10 @@ bool Partition::validate(ScriptOptions opts) const { } bool Partition::execute(ScriptOptions opts) const { + output_info("installfile:" + std::to_string(this->lineno()), + "partition: creating partition #" + std::to_string(_partno) + + " on " + _block); + if(opts.test(Simulate)) { output_error("installfile:" + std::to_string(this->lineno()), "partition: Not supported in Simulation mode"); @@ -826,6 +830,9 @@ bool Filesystem::execute(ScriptOptions opts) const { std::string cmd; std::vector<std::string> args; + output_info("installfile:" + std::to_string(line), + "fs: creating new filesystem on " + _block); + switch(_type) { case Ext2: cmd = "mkfs.ext2"; @@ -870,7 +877,7 @@ bool Filesystem::execute(ScriptOptions opts) const { } #ifdef HAS_INSTALL_ENV - const char **argv = new const char*[args.size() + 1]; + const char **argv = new const char*[args.size() + 2]; pid_t child; int status; @@ -878,13 +885,14 @@ bool Filesystem::execute(ScriptOptions opts) const { for(unsigned long index = 0; index < args.size(); index++) { argv[index + 1] = args.at(index).c_str(); } + argv[args.size() + 1] = nullptr; status = posix_spawnp(&child, cmd.c_str(), nullptr, nullptr, - const_cast<char * const *>(argv), nullptr); + const_cast<char * const *>(argv), environ); if(status != 0) { /* extremely unlikely failure case */ output_error("installfile:" + std::to_string(this->lineno()), - "filesystem: cannot fork", strerror(status)); + "fs: cannot fork", strerror(status)); delete[] argv; return false; } @@ -894,13 +902,13 @@ bool Filesystem::execute(ScriptOptions opts) const { if(waitpid(child, &status, 0) == -1) { /* unlikely failure case */ output_error("installfile:" + std::to_string(this->lineno()), - "filesystem: waitpid", strerror(errno)); + "fs: waitpid", strerror(errno)); return false; } if(!WIFEXITED(status)) { output_error("installfile:" + std::to_string(this->lineno()), - "filesystem: received fatal signal " + + "fs: received fatal signal " + std::to_string(WTERMSIG(status)) + " while running " + cmd); return false; @@ -908,7 +916,7 @@ bool Filesystem::execute(ScriptOptions opts) const { if(WEXITSTATUS(status) != 0) { output_error("installfile:" + std::to_string(this->lineno()), - "filesystem: " + cmd + " exited with status " + + "fs: " + cmd + " exited with status " + std::to_string(WEXITSTATUS(status))); return false; } |