From: Eric Bollengier Date: Fri, 5 Nov 2010 13:43:37 +0000 (+0100) Subject: Allow Plugin command without argument X-Git-Tag: Release-7.0.0~1438 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0b8951e87bddb06bd466fca629df5e825511ef19;p=bacula%2Fbacula Allow Plugin command without argument --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index d235d0c185..cc31de09b6 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -232,23 +232,32 @@ bool plugin_check_file(JCR *jcr, char *fname) * systemstate:/@SYSTEMSTATE/ * => ret = 11 * => can use strncmp(plugin_name, cmd, ret); + * + * The plugin command can contain only the plugin name + * Plugin = alldrives + * => ret = 9 */ static bool get_plugin_name(JCR *jcr, char *cmd, int *ret) { char *p; int len; - if (!cmd) { + if (!cmd || (*cmd == '\0')) { return false; } /* Handle plugin command here backup */ Dmsg1(dbglvl, "plugin cmd=%s\n", cmd); - if (!(p = strchr(cmd, ':'))) { - Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd); - return false; - } - len = p - cmd; - if (len <= 0) { - return false; + if ((p = strchr(cmd, ':')) == NULL) { + if (strchr(cmd, ' ') == NULL) { /* we have just the plugin name */ + len = strlen(cmd); + } else { + Jmsg1(jcr, M_ERROR, 0, "Malformed plugin command: %s\n", cmd); + return false; + } + } else { /* plugin:argument */ + len = p - cmd; + if (len <= 0) { + return false; + } } *ret = len; return true;