aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-10 23:58:02 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-10 23:58:02 +0000
commit31dd914627d2c8bb1f136f9581ee3abedbf390b4 (patch)
tree0dea6122d0d8f60e96e3bb1dfabb6958a229528d
parent250bfb1028681e16d12608ae4301dff111de14e8 (diff)
downloadpaludis-31dd914627d2c8bb1f136f9581ee3abedbf390b4.tar.gz
paludis-31dd914627d2c8bb1f136f9581ee3abedbf390b4.tar.xz
Rework security code. An external preprocessor is no longer required. The paludis 'all' security list is now part of adjutrix
-rw-r--r--configure.ac39
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/config_file.cc164
-rw-r--r--paludis/config_file.hh121
-rw-r--r--paludis/environment.cc4
-rw-r--r--paludis/environment.hh6
-rw-r--r--paludis/environment/default/default_environment.cc3
-rw-r--r--paludis/environment/default/default_environment.hh3
-rw-r--r--paludis/libxml/Makefile.am35
-rw-r--r--paludis/libxml/libxml.cc41
-rw-r--r--paludis/libxml/libxml.hh (renamed from paludis/qa/libxml_utils.hh)56
-rw-r--r--paludis/qa/Makefile.am.m46
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/metadata_check.cc2
-rw-r--r--paludis/qa/metadata_file.cc9
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc2
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh2
-rw-r--r--paludis/repositories/cran/cran_repository.cc2
-rw-r--r--paludis/repositories/cran/cran_repository.hh2
-rw-r--r--paludis/repositories/portage/Makefile.am47
-rw-r--r--paludis/repositories/portage/glsa.cc233
-rw-r--r--paludis/repositories/portage/glsa.hh97
-rw-r--r--paludis/repositories/portage/glsa.sr8
-rw-r--r--paludis/repositories/portage/make_ebin_repository.cc2
-rw-r--r--paludis/repositories/portage/make_ebuild_repository.cc2
-rw-r--r--paludis/repositories/portage/portage_repository.cc10
-rw-r--r--paludis/repositories/portage/portage_repository.hh2
-rw-r--r--paludis/repositories/portage/portage_repository_sets.cc381
-rw-r--r--paludis/repositories/portage/portage_repository_sets.hh6
-rw-r--r--paludis/repositories/portage/xml_things.cc188
-rw-r--r--paludis/repositories/portage/xml_things_TEST.cc92
-rwxr-xr-xpaludis/repositories/portage/xml_things_TEST_cleanup.sh11
-rwxr-xr-xpaludis/repositories/portage/xml_things_TEST_setup.sh115
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc2
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh2
-rw-r--r--paludis/repository.hh7
-rw-r--r--paludis/repository.sr14
-rw-r--r--paludis/tasks/install_task.cc2
-rw-r--r--paludis/util/collection.hh12
-rw-r--r--paludis/util/exception.cc5
-rw-r--r--paludis/util/exception.hh17
-rw-r--r--paludis/version_spec.hh2
-rw-r--r--src/adjutrix/Makefile.am1
-rw-r--r--src/adjutrix/adjutrix.cc13
-rw-r--r--src/adjutrix/command_line.cc5
-rw-r--r--src/adjutrix/command_line.hh1
-rw-r--r--src/adjutrix/find_insecure_packages.cc162
-rw-r--r--src/adjutrix/find_insecure_packages.hh (renamed from paludis/qa/libxml_utils.cc)15
-rw-r--r--src/paludis/command_line.cc2
-rw-r--r--src/paludis/command_line.hh3
-rw-r--r--src/paludis/list.cc39
-rw-r--r--src/paludis/list.hh3
-rw-r--r--src/paludis/paludis.cc9
53 files changed, 1318 insertions, 692 deletions
diff --git a/configure.ac b/configure.ac
index fedb890..025d26c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -176,6 +176,8 @@ AC_DEFINE_UNQUOTED([HAVE_STD_HASHES], $have_std_hashes, [Do we have std:: hashes
AC_SUBST([HAVE_STD_HASHES])
dnl }}}
+need_xml_check=
+
dnl {{{ we need libebt.
dnl don't use AC_CHECK_HEADER, it does silly things
AC_MSG_CHECKING([for libebt])
@@ -336,8 +338,7 @@ AC_SUBST([PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS])
AC_MSG_CHECKING([whether to enable visibility])
AC_ARG_ENABLE([visibility],
AS_HELP_STRING([--enable-visibility], [Enable visibility (g++-4.1)]),
- [ENABLE_VISIBILITY=$enableval
- AC_MSG_RESULT([$enableval])],
+ [ENABLE_VISIBILITY=$enableval],
[ENABLE_VISIBILITY=no])
AC_MSG_RESULT([$ENABLE_VISIBILITY])
AC_SUBST([ENABLE_VISIBILITY])
@@ -400,7 +401,7 @@ dnl }}}
dnl {{{ check for whether to build qa stuff
AC_MSG_CHECKING([whether to build QA tools])
AC_ARG_ENABLE([qa],
- AS_HELP_STRING([--enable-qa], [Build QA things (needs pcre++)]),
+ AS_HELP_STRING([--enable-qa], [Build QA things (needs pcre++, libxml2)]),
[ENABLE_QA=$enableval
AC_MSG_RESULT([$enableval])],
[ENABLE_QA=no
@@ -415,13 +416,38 @@ if test x"$ENABLE_QA" = "xyes" ; then
else
AC_MSG_ERROR([pcre++ (http://www.daemon.de/PCRE) is required if --enable-qa is used])
fi
+ need_xml_check=yes
+fi
+AC_SUBST([ENABLE_QA])
+AM_CONDITIONAL([ENABLE_QA], test "x$ENABLE_QA" = "xyes")
+dnl }}}
+
+dnl {{{ check for whether to build glsa stuff
+AC_MSG_CHECKING([whether to build GLSA support])
+AC_ARG_ENABLE([qa],
+ AS_HELP_STRING([--enable-glsa], [Build GLSA things (needs libxml2)]),
+ [ENABLE_GLSA=$enableval
+ AC_MSG_RESULT([$enableval])],
+ [ENABLE_GLSA=no
+ AC_MSG_RESULT([no])])
+if test x"$ENABLE_GLSA" = "xyes" ; then
+ need_xml_check=yes
+ AC_DEFINE([ENABLE_GLSA], [1], [Build GLSA support])
+fi
+AC_SUBST([ENABLE_GLSA])
+AM_CONDITIONAL([ENABLE_GLSA], test "x$ENABLE_QA" = "xyes")
+dnl }}}
+
+dnl {{{ libxml2 check
+NEED_XML=$need_xml_check
+if test "x$need_xml_check" = "xyes" ; then
PKG_CHECK_MODULES(LIBXML2DEPS, [libxml-2.0 >= 2.6], [],
- [AC_MSG_ERROR([libxml2 (http://xmlsoft.org/) is required if --enable-qa is used])])
+ [AC_MSG_ERROR([libxml2 (http://xmlsoft.org/) is required if --enable-qa or --enable-glsa is used])])
AC_SUBST(LIBXML2DEPS_CFLAGS)
AC_SUBST(LIBXML2DEPS_LIBS)
fi
-AC_SUBST([ENABLE_QA])
-AM_CONDITIONAL([ENABLE_QA], test "x$ENABLE_QA" = "xyes")
+AC_SUBST([NEED_XML])
+AM_CONDITIONAL([NEED_XML], test "x$NEED_XML" = "xyes")
dnl }}}
dnl {{{ colourschemes
@@ -627,6 +653,7 @@ AC_OUTPUT(
paludis/environment/no_config/Makefile
paludis/environment/test/Makefile
paludis/hashed_containers.hh
+ paludis/libxml/Makefile
paludis/qa/Makefile
paludis/repositories/Makefile
paludis/repositories/cran/Makefile
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 7acad31..071138e 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -64,7 +64,7 @@ DEFS= \
-DLIBDIR=\"$(libdir)\"
EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \
hashed_containers.hh.in testscriptlist srlist srcleanlist
-SUBDIRS = digests util . repositories environment args qa selinux tasks
+SUBDIRS = digests util libxml . repositories environment args qa selinux tasks
BUILT_SOURCES = srcleanlist
libpaludis_la_SOURCES = filelist
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 2b06f46..6bf6785 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -445,170 +445,6 @@ KeyValueConfigFile::end() const
return Iterator(_imp->entries.end());
}
-AdvisoryFileError::AdvisoryFileError(const std::string & msg,
- const std::string & filename) throw () :
- ConfigurationError("Advisory file error" +
- (filename.empty() ? ": " : "in file '" + filename + "': ") + msg)
-{
-}
-
-namespace paludis
-{
- /**
- * Implementation data for AdvisoryFile.
- *
- * \ingroup grpadvisoryconfigfile
- */
- template<>
- struct Implementation<AdvisoryFile> :
- InternalCounted<Implementation<AdvisoryFile> >
- {
- mutable std::map<std::string, std::string> entries;
- mutable std::list<std::string> affected;
- mutable std::list<std::string> unaffected;
- mutable bool end_of_header;
-
- Implementation() :
- end_of_header(false)
- {
- }
- };
-}
-
-AdvisoryFile::AdvisoryFile(std::istream * const s) :
- ConfigFile(s),
- PrivateImplementationPattern<AdvisoryFile>(new Implementation<AdvisoryFile>)
-{
- need_lines();
- sanitise();
-}
-
-AdvisoryFile::AdvisoryFile(const std::string & our_filename) :
- ConfigFile(our_filename),
- PrivateImplementationPattern<AdvisoryFile>(new Implementation<AdvisoryFile>)
-{
- need_lines();
- sanitise();
-}
-
-AdvisoryFile::AdvisoryFile(const FSEntry & our_filename) :
- ConfigFile(our_filename),
- PrivateImplementationPattern<AdvisoryFile>(new Implementation<AdvisoryFile>)
-{
- need_lines();
- sanitise();
-}
-
-AdvisoryFile::~AdvisoryFile()
-{
-}
-
-void
-AdvisoryFile::accept_line(const std::string & line) const
-{
- std::string::size_type p(line.find(':'));
-
- if ((std::string::npos == p) || (_imp->end_of_header))
- {
- _imp->entries["Description"] += line + "\n";
- _imp->end_of_header = true;
- }
- else
- {
- std::string key(line.substr(0, p)), value(line.substr(p + 1));
- normalise_line(key);
- normalise_line(value);
- if ((key == "Affected") || (key == "Bug-Id") || (key == "CVE") || (key == "Reference")
- || (key == "Restart") || (key == "Unaffected"))
- {
- if (key == "Affected")
- _imp->affected.push_back(value);
- else if (key == "Unaffected")
- _imp->unaffected.push_back(value);
- else
- {
- if (! _imp->entries[key].empty())
- value = "\n" + value;
- _imp->entries[key] += value;
- }
- }
- else
- {
- if (_imp->entries[key].empty())
- _imp->entries[key] = value;
- else
- throw AdvisoryFileError("When adding value for key '" + key + "': Duplicate key found.");
- }
- }
-}
-
-void
-AdvisoryFile::sanitise()
-{
- if (_imp->entries["Id"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Id'.");
-
- if (_imp->entries["Title"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Title'.");
-
- if (_imp->entries["Access"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Access'.");
-
- if (_imp->entries["Last-Modified"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Last-Modified'.");
-
- if (_imp->entries["Revision"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Revision'.");
-
- if (_imp->entries["Severity"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Severity'.");
-
- if (_imp->entries["Spec-Version"].empty())
- throw AdvisoryFileError("Missing mandatory key: 'Spec-Version'.");
-}
-
-AdvisoryFile::EntriesIterator
-AdvisoryFile::begin() const
-{
- return EntriesIterator(_imp->entries.begin());
-}
-
-AdvisoryFile::EntriesIterator
-AdvisoryFile::end() const
-{
- return EntriesIterator(_imp->entries.end());
-}
-
-AdvisoryFile::LineIterator
-AdvisoryFile::begin_affected() const
-{
- return LineIterator(_imp->affected.begin());
-}
-
-AdvisoryFile::LineIterator
-AdvisoryFile::end_affected() const
-{
- return LineIterator(_imp->affected.end());
-}
-
-AdvisoryFile::LineIterator
-AdvisoryFile::begin_unaffected() const
-{
- return LineIterator(_imp->unaffected.begin());
-}
-
-AdvisoryFile::LineIterator
-AdvisoryFile::end_unaffected() const
-{
- return LineIterator(_imp->unaffected.end());
-}
-
-std::string
-AdvisoryFile::get(const std::string & key) const
-{
- return _imp->entries[key];
-}
-
std::string
KeyValueConfigFile::get(const std::string & key) const
{
diff --git a/paludis/config_file.hh b/paludis/config_file.hh
index 25aa5ce..35d4fc7 100644
--- a/paludis/config_file.hh
+++ b/paludis/config_file.hh
@@ -299,127 +299,6 @@ namespace paludis
*/
std::string get(const std::string & key) const;
};
-
- /**
- * An AdvisoryFileError is thrown if bad data is encountered in
- * a ConfigFile.
- *
- * \ingroup grpadvisoryconfigfile
- * \ingroup grpexceptions
- */
- class AdvisoryFileError : public ConfigurationError
- {
- public:
- ///\name Basic operations
- ///\{
-
- AdvisoryFileError(const std::string & message,
- const std::string & filename = "") throw ();
-
- ///\}
- };
-
- /**
- * An AdvisoryFile is a file containing all necessary information to
- * update one or more packages in order to avoid a security problem.
- *
- * It uses a textformat with RFC 822 style headers, an empty line denotes
- * the beginning of a multi-line description of the security problem.
- *
- * Valid header items are:
- * Affected, Bug-Url, Committed-By, Id, Reviewed-By, Unaffected, Url
- *
- * \ingroup grpadvisoryconfigfile
- */
-
- class AdvisoryFile :
- protected ConfigFile,
- private PrivateImplementationPattern<AdvisoryFile>
- {
- protected:
- void accept_line(const std::string &) const;
-
- /**
- * Ensure that the AdvisoryFile contains all mandatory items.
- */
- void sanitise();
-
- public:
- ///\name Basic operations
- ///\{
-
- /**
- * Constructor, from a stream.
- */
- AdvisoryFile(std::istream * const);
-
- /**
- * Constructor, from a filename.
- */
- AdvisoryFile(const std::string & filename);
-
- /**
- * Constructor, from a filename.
- */
- AdvisoryFile(const FSEntry & filename);
-
-#if 0
- /**
- * Constructor, from a stream, with defaults.
- */
- AdvisoryFile(std::istream * const,
- AssociativeCollection<std::string, std::string>::ConstPointer);
-
- /**
- * Constructor, from a filename, with defaults.
- */
- AdvisoryFile(const std::string & filename,
- AssociativeCollection<std::string, std::string>::ConstPointer);
-
- /**
- * Constructor, from a filename, with defaults.
- */
- AdvisoryFile(const FSEntry & filename,
- AssociativeCollection<std::string, std::string>::ConstPointer);
-#endif
-
- ~AdvisoryFile();
-
- ///\}
-
- ///\name Iterate over our entries
- ///\{
-
- typedef libwrapiter::ForwardIterator<AdvisoryFile,
- std::pair<const std::string, std::string> > EntriesIterator;
-
- EntriesIterator begin() const;
-
- EntriesIterator end() const;
-
- ///\}
-
- ///\name Iterate over our Affected: and Unaffected: lines.
- ///\{
-
- typedef libwrapiter::ForwardIterator<AdvisoryFile, std::string> LineIterator;
-
- LineIterator begin_affected() const;
-
- LineIterator end_affected() const;
-
- LineIterator begin_unaffected() const;
-
- LineIterator end_unaffected() const;
-
- ///\}
-
- /**
- * Fetch the specified key, or a blank string.
- */
- std::string get(const std::string & key) const;
-
- };
}
#endif
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 98927b6..ff1bf4d 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -191,7 +191,7 @@ Environment::mask_reasons(const PackageDatabaseEntry & e) const
}
DepAtom::Pointer
-Environment::package_set(const std::string & s, const PackageSetOptions & o) const
+Environment::package_set(const std::string & s) const
{
/* favour local sets first */
CompositeDepAtom::Pointer result(local_package_set(s));
@@ -209,7 +209,7 @@ Environment::package_set(const std::string & s, const PackageSetOptions & o) con
if (! (*r)->sets_interface)
continue;
- DepAtom::Pointer add((*r)->sets_interface->package_set(s, o));
+ DepAtom::Pointer add((*r)->sets_interface->package_set(s));
if (0 != add)
{
if (! result)
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 1f0bd31..75924d8 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -106,8 +106,7 @@ namespace paludis
/**
* Local package set, or zero.
*/
- virtual CompositeDepAtom::Pointer local_package_set(const std::string &,
- const PackageSetOptions & = PackageSetOptions(false)) const
+ virtual CompositeDepAtom::Pointer local_package_set(const std::string &) const
{
return AllDepAtom::Pointer(0);
}
@@ -228,8 +227,7 @@ namespace paludis
/**
* Fetch a named package set.
*/
- DepAtom::Pointer package_set(const std::string &,
- const PackageSetOptions & = PackageSetOptions(false)) const;
+ DepAtom::Pointer package_set(const std::string &) const;
/**
* Subclass for callbacks used by add_appropriate_to_world and
diff --git a/paludis/environment/default/default_environment.cc b/paludis/environment/default/default_environment.cc
index c3c5dd6..a0a1f01 100644
--- a/paludis/environment/default/default_environment.cc
+++ b/paludis/environment/default/default_environment.cc
@@ -433,8 +433,7 @@ DefaultEnvironment::hook_dirs() const
}
CompositeDepAtom::Pointer
-DefaultEnvironment::local_package_set(const std::string & s,
- const PackageSetOptions &) const
+DefaultEnvironment::local_package_set(const std::string & s) const
{
Context context("When looking for package set '" + s + "' in default environment:");
diff --git a/paludis/environment/default/default_environment.hh b/paludis/environment/default/default_environment.hh
index c1d416d..8fbc704 100644
--- a/paludis/environment/default/default_environment.hh
+++ b/paludis/environment/default/default_environment.hh
@@ -49,8 +49,7 @@ namespace paludis
~DefaultEnvironment();
protected:
- CompositeDepAtom::Pointer local_package_set(const std::string &,
- const PackageSetOptions & = PackageSetOptions(false)) const;
+ CompositeDepAtom::Pointer local_package_set(const std::string &) const;
public:
virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
diff --git a/paludis/libxml/Makefile.am b/paludis/libxml/Makefile.am
new file mode 100644
index 0000000..67ae4a1
--- /dev/null
+++ b/paludis/libxml/Makefile.am
@@ -0,0 +1,35 @@
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+MAINTAINERCLEANFILES = Makefile.in
+AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DDATADIR=\"$(datadir)\"
+SUBDIRS = .
+
+TESTS =
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
+ PALUDIS_SKIP_CONFIG="yes" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ bash $(top_srcdir)/test/run_test.sh
+
+check_PROGRAMS = $(TESTS)
+check_SCRIPTS =
+
+if NEED_XML
+
+lib_LTLIBRARIES = libpaludislibxml.la
+paludis_libxml_includedir = $(includedir)/paludis/libxml
+paludis_libxml_include_HEADERS = \
+ libxml.hh
+libpaludislibxml_la_SOURCES = $(paludis_libxml_include_HEADERS) \
+ libxml.cc
+libpaludislibxml_la_CXXFLAGS = @LIBXML2DEPS_CFLAGS@
+libpaludislibxml_la_LIBADD = \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ @LIBXML2DEPS_LIBS@
+
+endif
+
diff --git a/paludis/libxml/libxml.cc b/paludis/libxml/libxml.cc
new file mode 100644
index 0000000..74c6461
--- /dev/null
+++ b/paludis/libxml/libxml.cc
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/libxml/libxml.hh>
+#include <list>
+#include <paludis/util/join.hh>
+#include <paludis/util/tokeniser.hh>
+
+std::string
+paludis::retarded_libxml_string_to_string(const xmlChar * s)
+{
+ if (s)
+ return std::string(reinterpret_cast<const char *>(s));
+ else
+ return "";
+}
+
+std::string
+paludis::normalise(const std::string & s)
+{
+ std::list<std::string> words;
+ WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(words));
+ return join(words.begin(), words.end(), " ");
+}
+
diff --git a/paludis/qa/libxml_utils.hh b/paludis/libxml/libxml.hh
index 04d610f..7f53a85 100644
--- a/paludis/qa/libxml_utils.hh
+++ b/paludis/libxml/libxml.hh
@@ -21,44 +21,44 @@
#define PALUDIS_GUARD_PALUDIS_QA_LIBXML_UTILS_HH 1
#include <libxml/parser.h>
+#include <paludis/util/attributes.hh>
#include <string>
namespace paludis
{
- namespace qa
+ template <typename PtrType_>
+ class LibXmlPtrHolder
{
- template <typename PtrType_>
- class LibXmlPtrHolder
- {
- private:
- PtrType_ _ptr;
- void (* _free_func) (PtrType_);
+ private:
+ PtrType_ _ptr;
+ void (* _free_func) (PtrType_);
- LibXmlPtrHolder(const LibXmlPtrHolder &);
- void operator= (const LibXmlPtrHolder &);
+ LibXmlPtrHolder(const LibXmlPtrHolder &);
+ void operator= (const LibXmlPtrHolder &);
- public:
- LibXmlPtrHolder(PtrType_ ptr, void (* free_func) (PtrType_)) :
- _ptr(ptr),
- _free_func(free_func)
- {
- }
+ public:
+ LibXmlPtrHolder(PtrType_ ptr, void (* free_func) (PtrType_)) :
+ _ptr(ptr),
+ _free_func(free_func)
+ {
+ }
- ~LibXmlPtrHolder()
- {
- if (0 != _ptr)
- _free_func(_ptr);
- }
+ ~LibXmlPtrHolder()
+ {
+ if (0 != _ptr)
+ _free_func(_ptr);
+ }
- operator PtrType_ () const
- {
- return _ptr;
- }
- };
+ operator PtrType_ () const
+ {
+ return _ptr;
+ }
+ };
- std::string
- retarded_libxml_string_to_string(const xmlChar * s);
- }
+ std::string
+ retarded_libxml_string_to_string(const xmlChar * s) PALUDIS_VISIBLE;
+
+ std::string normalise(const std::string & s) PALUDIS_VISIBLE;
}
diff --git a/paludis/qa/Makefile.am.m4 b/paludis/qa/Makefile.am.m4
index 1b9e835..10bd983 100644
--- a/paludis/qa/Makefile.am.m4
+++ b/paludis/qa/Makefile.am.m4
@@ -18,6 +18,7 @@ $1_TEST_LDADD = \
libpaludisqa.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
$(top_builddir)/paludis/repositories/virtuals/libpaludisvirtualsrepository.la \
$(DYNAMIC_LD_LIBS) \
@@ -57,6 +58,11 @@ INCLUDES = $(PCREPLUSPLUS_CFLAGS) $(LIBXML2DEPS_CFLAGS)
libpaludisqa_la_SOURCES = filelist
libpaludisqa_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
+libpaludisqa_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/libxml/libpaludislibxml.la \
+ @LIBXML2DEPS_LIBS@
TESTS = testlist
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index d9a4c6d..7d142c7 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -36,7 +36,6 @@ add(`homepage_check', `hh', `cc')
add(`inherits_check', `hh', `cc')
add(`iuse_check', `hh', `cc')
add(`keywords_check', `hh', `cc')
-add(`libxml_utils', `hh', `cc')
add(`license_check', `hh', `cc')
add(`message', `hh', `cc', `sr', `test')
add(`metadata_check', `hh', `cc')
diff --git a/paludis/qa/metadata_check.cc b/paludis/qa/metadata_check.cc
index edc3613..68f850b 100644
--- a/paludis/qa/metadata_check.cc
+++ b/paludis/qa/metadata_check.cc
@@ -20,7 +20,7 @@
#include <ctime>
#include <fstream>
#include <paludis/qa/metadata_check.hh>
-#include <paludis/qa/libxml_utils.hh>
+#include <paludis/libxml/libxml.hh>
#include <paludis/util/pstream.hh>
#include <paludis/util/system.hh>
#include <paludis/util/log.hh>
diff --git a/paludis/qa/metadata_file.cc b/paludis/qa/metadata_file.cc
index 536a6d3..8e409ac 100644
--- a/paludis/qa/metadata_file.cc
+++ b/paludis/qa/metadata_file.cc
@@ -18,7 +18,7 @@
*/
#include "metadata_file.hh"
-#include <paludis/qa/libxml_utils.hh>
+#include <paludis/libxml/libxml.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
@@ -41,13 +41,6 @@ namespace paludis
private:
std::string _email, _name;
- std::string normalise(const std::string & s)
- {
- std::list<std::string> words;
- WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(words));
- return join(words.begin(), words.end(), " ");
- }
-
public:
std::set<std::string> herds;
std::set<std::pair<std::string, std::string> > maintainers;
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index ac4ecaa..053315f 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -448,7 +448,7 @@ CRANInstalledRepository::do_uninstall(const QualifiedPackageName & q, const Vers
}
DepAtom::Pointer
-CRANInstalledRepository::do_package_set(const std::string & s, const PackageSetOptions &) const
+CRANInstalledRepository::do_package_set(const std::string & s) const
{
Context context("When fetching package set '" + s + "' from '" +
stringify(name()) + "':");
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index b8560b3..c531af5 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -80,7 +80,7 @@ namespace paludis
virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
- virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions &) const;
+ virtual DepAtom::Pointer do_package_set(const std::string &) const;
virtual SetsCollection::ConstPointer sets_list() const;
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index acb1bb9..e75aace 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -572,7 +572,7 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
}
DepAtom::Pointer
-CRANRepository::do_package_set(const std::string & s, const PackageSetOptions &) const
+CRANRepository::do_package_set(const std::string & s) const
{
if ("base" == s)
{
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index ce66d30..25376b7 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -89,7 +89,7 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
- virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions &) const;
+ virtual DepAtom::Pointer do_package_set(const std::string &) const;
virtual SetsCollection::ConstPointer sets_list() const;
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 16444b1..fa9a4d9 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -1,5 +1,5 @@
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
-DISTCLEANFILES = portage_repository-sr.hh portage_repository-sr.cc
+DISTCLEANFILES = portage_repository-sr.hh portage_repository-sr.cc glsa-sr.hh glsa-sr.cc
MAINTAINERCLEANFILES = Makefile.in
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@
@@ -15,6 +15,8 @@ paludis_repositories_portage_includedir = $(includedir)/paludis/repositories/por
libpaludisportagerepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_portage_include_HEADERS = \
+ glsa.hh \
+ glsa-sr.hh \
portage_repository.hh \
portage_repository_profile_file.hh \
portage_repository_profile.hh \
@@ -30,6 +32,7 @@ paludis_repositories_portage_include_HEADERS = \
make_ebin_repository.hh
libpaludisportagerepository_la_SOURCES = \
+ glsa.cc \
portage_repository.cc \
portage_repository_profile_file.cc \
portage_repository_profile.cc \
@@ -49,8 +52,6 @@ libpaludisportagerepository_la_LIBADD = \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(DYNAMIC_LD_LIBS)
-TESTS = portage_repository_TEST
-
portage_repository_TEST_SOURCES = portage_repository_TEST.cc
portage_repository_TEST_LDADD = \
@@ -62,25 +63,33 @@ portage_repository_TEST_LDADD = \
portage_repository_TEST_CXXFLAGS = -I$(top_srcdir)
EXTRA_DIST = \
+ glsa.sr \
portage_repository_TEST.cc \
portage_repository_TEST_setup.sh \
portage_repository_TEST_cleanup.sh \
portage_repository_params-sr.hh \
portage_repository_params-sr.cc \
- portage_repository_params.sr
+ portage_repository_params.sr \
+ xml_things_TEST.cc \
+ xml_things_TEST_setup.sh \
+ xml_things_TEST_cleanup.sh
BUILT_SOURCES = \
portage_repository_params-sr.hh \
- portage_repository_params-sr.cc
+ portage_repository_params-sr.cc \
+ glsa-sr.hh \
+ glsa-sr.cc
-check_PROGRAMS = $(TESTS)
-check_SCRIPTS = portage_repository_TEST_setup.sh portage_repository_TEST_cleanup.sh
+check_SCRIPTS = \
+ portage_repository_TEST_setup.sh portage_repository_TEST_cleanup.sh \
+ xml_things_TEST_setup.sh xml_things_TEST_cleanup.sh
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
PALUDIS_SKIP_CONFIG="yes" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ LD_LIBRARY_PATH="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/portage/`" \
bash $(top_srcdir)/test/run_test.sh
portage_repository_params-sr.hh : portage_repository_params.sr $(top_srcdir)/misc/make_sr.bash
@@ -89,4 +98,28 @@ portage_repository_params-sr.hh : portage_repository_params.sr $(top_srcdir)/mis
portage_repository_params-sr.cc : portage_repository_params.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --source $(srcdir)/portage_repository_params.sr > $@
+glsa-sr.hh : glsa.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/glsa.sr > $@
+
+glsa-sr.cc : glsa.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/glsa.sr > $@
+
+if ENABLE_GLSA
+lib_LTLIBRARIES = libpaludisportagerepositoryxmlthings.la
+libpaludisportagerepositoryxmlthings_la_SOURCES = xml_things.cc
+libpaludisportagerepositoryxmlthings_la_CXXFLAGS = @LIBXML2DEPS_CFLAGS@
+libpaludisportagerepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/libxml/libpaludislibxml.la
+
+GLSA_TESTS = xml_things_TEST
+xml_things_TEST_SOURCES = xml_things_TEST.cc
+xml_things_TEST_LDADD = \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/test/libtest.a \
+ libpaludisportagerepository.la
+endif
+
+TESTS = portage_repository_TEST $(GLSA_TESTS)
+check_PROGRAMS = $(TESTS)
diff --git a/paludis/repositories/portage/glsa.cc b/paludis/repositories/portage/glsa.cc
new file mode 100644
index 0000000..8e44e9f
--- /dev/null
+++ b/paludis/repositories/portage/glsa.cc
@@ -0,0 +1,233 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "glsa.hh"
+#include <paludis/util/iterator.hh>
+#include <paludis/util/stringify.hh>
+#include <list>
+#include <dlfcn.h>
+#include "config.h"
+
+#define STUPID_CAST(type, val) reinterpret_cast<type>(reinterpret_cast<uintptr_t>(val))
+
+using namespace paludis;
+
+#include "glsa-sr.cc"
+
+namespace paludis
+{
+ template<>
+ struct Implementation<GLSAPackage> :
+ InternalCounted<Implementation<GLSAPackage> >
+ {
+ QualifiedPackageName name;
+ std::list<UseFlagName> archs;
+ std::list<GLSARange> unaffected;
+ std::list<GLSARange> vulnerable;
+
+ Implementation(const QualifiedPackageName & n) :
+ name(n)
+ {
+ }
+ };
+
+ template<>
+ struct Implementation<GLSA> :
+ InternalCounted<Implementation<GLSA> >
+ {
+ std::string id;
+ std::string title;
+ std::list<GLSAPackage::ConstPointer> packages;
+ };
+}
+
+GLSAPackage::GLSAPackage(const QualifiedPackageName & n) :
+ PrivateImplementationPattern<GLSAPackage>(new Implementation<GLSAPackage>(n))
+{
+}
+
+GLSAPackage::~GLSAPackage()
+{
+}
+
+GLSAPackage::ArchsIterator
+GLSAPackage::begin_archs() const
+{
+ return ArchsIterator(_imp->archs.begin());
+}
+
+GLSAPackage::ArchsIterator
+GLSAPackage::end_archs() const
+{
+ return ArchsIterator(_imp->archs.end());
+}
+
+void
+GLSAPackage::add_arch(const UseFlagName & n)
+{
+ _imp->archs.push_back(n);
+}
+
+GLSAPackage::RangesIterator
+GLSAPackage::begin_unaffected() const
+{
+ return RangesIterator(_imp->unaffected.begin());
+}
+
+GLSAPackage::RangesIterator
+GLSAPackage::end_unaffected() const
+{
+ return RangesIterator(_imp->unaffected.end());
+}
+
+GLSAPackage::RangesIterator
+GLSAPackage::begin_vulnerable() const
+{
+ return RangesIterator(_imp->vulnerable.begin());
+}
+
+GLSAPackage::RangesIterator
+GLSAPackage::end_vulnerable() const
+{
+ return RangesIterator(_imp->vulnerable.end());
+}
+
+void
+GLSAPackage::add_unaffected(const GLSARange & r)
+{
+ _imp->unaffected.push_back(r);
+}
+
+void
+GLSAPackage::add_vulnerable(const GLSARange & r)
+{
+ _imp->vulnerable.push_back(r);
+}
+
+QualifiedPackageName
+GLSAPackage::name() const
+{
+ return _imp->name;
+}
+
+GLSA::GLSA() :
+ PrivateImplementationPattern<GLSA>(new Implementation<GLSA>)
+{
+}
+
+GLSA::~GLSA()
+{
+}
+
+GLSA::PackagesIterator
+GLSA::begin_packages() const
+{
+ return PackagesIterator(indirect_iterator<const GLSAPackage>(_imp->packages.begin()));
+}
+
+GLSA::PackagesIterator
+GLSA::end_packages() const
+{
+ return PackagesIterator(indirect_iterator<const GLSAPackage>(_imp->packages.end()));
+}
+
+void
+GLSA::add_package(GLSAPackage::ConstPointer p)
+{
+ _imp->packages.push_back(p);
+}
+
+void
+GLSA::set_id(const std::string & s)
+{
+ _imp->id = s;
+}
+
+void
+GLSA::set_title(const std::string & s)
+{
+ _imp->title = s;
+}
+
+std::string
+GLSA::id() const
+{
+ return _imp->id;
+}
+
+std::string
+GLSA::title() const
+{
+ return _imp->title;
+}
+
+namespace
+{
+ struct LibXMLHandle
+ {
+ void * handle;
+ GLSA::Pointer (* create_glsa_from_xml_file_handle)(const std::string &);
+
+ LibXMLHandle() :
+ handle(0),
+ create_glsa_from_xml_file_handle(0)
+ {
+ }
+
+ ~LibXMLHandle()
+ {
+ if (0 != handle)
+ dlclose(handle);
+ }
+
+ } libxmlhandle;
+}
+
+GLSA::Pointer
+GLSA::create_from_xml_file(const std::string & filename)
+{
+#if ENABLE_GLSA
+ if (0 == libxmlhandle.handle)
+ libxmlhandle.handle = dlopen("libpaludisportagerepositoryxmlthings.so",
+ RTLD_NOW | RTLD_GLOBAL);
+ if (0 == libxmlhandle.handle)
+ throw NotAvailableError("Cannot create GLSA from XML file '" + filename + "' due to error '"
+ + stringify(dlerror()) + "' when dlopen(libpaludisportagerepositoryxmlthings.so)");
+#else
+ /* avoid noreturn warning */
+ if (0 == libxmlhandle.handle)
+ throw NotAvailableError("Cannot create GLSA from XML file '" + filename + "' because Paludis was built "
+ "without GLSA support");
+#endif
+
+ if (0 == libxmlhandle.create_glsa_from_xml_file_handle)
+ libxmlhandle.create_glsa_from_xml_file_handle = STUPID_CAST(GLSA::Pointer (*)(const std::string &),
+ dlsym(libxmlhandle.handle, "create_glsa_from_xml_file"));
+ if (0 == libxmlhandle.create_glsa_from_xml_file_handle)
+ throw NotAvailableError("Cannot create GLSA from XML file '" + filename + "' due to error '"
+ + stringify(dlerror()) + "' when dlsym(libpaludisportagerepositoryxmlthings.so, create_glsa_from_xml_file)");
+
+ return (*libxmlhandle.create_glsa_from_xml_file_handle)(filename);
+}
+
+GLSAError::GLSAError(const std::string & msg, const std::string & filename) throw () :
+ ConfigurationError("GLSA error: " + msg + (filename.empty() ? "" : " in file " + filename))
+{
+}
+
diff --git a/paludis/repositories/portage/glsa.hh b/paludis/repositories/portage/glsa.hh
new file mode 100644
index 0000000..c612d40
--- /dev/null
+++ b/paludis/repositories/portage/glsa.hh
@@ -0,0 +1,97 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_GLSA_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_PORTAGE_GLSA_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/counted_ptr.hh>
+#include <paludis/util/sr.hh>
+#include <paludis/name.hh>
+#include <paludis/version_spec.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+
+#include <string>
+
+namespace paludis
+{
+
+#include <paludis/repositories/portage/glsa-sr.hh>
+
+ class GLSAError :
+ public ConfigurationError
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ GLSAError(const std::string & message,
+ const std::string & filename = "") throw ();
+
+ ///\}
+ };
+
+ class GLSAPackage :
+ private PrivateImplementationPattern<GLSAPackage>,
+ public InternalCounted<GLSAPackage>
+ {
+ public:
+ GLSAPackage(const QualifiedPackageName & name);
+ ~GLSAPackage();
+
+ typedef libwrapiter::ForwardIterator<GLSAPackage, const UseFlagName> ArchsIterator;
+ ArchsIterator begin_archs() const;
+ ArchsIterator end_archs() const;
+ void add_arch(const UseFlagName &);
+
+ typedef libwrapiter::ForwardIterator<GLSAPackage, const GLSARange> RangesIterator;
+ RangesIterator begin_unaffected() const;
+ RangesIterator end_unaffected() const;
+ RangesIterator begin_vulnerable() const;
+ RangesIterator end_vulnerable() const;
+ void add_unaffected(const GLSARange &);
+ void add_vulnerable(const GLSARange &);
+
+ QualifiedPackageName name() const;
+ };
+
+ class GLSA :
+ private PrivateImplementationPattern<GLSA>,
+ public InternalCounted<GLSA>
+ {
+ public:
+ GLSA();
+ ~GLSA();
+
+ static GLSA::Pointer create_from_xml_file(const std::string & filename);
+
+ typedef libwrapiter::ForwardIterator<GLSA, const GLSAPackage> PackagesIterator;
+ PackagesIterator begin_packages() const;
+ PackagesIterator end_packages() const;
+ void add_package(GLSAPackage::ConstPointer);
+
+ void set_id(const std::string &);
+ std::string id() const;
+
+ void set_title(const std::string &);
+ std::string title() const;
+ };
+}
+
+#endif
diff --git a/paludis/repositories/portage/glsa.sr b/paludis/repositories/portage/glsa.sr
new file mode 100644
index 0000000..359ffee
--- /dev/null
+++ b/paludis/repositories/portage/glsa.sr
@@ -0,0 +1,8 @@
+make_class_GLSARange()
+{
+ key op std::string;
+ # not a version, may be something like 1.3*
+ key version std::string;
+
+ allow_named_args;
+}
diff --git a/paludis/repositories/portage/make_ebin_repository.cc b/paludis/repositories/portage/make_ebin_repository.cc
index b170e7d..b4b2ca5 100644
--- a/paludis/repositories/portage/make_ebin_repository.cc
+++ b/paludis/repositories/portage/make_ebin_repository.cc
@@ -59,7 +59,7 @@ paludis::make_ebin_repository(
std::string securitydir;
if (m->end() == m->find("securitydir") || ((securitydir = m->find("securitydir")->second)).empty())
- securitydir = location + "/metadata/security";
+ securitydir = location + "/metadata/glsa";
std::string newsdir;
if (m->end() == m->find("newsdir") || ((newsdir = m->find("newsdir")->second)).empty())
diff --git a/paludis/repositories/portage/make_ebuild_repository.cc b/paludis/repositories/portage/make_ebuild_repository.cc
index 428bea7..426e0c2 100644
--- a/paludis/repositories/portage/make_ebuild_repository.cc
+++ b/paludis/repositories/portage/make_ebuild_repository.cc
@@ -84,7 +84,7 @@ paludis::make_ebuild_repository(
std::string securitydir;
if (m->end() == m->find("securitydir") || ((securitydir = m->find("securitydir")->second)).empty())
- securitydir = location + "/metadata/security";
+ securitydir = location + "/metadata/glsa";
std::string newsdir;
if (m->end() == m->find("newsdir") || ((newsdir = m->find("newsdir")->second)).empty())
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index 8c04925..637fdc5 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -472,9 +472,9 @@ PortageRepository::need_version_names(const QualifiedPackageName & n) const
try
{
- v->insert(strip_leading_string(
- strip_trailing_string(e->basename(), _imp->entries_ptr->file_extension()),
- stringify(n.package) + "-"));
+ v->insert(VersionSpec(strip_leading_string(
+ strip_trailing_string(e->basename(), _imp->entries_ptr->file_extension()),
+ stringify(n.package) + "-")));
}
catch (const NameError &)
{
@@ -680,7 +680,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
}
DepAtom::Pointer
-PortageRepository::do_package_set(const std::string & s, const PackageSetOptions & o) const
+PortageRepository::do_package_set(const std::string & s) const
{
if (s == "system")
{
@@ -688,7 +688,7 @@ PortageRepository::do_package_set(const std::string & s, const PackageSetOptions
return _imp->profile_ptr->system_packages();
}
- return _imp->sets_ptr->package_set(s, o);
+ return _imp->sets_ptr->package_set(s);
}
SetsCollection::ConstPointer
diff --git a/paludis/repositories/portage/portage_repository.hh b/paludis/repositories/portage/portage_repository.hh
index b53b509..f3e805a 100644
--- a/paludis/repositories/portage/portage_repository.hh
+++ b/paludis/repositories/portage/portage_repository.hh
@@ -99,7 +99,7 @@ namespace paludis
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
- virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions &) const;
+ virtual DepAtom::Pointer do_package_set(const std::string &) const;
virtual SetsCollection::ConstPointer sets_list() const;
diff --git a/paludis/repositories/portage/portage_repository_sets.cc b/paludis/repositories/portage/portage_repository_sets.cc
index b0db35e..9126263 100644
--- a/paludis/repositories/portage/portage_repository_sets.cc
+++ b/paludis/repositories/portage/portage_repository_sets.cc
@@ -20,6 +20,7 @@
#include <paludis/repositories/portage/portage_repository.hh>
#include <paludis/repositories/portage/portage_repository_sets.hh>
+#include <paludis/repositories/portage/glsa.hh>
#include <paludis/dep_list.hh>
#include <paludis/environment.hh>
@@ -35,119 +36,9 @@
#include <list>
#include <set>
-using namespace paludis;
-
-namespace
-{
- class AdvisoryVisitor :
- private InstantiationPolicy<AdvisoryVisitor, instantiation_method::NonCopyableTag>,
- public DepAtomVisitorTypes::ConstVisitor
- {
- private:
- const Environment * const _env;
-
- mutable const CompositeDepAtom & _a;
-
- mutable std::vector<const PackageDepAtom *> _atoms;
-
- protected:
- ///\name Visit methods
- ///{
- void visit(const AllDepAtom *);
- void visit(const AnyDepAtom *) PALUDIS_ATTRIBUTE((noreturn));
- void visit(const UseDepAtom *);
- void visit(const PlainTextDepAtom *);
- void visit(const PackageDepAtom *);
- void visit(const BlockDepAtom *);
- ///}
-
- public:
- /**
- * Constructor.
- */
- AdvisoryVisitor(const Environment * const env, const CompositeDepAtom & a);
-
- /**
- * Destructor.
- */
- ~AdvisoryVisitor()
- {
- }
-
- /**
- * Iterate over our dep atoms.
- */
- typedef std::vector<const PackageDepAtom *>::iterator Iterator;
-
- /**
- * Grab element by index.
- */
- const PackageDepAtom * at(std::vector<const PackageDepAtom *>::size_type n) const
- {
- return _atoms[n];
- }
-
- /**
- * Return the number of atoms.
- */
- std::vector<const PackageDepAtom *>::size_type size() const
- {
- return _atoms.size();
- }
- };
-}
-
-AdvisoryVisitor::AdvisoryVisitor(const Environment * const env, const CompositeDepAtom & a) :
- _env(env),
- _a(a)
-{
- Context c("When flattening the AdvisoryFile line:");
- std::for_each(a.begin(), a.end(), accept_visitor(this));
- if (_atoms.size() == 2)
- {
- VersionOperatorValue v1(_atoms[0]->version_operator().value()),
- v2(_atoms[1]->version_operator().value());
-
- if ((v1 == vo_equal) || (v2 == vo_equal))
- throw AdvisoryFileError("Broken line: Forbidden 'equal' atom in range");
- }
-}
-
-void
-AdvisoryVisitor::visit(const AllDepAtom * a)
-{
- std::for_each(a->begin(), a->end(), accept_visitor(this));
-}
-
-void
-AdvisoryVisitor::visit(const AnyDepAtom *)
-{
- throw AdvisoryFileError("Unexpected AnyDepAtom in line");
-}
-
-void
-AdvisoryVisitor::visit(const UseDepAtom * a)
-{
- if (_env->query_use(a->flag(), 0) ^ a->inverse())
- std::for_each(a->begin(), a->end(), accept_visitor(this));
-}
-
-void
-AdvisoryVisitor::visit(const PackageDepAtom * a)
-{
- _atoms.push_back(a);
-}
-
-void
-AdvisoryVisitor::visit(const PlainTextDepAtom *)
-{
-}
-
-void
-AdvisoryVisitor::visit(const BlockDepAtom *)
-{
-}
+#include "config.h"
+using namespace paludis;
namespace paludis
{
@@ -186,12 +77,14 @@ PortageRepositorySets::~PortageRepositorySets()
DepAtom::Pointer
-PortageRepositorySets::package_set(const std::string & s, const PackageSetOptions & o) const
+PortageRepositorySets::package_set(const std::string & s) const
{
if ("system" == s)
throw InternalError(PALUDIS_HERE, "system set should've been handled by PortageRepository");
else if ("security" == s)
- return security_set(o);
+ return security_set(false);
+ else if ("insecurity" == s)
+ return security_set(true);
else if ((_imp->params.setsdir / (s + ".conf")).exists())
{
GeneralSetDepTag::Pointer tag(new GeneralSetDepTag(s));
@@ -321,161 +214,163 @@ PortageRepositorySets::find_best(PackageDatabaseEntryCollection & c, const Packa
return i_best;
}
+namespace
+{
+ bool
+ match_range(const PackageDatabaseEntry & e, const GLSARange & r)
+ {
+ VersionOperatorValue our_op(static_cast<VersionOperatorValue>(-1));
+ std::string ver(r.version);
+ if (r.op == "le")
+ our_op = vo_less_equal;
+ if (r.op == "lt")
+ our_op = vo_less;
+ if (r.op == "eq")
+ {
+ if (! ver.empty() && '*' == ver.at(ver.length() - 1))
+ {
+ ver.erase(ver.length() - 1);
+ our_op = vo_equal_star;
+ }
+ else
+ our_op = vo_equal;
+ }
+ if (r.op == "gt")
+ our_op = vo_greater;
+ if (r.op == "ge")
+ our_op = vo_greater_equal;
+
+ if (-1 != our_op)
+ return (e.version.*(VersionOperator(our_op).as_version_spec_operator()))(VersionSpec(ver));
+
+ if (0 == r.op.compare(0, 1, "r"))
+ {
+ return (e.version.*(VersionOperator(vo_tilde).as_version_spec_operator()))(VersionSpec(ver)) &&
+ match_range(e, GLSARange::create().op(r.op.substr(1)).version(r.version));
+ }
+
+ throw GLSAError("Got bad op '" + r.op + "'");
+ }
+
+ bool
+ is_vulnerable(const GLSAPackage & glsa_pkg, const PackageDatabaseEntry & c)
+ {
+ /* a package is affected if it matches any vulnerable line, except if it matches
+ * any unaffected line. */
+ bool vulnerable(false);
+ for (GLSAPackage::RangesIterator r(glsa_pkg.begin_vulnerable()), r_end(glsa_pkg.end_vulnerable()) ;
+ r != r_end && ! vulnerable ; ++r)
+ if (match_range(c, *r))
+ vulnerable = true;
+
+ if (! vulnerable)
+ return false;
+
+ for (GLSAPackage::RangesIterator r(glsa_pkg.begin_unaffected()), r_end(glsa_pkg.end_unaffected()) ;
+ r != r_end && vulnerable ; ++r)
+ if (match_range(c, *r))
+ vulnerable = false;
+
+ return vulnerable;
+ }
+}
DepAtom::Pointer
-PortageRepositorySets::security_set(const PackageSetOptions & o) const
+PortageRepositorySets::security_set(bool insecurity) const
{
- Context c("When building security package set:");
+ Context context("When building security or insecurity package set:");
AllDepAtom::Pointer security_packages(new AllDepAtom);
- bool list_affected_only(o.list_affected_only);
- InstallState affected_state(list_affected_only ? is_either : is_installed_only);
-
if (!_imp->params.securitydir.is_directory())
- return DepAtom::Pointer(new AllDepAtom);
-
- std::list<FSEntry> advisories;
- std::copy(DirIterator(_imp->params.securitydir), DirIterator(),
- filter_inserter(std::back_inserter(advisories),
- IsFileWithExtension("advisory-", ".conf")));
+ return security_packages;
- std::list<FSEntry>::const_iterator f(advisories.begin()),
- f_end(advisories.end());
+ std::map<std::string, GLSADepTag::Pointer> glsa_tags;
- std::set<std::pair<PackageDatabaseEntry, std::string> > affected;
- PackageDatabaseEntryCollection::Concrete unaffected;
- std::map<std::string, std::string> advisory_map;
-
- for ( ; f != f_end; ++f)
+ for (DirIterator f(_imp->params.securitydir), f_end ; f != f_end; ++f)
{
- Context context("When parsing security advisory '" + stringify(*f) + "':");
+ if (! IsFileWithExtension("glsa-", ".xml")(*f))
+ continue;
+
+ Context local_context("When parsing security advisory '" + stringify(*f) + "':");
try
{
- AdvisoryFile advisory(*f);
- std::string advisory_id(advisory.get("Id"));
- advisory_map[advisory_id] = advisory.get("Title");
+ GLSA::ConstPointer glsa(GLSA::create_from_xml_file(stringify(*f)));
+ Context local_local_context("When handling GLSA '" + glsa->id() + "' from '" +
+ stringify(*f) + "':");
-
- AdvisoryFile::LineIterator a(advisory.begin_affected()), a_end(advisory.end_affected());
- for ( ; a != a_end ; ++a)
+ for (GLSA::PackagesIterator glsa_pkg(glsa->begin_packages()),
+ glsa_pkg_end(glsa->end_packages()) ; glsa_pkg != glsa_pkg_end ; ++glsa_pkg)
{
- Context local_context("When parsing line 'Affected: " + *a + "':");
-
- CompositeDepAtom::ConstPointer line(PortageDepParser::parse(*a));
- AdvisoryVisitor atoms(_imp->environment, *line);
-
- if ((0 == atoms.size()) || (2 < atoms.size()))
+ PackageDatabaseEntryCollection::ConstPointer candidates(_imp->environment->package_database()->query(
+ PackageDepAtom::Pointer(new PackageDepAtom(stringify(glsa_pkg->name()))),
+ insecurity ? is_either : is_installed_only));
+ for (PackageDatabaseEntryCollection::Iterator c(candidates->begin()), c_end(candidates->end()) ;
+ c != c_end ; ++c)
{
- continue;
- }
-
- bool is_range(2 == atoms.size());
-
- PackageDatabaseEntryCollection::ConstPointer affected_collection1(
- _imp->environment->package_database()->query(*atoms.at(0), affected_state));
- PackageDatabaseEntryCollection::ConstPointer affected_collection2(
- new PackageDatabaseEntryCollection::Concrete);
- PackageDatabaseEntryCollection::Iterator p(affected_collection1->begin()),
- p_end(affected_collection1->end());
-
- if (is_range)
- affected_collection2 = _imp->environment->package_database()->query(
- *atoms.at(1), affected_state);
-
- for ( ; p != p_end ; ++p)
- {
- if ((affected.end() != affected.find(std::make_pair(*p, advisory_id))))
+ if (! is_vulnerable(*glsa_pkg, *c))
continue;
- if ((! is_range) || (affected_collection2->end() != affected_collection2->find(*p)))
- affected.insert(std::make_pair(*p, advisory_id));
- }
- }
-
- AdvisoryFile::LineIterator u(advisory.begin_unaffected()), u_end(advisory.end_unaffected());
- for ( ; u != u_end ; ++u)
- {
- Context local_c("When parsing line 'Unaffected: " + *u + "':");
- CompositeDepAtom::ConstPointer line(PortageDepParser::parse(*u));
- AdvisoryVisitor atoms(_imp->environment, *line);
+ if (glsa_tags.end() == glsa_tags.find(glsa->id()))
+ glsa_tags.insert(std::make_pair(glsa->id(), GLSADepTag::Pointer(
+ new GLSADepTag(glsa->id(), glsa->title()))));
- if ((0 == atoms.size()) || (2 < atoms.size()))
- {
- continue;
- }
-
- bool is_range(2 == atoms.size());
-
- PackageDatabaseEntryCollection::ConstPointer unaffected_collection1(
- _imp->environment->package_database()->query(*atoms.at(0), is_either));
- PackageDatabaseEntryCollection::ConstPointer unaffected_collection2(
- new PackageDatabaseEntryCollection::Concrete);
- PackageDatabaseEntryCollection::Iterator p(unaffected_collection1->begin()),
- p_end(unaffected_collection1->end());
-
- if (is_range)
- unaffected_collection2 = _imp->environment->package_database()->query(
- *atoms.at(1), is_either);
-
- for ( ; p != p_end ; ++p)
- {
- if ((! is_range) || (unaffected_collection2->end() != unaffected_collection2->find(*p)))
+ if (insecurity)
{
- unaffected.insert(*p);
- std::set<std::pair<PackageDatabaseEntry, std::string> >::iterator
- aff(affected.find(std::make_pair(*p, advisory_id)));
- if (aff != affected.end())
- affected.erase(aff);
+ PackageDepAtom::Pointer atom(new PackageDepAtom(
+ "=" + stringify(c->name) + "-" + stringify(c->version) +
+ "::" + stringify(c->repository)));
+ atom->set_tag(glsa_tags.find(glsa->id())->second);
+ security_packages->add_child(atom);
+ }
+ else
+ {
+ /* we need to find the best not vulnerable installable package that isn't masked
+ * that's in the same slot as our vulnerable installed package. */
+ bool ok(false);
+ SlotName wanted_slot(_imp->environment->package_database()->fetch_repository(
+ c->repository)->version_metadata(c->name, c->version)->slot);
+
+ PackageDatabaseEntryCollection::ConstPointer available(
+ _imp->environment->package_database()->query(PackageDepAtom::Pointer(
+ new PackageDepAtom(stringify(glsa_pkg->name()))), is_uninstalled_only));
+ for (PackageDatabaseEntryCollection::ReverseIterator r(available->rbegin()),
+ r_end(available->rend()) ; r != r_end ; ++r)
+ {
+ if (_imp->environment->mask_reasons(*r).any())
+ continue;
+ if (_imp->environment->package_database()->fetch_repository(r->repository)->version_metadata(
+ r->name, r->version)->slot != wanted_slot)
+ continue;
+ if (is_vulnerable(*glsa_pkg, *r))
+ continue;
+
+ PackageDepAtom::Pointer atom(new PackageDepAtom(
+ "=" + stringify(r->name) + "-" + stringify(r->version) +
+ "::" + stringify(r->repository)));
+ atom->set_tag(glsa_tags.find(glsa->id())->second);
+ security_packages->add_child(atom);
+ ok = true;
+ break;
+ }
+
+ if (! ok)
+ throw GLSAError("Could not determine upgrade path to resolve '"
+ + glsa->id() + ": " + glsa->title() + "' for package '"
+ + stringify(*c) + "'");
}
}
}
}
- catch (const AdvisoryFileError & e)
- {
- Log::get_instance()->message(ll_warning, lc_context,
- "Malformed advisory file '" + stringify(*f) + "': " + e.message());
- }
- catch (const InternalError & e)
+ catch (const GLSAError & e)
{
- throw;
+ Log::get_instance()->message(ll_warning, lc_context, "Cannot use GLSA '" +
+ stringify(*f) + "' due to exception '" + e.message() + "' (" + e.what() + ")");
}
- catch (const Exception & e)
+ catch (const NameError & e)
{
- Log::get_instance()->message(ll_warning, lc_context,
- "Exception caught while parsing advisory '" + stringify(*f) +
- "': " + e.message());
- }
-
- }
-
- std::set<std::pair<PackageDatabaseEntry, std::string> >::const_iterator
- i(affected.begin()), i_end(affected.end());
- if (list_affected_only)
- {
- for ( ; i != i_end ; ++i)
- {
- Context context("When creating adding vulnerable package '" + stringify(i->first) + "':");
-
- PackageDepAtom::Pointer p(make_atom(i->first));
- p->set_tag(GLSADepTag::Pointer(new GLSADepTag(i->second, advisory_map[i->second])));
- security_packages->add_child(p);
- }
- }
- else
- {
- for ( ; i != i_end ; ++i)
- {
- Context context("When finding best update for package '" + stringify(i->first) +
- "', affected by '" + i->second + "':");
-
- PackageDatabaseEntryCollection::Iterator best = find_best(unaffected, i->first);
- if (best == unaffected.end())
- throw AllMaskedError("No best update available for package '" + stringify(i->first) + "':");
-
- PackageDepAtom::Pointer p(make_atom(*best));
- p->set_tag(GLSADepTag::Pointer(new GLSADepTag(i->second, advisory_map[i->second])));
- security_packages->add_child(p);
+ Log::get_instance()->message(ll_warning, lc_context, "Cannot use GLSA '" +
+ stringify(*f) + "' due to exception '" + e.message() + "' (" + e.what() + ")");
}
}
diff --git a/paludis/repositories/portage/portage_repository_sets.hh b/paludis/repositories/portage/portage_repository_sets.hh
index ec59393..d80a297 100644
--- a/paludis/repositories/portage/portage_repository_sets.hh
+++ b/paludis/repositories/portage/portage_repository_sets.hh
@@ -62,12 +62,12 @@ namespace paludis
/**
* Fetch a package set other than system.
*/
- DepAtom::Pointer package_set(const std::string & s, const PackageSetOptions & o) const;
+ DepAtom::Pointer package_set(const std::string & s) const;
/**
- * Fetch the security set.
+ * Fetch the security or insecurity set.
*/
- DepAtom::Pointer security_set(const PackageSetOptions & o) const;
+ DepAtom::Pointer security_set(bool insecure) const;
/**
* Give a list of all the sets in this repo.
diff --git a/paludis/repositories/portage/xml_things.cc b/paludis/repositories/portage/xml_things.cc
new file mode 100644
index 0000000..bfca771
--- /dev/null
+++ b/paludis/repositories/portage/xml_things.cc
@@ -0,0 +1,188 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <paludis/repositories/portage/glsa.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/config_file.hh>
+#include <paludis/libxml/libxml.hh>
+#include <set>
+
+using namespace paludis;
+
+extern "C"
+{
+ GLSA::Pointer create_glsa_from_xml_file(const std::string &);
+}
+
+namespace
+{
+ class Handler
+ {
+ private:
+ GLSA::Pointer _glsa;
+
+ public:
+ Handler() :
+ _glsa(new GLSA)
+ {
+ }
+
+ void handle_glsa_attrs(xmlDocPtr doc, xmlAttr * const attr)
+ {
+ for (xmlAttr * a(attr) ; a ; a = a->next)
+ {
+ if (a->type == XML_ATTRIBUTE_NODE)
+ {
+ std::string name(retarded_libxml_string_to_string(a->name));
+ if (name == "id")
+ _glsa->set_id(normalise(retarded_libxml_string_to_string(xmlNodeListGetString(doc,
+ a->xmlChildrenNode, 1))));
+ }
+ }
+ }
+
+ void handle_package_name(xmlDocPtr doc, xmlAttr * const attr, std::string & str)
+ {
+ for (xmlAttr * a(attr) ; a ; a = a->next)
+ {
+ if (a->type == XML_ATTRIBUTE_NODE)
+ {
+ std::string name(retarded_libxml_string_to_string(a->name));
+ if (name == "name")
+ str = normalise(retarded_libxml_string_to_string(xmlNodeListGetString(doc,
+ a->xmlChildrenNode, 1)));
+ }
+ }
+ }
+
+ void handle_package_archs(xmlDocPtr doc, xmlAttr * const attr, GLSAPackage::Pointer pkg)
+ {
+ for (xmlAttr * a(attr) ; a ; a = a->next)
+ {
+ if (a->type == XML_ATTRIBUTE_NODE)
+ {
+ std::string name(retarded_libxml_string_to_string(a->name));
+ if (name == "arch")
+ {
+ std::set<std::string> archs;
+ WhitespaceTokeniser::get_instance()->tokenise(retarded_libxml_string_to_string(
+ xmlNodeListGetString(doc, a->xmlChildrenNode, 1)),
+ std::inserter(archs, archs.end()));
+ archs.erase("*");
+ for (std::set<std::string>::const_iterator r(archs.begin()), r_end(archs.end()) ;
+ r != r_end ; ++r)
+ pkg->add_arch(UseFlagName(*r));
+ }
+ }
+ }
+ }
+
+ void handle_range_range(xmlDocPtr doc, xmlAttr * const attr, std::string & op)
+ {
+ for (xmlAttr * a(attr) ; a ; a = a->next)
+ {
+ if (a->type == XML_ATTRIBUTE_NODE)
+ {
+ std::string name(retarded_libxml_string_to_string(a->name));
+ if (name == "range")
+ op = normalise(retarded_libxml_string_to_string(xmlNodeListGetString(doc,
+ a->xmlChildrenNode, 1)));
+ }
+ }
+ }
+
+ void handle_package_children(xmlDocPtr doc, xmlNode * const node, GLSAPackage::Pointer pkg)
+ {
+ for (xmlNode * n(node) ; n ; n = n->next)
+ {
+ if (n->type == XML_ELEMENT_NODE)
+ {
+ std::string name(retarded_libxml_string_to_string(n->name));
+ if (name == "unaffected" || name == "vulnerable")
+ {
+ std::string op;
+ handle_range_range(doc, n->properties, op);
+ std::string version(normalise(retarded_libxml_string_to_string(
+ xmlNodeListGetString(doc, n->xmlChildrenNode, 1))));
+ ((*pkg).*(name == "unaffected" ? &GLSAPackage::add_unaffected : &GLSAPackage::add_vulnerable))
+ (GLSARange::create().op(op).version(version));
+ }
+ else
+ handle_node(doc, n->children);
+ }
+ else
+ handle_node(doc, n->children);
+ }
+
+ }
+
+ void handle_node(xmlDocPtr doc, xmlNode * const node)
+ {
+ for (xmlNode * n(node) ; n ; n = n->next)
+ {
+ if (n->type == XML_ELEMENT_NODE)
+ {
+ std::string name(retarded_libxml_string_to_string(n->name));
+ if (name == "glsa")
+ {
+ handle_glsa_attrs(doc, n->properties);
+ handle_node(doc, n->children);
+ }
+ else if (name == "title")
+ _glsa->set_title(normalise(retarded_libxml_string_to_string(xmlNodeListGetString(doc,
+ n->xmlChildrenNode, 1))));
+ else if (name == "package")
+ {
+ std::string name;
+ handle_package_name(doc, n->properties, name);
+ GLSAPackage::Pointer pkg(new GLSAPackage(QualifiedPackageName(name)));
+ handle_package_archs(doc, n->properties, pkg);
+ handle_package_children(doc, n->children, pkg);
+ _glsa->add_package(pkg);
+ }
+ else
+ handle_node(doc, n->children);
+ }
+ else
+ handle_node(doc, n->children);
+ }
+
+ }
+
+ GLSA::Pointer glsa()
+ {
+ return _glsa;
+ }
+ };
+}
+
+GLSA::Pointer
+create_glsa_from_xml_file(const std::string & filename)
+{
+ LibXmlPtrHolder<xmlDocPtr> xml_doc(xmlReadFile(filename.c_str(), 0, 0), &xmlFreeDoc);
+ if (! xml_doc)
+ throw GLSAError("Could not parse GLSA", filename);
+
+ Handler h;
+ h.handle_node(xml_doc, xmlDocGetRootElement(xml_doc));
+ return h.glsa();
+}
+
diff --git a/paludis/repositories/portage/xml_things_TEST.cc b/paludis/repositories/portage/xml_things_TEST.cc
new file mode 100644
index 0000000..748fc08
--- /dev/null
+++ b/paludis/repositories/portage/xml_things_TEST.cc
@@ -0,0 +1,92 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/portage/glsa.hh>
+#include <paludis/util/join.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+
+namespace test_cases
+{
+ struct GLSA123456_78Test : TestCase
+ {
+ GLSA123456_78Test() : TestCase("glsa 123456-78") { }
+
+ void run()
+ {
+ GLSA::Pointer glsa(GLSA::create_from_xml_file("xml_things_TEST_dir/glsa-123456-78.xml"));
+ TEST_CHECK(glsa);
+
+ TEST_CHECK_EQUAL("123456-78", glsa->id());
+ TEST_CHECK_EQUAL("Kittens: Too Adorable", glsa->title());
+
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages(), glsa->end_packages()));
+ TEST_CHECK_STRINGIFY_EQUAL("animal-feline/kitten", glsa->begin_packages()->name());
+ TEST_CHECK_STRINGIFY_EQUAL("0", std::distance(glsa->begin_packages()->begin_archs(),
+ glsa->begin_packages()->end_archs()));
+
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages()->begin_unaffected(),
+ glsa->begin_packages()->end_unaffected()));
+ TEST_CHECK_STRINGIFY_EQUAL("ge", glsa->begin_packages()->begin_unaffected()->op);
+ TEST_CHECK_STRINGIFY_EQUAL("1.23", glsa->begin_packages()->begin_unaffected()->version);
+
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages(), glsa->end_packages()));
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages()->begin_vulnerable(),
+ glsa->begin_packages()->end_vulnerable()));
+ TEST_CHECK_STRINGIFY_EQUAL("lt", glsa->begin_packages()->begin_vulnerable()->op);
+ TEST_CHECK_STRINGIFY_EQUAL("1.22", glsa->begin_packages()->begin_vulnerable()->version);
+ }
+ } glsa_test_123456_78;
+
+ struct GLSA987654_32Test : TestCase
+ {
+ GLSA987654_32Test() : TestCase("glsa 987654-32") { }
+
+ void run()
+ {
+ GLSA::Pointer glsa(GLSA::create_from_xml_file("xml_things_TEST_dir/glsa-987654-32.xml"));
+ TEST_CHECK(glsa);
+
+ TEST_CHECK_EQUAL("987654-32", glsa->id());
+ TEST_CHECK_EQUAL("Python: Retarded", glsa->title());
+
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages(), glsa->end_packages()));
+ TEST_CHECK_STRINGIFY_EQUAL("dev-lang/python", glsa->begin_packages()->name());
+ TEST_CHECK_STRINGIFY_EQUAL("3", std::distance(glsa->begin_packages()->begin_archs(),
+ glsa->begin_packages()->end_archs()));
+ TEST_CHECK_STRINGIFY_EQUAL("mips,sparc,x86", join(glsa->begin_packages()->begin_archs(),
+ glsa->begin_packages()->end_archs(), ","));
+
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages()->begin_unaffected(),
+ glsa->begin_packages()->end_unaffected()));
+ TEST_CHECK_STRINGIFY_EQUAL("ge", glsa->begin_packages()->begin_unaffected()->op);
+ TEST_CHECK_STRINGIFY_EQUAL("12.34", glsa->begin_packages()->begin_unaffected()->version);
+
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages(), glsa->end_packages()));
+ TEST_CHECK_STRINGIFY_EQUAL("1", std::distance(glsa->begin_packages()->begin_vulnerable(),
+ glsa->begin_packages()->end_vulnerable()));
+ TEST_CHECK_STRINGIFY_EQUAL("lt", glsa->begin_packages()->begin_vulnerable()->op);
+ TEST_CHECK_STRINGIFY_EQUAL("12.34", glsa->begin_packages()->begin_vulnerable()->version);
+ }
+ } glsa_test_987654_32;
+}
+
diff --git a/paludis/repositories/portage/xml_things_TEST_cleanup.sh b/paludis/repositories/portage/xml_things_TEST_cleanup.sh
new file mode 100755
index 0000000..5e0843f
--- /dev/null
+++ b/paludis/repositories/portage/xml_things_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d xml_things_TEST_dir ] ; then
+ rm -fr xml_things_TEST_dir
+else
+ true
+fi
+
+
+
diff --git a/paludis/repositories/portage/xml_things_TEST_setup.sh b/paludis/repositories/portage/xml_things_TEST_setup.sh
new file mode 100755
index 0000000..530af80
--- /dev/null
+++ b/paludis/repositories/portage/xml_things_TEST_setup.sh
@@ -0,0 +1,115 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir xml_things_TEST_dir || exit 1
+cd xml_things_TEST_dir || exit 1
+
+cat <<"END" > glsa-123456-78.xml
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="/xsl/glsa.xsl" type="text/xsl"?>
+<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
+<!DOCTYPE glsa SYSTEM "http://www.gentoo.org/dtd/glsa.dtd">
+
+<glsa id="123456-78">
+ <title>
+ Kittens: Too Adorable
+ </title>
+ <synopsis>
+ Kittens are too adorable. This can lead to excess cuteness.
+ </synopsis>
+ <product type="ebuild">kitten</product>
+ <announced>October 10, 2006</announced>
+ <revised>October 10, 2006: 01</revised>
+ <bug>123456</bug>
+ <access>remote</access>
+ <affected>
+ <package name="animal-feline/kitten" auto="yes" arch="*">
+ <unaffected range="ge">1.23</unaffected>
+ <vulnerable range="lt">1.22</vulnerable>
+ </package>
+ </affected>
+ <background>
+ <p>
+ Kittens are small cats.
+ </p>
+ </background>
+ <description>
+ <p>
+ By being adorable, kittens can get away with too much misbehaviour.
+ </p>
+ </description>
+ <impact type="high">
+ <p>
+ A kitten could get away with going undrowned because of its adorableness.
+ </p>
+ </impact>
+ <workaround>
+ <p>
+ There is no known workaround at this time.
+ </p>
+ </workaround>
+ <resolution>
+ <p>
+ All kitten users should upgrade to the latest version.
+ </p>
+ </resolution>
+ <references>
+ </references>
+</glsa>
+END
+
+cat <<"END" > glsa-987654-32.xml
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="/xsl/glsa.xsl" type="text/xsl"?>
+<?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
+<!DOCTYPE glsa SYSTEM "http://www.gentoo.org/dtd/glsa.dtd">
+
+<glsa id="987654-32">
+ <title>
+ Python: Retarded
+ </title>
+ <synopsis>
+ Python is retarded. Reading it can make your eyes bleed.
+ </synopsis>
+ <product type="ebuild">python</product>
+ <announced>October 10, 2006</announced>
+ <revised>October 10, 2006: 01</revised>
+ <bug>987654</bug>
+ <access>remote</access>
+ <affected>
+ <package name="dev-lang/python" auto="yes" arch="x86 sparc mips">
+ <unaffected range="ge">12.34</unaffected>
+ <vulnerable range="lt">12.34</vulnerable>
+ </package>
+ </affected>
+ <background>
+ <p>
+ Python purports to be a programming language.
+ </p>
+ </background>
+ <description>
+ <p>
+ Python abuses whitespace for block structures. This makes anyone reading it
+ suffer severe brain ache.
+ </p>
+ </description>
+ <impact type="high">
+ <p>
+ Anyone reading python code could go crazy.
+ </p>
+ </impact>
+ <workaround>
+ <p>
+ Use a real programming language.
+ </p>
+ </workaround>
+ <resolution>
+ <p>
+ All python users should get their brains examined.
+ </p>
+ </resolution>
+ <references>
+ </references>
+</glsa>
+END
+
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 7c4c8d0..73d3b0a 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -822,7 +822,7 @@ VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec &
}
DepAtom::Pointer
-VDBRepository::do_package_set(const std::string & s, const PackageSetOptions &) const
+VDBRepository::do_package_set(const std::string & s) const
{
Context context("When fetching package set '" + s + "' from '" +
stringify(name()) + "':");
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index a4e7806..4144ec7 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -83,7 +83,7 @@ namespace paludis
virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
- virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions & o) const;
+ virtual DepAtom::Pointer do_package_set(const std::string &) const;
/* RepositoryUseInterface */
diff --git a/paludis/repository.hh b/paludis/repository.hh
index d818e6b..41bb06f 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -567,16 +567,15 @@ namespace paludis
/**
* Override in descendents: package list.
*/
- virtual DepAtom::Pointer do_package_set(const std::string & id, const PackageSetOptions & o) const = 0;
+ virtual DepAtom::Pointer do_package_set(const std::string & id) const = 0;
public:
/**
* Fetch a package set.
*/
- virtual DepAtom::Pointer package_set(const std::string & s,
- const PackageSetOptions & o = PackageSetOptions(false)) const
+ virtual DepAtom::Pointer package_set(const std::string & s) const
{
- return do_package_set(s, o);
+ return do_package_set(s);
}
/**
diff --git a/paludis/repository.sr b/paludis/repository.sr
index 2194ddc..2370e1d 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -16,20 +16,6 @@ make_class_InstallOptions()
END
}
-make_class_PackageSetOptions()
-{
- key list_affected_only bool
-
- doxygen_comment << "END"
- /**
- * Options for the Repository::package_set method.
- *
- * \see Repository
- * \ingroup grprepository
- */
-END
-}
-
make_class_RepositoryCapabilities()
{
key installable_interface "RepositoryInstallableInterface *"
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index e5a2d98..f05e946 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -86,7 +86,7 @@ InstallTask::add_target(const std::string & target)
DepAtom::Pointer s(0);
- if (s = ((_imp->env->package_set(target))))
+ if ((target != "insecurity") && ((s = ((_imp->env->package_set(target))))))
{
if (_imp->had_set_targets)
throw MultipleSetTargetsSpecified();
diff --git a/paludis/util/collection.hh b/paludis/util/collection.hh
index 6ad6785..920bece 100644
--- a/paludis/util/collection.hh
+++ b/paludis/util/collection.hh
@@ -202,6 +202,18 @@ namespace paludis
virtual bool insert(const T_ & v) = 0;
/**
+ * Insert a range of items, return whether we inserted everything.
+ */
+ template <typename I_>
+ bool insert(I_ b, const I_ & e)
+ {
+ bool result(false);
+ for ( ; b != e ; ++b)
+ result |= insert(*b);
+ return result;
+ }
+
+ /**
* Erase an item, return whether we succeeded.
*/
virtual bool erase(const T_ & v) = 0;
diff --git a/paludis/util/exception.cc b/paludis/util/exception.cc
index 64caccb..f9c7548 100644
--- a/paludis/util/exception.cc
+++ b/paludis/util/exception.cc
@@ -100,6 +100,11 @@ Exception::backtrace(const std::string & delim) const
return _context_data->backtrace(delim);
}
+NotAvailableError::NotAvailableError(const std::string & msg) throw () :
+ Exception("Error: Not available: " + msg)
+{
+}
+
InternalError::InternalError(const std::string & where, const std::string & our_message) throw () :
Exception("Eek! Internal error at " + where + ": " + our_message)
{
diff --git a/paludis/util/exception.hh b/paludis/util/exception.hh
index 42f406a..4b0ce0d 100644
--- a/paludis/util/exception.hh
+++ b/paludis/util/exception.hh
@@ -145,6 +145,23 @@ namespace paludis
};
/**
+ * A NotAvailableError is an Exception that is thrown if something that is
+ * not available (for example due to compile time configure options or platform
+ * limitations) is used.
+ *
+ * \ingroup grpexceptions
+ */
+ class PALUDIS_VISIBLE NotAvailableError :
+ public Exception
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ NotAvailableError(const std::string & message) throw ();
+ };
+
+ /**
* A NameError is an Exception that is thrown when some kind of invalid
* name is encountered.
*
diff --git a/paludis/version_spec.hh b/paludis/version_spec.hh
index 2e078f1..74f97a9 100644
--- a/paludis/version_spec.hh
+++ b/paludis/version_spec.hh
@@ -72,7 +72,7 @@ namespace paludis
/**
* Constructor.
*/
- VersionSpec(const std::string & text);
+ explicit VersionSpec(const std::string & text);
/**
* Copy constructor.
diff --git a/src/adjutrix/Makefile.am b/src/adjutrix/Makefile.am
index f02d786..771631a 100644
--- a/src/adjutrix/Makefile.am
+++ b/src/adjutrix/Makefile.am
@@ -30,6 +30,7 @@ adjutrix_SOURCES = \
command_line.hh command_line.cc \
find_stable_candidates.hh find_stable_candidates.cc \
find_dropped_keywords.hh find_dropped_keywords.cc \
+ find_insecure_packages.hh find_insecure_packages.cc \
find_reverse_deps.hh find_reverse_deps.cc \
keywords_graph.hh keywords_graph.cc \
display_profiles_use.hh display_profiles_use.cc \
diff --git a/src/adjutrix/adjutrix.cc b/src/adjutrix/adjutrix.cc
index 282485f..8737fbd 100644
--- a/src/adjutrix/adjutrix.cc
+++ b/src/adjutrix/adjutrix.cc
@@ -21,6 +21,7 @@
#include "command_line.hh"
#include "find_stable_candidates.hh"
#include "find_dropped_keywords.hh"
+#include "find_insecure_packages.hh"
#include "find_reverse_deps.hh"
#include "keywords_graph.hh"
#include "display_profiles_use.hh"
@@ -136,6 +137,7 @@ main(int argc, char *argv[])
if (1 != (
CommandLine::get_instance()->a_find_stable_candidates.specified() +
CommandLine::get_instance()->a_find_dropped_keywords.specified() +
+ CommandLine::get_instance()->a_find_insecure_packages.specified() +
CommandLine::get_instance()->a_keywords_graph.specified() +
CommandLine::get_instance()->a_reverse_deps.specified() +
CommandLine::get_instance()->a_display_profiles_use.specified() +
@@ -167,6 +169,17 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+ if (CommandLine::get_instance()->a_find_insecure_packages.specified())
+ {
+ if (CommandLine::get_instance()->begin_parameters() !=
+ CommandLine::get_instance()->end_parameters())
+ throw DoHelp("find-dropped-keywords action takes no parameters");
+
+ do_find_insecure_packages(env);
+ return EXIT_SUCCESS;
+ }
+
+
if (CommandLine::get_instance()->a_keywords_graph.specified())
{
if (CommandLine::get_instance()->begin_parameters() !=
diff --git a/src/adjutrix/command_line.cc b/src/adjutrix/command_line.cc
index 5306bd7..c0b5c91 100644
--- a/src/adjutrix/command_line.cc
+++ b/src/adjutrix/command_line.cc
@@ -30,6 +30,8 @@ CommandLine::CommandLine() :
"find-stable-candidates", 's', "Search for stable package candidates"),
a_find_dropped_keywords(&tree_action_args,
"find-dropped-keywords", 'd', "Search for packages where keywords have been dropped"),
+ a_find_insecure_packages(&tree_action_args,
+ "find-insecure-packages", 'i', "Search for packages marked as insecure by a GLSA"),
a_keywords_graph(&tree_action_args,
"keyword-graph", 'k', "Display keywords graphically"),
a_reverse_deps(&tree_action_args,
@@ -88,6 +90,9 @@ CommandLine::CommandLine() :
add_usage_line("--find-dropped-keywords arch [ --repository-dir /path ] "
"[ --category app-misc --category sys-apps ... ] "
"[ --package foo --package fnord ... ] ");
+ add_usage_line("--find-insecure-packages [ --repository-dir /path ] "
+ "[ --category app-misc --category sys-apps ... ] "
+ "[ --package foo --package fnord ... ] ");
add_usage_line("--keywords-graph [ --repository-dir /path ] "
"[ --category app-misc --category sys-apps ... ] "
"[ --package foo --package fnord ... ]");
diff --git a/src/adjutrix/command_line.hh b/src/adjutrix/command_line.hh
index 66e4553..7414728 100644
--- a/src/adjutrix/command_line.hh
+++ b/src/adjutrix/command_line.hh
@@ -61,6 +61,7 @@ class CommandLine :
paludis::args::ArgsGroup tree_action_args;
paludis::args::SwitchArg a_find_stable_candidates;
paludis::args::SwitchArg a_find_dropped_keywords;
+ paludis::args::SwitchArg a_find_insecure_packages;
paludis::args::SwitchArg a_keywords_graph;
paludis::args::SwitchArg a_reverse_deps;
diff --git a/src/adjutrix/find_insecure_packages.cc b/src/adjutrix/find_insecure_packages.cc
new file mode 100644
index 0000000..1409c69
--- /dev/null
+++ b/src/adjutrix/find_insecure_packages.cc
@@ -0,0 +1,162 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "find_insecure_packages.hh"
+#include "command_line.hh"
+
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/compare.hh>
+
+#include <set>
+#include <map>
+#include <iostream>
+#include <iomanip>
+#include <algorithm>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+ const unsigned col_width_package = 30;
+ const unsigned col_width_id = 40;
+
+ void
+ write_repository_header(const RepositoryName & repo)
+ {
+ std::string s("Insecure packages from advisories in repository '" + stringify(repo) + "'");
+ cout << std::string(s.length(), '=') << endl;
+ cout << s << endl;
+ cout << std::string(s.length(), '=') << endl;
+ cout << endl;
+
+ cout << std::left
+ << std::setw(col_width_package) << "package"
+ << std::setw(col_width_id) << "GLSA IDs"
+ << endl;
+
+ cout
+ << std::string(col_width_package - 1, '-') << " "
+ << std::string(col_width_id - 1, '-') << " "
+ << endl;
+ }
+
+ class ListInsecureVisitor :
+ public DepAtomVisitorTypes::ConstVisitor
+ {
+ private:
+ const Environment & _env;
+ std::multimap<PackageDatabaseEntry, std::string> _found;
+
+ public:
+ ListInsecureVisitor(const Environment & e) :
+ _env(e)
+ {
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const PackageDepAtom * const a)
+ {
+ PackageDatabaseEntryCollection::ConstPointer insecure(
+ _env.package_database()->query(*a, is_either));
+ for (PackageDatabaseEntryCollection::Iterator i(insecure->begin()),
+ i_end(insecure->end()) ; i != i_end ; ++i)
+ if (a->tag())
+ _found.insert(std::make_pair(*i, a->tag()->short_text()));
+ else
+ throw InternalError(PALUDIS_HERE, "didn't get a tag");
+ }
+
+ void visit(const PlainTextDepAtom * const)
+ {
+ }
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+
+ friend std::ostream & operator<< (std::ostream &, const ListInsecureVisitor &);
+ };
+
+ std::ostream & operator<< (std::ostream & s, const ListInsecureVisitor & v)
+ {
+ QualifiedPackageName old_name("dormouse/teapot");
+ for (std::multimap<PackageDatabaseEntry, std::string>::const_iterator
+ f(v._found.begin()), f_end(v._found.end()) ; f != f_end ; ++f)
+ {
+ if (f->first.name != old_name)
+ s << std::setw(col_width_package) << (stringify(f->first.name) + " ") << endl;
+ old_name = f->first.name;
+ s << std::setw(col_width_package) << (" " + stringify(f->first.version) + " ")
+ << f->second;
+ while (next(f) != f_end)
+ {
+ if (next(f)->first != f->first)
+ break;
+ cout << " " << f->second;
+ ++f;
+ }
+ cout << endl;
+ }
+
+ return s;
+ }
+}
+
+void do_find_insecure_packages(const Environment & env)
+{
+ Context context("When performing find-insecure-packages action:");
+
+ for (IndirectIterator<PackageDatabase::RepositoryIterator, const Repository>
+ r(env.package_database()->begin_repositories()),
+ r_end(env.package_database()->end_repositories()) ; r != r_end ; ++r)
+ {
+ if (r->name() == RepositoryName("virtuals"))
+ continue;
+
+ if (! r->sets_interface)
+ continue;
+
+ write_repository_header(r->name());
+
+ DepAtom::ConstPointer all_insecure(r->sets_interface->package_set("insecurity"));
+ if (! all_insecure)
+ continue;
+ ListInsecureVisitor v(env);
+ all_insecure->accept(&v);
+ cout << v << endl;
+ }
+}
+
diff --git a/paludis/qa/libxml_utils.cc b/src/adjutrix/find_insecure_packages.hh
index d98c6aa..a8c1cc0 100644
--- a/paludis/qa/libxml_utils.cc
+++ b/src/adjutrix/find_insecure_packages.hh
@@ -17,14 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "libxml_utils.hh"
+#ifndef PALUDIS_GUARD_SRC_ADJUTRIX_FIND_INSECURE_PACKAGES_HH
+#define PALUDIS_GUARD_SRC_ADJUTRIX_FIND_INSECURE_PACKAGES_HH 1
-std::string
-paludis::qa::retarded_libxml_string_to_string(const xmlChar * s)
-{
- if (s)
- return std::string(reinterpret_cast<const char *>(s));
- else
- return "";
-}
+#include <paludis/environment.hh>
+void do_find_insecure_packages(const paludis::Environment & env);
+
+#endif
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index 54c8c54..de63493 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -51,7 +51,6 @@ CommandLine::CommandLine() :
a_list_repository_formats(&action_args_internal, "list-repository-formats", '\0',
"List available repository formats"),
a_list_dep_tag_categories(&action_args_internal, "list-dep-tag-categories", '\0', "List known dep tag categories"),
- a_list_vulnerabilities(&action_args_internal, "list-vulnerabilities", '\0', "List known vulnerabilities"),
a_update_news(&action_args_internal, "update-news", '\0', "Regenerate news.unread files"),
general_args(this, "General options",
@@ -186,7 +185,6 @@ CommandLine::CommandLine() :
add_usage_line("--list-sync-protocols");
add_usage_line("--list-repository-formats");
add_usage_line("--list-dep-tag-categories");
- add_usage_line("--list-vulnerabilities [--repository repo1 ...]");
add_usage_line("--update-news");
add_enviromnent_variable("PALUDIS_HOME", "Overrides the home directory used when searching "
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index fb508da..bd60b6c 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -122,9 +122,6 @@ class CommandLine :
/// --list-dep-tag-categories
paludis::args::SwitchArg a_list_dep_tag_categories;
- /// --list-vulnerabilities
- paludis::args::SwitchArg a_list_vulnerabilities;
-
/// --update-news
paludis::args::SwitchArg a_update_news;
diff --git a/src/paludis/list.cc b/src/paludis/list.cc
index c6dfb17..5b93fc1 100644
--- a/src/paludis/list.cc
+++ b/src/paludis/list.cc
@@ -336,42 +336,3 @@ namespace
}
}
-int
-do_list_vulnerabilities()
-{
- int ret_code = 0;
-
- p::Context context("When performing list-vulnerabilities action from command line:");
- p::Environment * const env(p::DefaultEnvironment::get_instance());
- p::PackageSetOptions opts(true);
-
- p::CompositeDepAtom::Pointer vulnerabilities(new p::AllDepAtom);
-
- for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
- r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
- r != r_end ; ++r)
- {
- if (CommandLine::get_instance()->a_repository.specified())
- if (CommandLine::get_instance()->a_repository.args_end() == std::find(
- CommandLine::get_instance()->a_repository.args_begin(),
- CommandLine::get_instance()->a_repository.args_end(),
- stringify(r->name())))
- continue;
-
- if (! r->sets_interface)
- continue;
-
- p::DepAtom::Pointer dep = r->sets_interface->package_set("security", opts);
- if (0 != dep)
- vulnerabilities->add_child(dep);
- }
-
- VulnerabilitiesPrinter vp;
- std::for_each(vulnerabilities->begin(), vulnerabilities->end(), p::accept_visitor(&vp));
-
- if (vp.size() == 0)
- ret_code = 1;
-
- return ret_code;
-}
-
diff --git a/src/paludis/list.hh b/src/paludis/list.hh
index 1e1bd84..204af50 100644
--- a/src/paludis/list.hh
+++ b/src/paludis/list.hh
@@ -36,7 +36,4 @@ int do_list_packages();
/// Handle --list-sets.
int do_list_sets();
-/// Handle --list-vulnerabilities.
-int do_list_vulnerabilities();
-
#endif
diff --git a/src/paludis/paludis.cc b/src/paludis/paludis.cc
index dd2b696..e44e791 100644
--- a/src/paludis/paludis.cc
+++ b/src/paludis/paludis.cc
@@ -171,7 +171,6 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_list_sync_protocols.specified() +
CommandLine::get_instance()->a_list_repository_formats.specified() +
CommandLine::get_instance()->a_list_dep_tag_categories.specified() +
- CommandLine::get_instance()->a_list_vulnerabilities.specified() +
CommandLine::get_instance()->a_contents.specified() +
CommandLine::get_instance()->a_owner.specified() +
CommandLine::get_instance()->a_has_version.specified() +
@@ -229,14 +228,6 @@ main(int argc, char *argv[])
return do_list_dep_tag_categories();
}
- if (CommandLine::get_instance()->a_list_vulnerabilities.specified())
- {
- if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-vulnerabilities action takes no paramters");
-
- return do_list_vulnerabilities();
- }
-
/* these actions do need DefaultConfig */
try