Commit eb692a97 authored by Brian Murray's avatar Brian Murray Committed by Julian Andres Klode

Import Debian version 0.9.3.5ubuntu2

python-apt (0.9.3.5ubuntu2) trusty-proposed; urgency=medium

  * Do not only look at Release files, but look at InRelease files as well.
    Change the code to open Release and InRelease files with
    apt_pkg.open_maybe_clear_signed_file() which will ignore the signature if
    it exists. (LP: #1503979)
  * tests/test_auth.py: update for gnupg 1.4.18 (Closes: #755342)
parent b037c727
......@@ -18,7 +18,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import print_function
import os.path
import os
import apt_pkg
......@@ -48,7 +48,9 @@ def get_release_date_from_release_file(path):
"""
if not path or not os.path.exists(path):
return None
tag = apt_pkg.TagFile(open(path))
data = os.fdopen(apt_pkg.open_maybe_clear_signed_file(path))
tag = apt_pkg.TagFile(data)
section = next(tag)
if not "Date" in section:
return None
......@@ -68,7 +70,7 @@ def get_release_filename_for_pkg(cache, pkgname, label, release):
if aver is None or aver.file_list is None:
continue
for ver_file, _index in aver.file_list:
#print verFile
# print verFile
if (ver_file.origin == label and
ver_file.label == label and
ver_file.archive == release):
......@@ -82,7 +84,9 @@ def get_release_filename_for_pkg(cache, pkgname, label, release):
indexfile.describe == m.describe and
indexfile.is_trusted):
dirname = apt_pkg.config.find_dir("Dir::State::lists")
name = (apt_pkg.uri_to_filename(metaindex.uri) +
"dists_%s_Release" % metaindex.dist)
return dirname + name
for relfile in ['InRelease', 'Release']:
name = (apt_pkg.uri_to_filename(metaindex.uri) +
"dists_%s_%s" % (metaindex.dist, relfile))
if os.path.exists(dirname + name):
return dirname + name
return None
python-apt (0.9.3.5ubuntu2) trusty-proposed; urgency=medium
* Do not only look at Release files, but look at InRelease files as well.
Change the code to open Release and InRelease files with
apt_pkg.open_maybe_clear_signed_file() which will ignore the signature if
it exists. (LP: #1503979)
* tests/test_auth.py: update for gnupg 1.4.18 (Closes: #755342)
-- Brian Murray <brian@ubuntu.com> Wed, 02 Dec 2015 10:51:58 -0800
python-apt (0.9.3.5ubuntu1) trusty-proposed; urgency=medium
* Rebuild to get updated mirror files. (LP: #1397578)
......
......@@ -27,6 +27,7 @@
#include <apt-pkg/orderlist.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/gpgv.h>
#include <sys/stat.h>
#include <libintl.h>
......@@ -426,6 +427,25 @@ static PyObject *InitSystem(PyObject *Self,PyObject *Args)
return HandleErrors(Py_None);
}
/*}}}*/
// gpgv.cc:OpenMaybeClearSignedFile /*{{{*/
// ---------------------------------------------------------------------
static char *doc_OpenMaybeClearSignedFile =
"open_maybe_clear_signed_file(file: str) -> int\n\n"
"Open a file and ignore a PGP clear signature.\n"
"Return a open file descriptor or a error.";
static PyObject *PyOpenMaybeClearSignedFile(PyObject *Self,PyObject *Args)
{
PyApt_Filename file;
char errors = false;
if (PyArg_ParseTuple(Args,"O&",PyApt_Filename::Converter, &file,&errors) == 0)
return 0;
FileFd Fd;
if (OpenMaybeClearSignedFile(file, Fd) == false)
return HandleErrors(MkPyNumber(-1));
return HandleErrors(MkPyNumber(dup(Fd.Fd())));
}
// fileutils.cc: GetLock /*{{{*/
// ---------------------------------------------------------------------
......@@ -500,6 +520,9 @@ static PyMethodDef methods[] =
// Tag File
{"rewrite_section",RewriteSection,METH_VARARGS,doc_RewriteSection},
{"open_maybe_clear_signed_file",PyOpenMaybeClearSignedFile,METH_VARARGS,
doc_OpenMaybeClearSignedFile},
// Locking
{"get_lock",GetLock,METH_VARARGS,doc_GetLock},
{"pkgsystem_lock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock},
......
......@@ -212,7 +212,10 @@ class TestAuthKeys(unittest.TestCase):
"0101010178F7FE5C3E65D8AF8B48AD6246925553",
"hkp://localhost:%d" % self.keyserver_port)
self.assertTrue(
str(cm.exception).startswith("Fingerprints do not match"),
str(cm.exception).startswith(
"recv from 'hkp://localhost:%d' failed for '%s'" % (
self.keyserver_port,
"0101010178F7FE5C3E65D8AF8B48AD6246925553")),
cm.exception)
def testAddKeyFromServer(self):
......
......@@ -28,6 +28,29 @@ if libdir:
import apt_pkg
class TestOpenMaybeClearSigned(unittest.TestCase):
def test_open_trivial(self):
basepath = os.path.dirname(__file__)
fd = apt_pkg.open_maybe_clear_signed_file(
os.path.join(basepath, "./data/test_debs/hello_2.5-1.dsc"))
with os.fdopen(fd) as f:
data = f.read()
self.assertTrue(data.startswith("Format: 1.0\n"))
def test_open_normal(self):
basepath = os.path.dirname(__file__)
fd = apt_pkg.open_maybe_clear_signed_file(
os.path.join(basepath, "./data/misc/foo_Release"))
with os.fdopen(fd) as f:
data = f.read()
self.assertTrue(data.startswith("Origin: Ubuntu\n"))
def xtest_open_does_not_exit(self):
with self.assertRaises(SystemError):
apt_pkg.open_maybe_clear_signed_file("does-not-exists")
class TestTagFile(unittest.TestCase):
""" test the apt_pkg.TagFile """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment