Pass package signature data up one more level
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
ec790ced7c
commit
b7ebacc576
3 changed files with 14 additions and 16 deletions
|
@ -279,10 +279,12 @@ static alpm_file_t *files_msort(alpm_file_t *files, size_t n)
|
||||||
* @param syncpkg package object to load verification data from (md5sum,
|
* @param syncpkg package object to load verification data from (md5sum,
|
||||||
* sha256sum, and/or base64 signature)
|
* sha256sum, and/or base64 signature)
|
||||||
* @param level the required level of signature verification
|
* @param level the required level of signature verification
|
||||||
|
* @param sigdata signature data from the package to pass back
|
||||||
* @return 0 if package is fully valid, -1 and pm_errno otherwise
|
* @return 0 if package is fully valid, -1 and pm_errno otherwise
|
||||||
*/
|
*/
|
||||||
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
|
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
|
||||||
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level)
|
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
|
||||||
|
alpm_siglist_t **sigdata)
|
||||||
{
|
{
|
||||||
int has_sig;
|
int has_sig;
|
||||||
|
|
||||||
|
@ -330,18 +332,13 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
|
||||||
/* even if we don't have a sig, run the check code if level tells us to */
|
/* even if we don't have a sig, run the check code if level tells us to */
|
||||||
if(has_sig || level & ALPM_SIG_PACKAGE) {
|
if(has_sig || level & ALPM_SIG_PACKAGE) {
|
||||||
const char *sig = syncpkg ? syncpkg->base64_sig : NULL;
|
const char *sig = syncpkg ? syncpkg->base64_sig : NULL;
|
||||||
alpm_siglist_t *siglist;
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "sig data: %s\n", sig ? sig : "<from .sig>");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "sig data: %s\n", sig ? sig : "<from .sig>");
|
||||||
if(_alpm_check_pgp_helper(handle, pkgfile, sig,
|
if(_alpm_check_pgp_helper(handle, pkgfile, sig,
|
||||||
level & ALPM_SIG_PACKAGE_OPTIONAL, level & ALPM_SIG_PACKAGE_MARGINAL_OK,
|
level & ALPM_SIG_PACKAGE_OPTIONAL, level & ALPM_SIG_PACKAGE_MARGINAL_OK,
|
||||||
level & ALPM_SIG_PACKAGE_UNKNOWN_OK, &siglist)) {
|
level & ALPM_SIG_PACKAGE_UNKNOWN_OK, sigdata)) {
|
||||||
handle->pm_errno = ALPM_ERR_PKG_INVALID_SIG;
|
handle->pm_errno = ALPM_ERR_PKG_INVALID_SIG;
|
||||||
alpm_siglist_cleanup(siglist);
|
|
||||||
free(siglist);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
alpm_siglist_cleanup(siglist);
|
|
||||||
free(siglist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -514,7 +511,7 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
|
||||||
CHECK_HANDLE(handle, return -1);
|
CHECK_HANDLE(handle, return -1);
|
||||||
ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
|
ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
|
||||||
|
|
||||||
if(_alpm_pkg_validate_internal(handle, filename, NULL, level) == -1) {
|
if(_alpm_pkg_validate_internal(handle, filename, NULL, level, NULL) == -1) {
|
||||||
/* pm_errno is set by pkg_validate */
|
/* pm_errno is set by pkg_validate */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,9 +134,9 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr);
|
||||||
void _alpm_pkg_free(alpm_pkg_t *pkg);
|
void _alpm_pkg_free(alpm_pkg_t *pkg);
|
||||||
void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
|
void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
|
||||||
|
|
||||||
|
|
||||||
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
|
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
|
||||||
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level);
|
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
|
||||||
|
alpm_siglist_t **sigdata);
|
||||||
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
|
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
|
||||||
const char *pkgfile, int full);
|
const char *pkgfile, int full);
|
||||||
|
|
||||||
|
|
|
@ -953,6 +953,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
alpm_pkg_t *spkg = i->data;
|
alpm_pkg_t *spkg = i->data;
|
||||||
char *filepath;
|
char *filepath;
|
||||||
alpm_siglevel_t level;
|
alpm_siglevel_t level;
|
||||||
|
alpm_siglist_t *siglist = NULL;
|
||||||
int percent = (int)(((double)current_bytes / total_bytes) * 100);
|
int percent = (int)(((double)current_bytes / total_bytes) * 100);
|
||||||
|
|
||||||
PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", percent,
|
PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", percent,
|
||||||
|
@ -966,14 +967,14 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
alpm_db_t *sdb = alpm_pkg_get_db(spkg);
|
alpm_db_t *sdb = alpm_pkg_get_db(spkg);
|
||||||
level = alpm_db_get_siglevel(sdb);
|
level = alpm_db_get_siglevel(sdb);
|
||||||
|
|
||||||
if(_alpm_pkg_validate_internal(handle, filepath, spkg, level) == -1) {
|
if(_alpm_pkg_validate_internal(handle, filepath, spkg, level, &siglist) == -1) {
|
||||||
prompt_to_delete(handle, filepath, handle->pm_errno);
|
prompt_to_delete(handle, filepath, handle->pm_errno);
|
||||||
errors++;
|
errors++;
|
||||||
*data = alpm_list_add(*data, strdup(spkg->filename));
|
*data = alpm_list_add(*data, strdup(spkg->filename));
|
||||||
FREE(filepath);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
FREE(filepath);
|
alpm_siglist_cleanup(siglist);
|
||||||
|
free(siglist);
|
||||||
|
free(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 100,
|
PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 100,
|
||||||
|
@ -1021,10 +1022,10 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
if(!pkgfile) {
|
if(!pkgfile) {
|
||||||
errors++;
|
errors++;
|
||||||
*data = alpm_list_add(*data, strdup(spkg->filename));
|
*data = alpm_list_add(*data, strdup(spkg->filename));
|
||||||
FREE(filepath);
|
free(filepath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FREE(filepath);
|
free(filepath);
|
||||||
pkgfile->reason = spkg->reason; /* copy over install reason */
|
pkgfile->reason = spkg->reason; /* copy over install reason */
|
||||||
i->data = pkgfile;
|
i->data = pkgfile;
|
||||||
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
|
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
|
||||||
|
|
Loading…
Add table
Reference in a new issue