[pacman-dev] [PATCH 1/2] handle: define a new callback for signature check
Rémy Oudompheng
remyoudompheng at gmail.com
Wed Mar 30 19:07:27 EDT 2011
This callback will make possible the use of an external
tool to check signatures.
Signed-off-by: Rémy Oudompheng <remy at archlinux.org>
---
lib/libalpm/alpm.h | 11 +++++++++++
lib/libalpm/error.c | 2 ++
lib/libalpm/handle.c | 13 +++++++++++++
lib/libalpm/handle.h | 1 +
4 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index b08191d..5fb3d86 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -94,6 +94,13 @@ typedef void (*alpm_cb_totaldl)(off_t total);
typedef int (*alpm_cb_fetch)(const char *url, const char *localpath,
int force);
+/** A callback for checking signatures.
+ * @param path the path of the signed file
+ * @param sig the signature to check
+ * @return an int value : 0 (valid), 1 (invalid), -1 (an error occured)
+ */
+typedef int (*alpm_cb_checksig)(const char *path, const pmpgpsig_t *sig);
+
/*
* Options
*/
@@ -110,6 +117,9 @@ void alpm_option_set_fetchcb(alpm_cb_fetch cb);
alpm_cb_totaldl alpm_option_get_totaldlcb(void);
void alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
+alpm_cb_checksig alpm_option_get_checksigcb(void);
+int alpm_option_set_checksigcb(alpm_cb_checksig cb);
+
const char *alpm_option_get_root(void);
int alpm_option_set_root(const char *root);
@@ -561,6 +571,7 @@ enum _pmerrno_t {
PM_ERR_LIBARCHIVE,
PM_ERR_LIBCURL,
PM_ERR_EXTERNAL_DOWNLOAD,
+ PM_ERR_EXTERNAL_SIGCHECK,
PM_ERR_GPGME
};
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 4d4a065..839ecc3 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -158,6 +158,8 @@ const char SYMEXPORT *alpm_strerror(int err)
return _("gpgme error");
case PM_ERR_EXTERNAL_DOWNLOAD:
return _("error invoking external downloader");
+ case PM_ERR_EXTERNAL_SIGCHECK:
+ return _("error invoking external signature check");
/* Unknown error! */
default:
return _("unexpected error");
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 42c0cd1..5eb0dc5 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -130,6 +130,12 @@ alpm_cb_totaldl SYMEXPORT alpm_option_get_totaldlcb()
return handle->totaldlcb;
}
+alpm_cb_checksig SYMEXPORT alpm_option_get_checksigcb()
+{
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL));
+ return handle->checksigcb;
+}
+
const char SYMEXPORT *alpm_option_get_root()
{
if (handle == NULL) {
@@ -310,6 +316,13 @@ void SYMEXPORT alpm_option_set_totaldlcb(alpm_cb_totaldl cb)
handle->totaldlcb = cb;
}
+int SYMEXPORT alpm_option_set_checksigcb(alpm_cb_checksig cb)
+{
+ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+ handle->checksigcb = cb;
+ return 0;
+}
+
int SYMEXPORT alpm_option_set_root(const char *root)
{
struct stat st;
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index cf192bc..2f2e5d2 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -52,6 +52,7 @@ typedef struct _pmhandle_t {
alpm_cb_download dlcb; /* Download callback function */
alpm_cb_totaldl totaldlcb; /* Total download callback function */
alpm_cb_fetch fetchcb; /* Download file callback function */
+ alpm_cb_checksig checksigcb; /* Signature check callback function */
/* filesystem paths */
char *root; /* Root path, default '/' */
--
1.7.4.2
More information about the pacman-dev
mailing list