[pacman-dev] [PATCH 1/2] User-visible log when validity check fails due to access
Currently, if checking the validity of packages fails due to an access error on one or more packages, the user must sift through debug output in order to find the culprit package(s). This patch adds a call to _alpm_log in such a case to make the culprits more easily visible. --- lib/libalpm/sync.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 696a5131..85f70200 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1187,6 +1187,10 @@ static int check_validity(alpm_handle_t *handle, prompt_to_delete(handle, v->path, v->error); } else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) { prompt_to_delete(handle, v->path, v->error); + } else if(v->error == ALPM_ERR_PKG_NOT_FOUND || + v->error == ALPM_ERR_BADPERMS || + v->error == ALPM_ERR_PKG_OPEN) { + _alpm_log(handle, ALPM_LOG_ERROR, _("error while reading file %s: %s\n"), v->path, alpm_strerror(v->error)); } alpm_siglist_cleanup(v->siglist); free(v->siglist); -- 2.18.0
On 10/9/18 10:59 am, David Phillips wrote:
Currently, if checking the validity of packages fails due to an access error on one or more packages, the user must sift through debug output in order to find the culprit package(s). This patch adds a call to _alpm_log in such a case to make the culprits more easily visible. --- lib/libalpm/sync.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 696a5131..85f70200 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1187,6 +1187,10 @@ static int check_validity(alpm_handle_t *handle, prompt_to_delete(handle, v->path, v->error); } else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) { prompt_to_delete(handle, v->path, v->error); + } else if(v->error == ALPM_ERR_PKG_NOT_FOUND || + v->error == ALPM_ERR_BADPERMS || + v->error == ALPM_ERR_PKG_OPEN) { + _alpm_log(handle, ALPM_LOG_ERROR, _("error while reading file %s: %s\n"), v->path, alpm_strerror(v->error));
This will print: error: error while reading How about "failed to read file %s: %s\n"? You will also need to rebase your switch statement on top of the adjusted patch. It would be better to do the convert to switch first to avoid this. A
--- lib/libalpm/sync.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 696a5131..699fb2fd 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1176,17 +1176,23 @@ static int check_validity(alpm_handle_t *handle, if(errors) { for(i = errors; i; i = i->next) { struct validity *v = i->data; - if(v->error == ALPM_ERR_PKG_MISSING_SIG) { + switch(v->error) { + case ALPM_ERR_PKG_MISSING_SIG: _alpm_log(handle, ALPM_LOG_ERROR, _("%s: missing required signature\n"), v->pkg->name); - } else if(v->error == ALPM_ERR_PKG_INVALID_SIG) { + break; + case ALPM_ERR_PKG_INVALID_SIG: _alpm_process_siglist(handle, v->pkg->name, v->siglist, v->siglevel & ALPM_SIG_PACKAGE_OPTIONAL, v->siglevel & ALPM_SIG_PACKAGE_MARGINAL_OK, v->siglevel & ALPM_SIG_PACKAGE_UNKNOWN_OK); + /* fallthrough */ + case ALPM_ERR_PKG_INVALID_CHECKSUM: prompt_to_delete(handle, v->path, v->error); - } else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) { - prompt_to_delete(handle, v->path, v->error); + break; + default: + /* ignore */ + break; } alpm_siglist_cleanup(v->siglist); free(v->siglist); -- 2.18.0
Currently, if checking the validity of packages fails due to an access error on one or more packages, the user must sift through debug output in order to find the culprit package(s). This patch adds a call to _alpm_log in such a case to make the culprits more easily visible. --- lib/libalpm/sync.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 699fb2fd..1b04e8d4 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1190,6 +1190,11 @@ static int check_validity(alpm_handle_t *handle, case ALPM_ERR_PKG_INVALID_CHECKSUM: prompt_to_delete(handle, v->path, v->error); break; + case ALPM_ERR_PKG_NOT_FOUND: + case ALPM_ERR_BADPERMS: + case ALPM_ERR_PKG_OPEN: + _alpm_log(handle, ALPM_LOG_ERROR, _("failed to read file %s: %s\n"), v->path, alpm_strerror(v->error)); + break; default: /* ignore */ break; -- 2.18.0
On 19/9/18 12:28 pm, David Phillips wrote:
--- lib/libalpm/sync.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Both patches are fine. Note that case statements should be indented one further than the switch statement. I have handed the adjustment. A
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 696a5131..699fb2fd 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1176,17 +1176,23 @@ static int check_validity(alpm_handle_t *handle, if(errors) { for(i = errors; i; i = i->next) { struct validity *v = i->data; - if(v->error == ALPM_ERR_PKG_MISSING_SIG) { + switch(v->error) { + case ALPM_ERR_PKG_MISSING_SIG: _alpm_log(handle, ALPM_LOG_ERROR, _("%s: missing required signature\n"), v->pkg->name); - } else if(v->error == ALPM_ERR_PKG_INVALID_SIG) { + break; + case ALPM_ERR_PKG_INVALID_SIG: _alpm_process_siglist(handle, v->pkg->name, v->siglist, v->siglevel & ALPM_SIG_PACKAGE_OPTIONAL, v->siglevel & ALPM_SIG_PACKAGE_MARGINAL_OK, v->siglevel & ALPM_SIG_PACKAGE_UNKNOWN_OK); + /* fallthrough */ + case ALPM_ERR_PKG_INVALID_CHECKSUM: prompt_to_delete(handle, v->path, v->error); - } else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) { - prompt_to_delete(handle, v->path, v->error); + break; + default: + /* ignore */ + break; } alpm_siglist_cleanup(v->siglist); free(v->siglist);
On Wed, Sep 19, 2018 at 10:53:22AM +1000, Allan McRae wrote:
[...]
This will print:
error: error while reading
How about "failed to read file %s: %s\n"?
Good catch, thanks for that! Please find this amended in an updated version of the patch (forgot to label it as v2).
You will also need to rebase your switch statement on top of the adjusted patch. It would be better to do the convert to switch first to avoid this.
Again thanks for that. I flipped the order of the patches with their second revisions too. Cheers, David
participants (2)
-
Allan McRae
-
David Phillips