diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-03-03 14:44:08 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-03-03 14:44:08 +0000 |
commit | 3256d14280ff7c278a5a81ab40df5153e2658677 (patch) | |
tree | 03442f35ae77912528915c05cc077be7fbbc7738 | |
parent | d235367b39a3ab11fe0cada6fa10578c78f35f6e (diff) | |
download | perl-URPM-3256d14280ff7c278a5a81ab40df5153e2658677.tar perl-URPM-3256d14280ff7c278a5a81ab40df5153e2658677.tar.gz perl-URPM-3256d14280ff7c278a5a81ab40df5153e2658677.tar.bz2 perl-URPM-3256d14280ff7c278a5a81ab40df5153e2658677.tar.xz perl-URPM-3256d14280ff7c278a5a81ab40df5153e2658677.zip |
New function verify_signature
-rw-r--r-- | URPM.xs | 46 |
1 files changed, 45 insertions, 1 deletions
@@ -1181,7 +1181,6 @@ update_header(char *filename, URPM__Package pkg, int keep_all_tags, int vsflags) FD_t fd = fdDup(d); Header header; rpmts ts; - /* rpmVSFlags vsflags, ovsflags; */ close(d); ts = rpmtsCreate(); @@ -3380,6 +3379,51 @@ Urpm_verify_rpm(filename, ...) OUTPUT: RETVAL +char * +Urpm_verify_signature(filename) + char *filename + PREINIT: + rpmts ts = NULL; + char result[1024]; + rpmRC rc; + FD_t fd; + Header h; + CODE: + fd = fdOpen(filename, O_RDONLY, 0); + if (fdFileno(fd) < 0) { + RETVAL = "NOT OK (could not read file)"; + } else { + read_config_files(0); + ts = rpmtsCreate(); + rpmtsSetRootDir(ts, "/"); + rpmtsOpenDB(ts, O_RDONLY); + rpmtsSetVSFlags(ts, RPMVSF_DEFAULT); + rc = rpmReadPackageFile(ts, fd, filename, &h); + *result = '\0'; + switch(rc) { + case RPMRC_OK: + snprintf(result, sizeof(result), "OK"); + break; + case RPMRC_NOTFOUND: + snprintf(result, sizeof(result), "NOT OK (signature not found): %s", rpmErrorString()); + break; + case RPMRC_FAIL: + snprintf(result, sizeof(result), "NOT OK (fail): %s", rpmErrorString()); + break; + case RPMRC_NOTTRUSTED: + snprintf(result, sizeof(result), "NOT OK (key not trusted): %s", rpmErrorString()); + break; + case RPMRC_NOKEY: + snprintf(result, sizeof(result), "NOT OK (no key): %s", rpmErrorString()); + break; + } + RETVAL = result; + rpmtsFree(ts); + } + + OUTPUT: + RETVAL + int Urpm_import_pubkey(...) PREINIT: |