From 599d91629e8d8df8fe63dd81d8a492ab293adac2 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 11 May 2017 20:28:22 +0200 Subject: wip Signed-off-by: Florian Pritz --- lib/libalpm/signing.c | 21 ++++++++++++++++++++- lib/libalpm/sync.c | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index b7587d1c..cf93fa2b 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -543,11 +543,30 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path, memset(&sigdata, 0, sizeof(sigdata)); memset(&filedata, 0, sizeof(filedata)); + char* filecontent; + struct stat statbuf; + + // TODO check return code + stat(path, &statbuf); + + size_t filesize = statbuf.st_size; + + filecontent = malloc(filesize); + if (filecontent == NULL) { + printf("Failed to allocate memory\n"); + goto error; + } + + if (fread(filecontent, filesize, 1, file) != 1) { + // TODO error handling + } + gpg_err = gpgme_new(&ctx); CHECK_ERR(); /* create our necessary data objects to verify the signature */ - gpg_err = gpgme_data_new_from_stream(&filedata, file); + //gpg_err = gpgme_data_new_from_stream(&filedata, file); + gpg_err = gpgme_data_new_from_mem(&filedata, filecontent, filesize, 1); CHECK_ERR(); /* next create data object for the signature */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index ba72906d..11742257 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1211,6 +1211,9 @@ static int check_validity(alpm_handle_t *handle, event.type = ALPM_EVENT_INTEGRITY_START; EVENT(handle, &event); + +struct timeval tv1, tv2; +gettimeofday(&tv1, NULL); PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 0, total, current); @@ -1220,6 +1223,11 @@ static int check_validity(alpm_handle_t *handle, total, current); event.type = ALPM_EVENT_INTEGRITY_DONE; EVENT(handle, &event); + gettimeofday(&tv2, NULL); + +printf ("Total time = %f seconds\n", + (double) (tv2.tv_usec - tv1.tv_usec) / 1000000 + + (double) (tv2.tv_sec - tv1.tv_sec)); if(errors) { for(i = errors; i; i = i->next) { -- cgit v1.2.3-24-g4f1b