Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# rpmchecksig.c

Go to the documentation of this file.

    00001 /* rpmchecksig: verify the signature of an RPM */
    00002
    00003 #include "system.h"
    00004
    00005 #include "rpmlib.h"
    00006
    00007 #include "rpmlead.h"
    00008 #include "signature.h"
    00009 #include "debug.h"
    00010
    00011 int main(int argc, char **argv)
    00012 {
    00013     int fd;
    00014     struct rpmlead lead;
    00015     char *sig;
    00016     char result[1024];
    00017     int res;
    00018
    00019     setprogname(argv[0]);       /* Retrofit glibc __progname */
    00020     if (argc == 1) {
    00021         fd = 0;
    00022     } else {
    00023         fd = open(argv[1], O_RDONLY, 0644);
    00024     }
    00025
    00026     /* Need this for any PGP settings */
    00027     if (rpmReadConfigFiles(NULL, NULL, NULL, 0))
    00028         exit(-1);
    00029
    00030     readLead(fd, &lead);
    00031     rpmReadSignature(fd, lead.signature_type, (void **) &sig);
    00032     res = verifySignature(fd, lead.signature_type, sig, result, 1);
    00033     fprintf(stdout, "%s", result);
    00034     if (res) {
    00035         fprintf(stdout, "Signature OK.\n");
    00036         return 0;
    00037     } else {
    00038         fprintf(stdout, "Signature NOT OK!\n");
    00039         return 1;
    00040     }
    00041 }