daemon: added command-line option to disable runtime plugin loading.
authorKrisztian Litkey <kli@iki.fi>
Thu, 21 Nov 2013 15:48:02 +0000 (17:48 +0200)
committerKrisztian Litkey <kli@iki.fi>
Thu, 21 Nov 2013 15:48:02 +0000 (17:48 +0200)
src/core/context.h
src/core/plugin.c
src/daemon/config.c

index 00616fb..357d9f5 100644 (file)
@@ -66,6 +66,7 @@ struct mrp_context_s {
     const char *whitelist_plugins;         /* whitelisted plugins */
     const char *whitelist_builtin;         /* whitelisted builtin plugins */
     const char *whitelist_dynamic;         /* whitelisted dynamic plugins */
+    bool        disable_runtime_load;      /* disallow post-startup loading */
     bool        disable_console;           /* disable murphy console */
 
     /* actual runtime context data */
index 75988eb..1a12dd4 100644 (file)
@@ -303,6 +303,11 @@ mrp_plugin_t *mrp_load_plugin(mrp_context_t *ctx, const char *name,
     if (instance == NULL)
         instance = name;
 
+    if (ctx->state == MRP_STATE_RUNNING && ctx->disable_runtime_load) {
+        mrp_log_error("Post-startup plugin loading has been disabled.");
+        return NULL;
+    }
+
     if (find_plugin_instance(ctx, instance) != NULL) {
         mrp_log_error("Plugin '%s' has already been loaded.", instance);
         return NULL;
index 512a57c..c3794a1 100644 (file)
@@ -93,6 +93,8 @@ static void print_usage(mrp_context_t *ctx, const char *argv0, int exit_code,
            "  -w, --whitelist-plugins <list> disable list of plugins\n"
            "  -i, --whitelist-builtin <list> disable list of builtin plugins\n"
            "  -e, --whitelist-dynamic <list> disable list of dynamic plugins\n"
+           "  -R, --no-poststart-load        "
+                    "disable post-startup plugin loading\n"
            "  -p, --disable-console          disable Murphy debug console\n"
            "  -V, --valgrind                 run through valgrind\n",
            argv0, ctx->config_file, ctx->config_dir, ctx->plugin_dir);
@@ -227,7 +229,7 @@ static void config_set_defaults(mrp_context_t *ctx, char *argv0)
 
 void mrp_parse_cmdline(mrp_context_t *ctx, int argc, char **argv, char **envp)
 {
-#   define OPTIONS "c:C:l:t:fP:a:vd:DhHqB:I:E:w:i:e:pV"
+#   define OPTIONS "c:C:l:t:fP:a:vd:DhHqB:I:E:w:i:e:RpV"
     struct option options[] = {
         { "config-file"      , required_argument, NULL, 'c' },
         { "config-dir"       , required_argument, NULL, 'C' },
@@ -249,6 +251,7 @@ void mrp_parse_cmdline(mrp_context_t *ctx, int argc, char **argv, char **envp)
         { "whitelist-plugins", required_argument, NULL, 'w' },
         { "whitelist-builtin", required_argument, NULL, 'i' },
         { "whitelist-dynamic", required_argument, NULL, 'e' },
+        { "no-poststart-load", no_argument      , NULL, 'R' },
         { "disable-console"  , no_argument      , NULL, 'p' },
         { "valgrind"         , optional_argument, NULL, 'V' },
         { NULL, 0, NULL, 0 }
@@ -392,6 +395,12 @@ void mrp_parse_cmdline(mrp_context_t *ctx, int argc, char **argv, char **envp)
             SAVE_OPTARG("-e", optarg);
             ctx->whitelist_dynamic = optarg;
             break;
+
+        case 'R':
+            SAVE_OPT("-R");
+            ctx->disable_runtime_load = true;
+            break;
+
         case 'p':
             SAVE_OPT("-p");
             ctx->disable_console = TRUE;