FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 03-30-2011, 11:07 PM
Rémy Oudompheng
 
Default handle: define a new callback for signature check

This callback will make possible the use of an external
tool to check signatures.

Signed-off-by: Rémy Oudompheng <remy@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
 
Old 04-10-2011, 11:38 AM
Rémy Oudompheng
 
Default handle: define a new callback for signature check

This callback will make possible the use of an external
tool to check signatures.

Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
---
lib/libalpm/alpm.h | 12 ++++++++++++
lib/libalpm/error.c | 2 ++
lib/libalpm/handle.c | 13 +++++++++++++
lib/libalpm/handle.h | 1 +
4 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 1777bf2..7979e9f 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -99,6 +99,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);
+
/** Fetch a remote pkg.
* @param url URL of the package to download
* @return the downloaded filepath on success, NULL on error
@@ -128,6 +135,10 @@ 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);

+/** Get/set the signature checking callback. */
+alpm_cb_checksig alpm_option_get_checksigcb(void);
+int alpm_option_set_checksigcb(alpm_cb_checksig cb);
+
/** Get/set the root of the destination filesystem. */
const char *alpm_option_get_root(void);
int alpm_option_set_root(const char *root);
@@ -942,6 +953,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 fd40f19..da5309d 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.4
 

Thread Tools




All times are GMT. The time now is 06:32 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org