From: Michal Rakowski Date: Wed, 23 Jun 2021 20:58:22 +0000 (+0200) Subject: Fix backward compatibility problem for plugin objects X-Git-Tag: Release-11.3.2~478 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e949cce6c414ca9b6361554a02a2aaaad90c816;p=thirdparty%2Fbacula.git Fix backward compatibility problem for plugin objects --- diff --git a/bacula/src/cats/cats.c b/bacula/src/cats/cats.c index aa0fe9d06..46319d0b7 100644 --- a/bacula/src/cats/cats.c +++ b/bacula/src/cats/cats.c @@ -166,6 +166,7 @@ bool OBJECT_DBR::parse_plugin_object_string(char **obj_str) { bool ret = false; int fnl, pnl; + uint64_t val = 0; char *tmp = get_next_tag(obj_str); if (!tmp) { @@ -224,38 +225,37 @@ bool OBJECT_DBR::parse_plugin_object_string(char **obj_str) unbash_spaces(ObjectUUID); tmp = get_next_tag(obj_str); - if (tmp) { - uint64_t val = str_to_uint64(tmp); - ObjectSize = (val > 9223372036854775808ULL /*2^63 */) ? 0 : val; - - } else if (*obj_str) { - /* Object size is the last tag here, we are not expecting to have status in the stream */ - uint64_t val = str_to_uint64(*obj_str); - ObjectSize = (val > 9223372036854775808ULL /*2^63 */) ? 0 : val; - ret = true; + if (!tmp) { goto bail_out; + } + val = str_to_uint64(tmp); + ObjectSize = (val > 9223372036854775808ULL /*2^63 */) ? 0 : val; - } else { + /* We should have status and count in the end of the stream */ + tmp = get_next_tag(obj_str); + if (!tmp) { + /* We want to work with plugins that does not send the status and count since it's not required, + * so we're good to proceed here - simply return success */ + ret = true; goto bail_out; } + ObjectStatus = (int)*tmp; - /* We should have status string in the end */ - if (*obj_str) { - tmp = get_next_tag(obj_str); - if (!tmp) { - goto bail_out; - } - ObjectStatus = (int)*tmp; - if (*obj_str) { - ObjectCount = str_to_uint64(*obj_str); - } - } else { + tmp = get_next_tag(obj_str); + if (!tmp) { goto bail_out; } + ObjectCount = str_to_uint64(*obj_str); ret = true; bail_out: + /* Print whatever was parsed */ + Dmsg11(dbglvl, "Parsed PluginObject: Path: %s Fname: %s PluginName: %s Category: %s " + "Type: %s Name: %s Source: %s UUID: %s Size: %lld Status: %d Count: %lld\n", + Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, + ObjectUUID, ObjectSize, (char)ObjectStatus, ObjectCount); + if (!ret) { /* Reset parsed fields */ reset(); diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 2a97ad1e8..6fdea955d 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1214,7 +1214,7 @@ bool BDB::bdb_create_object_record(JCR *jcr, OBJECT_DBR *obj) "VALUES (%lu, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %llu, '%c', %lu)", obj->JobId, esc_path, esc_filename, esc_plugin_name, esc_obj_category, esc_obj_type, esc_obj_name, esc_obj_source, esc_obj_uuid, - obj->ObjectSize, (char)obj->ObjectStatus, obj->ObjectCount); + obj->ObjectSize, obj->ObjectStatus ? (char)obj->ObjectStatus : 'U', obj->ObjectCount); obj->ObjectId = sql_insert_autokey_record(cmd, NT_("Object")); if (obj->ObjectId == 0) { diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 289b465db..ff0f50cc8 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -642,7 +642,8 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) } else if (Stream == STREAM_PLUGIN_OBJECT) { OBJECT_DBR obj_r; if (!obj_r.parse_plugin_object_string(&p)) { - Jmsg0(jcr, M_FATAL, 0, _("Failed to parse plugin object!\n")); + /* Report warning, backup can proceed without plugin object creation */ + Jmsg0(jcr, M_WARNING, 0, _("Failed to parse plugin object!\n")); return; }