summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-07 18:29:11 +0200
committerDan McGee <dan@archlinux.org>2012-04-07 18:29:11 +0200
commit42d408e0c253beca56f640729a85badffedd8a3f (patch)
tree8f1b367dd6e0c8cc27daaca15d2583dd1c8cf6a9 /lib/libalpm
parentcb5ae428b63c9807f855638c00720f54ea73413f (diff)
downloadpacman-42d408e0c253beca56f640729a85badffedd8a3f.tar.gz
pacman-42d408e0c253beca56f640729a85badffedd8a3f.tar.xz
Return more useful error codes on package open failures
Failure isn't always due to the package file location not existing; permission issues can also play a part on something like a FUSE-based filesystem inaccessible to root. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/be_package.c13
-rw-r--r--lib/libalpm/error.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index a33a591a..ce3ad55d 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -319,7 +319,14 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
/* attempt to access the package file, ensure it exists */
if(_alpm_access(handle, NULL, pkgfile, R_OK) != 0) {
- RET_ERR(handle, ALPM_ERR_PKG_NOT_FOUND, -1);
+ if(errno == ENOENT) {
+ handle->pm_errno = ALPM_ERR_PKG_NOT_FOUND;
+ } else if(errno == EACCES) {
+ handle->pm_errno = ALPM_ERR_BADPERMS;
+ } else {
+ handle->pm_errno = ALPM_ERR_PKG_OPEN;
+ }
+ return -1;
}
/* can we get away with skipping checksums? */
@@ -407,6 +414,10 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
if(fd < 0) {
if(errno == ENOENT) {
handle->pm_errno = ALPM_ERR_PKG_NOT_FOUND;
+ } else if(errno == EACCES) {
+ handle->pm_errno = ALPM_ERR_BADPERMS;
+ } else {
+ handle->pm_errno = ALPM_ERR_PKG_OPEN;
}
return NULL;
}
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 5354a47e..86b4efb2 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -41,7 +41,7 @@ const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
case ALPM_ERR_SYSTEM:
return _("unexpected system error");
case ALPM_ERR_BADPERMS:
- return _("insufficient privileges");
+ return _("permission denied");
case ALPM_ERR_NOT_A_FILE:
return _("could not find or read file");
case ALPM_ERR_NOT_A_DIR: