Initial revision
authorroot <devnull@localhost>
Thu, 22 Feb 1996 18:50:41 +0000 (18:50 +0000)
committerroot <devnull@localhost>
Thu, 22 Feb 1996 18:50:41 +0000 (18:50 +0000)
CVS patchset: 396
CVS date: 1996/02/22 18:50:41

checksig.c [new file with mode: 0644]
checksig.h [new file with mode: 0644]

diff --git a/checksig.c b/checksig.c
new file mode 100644 (file)
index 0000000..6c40ed8
--- /dev/null
@@ -0,0 +1,46 @@
+/* checksig.c: verify the signature of an RPM */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "rpmlib.h"
+#include "rpmlead.h"
+#include "signature.h"
+
+int doCheckSig(char **argv)
+{
+    int fd;
+    struct rpmlead lead;
+    char *sig, *rpm;
+    char result[1024];
+    int res = 0;
+    
+    while (*argv) {
+       rpm = *argv++;
+       if ((fd = open(rpm, O_RDONLY, 0644)) < 0) {
+           fprintf(stderr, "Open failed: %s\n", rpm);
+           res = -1;
+       }
+       if (readLead(fd, &lead)) {
+           fprintf(stderr, "readLead failed: %s\n", rpm);
+           res = -1;
+       }
+       if (!readSignature(fd, lead.signature_type, (void **) &sig)) {
+           fprintf(stderr, "readSignature failed: %s\n", rpm);
+           res = -1;
+       }
+       res = verifySignature(fd, lead.signature_type, sig, result);
+       if (res) {
+           printf("%s: %s", rpm, result);
+           printf("Signature OK.\n");
+       } else {
+           fprintf(stderr, "%s: %s", rpm, result);
+           fprintf(stderr, "Signature NOT OK!\n");
+           res = -1;
+       }
+       close(fd);
+    }
+
+    return res;
+}
diff --git a/checksig.h b/checksig.h
new file mode 100644 (file)
index 0000000..6868286
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef H_CHECKSIG
+#define H_CHECKSIG
+
+int doCheckSig(char **argv);
+
+#endif