dinitcheck: check for missing service command
authorDavin McCall <davmac@davmac.org>
Thu, 26 Dec 2019 05:07:18 +0000 (05:07 +0000)
committerDavin McCall <davmac@davmac.org>
Thu, 26 Dec 2019 05:07:18 +0000 (05:07 +0000)
src/dinitcheck.cc
src/igr-tests/check-basic/expected.txt

index 140ee2ba4189c5b9b34f0dc6489abc98a5ada1d5..c23f2649d8ef0ca54cca6f7290d13056372959a6 100644 (file)
@@ -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);
 }
index 43f5cd5348394ca22241af21d3abed1619d915c1..4f32b25ee13aa6923db23a91f2230675c1ea88cd 100644 (file)
@@ -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.