From 0c7a47300d76d05b4e87b16283cd09bf53d2a0a2 Mon Sep 17 00:00:00 2001 From: Sergio Correia Date: Wed, 7 Dec 2022 08:05:30 -0300 Subject: [PATCH] Report error details when json_load_file() fails --- ...ile-fails-report-the-error-details-i.patch | 36 +++++++++++++++++++ tang.spec | 7 +++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 0001-When-json_load_file-fails-report-the-error-details-i.patch diff --git a/0001-When-json_load_file-fails-report-the-error-details-i.patch b/0001-When-json_load_file-fails-report-the-error-details-i.patch new file mode 100644 index 0000000..f374c47 --- /dev/null +++ b/0001-When-json_load_file-fails-report-the-error-details-i.patch @@ -0,0 +1,36 @@ +From dac0dd6f729ed6cbdd4c92f5a8b2f5e1c66127fb Mon Sep 17 00:00:00 2001 +From: Barry +Date: Fri, 25 Nov 2022 16:36:26 +0000 +Subject: [PATCH] When json_load_file fails report the error details + information (#103) + +* When json_load_file fails report the error details information returned. + +This allows for file I/O issues as well as JSON parsing issues +to be reported. +--- + src/keys.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/keys.c b/src/keys.c +index 205bbe5..bbfc374 100644 +--- a/src/keys.c ++++ b/src/keys.c +@@ -369,9 +369,12 @@ load_keys(const char* jwkdir) + continue; + } + filepath[sizeof(filepath) - 1] = '\0'; +- json_auto_t* json = json_load_file(filepath, 0, NULL); ++ json_error_t error; ++ json_auto_t* json = json_load_file(filepath, 0, &error); + if (!json) { +- fprintf(stderr, "Invalid JSON file (%s); skipping\n", filepath); ++ fprintf(stderr, "Cannot load JSON file (%s); skipping\n", filepath); ++ fprintf(stderr, "error text %s, line %d, col %d, pos %d\n", ++ error.text, error.line, error.column, error.position); + continue; + } + +-- +2.38.1 + diff --git a/tang.spec b/tang.spec index 3423adc..1b62c2b 100644 --- a/tang.spec +++ b/tang.spec @@ -1,6 +1,6 @@ Name: tang Version: 11 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Network Presence Binding Daemon License: GPLv3+ @@ -8,6 +8,8 @@ URL: https://github.com/latchset/%{name} Source0: https://github.com/latchset/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.xz Source1: tang.sysusers +Patch: 0001-When-json_load_file-fails-report-the-error-details-i.patch + BuildRequires: gcc BuildRequires: meson BuildRequires: git-core @@ -98,6 +100,9 @@ fi %{_sysusersdir}/tang.conf %changelog +* Wed Dec 07 2022 Sergio Correia - 11-5 +- Report error details when json_load_file() fails + * Wed Aug 17 2022 Sergio Arroutbi - 11-4 - Adopt systemd-sysusers format