From: Davin McCall Date: Thu, 26 Dec 2019 05:07:18 +0000 (+0000) Subject: dinitcheck: check for missing service command X-Git-Tag: v0.8.1~11 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=320ab1b43c8ff7b84dacee256f744ba664bd0c2f;p=oweals%2Fdinit.git dinitcheck: check for missing service command --- diff --git a/src/dinitcheck.cc b/src/dinitcheck.cc index 140ee2b..c23f264 100644 --- a/src/dinitcheck.cc +++ b/src/dinitcheck.cc @@ -214,12 +214,17 @@ int main(int argc, char **argv) return errors_found ? EXIT_FAILURE : EXIT_SUCCESS; } -static void report_service_description_exc(service_description_exc &exc) +static void report_service_description_err(const std::string &service_name, const std::string &what) { - std::cerr << "Service '" << exc.service_name << "': " << exc.exc_description << "\n"; + std::cerr << "Service '" << service_name << "': " << what << "\n"; errors_found = true; } +static void report_service_description_exc(service_description_exc &exc) +{ + report_service_description_err(exc.service_name, exc.exc_description); +} + static void report_error(std::system_error &exc, const std::string &service_name) { std::cerr << "Service '" << service_name << "', error reading service description: " << exc.what() << "\n"; @@ -330,5 +335,9 @@ service_record *load_service(service_set_t &services, const std::string &name, return nullptr; } + if (settings.service_type != service_type_t::INTERNAL && settings.command.length() == 0) { + report_service_description_err(name, "Service command not specified."); + } + return new service_record(name, settings.depends); } diff --git a/src/igr-tests/check-basic/expected.txt b/src/igr-tests/check-basic/expected.txt index 43f5cd5..4f32b25 100644 --- a/src/igr-tests/check-basic/expected.txt +++ b/src/igr-tests/check-basic/expected.txt @@ -1,6 +1,7 @@ Checking service: boot... Service 'boot': Unknown setting: 'not-valid'. Service 'boot': run-as: Specified user id contains invalid numeric characters or is outside allowed range. +Service 'boot': Service command not specified. Checking service: test1... Unable to load service 'test1': Service description not found. One or more errors found.