Do not fatal out when an unknown filetype shows up. Also change the message sent from parser/filemode process to main from type::file::repoid to type::repoid::file since that simplifies the code a fair amount.
-- :wq Claudio Index: filemode.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/filemode.c,v retrieving revision 1.18 diff -u -p -r1.18 filemode.c --- filemode.c 29 Nov 2022 10:33:09 -0000 1.18 +++ filemode.c 5 Jan 2023 10:09:45 -0000 @@ -534,6 +534,7 @@ parse_file(struct entityq *q, struct msg b = io_new_buffer(); io_simple_buffer(b, &entp->type, sizeof(entp->type)); + io_simple_buffer(b, &entp->repoid, sizeof(entp->repoid)); io_str_buffer(b, entp->file); io_close_buffer(msgq, b); entity_free(entp); Index: main.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v retrieving revision 1.229 diff -u -p -r1.229 main.c --- main.c 15 Dec 2022 12:02:29 -0000 1.229 +++ main.c 5 Jan 2023 10:08:55 -0000 @@ -548,6 +548,7 @@ entity_process(struct ibuf *b, struct st * We follow that up with whether the resources didn't parse. */ io_read_buf(b, &type, sizeof(type)); + io_read_buf(b, &id, sizeof(id)); io_read_str(b, &file); /* in filemode messages can be ignored, only the accounting matters */ @@ -559,7 +560,6 @@ entity_process(struct ibuf *b, struct st goto done; } - io_read_buf(b, &id, sizeof(id)); rp = repo_byid(id); repo_stat_inc(rp, type, STYPE_OK); switch (type) { @@ -638,7 +638,8 @@ entity_process(struct ibuf *b, struct st case RTYPE_FILE: break; default: - errx(1, "unknown entity type %d", type); + warnx("%s: unknown entity type %d", file, type); + break; } done: Index: parser.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/parser.c,v retrieving revision 1.81 diff -u -p -r1.81 parser.c --- parser.c 15 Dec 2022 12:02:29 -0000 1.81 +++ parser.c 5 Jan 2023 10:08:05 -0000 @@ -630,14 +630,13 @@ parse_entity(struct entityq *q, struct m /* pass back at least type, repoid and filename */ b = io_new_buffer(); io_simple_buffer(b, &entp->type, sizeof(entp->type)); + io_simple_buffer(b, &entp->repoid, sizeof(entp->repoid)); file = NULL; f = NULL; switch (entp->type) { case RTYPE_TAL: io_str_buffer(b, entp->file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); if ((tal = tal_parse(entp->file, entp->data, entp->datasz)) == NULL) errx(1, "%s: could not parse tal file", @@ -649,8 +648,6 @@ parse_entity(struct entityq *q, struct m case RTYPE_CER: file = parse_load_file(entp, &f, &flen); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); if (entp->data != NULL) cert = proc_parser_root_cert(file, f, flen, entp->data, entp->datasz, @@ -677,14 +674,10 @@ parse_entity(struct entityq *q, struct m file = parse_filepath(entp->repoid, entp->path, entp->file, entp->location); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); break; case RTYPE_MFT: file = proc_parser_mft(entp, &mft); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); c = (mft != NULL); io_simple_buffer(b, &c, sizeof(int)); if (mft != NULL) @@ -694,8 +687,6 @@ parse_entity(struct entityq *q, struct m case RTYPE_ROA: file = parse_load_file(entp, &f, &flen); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); roa = proc_parser_roa(file, f, flen); c = (roa != NULL); io_simple_buffer(b, &c, sizeof(int)); @@ -706,15 +697,11 @@ parse_entity(struct entityq *q, struct m case RTYPE_GBR: file = parse_load_file(entp, &f, &flen); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); proc_parser_gbr(file, f, flen); break; case RTYPE_ASPA: file = parse_load_file(entp, &f, &flen); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); aspa = proc_parser_aspa(file, f, flen); c = (aspa != NULL); io_simple_buffer(b, &c, sizeof(int)); @@ -725,12 +712,14 @@ parse_entity(struct entityq *q, struct m case RTYPE_TAK: file = parse_load_file(entp, &f, &flen); io_str_buffer(b, file); - io_simple_buffer(b, &entp->repoid, - sizeof(entp->repoid)); proc_parser_tak(file, f, flen); break; default: - errx(1, "unhandled entity type %d", entp->type); + file = parse_filepath(entp->repoid, entp->path, + entp->file, entp->location); + io_str_buffer(b, file); + warnx("%s: unhandled type %d", file, entp->type); + break; } free(f);