summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-07-10 13:26:11 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-07-10 13:26:11 +0200
commit5a8cd0703bcc751ff5eb0ae5bf196e61bd428c91 (patch)
tree32003c19a929dc317a2049dbd1a2422ab977894e /apt-pkg/contrib/fileutl.cc
parent3ce22d4f714414d6deb8b044c5b08a8fe7a78967 (diff)
parent479a2beb0f5605652689d74a78dd224b69ba2e8f (diff)
merged the relevant bits from lp:~mvo/apt/lp346386
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 119cd1974..20d2a02f5 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -852,6 +852,26 @@ bool ExecWait(pid_t Pid,const char *Name,bool Reap)
}
/*}}}*/
+// IsPgpClearTextSignature - Check if a file is Pgp/GPG clearsigned /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool IsPgpClearTextSignature(string const &FileName)
+{
+ static const char* SIGMSG = "-----BEGIN PGP SIGNED MESSAGE-----\n";
+ char buffer[sizeof(SIGMSG)];
+ FILE* gpg = fopen(FileName.c_str(), "r");
+ if (gpg == NULL)
+ return false;
+
+ char const * const test = fgets(buffer, sizeof(buffer), gpg);
+ fclose(gpg);
+ if (test == NULL || strcmp(buffer, SIGMSG) != 0)
+ return false;
+
+ return true;
+}
+
+
// FileFd::Open - Open a file /*{{{*/
// ---------------------------------------------------------------------
/* The most commonly used open mode combinations are given with Mode */