Make legacy app handler refuse invalid shutdown modes
authorJonathan Maw <jonathan.maw@codethink.co.uk>
Fri, 3 Aug 2012 13:09:06 +0000 (14:09 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Fri, 3 Aug 2012 13:43:11 +0000 (14:43 +0100)
Added code to the register signal handler to refuse any register signal
which is not a combination of NSM_SHUTDOWN_TYPE_NORMAL and
NSM_SHUTDOWN_TYPE_FAST and log an error.

node-startup-controller/la-handler-service.c

index 32aa007..85769eb 100644 (file)
@@ -310,6 +310,17 @@ la_handler_service_handle_register (LAHandler             *interface,
   g_return_val_if_fail (unit != NULL && *unit != '\0', FALSE);
   g_return_val_if_fail (LA_HANDLER_IS_SERVICE (service), FALSE);
 
+  if (shutdown_mode != NSM_SHUTDOWN_TYPE_NORMAL
+      && shutdown_mode != NSM_SHUTDOWN_TYPE_FAST
+      && shutdown_mode != NSM_SHUTDOWN_TYPE_NORMAL | NSM_SHUTDOWN_TYPE_FAST)
+    {
+      /* the shutdown mode is invalid */
+      DLT_LOG (la_handler_context, DLT_LOG_ERROR,
+               DLT_STRING ("Register called with invalid shutdown mode"));
+      la_handler_complete_register (interface, invocation);
+      return TRUE;
+    }
+
   /* find out if we have a shutdown client for this unit already */
   client = g_hash_table_lookup (service->units_to_clients, unit);
   if (client != NULL)