summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/gpgv.h
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2013-04-23 08:08:54 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2013-04-23 08:08:54 +0200
commit3444603f5ff2b4c4816e45e686e06e01df31cdc4 (patch)
treeb0e63e9bc86ca6d39f6987381ca7bfa64e186048 /apt-pkg/contrib/gpgv.h
parent52d5690b47bd4efe425fa23d9f6559bb44324cd1 (diff)
parent3278fe66567d149ea92c1afa78941f2bc3c71c85 (diff)
merged debian-sid branch and resolved conflicts
Diffstat (limited to 'apt-pkg/contrib/gpgv.h')
-rw-r--r--apt-pkg/contrib/gpgv.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h
new file mode 100644
index 000000000..08b10a97a
--- /dev/null
+++ b/apt-pkg/contrib/gpgv.h
@@ -0,0 +1,82 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ Helpers to deal with gpgv better and more easily
+
+ ##################################################################### */
+ /*}}}*/
+#ifndef CONTRIB_GPGV_H
+#define CONTRIB_GPGV_H
+
+#include <string>
+#include <vector>
+
+#include <apt-pkg/fileutl.h>
+
+#if __GNUC__ >= 4
+ #define APT_noreturn __attribute__ ((noreturn))
+#else
+ #define APT_noreturn /* no support */
+#endif
+
+/** \brief generates and run the command to verify a file with gpgv
+ *
+ * If File and FileSig specify the same file it is assumed that we
+ * deal with a clear-signed message. In that case the file will be
+ * rewritten to be in a good-known format without uneeded whitespaces
+ * and additional messages (unsigned or signed).
+ *
+ * @param File is the message (unsigned or clear-signed)
+ * @param FileSig is the signature (detached or clear-signed)
+ */
+void ExecGPGV(std::string const &File, std::string const &FileSig,
+ int const &statusfd, int fd[2]) APT_noreturn;
+inline void ExecGPGV(std::string const &File, std::string const &FileSig,
+ int const &statusfd = -1) {
+ int fd[2];
+ ExecGPGV(File, FileSig, statusfd, fd);
+};
+
+#undef APT_noreturn
+
+/** \brief Split an inline signature into message and signature
+ *
+ * Takes a clear-signed message and puts the first signed message
+ * in the content file and all signatures following it into the
+ * second. Unsigned messages, additional messages as well as
+ * whitespaces are discarded. The resulting files are suitable to
+ * be checked with gpgv.
+ *
+ * If a FileFd pointers is NULL it will not be used and the content
+ * which would have been written to it is silently discarded.
+ *
+ * The content of the split files is undefined if the splitting was
+ * unsuccessful.
+ *
+ * Note that trying to split an unsigned file will fail, but
+ * not generate an error message.
+ *
+ * @param InFile is the clear-signed file
+ * @param ContentFile is the FileFd the message will be written to
+ * @param ContentHeader is a list of all required Amored Headers for the message
+ * @param SignatureFile is the FileFd all signatures will be written to
+ * @return true if the splitting was successful, false otherwise
+ */
+bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
+ std::vector<std::string> * const ContentHeader, FileFd * const SignatureFile);
+
+/** \brief open a file which might be clear-signed
+ *
+ * This method tries to extract the (signed) message of a file.
+ * If the file isn't signed it will just open the given filename.
+ * Otherwise the message is extracted to a temporary file which
+ * will be opened instead.
+ *
+ * @param ClearSignedFileName is the name of the file to open
+ * @param[out] MessageFile is the FileFd in which the file will be opened
+ * @return true if opening was successful, otherwise false
+ */
+bool OpenMaybeClearSignedFile(std::string const &ClearSignedFileName, FileFd &MessageFile);
+
+#endif