diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-11-17 21:51:32 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-11-17 21:51:32 -0600 |
commit | 3f3d176e2d3960b9c18589e64af2fbe9de435f0d (patch) | |
tree | b3da7478e5c8d9d13f38877a93ba704e9acace15 | |
parent | 8801c9ccaeaab68174312cf025bce771e2ea77df (diff) | |
download | horizon-3f3d176e2d3960b9c18589e64af2fbe9de435f0d.tar.gz horizon-3f3d176e2d3960b9c18589e64af2fbe9de435f0d.tar.bz2 horizon-3f3d176e2d3960b9c18589e64af2fbe9de435f0d.tar.xz horizon-3f3d176e2d3960b9c18589e64af2fbe9de435f0d.zip |
Executor: Only stack runlevels if runlevels exist
If we are doing a mini-rootfs or container installation, we may not have
OpenRC at all. This would mean /etc/runlevels doesn't exist in the target.
In that case, we crash with:
boost::filesystem::directory_iterator::construct: No such file or directory
[system:2]: "/tmp/horizon-image/target/etc/runlevels"
Closes: #378
Fixes: a9ccd9bc7e ("hscript: Allow svcenable to create new runlevels")
-rw-r--r-- | hscript/script_e.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/hscript/script_e.cc b/hscript/script_e.cc index 8f0f4b4..50f92e1 100644 --- a/hscript/script_e.cc +++ b/hscript/script_e.cc @@ -678,14 +678,14 @@ bool Script::execute() const { EXECUTE_OR_FAIL("svcenable", svc) } #ifdef HAS_INSTALL_ENV - if(!opts.test(Simulate)) { - const std::set<std::string> def_runlevels{ + if(!opts.test(Simulate) && fs::exists(targ_etc + "/runlevels", ec)) { + const std::set<std::string> def_runlevels{ "boot", "default", "empty", "nonetwork", "shutdown", "sysinit" }; - const auto rl_dir{targ_etc + "/runlevels"}; + const auto rl_dir{targ_etc + "/runlevels"}; for(auto &&file : fs::directory_iterator(rl_dir)) { const auto runlevel{file.path().filename().string()}; - if(def_runlevels.find(runlevel) == def_runlevels.end()) { + if(def_runlevels.find(runlevel) == def_runlevels.end()) { fs::create_symlink("../default", rl_dir + "/" + runlevel + "/default", ec); if(ec) { |