# - Consider calling ./mkChangelog to assist you.
# See './mkChangelog -h' for help.
#
-SET(LIBZYPP_MAJOR "14")
-SET(LIBZYPP_COMPATMINOR "39")
-SET(LIBZYPP_MINOR "44")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_MAJOR "15")
+SET(LIBZYPP_COMPATMINOR "0")
+SET(LIBZYPP_MINOR "0")
+SET(LIBZYPP_PATCH "0")
#
-# LAST RELEASED: 14.44.1 (39)
+# LAST RELEASED: 15.0.0 (0)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
#=======
<DT>plugin:commit</DT>
<DD><DL>
- <DT>\ref plugin-commit </DT>
<DT>version 0</DT>
- <DD>Basic plugin indicating start and end of commit.</DD>
- <DT>version 1</DT>
- <DD>Added COMMITBEGIN/COMMITEND.</DD>
+ <DD>\see \ref plugin-commit </DD>
</DL></DD>
<DT>plugin:services</DT>
<DD><DL>
- <DT>\ref plugin-services </DT>
<DT>version 0</DT>
- <DD>Provide a client a list of repositories.</DD>
- <DT>version 1</DT>
- <DD>Support multiple repo baseurls in plugin services.</DD>
+ <DD>\see \ref plugin-services </DD>
</DL></DD>
<DT>plugin:system</DT>
<DD><DL>
- <DT>\ref plugin-system </DT>
<DT>version 0</DT>
<DD>Plugin executed when system content change is detected (by now SUSE Manager/spacewalk only).</DD>
- <DT>version 1</DT>
- <DD>Plugin executed when system content change is detected (all installed plugins).</DD>
</DL></DD>
<DT>plugin:urlresolver</DT>
<DD><DL>
- <DT>\ref plugin-url-resolver </DT>
<DT>version 0</DT>
- <DD>Convert urls of scheme "plugin" into a supported scheme. </DD>
+ <DD>\see \ref plugin-url-resolver </DD>
</DL></DD>
<DT>repovarexpand</DT>
<DD><DL>
- <DT>\ref zypp-repovars </DT>
<DT>version 0</DT>
- <DD>Also support braced variables, shell like default and alternate values.</DD>
+ <DD>Also support braced variables, shell like default and alternate values. \see \ref zypp-repovars</DD>
</DL></DD>
</DL>
+++ /dev/null
-/**
-
-\page plugin-system System plugin
-
-\author Michael Andres <ma@suse.de>
-
-<HR><!-- ====================================================================== -->
-\section intro Introduction
-
-This is a statefull plugin executed at the end of \ref zypp::ZYpp::commit, if the system content has change, i.e. if packages have actually been installed or deleted.
-
-All plugins found in \c /usr/lib/zypp/plugins/system are launched. Unless otherwise specified, messages received need to be confirmed by sending an \c ACC message. Sending back an unexpected or \c ERROR message, the execution of the plugin will be canceled.
-
-If you have e.g. \c zypp-plugin-python installed a basic system plugin could look like this:
-
-\verbatim
-#!/usr/bin/env python
-#
-# zypp system plugin
-#
-import os
-import sys
-from zypp_plugin import Plugin
-
-class MyPlugin(Plugin):
-
- def PACKAGESETCHANGED(self, headers, body):
-
- // Installation has ended. The set of installed packages has changed.
- // ....
-
- self.ack()
- def
-
-plugin = MyPlugin()
-plugin.main()
-\endverbatim
-
-\see \ref plugin-writing
-
-<HR><!-- ====================================================================== -->
-\section pluginbegin PLUGINBEGIN
-\verbatim
-PLUGINBEGIN
-userdata:TIDfoo42
-
-^@
-\endverbatim
-Sent as 1st message after the plugin was launched. Prepare your plugin and send an \c ACC message when you are done.
-
-\li \c userdata:stringval Optional header sent if the application has provided a user data string. \see \ref zypp-userdata
-
-
-<HR><!-- ====================================================================== -->
-\section packagesetchanged PACKAGESETCHANGED
-\verbatim
-PACKAGESETCHANGED
-
-^@
-\endverbatim
-Installation has ended. The set of installed packages has changed.
-
-\see \ref zypp::sat::Transaction::Step
-
-<HR><!-- ====================================================================== -->
-\section pluginend PLUGINEND
-\verbatim
-PLUGINEND
-
-^@
-\endverbatim
-This message is sent at the end before the plugin is closed. You should receive this message even if the action was aborted by some unexpected exception.
-
-
-*/
\subpage plugin-commit Escort installation of packages
-\subpage plugin-system Receive notification if system content has changed
-
\ref plugin-services
\ref plugin-url-resolver
plugin:foo?param1=val1¶m2=val2
\endverbatim
-ZYpp tries to execute a plugin named foo (in /usr/lib/zypp/plugins/urlresolver) and call it with the following protocol:
+ZYpp tries to executa a plugin named foo (in /usr/lib/zypp/plugins/urlresolver) and call it with the following protocol:
\verbatim
RESOLVEURL
\note REPO_METADATA_PATH can be empty or a not existing directory, indicating valid metadata for the repo are not yet available.
Scripts are executed 'fire and forget' whenever a RepoManager instance that performed changes goes out of scope. So it's up to the script to protect against concurrency.
-*/
+*/
\ No newline at end of file
.\" Title: locks
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 06/12/2015
+.\" Date: 10/02/2014
.\" Manual: LIBZYPP
-.\" Source: SUSE Linux
+.\" Source: libzypp
.\" Language: English
.\"
-.TH "LOCKS" "5" "06/12/2015" "SUSE Linux" "LIBZYPP"
+.TH "LOCKS" "5" "10/02/2014" "libzypp" "LIBZYPP"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
-LOCKS(5)
+locks(5)
========
:man manual: LIBZYPP
-:man source: SUSE Linux
+:man source: libzypp
NAME
'\" t
-.\" Title: zypp-checkaccessdeleted
+.\" Title: zypp-CheckAccessDeleted
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 06/12/2015
+.\" Date: 10/02/2014
.\" Manual: LIBZYPP
-.\" Source: SUSE Linux
+.\" Source: libzypp
.\" Language: English
.\"
-.TH "ZYPP\-CHECKACCESSDEL" "1" "06/12/2015" "SUSE Linux" "LIBZYPP"
+.TH "ZYPP\-CHECKACCESSDEL" "1" "10/02/2014" "libzypp" "LIBZYPP"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
-ZYPP-CHECKACCESSDELETED(1)
+zypp-CheckAccessDeleted(1)
==========================
:man manual: LIBZYPP
-:man source: SUSE Linux
+:man source: libzypp
NAME
'\" t
-.\" Title: zypp-namereqprv
+.\" Title: zypp-NameReqPrv
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 06/12/2015
+.\" Date: 10/02/2014
.\" Manual: LIBZYPP
-.\" Source: SUSE Linux
+.\" Source: libzypp
.\" Language: English
.\"
-.TH "ZYPP\-NAMEREQPRV" "1" "06/12/2015" "SUSE Linux" "LIBZYPP"
+.TH "ZYPP\-NAMEREQPRV" "1" "10/02/2014" "libzypp" "LIBZYPP"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
-ZYPP-NAMEREQPRV(1)
+zypp-NameReqPrv(1)
==================
:man manual: LIBZYPP
-:man source: SUSE Linux
+:man source: libzypp
NAME
Provides: libzypp(plugin) = 0
Provides: libzypp(plugin:appdata) = 0
Provides: libzypp(plugin:commit) = 1
-Provides: libzypp(plugin:services) = 1
-Provides: libzypp(plugin:system) = 1
+Provides: libzypp(plugin:services) = 0
+Provides: libzypp(plugin:system) = 0
Provides: libzypp(plugin:urlresolver) = 0
Provides: libzypp(repovarexpand) = 0
BuildRequires: pkg-config
%endif
-BuildRequires: libsolv-devel >= 0.6.19
+BuildRequires: libsolv-devel >= 0.6.7
%if 0%{?suse_version} >= 1100
BuildRequires: libsolv-tools
%requires_eq libsolv-tools
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/services.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/vendors.d
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/multiversion.d
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/zypp/credentials.d
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/zypp/plugins/appdata
%dir %{_sysconfdir}/zypp/services.d
%dir %{_sysconfdir}/zypp/vendors.d
%dir %{_sysconfdir}/zypp/multiversion.d
-%dir %{_sysconfdir}/zypp/credentials.d
%config(noreplace) %{_sysconfdir}/zypp/zypp.conf
%config(noreplace) %{_sysconfdir}/zypp/systemCheck
%config(noreplace) %{_sysconfdir}/logrotate.d/zypp-history.lr
export LC_ALL=""
export LANG="en"
-
-function Edit()
-{
- local FILE="$1"
- vi "$FILE"
- sed -i 's/ \+$//' "$FILE"
-}
+EDITOR=${EDITOR:-vi}
EMAIL="$(git config --get user.email)"
echo
case "${RES:-e}" in
[eE]*)
- Edit $VERSIONFILE
+ $EDITOR $VERSIONFILE
eval $(getversion)
continue
;;
RES=e
while [ "$RES" == "e" ]; do
- Edit $TMPFILE
+ $EDITOR $TMPFILE
echo
awk '{print}/^----------/{n=n+1; if ( n == 2 ) exit 0; }' $TMPFILE
read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (s)ubmitt, (e)dit [e]: ")" RES
-------------------------------------------------------------------
-Tue Oct 11 18:07:13 CEST 2016 - ma@suse.de
+Thu Apr 2 19:06:56 CEST 2015 - ma@suse.de
-- Let 'dup --from' leave an updateTestcase-<DATE> in /var/log (bsc#1004096)
-- version 14.44.1 (39)
-
--------------------------------------------------------------------
-Tue Oct 11 12:32:32 CEST 2016 - ma@suse.de
-
-- RepoInfo: Allow parsing multiple gpgkey= URLs (bsc#1003748)
-- version 14.44.0 (39)
-
--------------------------------------------------------------------
-Fri Sep 16 12:58:46 CEST 2016 - ma@suse.de
-
-- guessPackageSpec: Don't break globbing (fixes openSUSE/zypper#97)
-- version 14.43.4 (39)
-
--------------------------------------------------------------------
-Thu Sep 15 15:29:40 CEST 2016 - ma@suse.de
-
-- RepoFileReader: fix parsing of multiline url entries (bsc#964932)
-- version 14.43.3 (39)
-
--------------------------------------------------------------------
-Wed Aug 10 12:20:40 CEST 2016 - ma@suse.de
-
-- Report numeric curl error if code is unrecognized (bsc#992302)
-- version 14.43.2 (39)
-
--------------------------------------------------------------------
-Wed Jun 15 12:43:39 CEST 2016 - ma@suse.de
-
-- Fix bug in removeRepository which may keep an empty .repo file
- rather than deleting it (bsc#984494)
-- version 14.43.1 (39)
-
--------------------------------------------------------------------
-Sun May 1 01:13:40 CEST 2016 - ma@suse.de
-
-- Update sle-zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Tue Apr 26 12:38:14 CEST 2016 - ma@suse.de
-
-- Provide 'libzypp(plugin:services) = 1' after fixing bsc#933760
-- Fix credential file parser losing entries with known URL but
- different user name (bsc#933760)
-- RepoManager: allow extraction of multiple baseurls for service
- repos (bsc#964932)
-- addRepository: fix to use the correct history file for logging
-- specfile: add /etc/zypp/credentials.d to the file list
-- version 14.43.0 (39)
-
--------------------------------------------------------------------
-Fri Apr 15 11:28:42 CEST 2016 - ma@suse.de
-
-- DiskUsageCounter: Limit estimated waste per file (bsc#974275)
-- Filter unwanted btrfs subvolumes (fixes #54, closes #55, bnc#949945)
-- version 14.42.7 (39)
-
--------------------------------------------------------------------
-Mon Apr 11 12:47:27 CEST 2016 - ma@suse.de
-
-- Use PluginExecutor for commit- and system-hooks (bnc#971637)
-- version 14.42.6 (39)
-
--------------------------------------------------------------------
-Tue Mar 15 14:37:39 CET 2016 - ma@suse.de
-
-- BuildRequires: libsolv-devel >= 0.6.19 (bnc#971018)
-- version 14.42.5 (39)
-
--------------------------------------------------------------------
-Tue Mar 1 12:33:36 CET 2016 - ma@suse.de
-
-- media: Send stats header to download.opensuse.org only (bsc#955801)
-- version 14.42.4 (39)
-
--------------------------------------------------------------------
-Fri Oct 23 17:15:37 CEST 2015 - ma@suse.de
-
-- Fix broken product: <-> -release package relation (bnc#951782)
-- version 14.42.3 (39)
-
--------------------------------------------------------------------
-Thu Oct 22 10:27:41 CEST 2015 - ma@suse.de
-
-- fix Plugin-services not updating repo GPGCheck settings (bnc#951402)
-- version 14.42.2 (39)
-
--------------------------------------------------------------------
-Sun Oct 18 01:14:29 CEST 2015 - ma@suse.de
-
-- Update zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Thu Oct 15 10:44:14 CEST 2015 - ma@suse.de
-
-- make Solvable::asUserString more readable (bnc#949957)
-- version 14.42.1 (39)
-
--------------------------------------------------------------------
-Thu Oct 15 01:14:55 CEST 2015 - ma@suse.de
-
-- Update zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Thu Oct 8 01:17:27 CEST 2015 - ma@suse.de
-
-- Update sle-zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Tue Sep 29 18:40:05 CEST 2015 - ma@suse.de
-
-- ZYppCommitResult: add attemptToModify to indicate an attempt to
- actually install/remove was made (bsc#946750, FATE#319467)
-- version 14.42.0 (39)
-
--------------------------------------------------------------------
-Fri Sep 25 10:54:20 CEST 2015 - ma@suse.de
-
-- Avoid URL rewrite if probing local cache directories (bsc#946129)
-- version 14.41.1 (39)
-
--------------------------------------------------------------------
-Mon Sep 7 09:41:44 CEST 2015 - ma@suse.de
-
-- Don't cache repo releasever (bnc#943563)
-- version 14.41.0 (39)
-
--------------------------------------------------------------------
-Thu Sep 3 01:14:27 CEST 2015 - ma@suse.de
-
-- Update zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Thu Aug 27 01:14:57 CEST 2015 - ma@suse.de
-
-- Update sle-zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Thu Aug 13 01:14:45 CEST 2015 - ma@suse.de
-
-- Update zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Wed Aug 12 18:09:22 CEST 2015 - ma@suse.de
-
-- Fix setting dup_allow* solver options (bnc#941463)
-- version 14.40.2 (39)
-
--------------------------------------------------------------------
-Wed Aug 12 15:49:49 CEST 2015 - ma@suse.de
-
-- Don't make zypper encode {} around repo vars (bnc#941453)
-- Support for MIPS architectures
-- version 14.40.1 (39)
-
--------------------------------------------------------------------
-Sun Aug 2 01:14:24 CEST 2015 - ma@suse.de
-
-- Update zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Mon Jul 27 09:54:15 CEST 2015 - ma@suse.de
-
-- Update zypp-po.tar.bz2
-
--------------------------------------------------------------------
-Fri Jul 3 15:24:15 CEST 2015 - ma@suse.de
-
-- Resolver allow tuning DUP mode solver flags (FATE#319128)
-- version 14.40.0 (39)
-
--------------------------------------------------------------------
-Fri Jun 12 12:40:36 CEST 2015 - ma@suse.de
-
-- zypp.conf: Add config values for gpgcheck, repo_gpgcheck
- and pkg_gpgcheck. The default behavior 'gpgcheck=On' will
- automatically turn on the gpg signature check for packages
- downloaded from repository with unsigned metadata. If the
- repo metadata are signed, a faster comparison via checksums
- is done. By explicitly setting repo_gpgcheck or pkg_gpgcheck
- you can enforce the signature check of repository metadata
- or downloaded packages to be always performed. Those defaults
- can be overwritten per repository. (FATE#314603)
-- Downloader: Accept unsigned repository if pkgGpgCheck is ON.
-- version 14.39.0 (39)
-
--------------------------------------------------------------------
-Tue Jun 2 16:56:13 CEST 2015 - ma@suse.de
-
-- Fix SSL client certificate authentication via URL option
- ssl_clientcert/ssl_clientkey (bnc#932393)
-- version 14.38.6 (30)
-
--------------------------------------------------------------------
-Mon Jun 1 16:14:04 CEST 2015 - ma@suse.de
-
-- FindFileConflicts: avoid nested exception on user abort (bnc#931601)
-- version 14.38.5 (30)
-
--------------------------------------------------------------------
-Wed May 6 14:26:54 CEST 2015 - ma@suse.de
-
-- Fix repo alias containing ']' not handled correctly (bnc#929528)
-- version 14.38.4 (30)
-
--------------------------------------------------------------------
-Tue May 5 14:33:23 CEST 2015 - ma@suse.de
-
-- Fix SEGV when dumping rpm header with epoch (bnc#929483)
-- version 14.38.3 (30)
+- POODLE: libzypp should only talk TLS (bnc#903405)
+- Bump major version for Factory, 14.x is continued on SuSE-SLE-12-Branch
+- version 15.0.0 (0)
-------------------------------------------------------------------
-Thu Apr 2 19:21:07 CEST 2015 - ma@suse.de
+Thu Apr 2 16:01:43 CEST 2015 - ma@suse.de
-- POODLE: libzypp should only talk TLS (bnc#903405)
-- version 14.38.2 (30)
+- Fixes to build with gcc5
+- RepoProvideFile: Suppress MediaChangeReport while testing
+ multiple baseurls (bnc#899510)
+- version 14.38.1 (30)
-------------------------------------------------------------------
Thu Mar 19 16:44:39 CET 2015 - ma@suse.de
-------------------------------------------------------------------
Wed Mar 11 09:22:46 CET 2015 - ma@suse.de
-- New RepoVarExpand: Functor expanding repo variables in a
+- New RepoVarExpand: Functor expanding repo variables in a
string . Supports bash style default ${v:-w}' and alternate ${v:+w}
values (FATE#318354)
- Easy.h: Use __typeof__ rather than typeof in header
- Support repo variable replacement in service url
- Support repo variable replacement in gpg url
-- Gettext.h: Fallback to ::gettext if accidentally included
+- Gettext.h: Fallback to ::gettext if accidentally included
outside libzypp
- version 14.37.0 (30)
-------------------------------------------------------------------
Mon Feb 9 16:05:38 CET 2015 - ma@suse.de
-- Don't execute scripts in /tmp or /var/tmp, as they could be
+- Don't execute scripts in /tmp or /var/tmp, as they could be
mounted noexec for security reasons (bnc#915928)
- zypp/PublicKey.cc: Use GPG_BINARY from KeyRing
-- Support $releasever_major/$releasever_minor repo variables
+- Support $releasever_major/$releasever_minor repo variables
(FATE#318354)
- version 14.36.0 (30)
Mon Jan 12 15:04:17 CET 2015 - ma@suse.de
- Properly propagate repo variables in service refresh.
-- Let $ZYPP_REPO_RELEASEVER overwrite $releasever in .repo files
+- Let $ZYPP_REPO_RELEASEVER overwrite $releasever in .repo files
(bnc#911658)
- Call pool_set_rootdir to properly check for file conflicts.
- Use xgettext --boost to support boost-format (%N%)
CredentialFileReader reader(credfile,
bind( &CredCollector::collect, &collector, _1 ));
- BOOST_CHECK_EQUAL(collector.creds.size(), 3);
+ BOOST_CHECK(collector.creds.size() == 2);
}
using namespace zypp;
using namespace zypp::media;
-inline void testGetCreds( CredentialManager & cm_r, const std::string & url_r,
- const std::string & user_r = "",
- const std::string & pass_r = "" )
-{
- Url url( url_r );
- AuthData_Ptr cred = cm_r.getCred( url );
- //cout << "FOR: " << url << endl;
- //cout << "GOT: " << cred << endl;
- if ( user_r.empty() && pass_r.empty() )
- {
- BOOST_CHECK_EQUAL( cred, AuthData_Ptr() );
- }
- else
- {
- BOOST_CHECK_EQUAL( cred->username(), user_r );
- BOOST_CHECK_EQUAL( cred->password(), pass_r );
- }
-}
BOOST_AUTO_TEST_CASE(read_cred_for_url)
{
CredManagerOptions opts;
opts.globalCredFilePath = TESTS_SRC_DIR "/media/data/credentials.cat";
opts.userCredFilePath = Pathname();
- CredentialManager cm( opts );
- BOOST_CHECK_EQUAL( cm.credsGlobalSize(), 3 );
-
- testGetCreds( cm, "https://drink.it/repo/roots", "ginger", "ale" );
- testGetCreds( cm, "ftp://weprovidesoft.fr/download/opensuse/110", "agda", "ichard" );
- testGetCreds( cm, "ftp://magda@weprovidesoft.fr/download/opensuse/110", "magda", "richard" );
- testGetCreds( cm, "ftp://agda@weprovidesoft.fr/download/opensuse/110", "agda", "ichard" );
- testGetCreds( cm, "ftp://unknown@weprovidesoft.fr/download/opensuse/110" ); // NULL
- testGetCreds( cm, "http://url.ok/but/not/creds" ); // NULL
+ CredentialManager cm(opts);
+ BOOST_CHECK(cm.credsGlobalSize() == 2);
+
+ Url url("https://drink.it/repo/roots");
+ AuthData_Ptr credentials = cm.getCred(url);
+ BOOST_CHECK(credentials.get() != NULL);
+ if (!credentials)
+ return;
+ BOOST_CHECK(credentials->username() == "ginger");
+ BOOST_CHECK(credentials->password() == "ale");
+
+ Url url2("ftp://magda@weprovidesoft.fr/download/opensuse/110");
+ credentials = cm.getCred(url2);
+ BOOST_CHECK(credentials.get() != NULL);
+ if (!credentials)
+ return;
+ BOOST_CHECK(credentials->username() == "magda");
+ BOOST_CHECK(credentials->password() == "richard");
}
struct CredCollector
{
bool collect(AuthData_Ptr & cred)
{
- //cout << "got: " << endl << *cred << endl;
+ cout << "got: " << endl << *cred << endl;
creds.insert(cred);
return true;
}
BOOST_AUTO_TEST_CASE(save_creds)
{
filesystem::TmpDir tmp;
+
CredManagerOptions opts;
opts.globalCredFilePath = tmp / "fooha";
- CredentialManager cm1(opts);
+ CredentialManager cm1(opts);
AuthData cr1("benson","absolute");
cr1.setUrl(Url("http://joooha.com"));
-
AuthData cr2("pat","vymetheny");
cr2.setUrl(Url("ftp://filesuck.org"));
cm1.saveInGlobal(cr1);
CredCollector collector;
- CredentialFileReader( opts.globalCredFilePath, bind( &CredCollector::collect, &collector, _1 ) );
- BOOST_CHECK_EQUAL( collector.creds.size(), 1 );
+ CredentialFileReader reader(opts.globalCredFilePath,
+ bind( &CredCollector::collect, &collector, _1 ));
+ BOOST_CHECK(collector.creds.size() == 1);
+ cout << "----" << endl;
collector.creds.clear();
+
cm1.saveInGlobal(cr2);
- CredentialFileReader( opts.globalCredFilePath, bind( &CredCollector::collect, &collector, _1 ) );
- BOOST_CHECK_EQUAL(collector.creds.size(), 2 );
+ CredentialFileReader reader1(opts.globalCredFilePath,
+ bind( &CredCollector::collect, &collector, _1 ));
+ BOOST_CHECK(collector.creds.size() == 2);
+
+ cout << "----" << endl;
collector.creds.clear();
+
// save the same creds again
cm1.saveInGlobal(cr2);
- CredentialFileReader( opts.globalCredFilePath, bind( &CredCollector::collect, &collector, _1 ) );
- BOOST_CHECK_EQUAL(collector.creds.size(), 2 );
+ CredentialFileReader reader2(opts.globalCredFilePath,
+ bind( &CredCollector::collect, &collector, _1 ));
+ BOOST_CHECK(collector.creds.size() == 2);
// todo check created file permissions
}
BOOST_AUTO_TEST_CASE(service_base_url)
{
filesystem::TmpDir tmp;
+
CredManagerOptions opts;
opts.globalCredFilePath = tmp / "fooha";
- CredentialManager cm( opts );
- AuthData cred( "benson","absolute" );
- cred.setUrl( Url( "http://joooha.com/service/path" ) );
- cm.addGlobalCred( cred );
+ CredentialManager cm1(opts);
+ AuthData cr1("benson","absolute");
+ cr1.setUrl(Url("http://joooha.com/service/path"));
+ cm1.addGlobalCred(cr1);
+
+ AuthData_Ptr creds;
+ creds = cm1.getCred(Url("http://joooha.com/service/path/repo/repofoo"));
+
+ BOOST_CHECK(creds.get() != NULL);
+ if (!creds)
+ return;
+ BOOST_CHECK(creds->username() == "benson");
+
+ creds = cm1.getCred(Url("http://benson@joooha.com/service/path/repo/repofoo"));
+
+ BOOST_CHECK(creds.get() != NULL);
+ if (!creds)
+ return;
+ BOOST_CHECK(creds->username() == "benson");
- testGetCreds( cm, "http://joooha.com/service/path/repo/repofoo", "benson", "absolute" );
- testGetCreds( cm, "http://benson@joooha.com/service/path/repo/repofoo", "benson", "absolute" );
- testGetCreds( cm, "http://nobody@joooha.com/service/path/repo/repofoo" ); // NULL
+ creds = cm1.getCred(Url("http://nobody@joooha.com/service/path/repo/repofoo"));
+ BOOST_CHECK(creds.get() == NULL);
}
-# no 1
[https://drink.it/repo/roots]
username=ginger
password=ale
-#no 2
[ftp://weprovidesoft.fr/download/opensuse/110]
username=magda
password=richard
-# no 3 - same urla s 2 but different user (lex less than magda)
-[ftp://weprovidesoft.fr/download/opensuse/110]
-username=agda
-password=ichard
-
-# fail
[http://url.ok/but/not/creds]
username=
password=any
-# fail
[badurl]
username=foo
password=bar
"enabled=1\n"
"autorefresh=0\n"
"baseurl=http://download.opensuse.org/factory-tested/repo/oss/\n"
-"baseurl=http://download.opensuse.org/factory-tested/repo/oss/2\n"
-"plugin:spacewalk?channel=sle-manager-tools12-pool-x86_64-sp1&server=0\n"
-"http://download.opensuse.org/factory-tested/repo/=oss/4\n"
"type=yast2\n"
"keeppackages=0\n";
static string fedora_repo = "[fedora]\n"
"name=Fedora $releasever - $basearch\n"
"failovermethod=priority\n"
-"baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/\n"
-" http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os2/\n"
-"mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch\n"
+"#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/\n"
+"#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch\n"
"mirrorlist=file:///etc/yum.repos.d/local.mirror\n"
"enabled=1\n"
"gpgcheck=1\n"
-"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY-$releasever/\n"
-"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-3\n"
-"file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-4\n";
+"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY\n";
struct RepoCollector : private base::NonCopyable
{
RepoCollector collector;
parser::RepoFileReader parser( input, bind( &RepoCollector::collect, &collector, _1 ) );
BOOST_CHECK_EQUAL(1, collector.repos.size());
-
- const RepoInfo & repo( collector.repos.front() );
- BOOST_CHECK_EQUAL( 4, repo.baseUrlsSize() );
- // cout << repo << endl;
}
// fedora
{
RepoInfo repo = *collector.repos.begin();
// should have taken the first url if more are present
BOOST_CHECK_EQUAL(Url("file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora"), repo.gpgKeyUrl());
- BOOST_CHECK_EQUAL( 4, repo.gpgKeyUrlsSize() );
- // cout << repo << endl;
- // cout << "------------------------------------------------------------" << endl;
- // repo.dumpOn( cout ) << endl;
- // cout << "------------------------------------------------------------" << endl;
- // repo.dumpAsIniOn( cout ) << endl;
- // cout << "------------------------------------------------------------" << endl;
- // repo.dumpAsXmlOn( cout ) << endl;
}
}
name1= =foo
name2=f=oo
name3=foo=
-[te]st]
-name=foo
virtual void consume( const std::string §ion )
{
MIL << section << endl;
- BOOST_CHECK(section == "base" || section == "equal" || section == "te]st");
+ BOOST_CHECK(section == "base" || section == "equal");
}
virtual void consume( const std::string §ion, const std::string &key, const std::string &value )
/* check RepoVariablesUrlReplacer */
repo::RepoVariablesUrlReplacer replacer2;
-// // first of all url with {} must be accepted:
- BOOST_CHECK_NO_THROW( Url("ftp://site.org/${arch}/?arch=${arch}") );
- BOOST_CHECK_NO_THROW( Url("ftp://site.org/${arch:-noarch}/?arch=${arch:-noarch}") );
- BOOST_CHECK_NO_THROW( Url("ftp://site.org/${arch:+somearch}/?arch=${arch:+somearch}") );
-
BOOST_CHECK_EQUAL(replacer2(Url("ftp://user:secret@site.org/$arch/")).asCompleteString(),
"ftp://user:secret@site.org/i686/");
StrMatcher
Target
Url
- UserData
Vendor
Vendor2
)
#include <sstream>
#include "TestSetup.h"
-#include "zypp/PluginExecutor.h"
+#include "zypp/PluginScript.h"
BOOST_AUTO_TEST_CASE(InitialSettings)
{
BOOST_AUTO_TEST_CASE(PluginFrameDefaultCtor)
{
PluginFrame f;
- BOOST_CHECK_EQUAL( bool(f), !f.empty() );
BOOST_CHECK_EQUAL( f.empty(), true );
+ BOOST_CHECK_EQUAL( bool(f), f.empty() );
BOOST_CHECK_EQUAL( f.command().empty(), true );
BOOST_CHECK_EQUAL( f.body().empty(), true );
BOOST_CHECK_EQUAL( f.headerEmpty(), true );
BOOST_AUTO_TEST_CASE(PluginFrameCtorAssign)
{
PluginFrame f( "command" );
- BOOST_CHECK_EQUAL( bool(f), !f.empty() );
BOOST_CHECK_EQUAL( f.empty(), false );
+ BOOST_CHECK_EQUAL( bool(f), f.empty() );
BOOST_CHECK_EQUAL( f.command(), "command" );
BOOST_CHECK_EQUAL( f.body().empty(), true );
BOOST_CHECK_EQUAL( f.headerEmpty(), true );
BOOST_CHECK_EQUAL( (f != f), false );
PluginFrame g( "command", "body" );
- BOOST_CHECK_EQUAL( bool(g), !g.empty() );
BOOST_CHECK_EQUAL( g.empty(), false );
+ BOOST_CHECK_EQUAL( bool(g), g.empty() );
BOOST_CHECK_EQUAL( g.command(), "command" );
BOOST_CHECK_EQUAL( g.body(), "body");
BOOST_CHECK_EQUAL( g.headerEmpty(), true );
::kill( scr.getPid(), SIGKILL);
BOOST_CHECK_THROW( scr.receive(), PluginScriptDiedUnexpectedly );
}
-
-BOOST_AUTO_TEST_CASE(PluginExecutorTest)
-{
- PluginExecutor exec;
- BOOST_CHECK_EQUAL( (bool)exec, !exec.empty() );
- BOOST_CHECK_EQUAL( exec.empty(), true );
- BOOST_CHECK_EQUAL( exec.size(), 0 );
-
- exec.load( "/bin/cat" );
- BOOST_CHECK_EQUAL( (bool)exec, !exec.empty() );
- BOOST_CHECK_EQUAL( exec.empty(), false );
- BOOST_CHECK_EQUAL( exec.size(), 1 );
-
- exec.load( "/bin/cat" );
- BOOST_CHECK_EQUAL( exec.size(), 2 );
-
- exec.send( PluginFrame( "ACK" ) );
- BOOST_CHECK_EQUAL( exec.size(), 2 );
-
- exec.send( PluginFrame( "ERROR" ) );
- BOOST_CHECK_EQUAL( exec.size(), 0 ); // deleted failing scripts
-}
}
}
-BOOST_AUTO_TEST_CASE( test_url5)
-{
- std::string str( "file:/some/${var:+path}/${var:-with}/${vars}" );
- BOOST_CHECK_EQUAL( Url(str).asString(), str );
- BOOST_CHECK_EQUAL( Url(zypp::url::encode( str, URL_SAFE_CHARS )).asString(), str );
-}
-
BOOST_AUTO_TEST_CASE(plugin_querystring_args)
{
// url querysting options without value must be possible
+++ /dev/null
-#include <boost/test/auto_unit_test.hpp>
-#include <iostream>
-#include <set>
-#include "zypp/UserData.h"
-
-using std::cout;
-using std::endl;
-
-using zypp::callback::UserData;
-const std::string key( "key" );
-
-#define checkIsEmpty(v) \
- BOOST_CHECK( !v ); \
- BOOST_CHECK( v.empty() ); \
- BOOST_CHECK_EQUAL( v.size(), 0 ); \
- BOOST_CHECK_EQUAL( v.haskey( key ), false ); \
- BOOST_CHECK_EQUAL( v.hasvalue( key ), false ); \
- BOOST_CHECK_EQUAL( v.getvalue( key ).empty(), true );
-
-#define checkIsNotEmpty(v,s) \
- BOOST_CHECK( v ); \
- BOOST_CHECK( !v.empty() ); \
- if ( s ) \
- { BOOST_CHECK_EQUAL( v.size(), s ); } \
- else \
- { BOOST_CHECK( v.size() ); } \
- BOOST_CHECK_EQUAL( v.haskey( key ), true );
-
-
-BOOST_AUTO_TEST_CASE(useruata_default)
-{
- UserData v;
- checkIsEmpty( v );
-
- // set key with empty value
- v.reset( key );
- checkIsNotEmpty( v, 1 );
- BOOST_CHECK_EQUAL( v.hasvalue( key ), false );
- BOOST_CHECK_EQUAL( v.getvalue( key ).empty(), true );
-
- std::string rs;
- unsigned ru = 0;
- int ri = 0;
- char rc = 0;
-
- // set key with value
- v.set( key, 42 );
- BOOST_CHECK_EQUAL( v.hasvalue( key ), true );
- BOOST_CHECK_EQUAL( v.getvalue( key ).empty(), false );
-
- // get back data
- BOOST_CHECK_EQUAL( v.get( key, rs ), false );
- BOOST_CHECK_EQUAL( v.get( key, ru ), false );
- BOOST_CHECK_EQUAL( v.get( key, ri ), true );
- BOOST_CHECK_EQUAL( v.get( key, rc ), false );
- BOOST_CHECK_EQUAL( ru, 0 );
- BOOST_CHECK_EQUAL( ri, 42 );
- BOOST_CHECK_EQUAL( rc, 0 );
-
- v.set( key, 43U );
- BOOST_CHECK_EQUAL( v.get( key, rs ), false );
- BOOST_CHECK_EQUAL( v.get( key, ru ), true );
- BOOST_CHECK_EQUAL( v.get( key, ri ), false );
- BOOST_CHECK_EQUAL( v.get( key, rc ), false );
- BOOST_CHECK_EQUAL( ru, 43 );
- BOOST_CHECK_EQUAL( ri, 42 );
- BOOST_CHECK_EQUAL( rc, 0 );
-
- // set key with empty value
- v.reset( key );
- BOOST_CHECK_EQUAL( v.hasvalue( key ), false );
- BOOST_CHECK_EQUAL( v.getvalue( key ).empty(), true );
- checkIsNotEmpty( v, 1 );
-
- // erase key
- v.erase( key );
- BOOST_CHECK_EQUAL( v.hasvalue( key ), false );
- BOOST_CHECK_EQUAL( v.getvalue( key ).empty(), true );
- checkIsEmpty( v );
-
- // const may add but not manip non-empty values
- const UserData & cv( v );
- BOOST_CHECK_EQUAL( cv.reset( key ), true ); // add new key: ok
- BOOST_CHECK_EQUAL( cv.set( key, 42 ), true ); // empty -> non-empty: ok
- BOOST_CHECK_EQUAL( cv.set( key, 43 ), false );// change non-empty: not ok
- BOOST_CHECK_EQUAL( cv.reset( key ), false ); // change non-empty: not ok
-}
## download.media_preference = download
##
-## Signature checking (repodata and rpm packages)
-##
-## boolean gpgcheck (default: on)
-## boolean repo_gpgcheck (default: unset -> according to gpgcheck)
-## boolean pkg_gpgcheck (default: unset -> according to gpgcheck)
-##
-## If 'gpgcheck' is 'on' we will either check the signature of repo metadata
-## (packages are secured via checksum in the metadata), or the signature of
-## an rpm package to install if it's repo metadata are not signed or not
-## checked.
-##
-## The default behavior can be altered by explicitly setting 'repo_gpgcheck' and/or
-## 'pkg_gpgcheck' to perform those checks always (if 'on') or never (if 'off').
-##
-## Explicitly setting 'gpgcheck', 'repo_gpgcheck' 'pkg_gpgcheck' in a
-## repositories .repo file will overwrite the defaults here.
-##
-## DISABLING GPG CHECKS IS NOT RECOMMENDED.
-## Signing data enables the recipient to verify that no modifications
-## occurred after the data were signed. Accepting data with no, wrong
-## or unknown signature can lead to a corrupted system and in extreme
-## cases even to a system compromise.
-##
-# repo_gpgcheck = unset -> according to gpgcheck
-# pkg_gpgcheck = unset -> according to gpgcheck
-
-##
## Commit download policy to use as default.
##
## DownloadOnly, Just download all packages to the local cache.
DEF_BUILTIN( sh4 );
DEF_BUILTIN( sh4a );
- DEF_BUILTIN( m68k );
-
- DEF_BUILTIN( mips );
- DEF_BUILTIN( mipsel );
- DEF_BUILTIN( mips64 );
- DEF_BUILTIN( mips64el );
+ DEF_BUILTIN(m68k);
#undef DEF_BUILTIN
///////////////////////////////////////////////////////////////////
defCompatibleWith( _sh4(), _noarch() );
defCompatibleWith( _sh4a(), _noarch(),_sh4() );
- defCompatibleWith( _m68k(), _noarch() );
-
- defCompatibleWith( _mips(), _noarch() );
- defCompatibleWith( _mipsel(), _noarch() );
- defCompatibleWith( _mips64(), _noarch() );
- defCompatibleWith( _mips64el(), _noarch() );
+ defCompatibleWith(_m68k(), _noarch());
//
///////////////////////////////////////////////////////////////////
// dumpOn( USR ) << endl;
/** \relates Arch */
extern const Arch Arch_m68k;
-
- /** \relates Arch */
- extern const Arch Arch_mips;
- /** \relates Arch */
- extern const Arch Arch_mipsel;
- /** \relates Arch */
- extern const Arch Arch_mips64;
- /** \relates Arch */
- extern const Arch Arch_mips64el;
//@}
///////////////////////////////////////////////////////////////////
PluginFrameException.cc
PluginScript.cc
PluginScriptException.cc
- PluginExecutor.cc
Fetcher.cc
FileChecker.cc
Glob.cc
PluginFrameException.h
PluginScript.h
PluginScriptException.h
- PluginExecutor.h
Fetcher.h
FileChecker.h
Glob.h
#define ZYPP_CALLBACK_H
#include "zypp/base/NonCopyable.h"
-#include "zypp/UserData.h"
///////////////////////////////////////////////////////////////////
namespace zypp
/** */
struct ReportBase
{
- typedef callback::UserData UserData;
virtual ~ReportBase()
{}
};
struct ReceiveReport : public _Report
{
typedef _Report ReportType;
- typedef typename ReportType::UserData UserData;
typedef ReceiveReport<_Report> Receiver;
typedef DistributeReport<_Report> Distributor;
{
public:
typedef _Report ReportType;
- typedef typename ReportType::UserData UserData;
typedef ReceiveReport<_Report> Receiver;
typedef DistributeReport<_Report> Distributor;
struct SendReport : private zypp::base::NonCopyable
{
typedef _Report ReportType;
- typedef typename ReportType::UserData UserData;
typedef ReceiveReport<_Report> Receiver;
typedef DistributeReport<_Report> Distributor;
struct TempConnect
{
typedef _Report ReportType;
- typedef typename ReportType::UserData UserData;
typedef ReceiveReport<_Report> Receiver;
typedef DistributeReport<_Report> Distributor;
// str_r might be the form "libzypp-1.2.3-4.5(.arch)'
// correctly parsed as name capability by the ctor.
- // TODO: Think about allowing glob char in name - for now don't process
- if ( detail.isNamed() && !::strpbrk( detail.name().c_str(), "*?[{" )
- && ::strrchr( detail.name().c_str(), '-' ) && sat::WhatProvides( cap ).empty() )
+ if ( detail.isNamed() && ::strrchr( detail.name().c_str(), '-' ) && sat::WhatProvides( cap ).empty() )
{
Arch origArch( detail.arch() ); // to support a trailing .arch
/** Ctor taking <tt>"type[/subtype]"</tt>
* \throws std::invalid_argument if string is malformed
*/
- explicit ContentType( std::string type_r )
+ explicit ContentType( const std::string & type_r )
{
std::string::size_type pos = type_r.find( "/" );
- if ( pos != std::string::npos )
+ if ( pos == std::string::npos )
{
+ testAndSet( _type, type_r );
+ }
+ else
+ {
+ testAndSet( _type, type_r.substr( 0, pos ) );
testAndSet( _subtype, type_r.substr( pos+1 ) );
- type_r.erase( pos );
}
- testAndSet( _type, std::move(type_r) );
}
/** Ctor taking type and subtype
* \throws std::invalid_argument if string is malformed
*/
- ContentType( std::string type_r, std::string subtype_r )
+ ContentType( const std::string & type_r, const std::string & subtype_r )
{
- testAndSet( _type, std::move(type_r) );
- testAndSet( _subtype, std::move(subtype_r) );
+ testAndSet( _type, type_r );
+ testAndSet( _subtype, subtype_r );
}
public:
/** Set type
* \throws std::invalid_argument if string is malformed
*/
- void type( std::string type_r )
- { _type = std::move(type_r); }
+ void type( const std::string & type_r )
+ { _type = type_r; }
/** Get subtype */
const std::string & subtype() const
/** Set subtype
* \throws std::invalid_argument if string is malformed
*/
- void subtype( std::string subtype_r )
- { _subtype = std::move(subtype_r); }
+ void subtype( const std::string & subtype_r )
+ { _subtype = subtype_r; }
public:
/** Whether type and subtype are empty */
{ std::string ret( type() ); if ( ! emptySubtype() ) { ret += "/"; ret += subtype(); } return ret; }
private:
- void testAndSet( std::string & var_r, std::string val_r )
+ void testAndSet( std::string & var_r, const std::string & val_r )
{
if ( val_r.find_first_of( "/ \t\r\n" ) != std::string::npos )
throw std::invalid_argument( "ContentType: illegal char in '" + val_r + "'" );
- var_r = std::move(val_r);
+ var_r = val_r;
}
private:
std::string _type;
unsigned idx = 0;
for_( it, result.begin(), result.end() )
{
- // Limit estimated waste (half block per file) as it does not apply to
- // btrfs, which reports up to 64K blocksize (bsc#974275,bsc#965322)
- static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / 2 / 1K; result value in K!
-
+ static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K)
it->pkg_size = it->used_size // current usage
+ duchanges[idx].kbytes // package data size
- + ( duchanges[idx].files * ( it->fstype == "btrfs" ? 4096 : it->block_size ) / blockAdjust ); // half block per file
+ + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file
++idx;
}
}
{
DiskUsageCounter::MountPointSet ret;
- typedef std::map<std::string, MountPoint> Btrfsfilter;
- Btrfsfilter btrfsfilter; // see btrfs hack below
-
std::ifstream procmounts( "/proc/mounts" );
if ( !procmounts ) {
//
const char * mpunwanted[] = {
"/mnt", "/media", "/mounts", "/floppy", "/cdrom",
- "/suse", "/tmp", "/var/tmp", "/var/adm/mount", "/var/adm/YaST",
+ "/suse", "/var/tmp", "/var/adm/mount", "/var/adm/YaST",
/*last*/0/*entry*/
};
//
// check for snapshotting btrfs
//
- bool btrfshack = false;
if ( words[2] == "btrfs" )
{
- btrfshack = true;
if ( geteuid() != 0 )
{
DBG << "Assume snapshots on " << words[1] << ": non-root user can't check" << std::endl;
DBG << "Filter zero-sized mount point : " << l << std::endl;
continue;
}
- if ( btrfshack )
- {
- // HACK:
- // Collect just the top/1st mountpoint of each btrfs volume
- // (by device). This filters away nested subvolumes
- // which otherwise break per package disk usage computation.
- // FIX: Computation must learn to handle multiple mount points
- // contributing to the same file system.
- MountPoint & bmp( btrfsfilter[words[0]] );
- if ( bmp.fstype.empty() ) // 1st occurance
- {
- bmp = DiskUsageCounter::MountPoint( mp, words[2], sb.f_bsize,
- ((long long)sb.f_blocks)*sb.f_bsize/1024,
- ((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints );
- }
- else if ( bmp.dir > mp )
- bmp.dir = mp;
- continue;
- }
ret.insert( DiskUsageCounter::MountPoint( mp, words[2], sb.f_bsize,
((long long)sb.f_blocks)*sb.f_bsize/1024,
((long long)(sb.f_blocks - sb.f_bfree))*sb.f_bsize/1024, 0LL, hints ) );
}
}
- // collect filtered btrfs volumes
- for ( auto && bmp : btrfsfilter )
- ret.insert( std::move(bmp.second) );
-
return ret;
}
// if the file was not transferred, and no exception, just
// return, as it was an optional file
if ( ! PathInfo(dest_dir + (*it_res)->location.filename()).isExist() )
- continue;
+ return;
// if the checksum is empty, but the checksum is in one of the
// indexes checksum, then add a checker
using namespace std;
-#undef ZYPP_BASE_LOGGER_LOGGROUP
-#define ZYPP_BASE_LOGGER_LOGGROUP "FileChecker"
-
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
ChecksumFileChecker::ChecksumFileChecker( const CheckSum &checksum )
: _checksum(checksum)
- {}
+ {
+ }
void ChecksumFileChecker::operator()( const Pathname &file ) const
{
- //MIL << "checking " << file << " file against checksum '" << _checksum << "'" << endl;
+ //MIL << "checking " << file << " file against checksum '" << _checksum << "'" << endl;
callback::SendReport<DigestReport> report;
if ( _checksum.empty() )
}
else
{
- ZYPP_THROW( ExceptionType( file.basename() + " has no checksum" ) );
+ ZYPP_THROW( FileCheckException( file.basename() + " has no checksum" ) );
}
}
else
CheckSum real_checksum( _checksum.type(), filesystem::checksum( file, _checksum.type() ));
if ( (real_checksum != _checksum) )
{
- WAR << "File " << file << " has wrong checksum " << real_checksum << " (expected " << _checksum << ")" << endl;
if ( report->askUserToAcceptWrongDigest( file, _checksum.checksum(), real_checksum.checksum() ) )
{
WAR << "User accepted " << file << " with WRONG CHECKSUM." << std::endl;
}
else
{
- ZYPP_THROW( ExceptionType( file.basename() + " has wrong checksum" ) );
+ ZYPP_THROW( FileCheckException( file.basename() + " has wrong checksum" ) );
}
}
}
}
void CompositeFileChecker::add( const FileChecker &checker )
- { _checkers.push_back(checker); }
+ {
+ //MIL << "||# " << _checkers.size() << endl;
+ _checkers.push_back(checker);
+ //MIL << "||* " << _checkers.size() << endl;
+ }
- SignatureFileChecker::SignatureFileChecker( const Pathname & signature )
+ SignatureFileChecker::SignatureFileChecker( const Pathname &signature )
: _signature(signature)
- {}
+ {
+
+ }
+
SignatureFileChecker::SignatureFileChecker()
- {}
+ {
+ }
void SignatureFileChecker::setKeyContext(const KeyContext & keycontext)
{ _context = keycontext; }
void SignatureFileChecker::operator()(const Pathname &file ) const
{
- if ( (! PathInfo(_signature).isExist()) && (!_signature.empty()) )
+ ZYpp::Ptr z = getZYpp();
+
+ if ( (! PathInfo(_signature).isExist()) && (!_signature.empty()))
{
- ZYPP_THROW( ExceptionType("Signature " + _signature.asString() + " not found.") );
+ ZYPP_THROW(FileCheckException("Signature " + _signature.asString() + " not found."));
}
MIL << "checking " << file << " file validity using digital signature.." << endl;
- _fileValidated = false;
- _fileAccepted = getZYpp()->keyRing()->verifyFileSignatureWorkflow( file, file.basename(), _signature, _fileValidated, _context );
+ bool valid = z->keyRing()->verifyFileSignatureWorkflow( file, file.basename(), _signature, _context);
- if ( !_fileAccepted )
- ZYPP_THROW( ExceptionType( "Signature verification failed for " + file.basename() ) );
- }
+ if (!valid)
+ ZYPP_THROW( FileCheckException( "Signature verification failed for " + file.basename() ) );
+ }
/******************************************************************
**
#include <iosfwd>
#include <list>
-#include "zypp/base/DefaultIntegral.h"
#include "zypp/base/Exception.h"
#include "zypp/base/Function.h"
#include "zypp/PathInfo.h"
class CheckSumCheckException : public FileCheckException
{
- public:
- CheckSumCheckException(const std::string &msg)
- : FileCheckException(msg)
- {}
+ //TODO
};
class SignatureCheckException : public FileCheckException
{
- public:
- SignatureCheckException(const std::string &msg)
- : FileCheckException(msg)
- {}
+ //TODO
};
/**
class ChecksumFileChecker
{
public:
- typedef CheckSumCheckException ExceptionType;
/**
* Constructor.
* \param checksum Checksum that validates the file
class SignatureFileChecker
{
public:
- typedef SignatureCheckException ExceptionType;
- typedef function<void ( const SignatureFileChecker & checker, const Pathname & file )> OnSigValidated;
-
- public:
/**
* Constructor.
* \param signature Signature that validates the file
*/
void setKeyContext(const KeyContext & keycontext);
- /** Return the current context */
- const KeyContext & keyContext() const
- { return _context; }
-
- /** Return whether the last file passed to \ref operator() was accepted.
- * If this is \ref false \ref operator() was not invoked or threw a
- * \ref SignatureCheckException.
- */
- bool fileAccepted() const
- { return _fileAccepted; }
-
- /** Return whether the last file passed to \ref operator() was actually sucessfully verified.
- * If this is \c false but \ref fileAccepted, the file was accepted due to user interaction or
- * global settings, but the signature was not verified.
- */
- bool fileValidated() const
- { return _fileValidated; }
-
/**
* add a public key to the list of known keys
*/
void addPublicKey( const Pathname & publickey, const KeyContext & keycontext = KeyContext());
/**
- * Calls \ref KeyRing::verifyFileSignatureWorkflow to verify the file.
- *
- * Keep in mind the the workflow may return \c true (file accepted) due to user interaction
- * or global defaults even if a signature was not actually sucessfully verified. Whether a
- * signature was actually sucessfully verified can be determined by checking \ref fileValidated
- * which is invokes IFF a signature for this file actually validated.
- *
- * \param file File to validate.fileValidated
- *
- * \throws SignatureCheckException if validation fails
- */
+ * \short Try to validate the file
+ * \param file File to validate.
+ *
+ * \throws SignatureCheckException if validation fails
+ */
void operator()( const Pathname &file ) const;
protected:
Pathname _signature;
KeyContext _context;
- mutable DefaultIntegral<bool,false> _fileAccepted;
- mutable DefaultIntegral<bool,false> _fileValidated;
};
/**
PublicKey exportTrustedPublicKey( const PublicKeyData & keyData )
{ return exportKey( keyData, trustedKeyRing() ); }
- bool verifyFileSignatureWorkflow( const Pathname & file, const std::string & filedesc, const Pathname & signature, bool & sigValid_r, const KeyContext & keycontext = KeyContext());
+ bool verifyFileSignatureWorkflow(
+ const Pathname & file,
+ const std::string & filedesc,
+ const Pathname & signature,
+ const KeyContext & keycontext = KeyContext());
bool verifyFileSignature( const Pathname & file, const Pathname & signature )
{ return verifyFile( file, signature, generalKeyRing() ); }
return tmpFile;
}
- bool KeyRing::Impl::verifyFileSignatureWorkflow( const Pathname & file, const std::string & filedesc, const Pathname & signature, bool & sigValid_r, const KeyContext & context )
+ bool KeyRing::Impl::verifyFileSignatureWorkflow(
+ const Pathname & file,
+ const std::string & filedesc,
+ const Pathname & signature,
+ const KeyContext & context )
{
- sigValid_r = false; // set true if signature is actually successfully validated!
-
callback::SendReport<KeyRingReport> report;
MIL << "Going to verify signature for " << filedesc << " ( " << file << " ) with " << signature << endl;
// it exists, is trusted, does it validates?
if ( verifyFile( file, signature, trustedKeyRing() ) )
- {
- return (sigValid_r=true); // signature is actually successfully validated!
- }
+ return true;
else
{
return report->askUserToAcceptVerificationFailed( filedesc, exportKey( trustedKeyData, trustedKeyRing() ), context );
if ( verifyFile( file, signature, whichKeyring ) )
{
MIL << "File signature is verified" << endl;
- return (sigValid_r=true); // signature is actually successfully validated!
+ return true;
}
else
{
std::list<PublicKeyData> KeyRing::trustedPublicKeyData()
{ return _pimpl->trustedPublicKeyData(); }
- bool KeyRing::verifyFileSignatureWorkflow( const Pathname & file, const std::string & filedesc, const Pathname & signature, bool & sigValid_r, const KeyContext & keycontext )
- { return _pimpl->verifyFileSignatureWorkflow( file, filedesc, signature, sigValid_r, keycontext ); }
-
- bool KeyRing::verifyFileSignatureWorkflow( const Pathname & file, const std::string filedesc, const Pathname & signature, const KeyContext & keycontext )
- { bool unused; return _pimpl->verifyFileSignatureWorkflow( file, filedesc, signature, unused, keycontext ); }
+ bool KeyRing::verifyFileSignatureWorkflow(
+ const Pathname & file,
+ const std::string filedesc,
+ const Pathname & signature,
+ const KeyContext & keycontext )
+ { return _pimpl->verifyFileSignatureWorkflow( file, filedesc, signature, keycontext ); }
bool KeyRing::verifyFileSignature( const Pathname & file, const Pathname & signature )
{ return _pimpl->verifyFileSignature( file, signature ); }
* To propagate user decisions, either connect to the \ref KeyRingReport
* or use its static methods to set the desired defaults.
*
- * A second bool passed as reference arg \a sigValid_r tells whether the
- * signature was actually successfully verified. If \a sigValid_r returns
- * \c false, but the method \c true, you know it's due to user callback or
- * defaults.
- *
* \code
* struct KeyRingReportReceive : public callback::ReceiveReport<KeyRingReport>
* {
* \param file Path of the file to be verified
* \param filedesc Description of the file (to give the user some context)
* \param signature Signature to verify the file against
- * \param sigValid_r Returns whether signature was successfully verified
*
* \see \ref KeyRingReport
*/
- bool verifyFileSignatureWorkflow( const Pathname &file, const std::string &filedesc, const Pathname &signature, bool & sigValid_r, const KeyContext &keycontext = KeyContext());
- /** \overload legacy version without 'bool & sigValid_r' */
- bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature, const KeyContext &keycontext = KeyContext());
+ bool verifyFileSignatureWorkflow(
+ const Pathname &file,
+ const std::string filedesc,
+ const Pathname &signature,
+ const KeyContext &keycontext = KeyContext());
+
/**
* Verifies a file against a signature, with no user interaction
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/PluginExecutor.cc
- */
-#include <iostream>
-#include "zypp/base/LogTools.h"
-#include "zypp/base/NonCopyable.h"
-
-#include "zypp/ZConfig.h"
-#include "zypp/PathInfo.h"
-#include "zypp/PluginExecutor.h"
-
-using std::endl;
-
-#undef ZYPP_BASE_LOGGER_LOGGROUP
-#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::plugin"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
- ///////////////////////////////////////////////////////////////////
- /// \class PluginExecutor::Impl
- /// \brief PluginExecutor implementation.
- ///////////////////////////////////////////////////////////////////
- class PluginExecutor::Impl : private base::NonCopyable
- {
- public:
- Impl()
- {}
-
- ~Impl()
- {
- if ( ! empty() )
- send( PluginFrame( "PLUGINEND" ) );
- // ~PluginScript will disconnect all remaining plugins!
- }
-
- bool empty() const
- { return _scripts.empty(); }
-
- size_t size() const
- { return _scripts.size(); }
-
- void load( const Pathname & path_r )
- {
- PathInfo pi( path_r );
- DBG << "+++++++++++++++ load " << pi << endl;
- if ( pi.isDir() )
- {
- std::list<Pathname> entries;
- if ( filesystem::readdir( entries, pi.path(), false ) != 0 )
- {
- WAR << "Plugin dir is not readable: " << pi << endl;
- return;
- }
- for_( it, entries.begin(), entries.end() )
- {
- PathInfo pii( *it );
- if ( pii.isFile() && pii.userMayRX() )
- doLoad( pii );
- }
- }
- else if ( pi.isFile() )
- {
- if ( pi.userMayRX() )
- doLoad( pi );
- else
- WAR << "Plugin file is not executable: " << pi << endl;
- }
- else
- {
- WAR << "Plugin path is neither dir nor file: " << pi << endl;
- }
- DBG << "--------------- load " << pi << endl;
- }
-
- void send( const PluginFrame & frame_r )
- {
- DBG << "+++++++++++++++ send " << frame_r << endl;
- for ( auto it = _scripts.begin(); it != _scripts.end(); )
- {
- doSend( *it, frame_r );
- if ( it->isOpen() )
- ++it;
- else
- it = _scripts.erase( it );
- }
- DBG << "--------------- send " << frame_r << endl;
- }
-
- const std::list<PluginScript> scripts() const
- { return _scripts; }
-
- private:
- /** Launch a plugin sending PLUGINSTART message. */
- void doLoad( const PathInfo & pi_r )
- {
- MIL << "Load plugin: " << pi_r << endl;
- try {
- PluginScript plugin( pi_r.path() );
- plugin.open();
-
- PluginFrame frame( "PLUGINBEGIN" );
- if ( ZConfig::instance().hasUserData() )
- frame.setHeader( "userdata", ZConfig::instance().userData() );
-
- doSend( plugin, frame ); // closes on error
- if ( plugin.isOpen() )
- _scripts.push_back( plugin );
- }
- catch( const zypp::Exception & e )
- {
- WAR << "Failed to load plugin " << pi_r << endl;
- }
- }
-
- PluginFrame doSend( PluginScript & script_r, const PluginFrame & frame_r )
- {
- PluginFrame ret;
-
- try {
- script_r.send( frame_r );
- ret = script_r.receive();
- }
- catch( const zypp::Exception & e )
- {
- ZYPP_CAUGHT(e);
- WAR << e.asUserHistory() << endl;
- }
-
- // Allow using "/bin/cat" as reflector-script for testing
- if ( ! ( ret.isAckCommand() || ret.isEnomethodCommand() || ( script_r.script() == "/bin/cat" && frame_r.command() != "ERROR" ) ) )
- {
- WAR << "Bad plugin response from " << script_r << ": " << ret << endl;
- WAR << "(Expected " << PluginFrame::ackCommand() << " or " << PluginFrame::enomethodCommand() << ")" << endl;
- script_r.close();
- }
-
- return ret;
- }
- private:
- std::list<PluginScript> _scripts;
- };
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PluginExecutor
- //
- ///////////////////////////////////////////////////////////////////
-
- PluginExecutor::PluginExecutor()
- : _pimpl( new Impl() )
- {}
-
- PluginExecutor::~PluginExecutor()
- {}
-
- bool PluginExecutor::empty() const
- { return _pimpl->empty(); }
-
- size_t PluginExecutor::size() const
- { return _pimpl->size(); }
-
- void PluginExecutor::load( const Pathname & path_r )
- { _pimpl->load( path_r ); }
-
- void PluginExecutor::send( const PluginFrame & frame_r )
- { _pimpl->send( frame_r ); }
-
- std::ostream & operator<<( std::ostream & str, const PluginExecutor & obj )
- { return str << obj._pimpl->scripts(); }
-
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/PluginExecutor.h
- */
-#ifndef ZYPP_PLUGINEXECUTOR_H
-#define ZYPP_PLUGINEXECUTOR_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp/PluginScript.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
- ///////////////////////////////////////////////////////////////////
- /// \class PluginExecutor
- /// \brief Parallel execution of stateful PluginScripts
- ///
- /// Sent PluginFrames are distributed to all open PluginScripts and
- /// need to be receipted by sending back either \c ACK or \c _ENOMETHOD
- /// command.
- ///
- /// All PluginScripts receive an initial \c PLUGINBEGIN frame, containing
- /// a \c userdata header if \ref ZConfig::userData are defined.
- /// \see also zypper '--userdata' option
- ///
- /// A final \c PLUGINEND frame is sent and open scripts are closed, when the
- /// executors last reference goes out of scope. Failing PluginScripts are
- /// closed immediately.
- ///
- /// \see PluginScript
- /// \ingroup g_RAII
- ///////////////////////////////////////////////////////////////////
- class PluginExecutor
- {
- friend std::ostream & operator<<( std::ostream & str, const PluginExecutor & obj );
- friend bool operator==( const PluginExecutor & lhs, const PluginExecutor & rhs );
-
- public:
- /** Default ctor: Empty plugin list */
- PluginExecutor();
-
- /** Dtor: Send \c PLUGINEND and close all plugins */
- ~PluginExecutor();
-
- public:
- /** Validate object in a boolean context: There are plugins waiting for input */
- explicit operator bool() const
- { return !empty(); }
-
- /** Whether no plugins are waiting */
- bool empty() const;
-
- /** Number of open plugins */
- size_t size() const;
-
- public:
- /** Find and launch plugins sending \c PLUGINBEGIN.
- *
- * If \a path_r is a directory all executable files within are
- * expected to be plugins. Otherwise \a path_r must point to an
- * executable plugin.
- */
- void load( const Pathname & path_r );
-
- /** Send \ref PluginFrame to all open plugins.
- * Failed plugins are removed from the execution list.
- */
- void send( const PluginFrame & frame_r );
-
- public:
- class Impl; ///< Implementation class.
- private:
- RW_pointer<Impl> _pimpl; ///< Pointer to implementation.
- };
-
- /** \relates PluginExecutor Stream output */
- std::ostream & operator<<( std::ostream & str, const PluginExecutor & obj );
-
- /** \relates PluginExecutor Comparison based on reference. */
- inline bool operator==( const PluginExecutor & lhs, const PluginExecutor & rhs )
- { return ( lhs._pimpl == rhs._pimpl ); }
-
- /** \relates PluginExecutor Comparison based on reference. */
- inline bool operator!=( const PluginExecutor & lhs, const PluginExecutor & rhs )
- { return( ! operator==( lhs, rhs ) ); }
-
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PLUGINEXECUTOR_H
/** Whether this is an empty frame. */
bool empty() const;
- /** Evaluate in a boolean context (not an empty frame) */
+ /** Evaluate in a boolean context (empty frame) */
explicit operator bool() const
- { return !empty(); }
+ { return empty(); }
public:
/** Return the frame command. */
bool keyEmpty( const std::string & key_r ) const
{ return headerList().find( key_r ) == headerEnd(); }
- /** Return number of header entries for \c key_r. */
+ /** Return number of header entires for \c key_r. */
bool keySize( const std::string & key_r ) const
{ return headerList().count( key_r ); }
/** Not throwing version returing one of the matching header values or \c default_r string. */
const std::string & getHeaderNT( const std::string & key_r, const std::string & default_r = std::string() ) const;
- /** Set header for \c key_r removing all other occurrences of \c key_r.
+ /** Set header for \c key_r removing all other occurences of \c key_r.
* \throw PluginFrameException If key contains illegal chars (\c NL or \c :)
* \throw PluginFrameException If value contains illegal chars (\c NL)
*/
/** \relates PluginFrame Stream output for logging */
std::ostream & operator<<( std::ostream & str, const PluginFrame & obj );
- /** \relates PluginFrame Stream output writing all data for logging (no throw) */
+ /** \relates PluginFrame Stream output sending all data */
inline std::ostream & dumpOn( std::ostream & str, const PluginFrame & obj )
- { if ( str ) try { PluginFrame::writeTo( str, obj ); } catch(...){}; return str; }
+ { return PluginFrame::writeTo( str, obj ); }
/** \relates PluginFrame Construct from stream. */
inline std::istream & operator>>( std::istream & str, PluginFrame & obj )
{ /////////////////////////////////////////////////////////////////
/**
- * \brief Interface to plugin scripts using a \c Stomp inspired communication protocol.
+ * \brief Interface to pluigin scripts using a \c Stomp inspired communication protocol.
*
* \note \ref PluginScript is copyable and assignable, but the connection is shared
* among multiple copies. It gets automatically closed if the last copy goes out of
PoolItem myBuddy( solv_r );
if ( myBuddy )
{
- if ( myBuddy._pimpl->_buddy )
- {
- ERR << *this << " would be buddy2 in " << myBuddy << endl;
- return;
- }
myBuddy._pimpl->_buddy = -resolvable()->satSolvable().id();
_buddy = myBuddy.satSolvable().id();
DBG << *this << " has buddy " << myBuddy << endl;
public:
/** Default ctor. */
PoolItemBest()
- { _ctor_init(); }
+ {}
/** Ctor feeding a \ref sat::Solvable. */
PoolItemBest( sat::Solvable slv_r )
// Look for a provider of 'product(name) = version' of same
// architecture and within the same repo.
//
- // Code12: Update repos may have multiple release package versions
- // providing the same product. Prefer the one matching the buildtime,
- // as the product buildtime is derived from the -release package.
+ // bnc #497696: Update repos may have multiple release package versions
+ // providing the same product. As a workaround we link to the one with
+ // the highest version.
Capability identCap( str::form( "product(%s) = %s", name().c_str(), edition().c_str() ) );
sat::Solvable found;
- bool foundBuildTime = false;
sat::WhatProvides providers( identCap );
for_( it, providers.begin(), providers.end() )
{
- if ( it->repository() == repository() && it->arch() == arch() )
+ if ( it->repository() == repository()
+ && it->arch() == arch() )
{
- bool fitsBuildtime = ( PoolItem(*it)->buildtime() == buildtime() );
- if ( found )
- {
- bool lowerEdition = ( it->edition() <= found.edition() );
- if ( ( foundBuildTime && ( !fitsBuildtime || lowerEdition ) )
- || ( !foundBuildTime && ( !fitsBuildtime && lowerEdition ) ) )
- continue;
- }
- found = *it;
- if ( fitsBuildtime )
- foundBuildTime = true;
+ if ( ! found || found.edition() < it->edition() )
+ found = *it;
}
}
#include "zypp/RepoInfo.h"
#include "zypp/TriBool.h"
#include "zypp/Pathname.h"
-#include "zypp/ZConfig.h"
#include "zypp/repo/RepoMirrorList.h"
#include "zypp/ExternalProgram.h"
#include "zypp/media/MediaAccess.h"
struct RepoInfo::Impl
{
Impl()
- : _gpgCheck( indeterminate )
- , _repoGpgCheck( indeterminate )
- , _pkgGpgCheck( indeterminate )
- , _validRepoSignature( indeterminate )
+ : gpgcheck(indeterminate)
, keeppackages(indeterminate)
, type(repo::RepoType::NONE_e)
, emptybaseurls(false)
{ return !emptybaseurls && !_baseUrls.empty(); }
- const RepoVariablesReplacedUrlList & gpgKeyUrls() const
- { return _gpgKeyUrls; }
-
- RepoVariablesReplacedUrlList & gpgKeyUrls()
- { return _gpgKeyUrls; }
-
void addContent( const std::string & keyword_r )
{ _keywords.insert( keyword_r ); }
return( _keywords.find( keyword_r ) != _keywords.end() );
}
- /** Signature check result needs to be stored/retrieved from _metadatapath.
- * Don't call them from outside validRepoSignature/setValidRepoSignature
- */
- //@{
- TriBool internalValidRepoSignature() const
- {
- if ( ! indeterminate(_validRepoSignature) ) return _validRepoSignature;
- // check metadata:
- if ( ! metadatapath.empty() )
- {
- //TODO: a missing ".repo_gpgcheck" might be plaindir(no Downloader) or not yet refreshed signed repo!
- TriBool linkval = triBoolFromPath( metadatapath / ".repo_gpgcheck" );
- return linkval;
- }
- return indeterminate;
- }
-
- void internalSetValidRepoSignature( TriBool value_r )
- {
- if ( PathInfo(metadatapath).isDir() )
- {
- Pathname gpgcheckFile( metadatapath / ".repo_gpgcheck" );
- if ( PathInfo(gpgcheckFile).isExist() )
- {
- TriBool linkval( indeterminate );
- if ( triBoolFromPath( gpgcheckFile, linkval ) && linkval == value_r )
- return; // existing symlink fits value_r
- else
- filesystem::unlink( gpgcheckFile ); // will write a new one
- }
- filesystem::symlink( asString(value_r), gpgcheckFile );
- }
- _validRepoSignature = value_r;
- }
-
- bool triBoolFromPath( const Pathname & path_r, TriBool & ret_r ) const
- {
- static const Pathname truePath( "true" );
- static const Pathname falsePath( "false" );
- static const Pathname indeterminatePath( "indeterminate" );
- Pathname linkval( filesystem::readlink( path_r ) );
- bool known = true;
- if ( linkval == truePath )
- ret_r = true;
- else if ( linkval == falsePath )
- ret_r = false;
- else if ( linkval == indeterminatePath )
- ret_r = indeterminate;
- else
- known = false;
- return known;
- }
-
- TriBool triBoolFromPath( const Pathname & path_r ) const
- { TriBool ret(indeterminate); triBoolFromPath( path_r, ret ); return ret; }
-
- //@}
-
- public:
- TriBool _gpgCheck; ///< default gpgcheck behavior: Y/N/ZConf
- TriBool _repoGpgCheck; ///< need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
- TriBool _pkgGpgCheck; ///< need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck && no valid repo sign.))
- private:
- TriBool _validRepoSignature;///< have signed and valid repo metadata
public:
+ TriBool gpgcheck;
TriBool keeppackages;
+ RepoVariablesReplacedUrl _gpgKeyUrl;
RepoVariablesReplacedUrl _mirrorListUrl;
repo::RepoType type;
Pathname path;
mutable RepoVariablesReplacedUrlList _baseUrls;
mutable std::set<std::string> _keywords;
- RepoVariablesReplacedUrlList _gpgKeyUrls;
-
friend Impl * rwcowClone<Impl>( const Impl * rhs );
/** clone for RWCOW_pointer */
Impl * clone() const
const RepoInfo RepoInfo::noRepo;
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoInfo::RepoInfo
+ // METHOD TYPE : Ctor
+ //
RepoInfo::RepoInfo()
: _pimpl( new Impl() )
{}
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : RepoInfo::~RepoInfo
+ // METHOD TYPE : Dtor
+ //
RepoInfo::~RepoInfo()
- {}
+ {
+ //MIL << std::endl;
+ }
unsigned RepoInfo::priority() const
{ return _pimpl->priority; }
void RepoInfo::setPriority( unsigned newval_r )
{ _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
-
- bool RepoInfo::gpgCheck() const
- { return indeterminate(_pimpl->_gpgCheck) ? ZConfig::instance().gpgCheck() : (bool)_pimpl->_gpgCheck; }
-
- void RepoInfo::setGpgCheck( TriBool value_r )
- { _pimpl->_gpgCheck = value_r; }
-
- void RepoInfo::setGpgCheck( bool value_r ) // deprecated legacy and for squid
- { setGpgCheck( TriBool(value_r) ); }
-
-
- bool RepoInfo::repoGpgCheck() const
- {
- if ( ! indeterminate(_pimpl->_repoGpgCheck) ) return _pimpl->_repoGpgCheck;
- if ( ! indeterminate(ZConfig::instance().repoGpgCheck()) ) return ZConfig::instance().repoGpgCheck();
- return gpgCheck(); // no preference: follow gpgCheck
- }
-
- void RepoInfo::setRepoGpgCheck( TriBool value_r )
- { _pimpl->_repoGpgCheck = value_r; }
-
-
- bool RepoInfo::pkgGpgCheck() const
- {
- if ( ! indeterminate(_pimpl->_pkgGpgCheck) ) return _pimpl->_pkgGpgCheck;
- if ( ! indeterminate(ZConfig::instance().pkgGpgCheck()) ) return ZConfig::instance().pkgGpgCheck();
- // no preference: follow gpgCheck and check package if repo signature not available or not checked
- return gpgCheck() && ( !repoGpgCheck() || !(bool)validRepoSignature() ); // !(bool)TriBool ==> false or indeterminate
- }
-
- void RepoInfo::setPkgGpgCheck( TriBool value_r )
- { _pimpl->_pkgGpgCheck = value_r; }
-
- void RepoInfo::getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const
- {
- g_r = _pimpl->_gpgCheck;
- r_r = _pimpl->_repoGpgCheck;
- p_r = _pimpl->_pkgGpgCheck;
- }
-
- TriBool RepoInfo::validRepoSignature() const
- {
- TriBool ret = _pimpl->internalValidRepoSignature();
- // keep indeterminate(=unsigned) but invalidate any signature if !repoGpgCheck
- if ( !indeterminate(ret) && !repoGpgCheck() )
- ret = false;
- return ret;
- }
-
- void RepoInfo::setValidRepoSignature( TriBool value_r )
- { _pimpl->internalSetValidRepoSignature( value_r ); }
-
+ void RepoInfo::setGpgCheck( bool check )
+ { _pimpl->gpgcheck = check; }
void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
{ _pimpl->_mirrorListUrl.raw() = url_r; }
- void RepoInfo::setGpgKeyUrls( url_set urls )
- { _pimpl->gpgKeyUrls().raw().swap( urls ); }
-
void RepoInfo::setGpgKeyUrl( const Url & url_r )
- {
- _pimpl->gpgKeyUrls().raw().clear();
- _pimpl->gpgKeyUrls().raw().push_back( url_r );
- }
+ { _pimpl->_gpgKeyUrl.raw() = url_r; }
void RepoInfo::addBaseUrl( const Url & url_r )
{
_pimpl->baseUrls().raw().push_back( url_r );
}
- void RepoInfo::setBaseUrls( url_set urls )
- { _pimpl->baseUrls().raw().swap( urls ); }
-
void RepoInfo::setPath( const Pathname &path )
{ _pimpl->path = path; }
void RepoInfo::setTargetDistribution( const std::string & targetDistribution )
{ _pimpl->targetDistro = targetDistribution; }
+ bool RepoInfo::gpgCheck() const
+ { return indeterminate(_pimpl->gpgcheck) ? true : (bool)_pimpl->gpgcheck; }
+
bool RepoInfo::keepPackages() const
{ return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
Url RepoInfo::rawMirrorListUrl() const // Raw
{ return _pimpl->_mirrorListUrl.raw(); }
- bool RepoInfo::gpgKeyUrlsEmpty() const
- { return _pimpl->gpgKeyUrls().empty(); }
-
- RepoInfo::urls_size_type RepoInfo::gpgKeyUrlsSize() const
- { return _pimpl->gpgKeyUrls().size(); }
-
- RepoInfo::url_set RepoInfo::gpgKeyUrls() const // Variables replaced!
- { return _pimpl->gpgKeyUrls().transformed(); }
-
- RepoInfo::url_set RepoInfo::rawGpgKeyUrls() const // Raw
- { return _pimpl->gpgKeyUrls().raw(); }
-
Url RepoInfo::gpgKeyUrl() const // Variables replaced!
- { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
+ { return _pimpl->_gpgKeyUrl.transformed(); }
Url RepoInfo::rawGpgKeyUrl() const // Raw
- { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
+ { return _pimpl->_gpgKeyUrl.raw(); }
RepoInfo::url_set RepoInfo::baseUrls() const // Variables replaced!
{ return _pimpl->baseUrls().transformed(); }
strif( "- path : ", path().asString() );
str << "- type : " << type() << std::endl;
str << "- priority : " << priority() << std::endl;
-
- // Yes No Default(Y) Default(N)
-#define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
- str << "- gpgcheck : " << OUTS(_pimpl->_gpgCheck,gpgCheck())
- << " repo" << OUTS(_pimpl->_repoGpgCheck,repoGpgCheck())
- << " sig" << asString( validRepoSignature(), "?", "Y", "N" )
- << " pkg" << OUTS(_pimpl->_pkgGpgCheck,pkgGpgCheck())
- << std::endl;
-#undef OUTS
-
- for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
- {
- str << "- gpgkey : " << url << std::endl;
- }
+ str << "- gpgcheck : " << gpgCheck() << std::endl;
+ strif( "- gpgkey : ", rawGpgKeyUrl().asString() );
if ( ! indeterminate(_pimpl->keeppackages) )
str << "- keeppackages: " << keepPackages() << std::endl;
if ( priority() != defaultPriority() )
str << "priority=" << priority() << endl;
- if ( ! indeterminate(_pimpl->_gpgCheck) )
- str << "gpgcheck=" << (_pimpl->_gpgCheck ? "1" : "0") << endl;
-
- if ( ! indeterminate(_pimpl->_repoGpgCheck) )
- str << "repo_gpgcheck=" << (_pimpl->_repoGpgCheck ? "1" : "0") << endl;
-
- if ( ! indeterminate(_pimpl->_pkgGpgCheck) )
- str << "pkg_gpgcheck=" << (_pimpl->_pkgGpgCheck ? "1" : "0") << endl;
+ if (!indeterminate(_pimpl->gpgcheck))
+ str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
- {
- std::string indent( "gpgkey=");
- for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
- {
- str << indent << url << endl;
- if ( indent[0] != ' ' )
- indent = " ";
- }
- }
+ if ( ! (rawGpgKeyUrl().asString().empty()) )
+ str << "gpgkey=" << rawGpgKeyUrl() << endl;
if (!indeterminate(_pimpl->keeppackages))
str << "keeppackages=" << keepPackages() << endl;
<< " priority=\"" << priority() << "\""
<< " enabled=\"" << enabled() << "\""
<< " autorefresh=\"" << autorefresh() << "\""
- << " gpgcheck=\"" << gpgCheck() << "\""
- << " repo_gpgcheck=\"" << repoGpgCheck() << "\""
- << " pkg_gpgcheck=\"" << pkgGpgCheck() << "\"";
+ << " gpgcheck=\"" << gpgCheck() << "\"";
if (!(tmpstr = gpgKeyUrl().asString()).empty())
str << " gpgkey=\"" << escape(tmpstr) << "\"";
if (!(tmpstr = mirrorListUrl().asString()).empty())
#include "zypp/Url.h"
#include "zypp/Locale.h"
-#include "zypp/TriBool.h"
#include "zypp/repo/RepoType.h"
#include "zypp/repo/RepoVariables.h"
* Clears current base URL list and adds \a url.
*/
void setBaseUrl( const Url &url );
- /**
- * Clears current base URL list and adds an \ref url_set.
- */
- void setBaseUrls( url_set urls );
/**
* \short Repository path
*/
void setPackagesPath( const Pathname &path );
-
- /** Whether default signature checking should be performed for this repo.
+ /**
+ * \short Whether to check or not this repository with gpg
*
- * This will turn on \ref repoGpgCheck for signed repos and
- * \ref pkgGpgCheck for unsigned ones or if \ref repoGpgCheck is off.
+ * \note This is a just a hint to the application and can
+ * be ignored.
*
- * The default is \c true but may be overwritten by \c zypp.conf or a \ref .repo file.
*/
bool gpgCheck() const;
- /** Set the value for \ref gpgCheck (or \c indeterminate to use the default). */
- void setGpgCheck( TriBool value_r );
- /** \overload \deprecated legacy and for squid */
- void setGpgCheck( bool value_r );
-
- /** Whether the signature of repo metadata should be checked for this repo.
- * The default is defined by \ref gpgCheck but may be overwritten by \c zypp.conf or a \ref .repo file.
- */
- bool repoGpgCheck() const;
- /** Set the value for \ref repoGpgCheck (or \c indeterminate to use the default). */
- void setRepoGpgCheck( TriBool value_r );
-
- /** Whether the signature of rpm packages should be checked for this repo.
- * The default is defined by \ref gpgCheck but may be overwritten by \c zypp.conf or a \ref .repo file.
+ /**
+ * \short Whether to check or not this repository with gpg
+ *
+ * \param check true (check) or false (dont'check)
+ *
+ * \note This is a just a hint to the application and can
+ * be ignored.
+ *
*/
- bool pkgGpgCheck() const;
- /** Set the value for \ref pkgGpgCheck (or \c indeterminate to use the default). */
- void setPkgGpgCheck( TriBool value_r );
+ void setGpgCheck( bool check );
- /** Whether the repo metadata are signed and successfully validated or \c indeterminate if unsigned.
- * The value is usually set by \ref repo::Downloader when retrieving the metadata.
+ /**
+ * \short Key to use for gpg checking of this repository
+ *
+ * \param url Url to the key in ASCII armored format
+ *
+ * \note This is a just a hint to the application and can
+ * be ignored.
+ *
*/
- TriBool validRepoSignature() const;
- /** Set the value for \ref validRepoSignature (or \c indeterminate if unsigned). */
- void setValidRepoSignature( TriBool value_r );
-
-
- /** Whether gpgkey URLs are defined */
- bool gpgKeyUrlsEmpty() const;
- /** Number of gpgkey URLs defined */
- urls_size_type gpgKeyUrlsSize() const;
-
- /** The list of gpgkey URLs defined for this repo */
- url_set gpgKeyUrls() const;
- /** The list of raw gpgkey URLs defined for this repo (no variables replaced) */
- url_set rawGpgKeyUrls() const;
- /** Set a list of gpgkey URLs defined for this repo */
- void setGpgKeyUrls( url_set urls );
-
- /** (leagcy API) The 1st gpgkey URL defined for this repo */
Url gpgKeyUrl() const;
- /** (leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) */
+ /**
+ * The raw gpgKeyUrl (no variables replaced).
+ */
Url rawGpgKeyUrl() const;
- /** (leagcy API) Set the gpgkey URL defined for this repo */
+ /**
+ * \short Key to use for gpg checking of this repository
+ *
+ * \param url Url to the key in ASCII armored format
+ *
+ * \note This is a just a hint to the application and can
+ * be ignored.
+ *
+ */
void setGpgKeyUrl( const Url &gpgkey );
-
/**
* \short Whether packages downloaded from this repository will be kept in local cache
*/
LocaleSet getLicenseLocales() const;
//@}
+ /** \name Repository global unique id
+ *
+ *
+ */
+ //@{
+ //@}
+
public:
/**
* Write a human-readable representation of this RepoInfo object
class Impl;
private:
- friend class RepoManager;
- /** Raw values for RepoManager */
- void getRawGpgChecks( TriBool & g_r, TriBool & r_r, TriBool & p_r ) const;
-
/** Pointer to implementation */
RWCOW_pointer<Impl> _pimpl;
};
///////////////////////////////////////////////////////////////////
namespace
{
- ///////////////////////////////////////////////////////////////////
- /// \class UrlCredentialExtractor
- /// \brief Extract credentials in \ref Url authority and store them via \ref CredentialManager.
- ///
- /// Lazy init CredentialManager and save collected credentials when
- /// going out of scope.
- ///
- /// Methods return whether a password has been collected/extracted.
- ///
- /// \code
- /// UrlCredentialExtractor( "/rootdir" ).collect( oneUrlOrUrlContainer );
- /// \endcode
- /// \code
- /// {
- /// UrlCredentialExtractor extractCredentials;
- /// extractCredentials.collect( oneUrlOrUrlContainer );
- /// extractCredentials.extract( oneMoreUrlOrUrlContainer );
- /// ....
- /// }
- /// \endcode
- ///
- class UrlCredentialExtractor
- {
- public:
- UrlCredentialExtractor( Pathname & root_r )
- : _root( root_r )
- {}
-
- ~UrlCredentialExtractor()
- { if ( _cmPtr ) _cmPtr->save(); }
-
- /** Remember credentials stored in URL authority leaving the password in \a url_r. */
- bool collect( const Url & url_r )
- {
- bool ret = url_r.hasCredentialsInAuthority();
- if ( ret )
- {
- if ( !_cmPtr ) _cmPtr.reset( new media::CredentialManager( _root ) );
- _cmPtr->addUserCred( url_r );
- }
- return ret;
- }
- /** \overload operating on Url container */
- template<class TContainer>
- bool collect( const TContainer & urls_r )
- { bool ret = false; for ( const Url & url : urls_r ) { if ( collect( url ) && !ret ) ret = true; } return ret; }
-
- /** Remember credentials stored in URL authority stripping the passowrd from \a url_r. */
- bool extract( Url & url_r )
- {
- bool ret = collect( url_r );
- if ( ret )
- url_r.setPassword( std::string() );
- return ret;
- }
- /** \overload operating on Url container */
- template<class TContainer>
- bool extract( TContainer & urls_r )
- { bool ret = false; for ( Url & url : urls_r ) { if ( extract( url ) && !ret ) ret = true; } return ret; }
-
- private:
- const Pathname & _root;
- scoped_ptr<media::CredentialManager> _cmPtr;
- };
- } // namespace
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- namespace
- {
/** Simple media mounter to access non-downloading URLs e.g. for non-local plaindir repos.
* \ingroup g_RAII
*/
void buildCache( const RepoInfo & info, CacheBuildPolicy policy, OPT_PROGRESS );
repo::RepoType probe( const Url & url, const Pathname & path = Pathname() ) const;
- repo::RepoType probeCache( const Pathname & path_r ) const;
void cleanCacheDirGarbage( OPT_PROGRESS );
RepoType repokind = info.type();
// If unknown, probe the local metadata
if ( repokind == RepoType::NONE )
- repokind = probeCache( productdatapath );
+ repokind = probe( productdatapath.asUrl() );
RepoStatus status;
switch ( repokind.toEnum() )
RepoType repokind = info.type();
if ( repokind.toEnum() == RepoType::NONE_e )
// unknown, probe the local metadata
- repokind = probeCache( productdatapath );
+ repokind = probe( productdatapath.asUrl() );
// if still unknown, just return
if (repokind == RepoType::NONE_e)
return;
// cause of the problem of the first URL remembered
if (it == info.baseUrlsBegin())
rexception.remember(e);
- else
- rexception.addHistory( e.asUserString() );
-
}
} // for every url
ERR << "No more urls..." << endl;
{
case RepoType::NONE_e:
// unknown, probe the local metadata
- repokind = probeCache( productdatapath );
+ repokind = probe( productdatapath.asUrl() );
break;
default:
break;
////////////////////////////////////////////////////////////////////////////
-
- /** Probe the metadata type of a repository located at \c url.
- * Urls here may be rewritten by \ref MediaSetAccess to reflect the correct media number.
- *
- * \note Metadata in local cache directories must be probed using \ref probeCache as
- * a cache path must not be rewritten (bnc#946129)
- */
repo::RepoType RepoManager::Impl::probe( const Url & url, const Pathname & path ) const
{
MIL << "going to probe the repo type at " << url << " (" << path << ")" << endl;
return repo::RepoType::NONE;
}
- /** Probe Metadata in a local cache directory
- *
- * \note Metadata in local cache directories must not be probed using \ref probe as
- * a cache path must not be rewritten (bnc#946129)
- */
- repo::RepoType RepoManager::Impl::probeCache( const Pathname & path_r ) const
- {
- MIL << "going to probe the cached repo at " << path_r << endl;
-
- repo::RepoType ret = repo::RepoType::NONE;
-
- if ( PathInfo(path_r/"/repodata/repomd.xml").isFile() )
- { ret = repo::RepoType::RPMMD; }
- else if ( PathInfo(path_r/"/content").isFile() )
- { ret = repo::RepoType::YAST2; }
- else if ( PathInfo(path_r).isDir() )
- { ret = repo::RepoType::RPMPLAINDIR; }
-
- MIL << "Probed cached type " << ret << " at " << path_r << endl;
- return ret;
- }
-
////////////////////////////////////////////////////////////////////////////
void RepoManager::Impl::cleanCacheDirGarbage( const ProgressData::ReceiverFnc & progressrcv )
progress.set(90);
// check for credentials in Urls
- UrlCredentialExtractor( _options.rootDir ).collect( tosave.baseUrls() );
+ bool havePasswords = false;
+ for_( urlit, tosave.baseUrlsBegin(), tosave.baseUrlsEnd() )
+ if ( urlit->hasCredentialsInAuthority() )
+ {
+ havePasswords = true;
+ break;
+ }
+ // save the credentials
+ if ( havePasswords )
+ {
+ media::CredentialManager cm(
+ media::CredManagerOptions(_options.rootDir) );
+
+ for_(urlit, tosave.baseUrlsBegin(), tosave.baseUrlsEnd())
+ if (urlit->hasCredentialsInAuthority())
+ //! \todo use a method calling UI callbacks to ask where to save creds?
+ cm.saveInUser(media::AuthData(*urlit));
+ }
- HistoryLog(_options.rootDir).addRepository(tosave);
+ HistoryLog().addRepository(tosave);
progress.toMax();
MIL << "done" << endl;
{
// figure how many repos are there in the file:
std::list<RepoInfo> filerepos = repositories_in_file(todelete.filepath());
- if ( filerepos.size() == 0 // bsc#984494: file may have already been deleted
- ||(filerepos.size() == 1 && filerepos.front().alias() == todelete.alias() ) )
+ if ( (filerepos.size() == 1) && ( filerepos.front().alias() == todelete.alias() ) )
{
- // easy: file does not exist, contains no or only the repo to delete: delete the file
- int ret = filesystem::unlink( todelete.filepath() );
- if ( ! ( ret == 0 || ret == ENOENT ) )
+ // easy, only this one, just delete the file
+ if ( filesystem::unlink(todelete.filepath()) != 0 )
{
// TranslatorExplanation '%s' is a filename
ZYPP_THROW(RepoException( todelete, str::form( _("Can't delete '%s'"), todelete.filepath().c_str() )));
newinfo.setFilepath(toedit.filepath());
reposManip().erase(toedit);
reposManip().insert(newinfo);
- // check for credentials in Urls
- UrlCredentialExtractor( _options.rootDir ).collect( newinfo.baseUrls() );
HistoryLog(_options.rootDir).modifyRepository(toedit, newinfo);
MIL << "repo " << alias << " modified" << endl;
}
saveService( toSave );
_services.insert( toSave );
- // check for credentials in Url
- UrlCredentialExtractor( _options.rootDir ).collect( toSave.url() );
+ // check for credentials in Url (username:password, not ?credentials param)
+ if ( toSave.url().hasCredentialsInAuthority() )
+ {
+ media::CredentialManager cm(
+ media::CredManagerOptions(_options.rootDir) );
+
+ //! \todo use a method calling UI callbacks to ask where to save creds?
+ cm.saveInUser(media::AuthData(toSave.url()));
+ }
MIL << "added service " << toSave.alias() << endl;
}
{
// First of all: Prepend service alias:
it->setAlias( str::form( "%s:%s", service.alias().c_str(), it->alias().c_str() ) );
- // set reference to the parent service
+ // set refrence to the parent service
it->setService( service.alias() );
// remember the new parsed repo state
newRepoStates[it->alias()] = *it;
- // - If the repo url was not set by the repoindex parser, set service's url.
- // - Libzypp currently has problem with separate url + path handling so just
- // append a path, if set, to the baseurls
- // - Credentials in the url authority will be extracted later, either if the
- // repository is added or if we check for changed urls.
- Pathname path;
- if ( !it->path().empty() )
- {
- if ( it->path() != "/" )
- path = it->path();
- it->setPath("");
- }
-
+ // if the repo url was not set by the repoindex parser, set service's url
+ Url url;
if ( it->baseUrlsEmpty() )
+ url = service.rawUrl();
+ else
{
- Url url( service.rawUrl() );
- if ( !path.empty() )
- url.setPathName( url.getPathName() / path );
- it->setBaseUrl( std::move(url) );
+ // service repo can contain only one URL now, so no need to iterate.
+ url = it->rawUrl(); // raw!
}
- else if ( !path.empty() )
+
+ // libzypp currently has problem with separate url + path handling
+ // so just append the path to the baseurl
+ if ( !it->path().empty() )
{
- RepoInfo::url_set urls( it->rawBaseUrls() );
- for ( Url & url : urls )
- {
- url.setPathName( url.getPathName() / path );
- }
- it->setBaseUrls( std::move(urls) );
+ Pathname path(url.getPathName());
+ path /= it->path();
+ url.setPathName( path.asString() );
+ it->setPath("");
}
+
+ // save the url
+ it->setBaseUrl( url );
}
////////////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////////////
- // create missing repositories and modify existing ones if needed...
- UrlCredentialExtractor urlCredentialExtractor( _options.rootDir ); // To collect any credentials stored in repo URLs
+ // create missing repositories and modify exising ones if needed...
for_( it, collector.repos.begin(), collector.repos.end() )
{
// User explicitly requested the repo being enabled?
}
// changed url?
+ // service repo can contain only one URL now, so no need to iterate.
+ if ( oldRepo->rawUrl() != it->rawUrl() )
{
- RepoInfo::url_set newUrls( it->rawBaseUrls() );
- urlCredentialExtractor.extract( newUrls ); // Extract! to prevent passwds from disturbing the comparison below
- if ( oldRepo->rawBaseUrls() != newUrls )
- {
- DBG << "Service repo " << it->alias() << " gets new URLs " << newUrls << endl;
- oldRepo->setBaseUrls( std::move(newUrls) );
- oldRepoModified = true;
- }
- }
-
- // changed gpg check settings?
- // ATM only plugin services can set GPG values.
- if ( service.type() == ServiceType::PLUGIN )
- {
- TriBool ogpg[3]; // Gpg RepoGpg PkgGpg
- TriBool ngpg[3];
- oldRepo->getRawGpgChecks( ogpg[0], ogpg[1], ogpg[2] );
- it-> getRawGpgChecks( ngpg[0], ngpg[1], ngpg[2] );
-#define Z_CHKGPG(I,N) \
- if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \
- { \
- DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << endl; \
- oldRepo->set##N##Check( ngpg[I] ); \
- oldRepoModified = true; \
- }
- Z_CHKGPG( 0, Gpg );
- Z_CHKGPG( 1, RepoGpg );
- Z_CHKGPG( 2, PkgGpg );
-#undef Z_CHKGPG
- }
+ DBG << "Service repo " << it->alias() << " gets new URL " << it->rawUrl() << endl;
+ oldRepo->setBaseUrl( it->rawUrl() );
+ oldRepoModified = true;
+ }
// save if modified:
if ( oldRepoModified )
_services.erase(oldAlias);
_services.insert(service);
- // check for credentials in Urls
- UrlCredentialExtractor( _options.rootDir ).collect( service.url() );
-
// changed properties affecting also repositories
if ( oldAlias != service.alias() // changed alias
bool multiversionInstall() const
{ return sat::Solvable::multiversionInstall(); }
- using sat::Solvable::asString;
- using sat::Solvable::asUserString;
-
/** \name Dependencies. */
//@{
/** Select by Dep. */
void Resolver::setDefaultCleandepsOnRemove() { _pimpl->setCleandepsOnRemove( indeterminate ); }
bool Resolver::cleandepsOnRemove() const { return _pimpl->cleandepsOnRemove(); }
-#define ZOLV_FLAG_BOOL( ZSETTER, ZGETTER ) \
- void Resolver::ZSETTER( bool yesno_r ){ _pimpl->ZSETTER( yesno_r ); } \
- bool Resolver::ZGETTER() const { return _pimpl->ZGETTER(); } \
-
-#define ZOLV_FLAG_TRIBOOL( ZSETTER, ZDEFAULT, ZGETTER ) \
- ZOLV_FLAG_BOOL( ZSETTER , ZGETTER ) \
- void Resolver::ZDEFAULT() { _pimpl->ZSETTER( indeterminate ); } \
-
- ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade, dupSetDefaultAllowDowngrade, dupAllowDowngrade )
- ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange, dupSetDefaultAllowNameChange, dupAllowNameChange )
- ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange, dupSetDefaultAllowArchChange, dupAllowArchChange )
- ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange, dupSetDefaultAllowVendorChange, dupAllowVendorChange )
-
-#undef ZOLV_FLAG_BOOL
-#undef ZOLV_FLAG_TRIBOOL
-
void Resolver::addUpgradeRepo( Repository repo_r ) { _pimpl->addUpgradeRepo( repo_r ); }
- bool Resolver::upgradingRepos() const { return !_pimpl->upgradeRepos().empty(); }
bool Resolver::upgradingRepo( Repository repo_r ) const { return _pimpl->upgradingRepo( repo_r ); }
void Resolver::removeUpgradeRepo( Repository repo_r ) { _pimpl->removeUpgradeRepo( repo_r ); }
void Resolver::removeUpgradeRepos() { _pimpl->removeUpgradeRepos(); }
/**
- * Do an distribution upgrade (DUP)
+ * Do an distribution upgrade
*
* Perform a distribution upgrade. This performs an update of
* all packages with a special resolver algorithm which takes
void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
bool cleandepsOnRemove() const;
- /** \name Solver flags for DUP mode.
- * DUP mode default settings differ from 'ordinary' ones. Default for
- * all DUP flags is \c true.
- */
- //@{
- /** dup mode: allow to downgrade installed solvable */
- void dupSetAllowDowngrade( bool yesno_r );
- void dupSetDefaultAllowDowngrade(); // Set back to default
- bool dupAllowDowngrade() const;
-
- /** dup mode: allow to change name of installed solvable */
- void dupSetAllowNameChange( bool yesno_r );
- void dupSetDefaultAllowNameChange(); // Set back to default
- bool dupAllowNameChange() const;
-
- /** dup mode: allow to change architecture of installed solvables */
- void dupSetAllowArchChange( bool yesno_r );
- void dupSetDefaultAllowArchChange(); // Set back to default
- bool dupAllowArchChange() const;
-
- /** dup mode: allow to change vendor of installed solvables*/
- void dupSetAllowVendorChange( bool yesno_r );
- void dupSetDefaultAllowVendorChange(); // Set back to default
- bool dupAllowVendorChange() const;
- //@}
-
/** \name Upgrade to content of a specific repository.
* \note This is an ordinary solver request. You should simply
* \ref resolvePool to execute, and not \ref doUpgrade.
void addUpgradeRepo( Repository repo_r );
/**
- * Whether there is at least one \c UpgradeRepo request pending
- */
- bool upgradingRepos() const;
-
- /**
* Whether there is an \c UpgradeRepo request pending for this repo.
*/
bool upgradingRepo( Repository repo_r ) const;
#define ZYPP_TRIBOOL_H
#include <iosfwd>
-#include <string>
#include <boost/logic/tribool.hpp>
///////////////////////////////////////////////////////////////////
using boost::logic::tribool;
using boost::logic::indeterminate;
- inline std::string asString( const TriBool & val_r, const std::string & istr_r = std::string(),
- const std::string & tstr_r = std::string(),
- const std::string & fstr_r = std::string() )
- {
- std::string ret;
- if (indeterminate(val_r))
- ret = ( istr_r.empty() ? "indeterminate" : istr_r );
- else if (val_r)
- ret = ( tstr_r.empty() ? "true" : tstr_r );
- else
- ret = ( fstr_r.empty() ? "false" : fstr_r );
- return ret;
- }
-
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
{
/** \relates TriBool stream output */
inline std::ostream & operator<<(std::ostream & s, const tribool & obj)
- { return s << zypp::asString( obj ); }
-
- /** \relates TriBool whether 2 tribool have the same state (this is NOT ==) */
- inline bool sameTriboolState( tribool lhs, tribool rhs )
- { return( ( indeterminate(lhs) && indeterminate(rhs) ) || ( lhs == rhs ) ); }
+ {
+ if (indeterminate(obj))
+ s << "indeterminate";
+ else if (obj)
+ s << "true";
+ else
+ s << "false";
+ return s;
+ }
}
}
#endif // ZYPP_TRIBOOL_H
///
/// Basically a <tt>std::map<std::string,boost::any></tt> plus
/// associated \ref ContentType.
- ///
- /// Constness protects non-empty values from being modified.
- /// It is possible to overwrite empty values or to add new ones.
///////////////////////////////////////////////////////////////////
class UserData
{
typedef std::map<std::string,boost::any> DataType;
- typedef DataType::size_type size_type;
- typedef DataType::key_type key_type;
- typedef DataType::value_type value_type;
- typedef DataType::const_iterator const_iterator;
public:
- /** Default ctor. */
+ /** Default ctor */
UserData()
{}
- /** Ctor taking ContentType. */
- explicit UserData( ContentType type_r )
- : _type( std::move(type_r) )
- {}
- /** Ctor taking ContentType. */
- explicit UserData( std::string type_r )
- : UserData( ContentType( std::move(type_r) ) )
- {}
- /** Ctor taking ContentType. */
- UserData( std::string type_r, std::string subtype_r )
- : UserData( ContentType( std::move(type_r), std::move(subtype_r) ) )
- {}
-
public:
- /** Get type. */
+ /** Get type */
const ContentType & type() const
{ return _type; }
- /** Set type. */
- void type( ContentType type_r )
- { _type = std::move(type_r); }
+ /** Set type */
+ void type( const ContentType & type_r )
+ { _type = type_r; }
public:
- /** Validate object in a boolean context: has data */
+ /** Validate object in a boolean context: has data */
explicit operator bool() const
- { return !empty(); }
-
- /** Whether \ref data is empty. */
- bool empty() const
- { return !_dataP || _dataP->empty(); }
-
- /** Size of \ref data. */
- size_type size() const
- { return _dataP ? _dataP->size() : 0; }
-
- /** The \ref data. */
- const DataType & data() const
- { return dataRef(); }
-
- /** Whether \a key_r is in \ref data. */
- bool haskey( const std::string & key_r ) const
- { return _dataP && _dataP->find( key_r ) != _dataP->end(); }
-
- /** Whether \a key_r is in \ref data and value is not empty. */
- bool hasvalue( const std::string & key_r ) const
- {
- bool ret = false;
- if ( _dataP )
- {
- const_iterator it = _dataP->find( key_r );
- if ( it != _dataP->end() && ! it->second.empty() )
- {
- ret = true;
- }
- }
- return ret;
- }
-
- /** Set the value for key (nonconst version always returns true).
- * Const version is allowed to set empty values or to add new ones only.
- */
- bool set( const std::string & key_r, boost::any val_r )
- { dataRef()[key_r] = std::move(val_r); return true; }
- /** \overload const version */
- bool set( const std::string & key_r, boost::any val_r ) const
- {
- bool ret = false;
- boost::any & val( dataRef()[key_r] );
- if ( val.empty() )
- {
- val = std::move(val_r);
- ret = true;
- }
- return ret;
- }
-
- /** Set an empty value for \a key_r (if possible). */
- bool reset( const std::string & key_r )
- { return set( key_r, boost::any() ); }
- /** \overload const version */
- bool reset( const std::string & key_r ) const
- { return set( key_r, boost::any() ); }
-
- /** Remove key from data.*/
- void erase( const std::string & key_r )
- { if ( _dataP ) _dataP->erase( key_r ); }
-
- /** Return the keys boost::any value or an empty value if key does not exist. */
- const boost::any & getvalue( const std::string & key_r ) const
- {
- if ( _dataP )
- {
- const_iterator it = _dataP->find( key_r );
- if ( it != _dataP->end() )
- {
- return it->second;
- }
- }
- static const boost::any none;
- return none;
- }
-
- /** Pass back a <tt>const Tp &</tt> reference to \a key_r value.
- * \throws boost::bad_any_cast if key is not set or value is not of appropriate type
- * \code
- * UserData data;
- * std::string value( "defaultvalue" );
- * try
- * {
- * value = data.get<std::string>( "mykey" );
- * }
- * catch ( const boost::bad_any_cast & )
- * {
- * // no "mykey" or not a std::sting
- * }
- * \endcode
- */
- template <class Tp>
- const Tp & get( const std::string & key_r ) const
- { return boost::any_cast<const Tp &>( getvalue( key_r ) ); }
-
- /** Pass back a \a Tp copy of \a key_r value.
- * \throws boost::bad_any_cast if key is not set or value is not of appropriate type
- * \code
- * UserData data;
- * std::string value = data.get<std::string>( "mykey", "defaultvalue" );
- * \endcode
- */
- template <class Tp>
- Tp get( const std::string & key_r, const Tp & default_r ) const
- { Tp ret( default_r ); get( key_r, ret ); return ret; }
-
- /** If the value for \a key_r is of the same type as \a ret_r, pass it back in \a ret_r and return \c true;.
- * \code
- * UserData data;
- * std::string value( "defaultvalue" );
- * if ( ! data.get<std::string>( "mykey", value )
- * {
- * // no "mykey" or not a std::sting
- * }
- * \endcode
- */
- template <class Tp>
- bool get( const std::string & key_r, Tp & ret_r ) const
- {
- bool ret = false;
- if ( _dataP )
- {
- const_iterator it = _dataP->find( key_r );
- if ( it != _dataP->end() )
- {
- auto ptr = boost::any_cast<const Tp>(&it->second);
- if ( ptr )
- {
- ret_r = *ptr;
- ret = true;
- }
- }
- }
- return ret;
- }
-
- private:
- DataType & dataRef() const
- { if ( ! _dataP ) _dataP.reset( new DataType ); return *_dataP; }
+ { return ! ( _dataP == nullptr || _dataP->empty() ); }
private:
- ContentType _type;
- mutable shared_ptr<DataType> _dataP;
+ ContentType _type;
+ shared_ptr<DataType> _dataP;
};
/** \relates UserData Stream output */
inline std::ostream & operator<<( std::ostream & str, const UserData & obj )
- { return str << "UserData(" << obj.type() << ":" << obj.size() << ")";}
+ { return str << "UserData(" << obj.type() << ")";}
} // namespace callback
///////////////////////////////////////////////////////////////////
, download_max_silent_tries ( 5 )
, download_transfer_timeout ( 180 )
, commit_downloadMode ( DownloadDefault )
- , gpgCheck ( true )
- , repoGpgCheck ( indeterminate )
- , pkgGpgCheck ( indeterminate )
, solver_onlyRequires ( false )
, solver_allowVendorChange ( false )
, solver_cleandepsOnRemove ( false )
{
commit_downloadMode.set( deserializeDownloadMode( value ) );
}
- else if ( entry == "gpgcheck" )
- {
- gpgCheck.set( str::strToBool( value, gpgCheck ) );
- }
- else if ( entry == "repo_gpgcheck" )
- {
- repoGpgCheck.set( str::strToTriBool( value ) );
- }
- else if ( entry == "pkg_gpgcheck" )
- {
- pkgGpgCheck.set( str::strToTriBool( value ) );
- }
else if ( entry == "vendordir" )
{
cfg_vendor_path = Pathname(value);
Option<DownloadMode> commit_downloadMode;
- Option<bool> gpgCheck;
- Option<TriBool> repoGpgCheck;
- Option<TriBool> pkgGpgCheck;
-
Option<bool> solver_onlyRequires;
Option<bool> solver_allowVendorChange;
Option<bool> solver_cleandepsOnRemove;
DownloadMode ZConfig::commit_downloadMode() const
{ return _pimpl->commit_downloadMode; }
- bool ZConfig::gpgCheck() const
- { return _pimpl->gpgCheck; }
-
- TriBool ZConfig::repoGpgCheck() const
- { return _pimpl->repoGpgCheck; }
-
- TriBool ZConfig::pkgGpgCheck() const
- { return _pimpl->pkgGpgCheck; }
-
bool ZConfig::solver_onlyRequires() const
{ return _pimpl->solver_onlyRequires; }
#include "zypp/Locale.h"
#include "zypp/Pathname.h"
#include "zypp/IdString.h"
-#include "zypp/TriBool.h"
#include "zypp/DownloadMode.h"
#include "zypp/target/rpm/RpmFlags.h"
*/
DownloadMode commit_downloadMode() const;
- /** \name Signature checking (repodata and packages)
- * If \ref gpgcheck is \c on (the default) we will either check the signature
- * of repo metadata (packages are secured via checksum in the metadata), or the
- * signature of an rpm package to install if it's repo metadata are not signed
- * or not checked. If \ref gpgcheck is \c off, no checks are performed.
- *
- * The default behavior can be altered by explicitly setting \ref repo_gpgcheck and/or
- * \ref pkg_gpgcheck to perform those checks always (\c on) or never (\c off).
- *
- * Explicitly setting \c gpgcheck, \c repo_gpgcheck or \c pkg_gpgcheck in a
- * repositories \a .repo file will overwrite the defaults here.
- */
- //@{
- bool gpgCheck() const; ///< Turn signature checking on/off (on)
- TriBool repoGpgCheck() const; ///< Check repo matadata signatures (indeterminate - according to gpgcheck)
- TriBool pkgGpgCheck() const; ///< Check rpm package signatures (indeterminate - according to gpgcheck)
- //@}
- //
/**
* Directory for equivalent vendor definitions (configPath()/vendors.d)
* \ingroup g_ZC_CONFIGFILES
, const std::string &/*description*/
) { return ABORT; }
-
- /** Detail information about the result of a performed pkgGpgCheck.
- *
- * Userdata sent:
- * \param "Package" Package::constPtr of the package
- * \param "Localpath" Pathname to downloaded package on disk
- * \param "CheckPackageResult" RpmDb::CheckPackageResult of signature check
- * \param "CheckPackageDetail" RpmDb::CheckPackageDetail logmessages of rpm signature check
- *
- * Userdata accepted:
- * \param "Action" DownloadResolvableReport::Action user advice how to behave on error (ABORT).
- * If you set just an empty value here, a default probelm report will be triggered.
- */
- virtual void pkgGpgCheck( const UserData & userData_r = UserData() )
- {}
-
virtual void finish(Resolvable::constPtr /*resolvable_ptr*/
, Error /*error*/
, const std::string &/*reason*/
public:
Pathname _root;
- FalseBool _attemptToModify;
sat::Transaction _transaction;
TransactionStepList _transactionStepList;
UpdateNotifications _updateMessages;
const Pathname & ZYppCommitResult::root() const
{ return _pimpl->_root; }
- bool ZYppCommitResult::attemptToModify() const
- { return _pimpl->_attemptToModify; }
-
- void ZYppCommitResult::attemptToModify( bool yesno_r )
- { _pimpl->_attemptToModify = yesno_r; }
-
const sat::Transaction & ZYppCommitResult::transaction() const
{ return _pimpl->_transaction; }
*/
const Pathname & root() const;
- /** \c True if at least one attempt to actually install/remove packages was made.
- * While this is false there should have been no serious modifications to the system.
- * Mainly used to detect whether commit failed while preloading the caches or within
- * the real action.
- */
- bool attemptToModify() const;
-
- /** Set \ref attemptToModify */
- void attemptToModify( bool yesno_r );
-
/** The full transaction list.
* The complete list including transaction steps that do not require
* any action (like obsoletes or non-package actions). Depending on
_Tp _val;
};
- /** \relates DefaultIntegral \c true initialized \c bool */
- typedef DefaultIntegral<bool,true> TrueBool;
-
- /** \relates DefaultIntegral \c false initialized \c bool */
- typedef DefaultIntegral<bool,false> FalseBool;
-
- /** \relates DefaultIntegral \c zero initialized \c integral */
- template<typename TIntegral>
- using ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>;
-
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/base/String.h"
#include "zypp/base/LogTools.h"
-#include "zypp/TriBool.h"
-
using std::string;
///////////////////////////////////////////////////////////////////
);
}
- TriBool strToTriBool( const C_Str & str ) // from TriBool.h
- {
- if ( strToTrue( str ) ) return true;
- if ( !strToFalse( str ) ) return false;
- return indeterminate;
- }
-
///////////////////////////////////////////////////////////////////
// Hexencode
///////////////////////////////////////////////////////////////////
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Function.h"
-///////////////////////////////////////////////////////////////////
-namespace boost { namespace logic { class tribool; } }
-namespace zypp { typedef boost::logic::tribool TriBool; }
-///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace boost
return return_r;
}
- /** Parse \c str into a bool if it's a legal \c true or \c false string; else \c indterminate. */
- TriBool strToTriBool( const C_Str & str );
-
//@}
/**
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
+
///////////////////////////////////////////////////////////////////
namespace zypp
-{
+{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace media
+ { /////////////////////////////////////////////////////////////////
+
+
+ //////////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CredentialFileReader
+ //
+ //////////////////////////////////////////////////////////////////////
+
+ CredentialFileReader::CredentialFileReader(
+ const Pathname & crfile,
+ const ProcessCredentials & callback)
{
- ///////////////////////////////////////////////////////////////////
- namespace
+ InputStream is(crfile);
+ parser::IniDict dict(is);
+ for (parser::IniDict::section_const_iterator its = dict.sectionsBegin();
+ its != dict.sectionsEnd();
+ ++its)
{
- // Looks like INI but allows multiple sections for the same URL
- // but different user (in .cat files). So don't use an Ini
- // Also support a global section without '[URL]' which is used
- // in credential files.
- // -------------------------------------
- // username = emptyUSER
- // password = emptyPASS
- // -------------------------------------
- // [http://server/tmp/sumafake222]
- // username = USER
- // password = PASS
- //
- // [http://server/tmp/sumafake222]
- // username = USER2
- // password = PASS
- // -------------------------------------
- struct CredentialFileReaderImpl : public parser::IniParser
+ Url storedUrl;
+ if (!its->empty())
+ {
+ try { storedUrl = Url(*its); }
+ catch (const url::UrlException &)
+ {
+ ERR << "invalid URL '" << *its << "' in credentials in file: "
+ << crfile << endl;
+ continue;
+ }
+ }
+
+ AuthData_Ptr credentials;
+ credentials.reset(new AuthData());
+
+ // set url
+ if (storedUrl.isValid())
+ credentials->setUrl(storedUrl);
+
+ for (parser::IniDict::entry_const_iterator it = dict.entriesBegin(*its);
+ it != dict.entriesEnd(*its);
+ ++it)
{
- typedef CredentialFileReader::ProcessCredentials ProcessCredentials;
-
- struct StopParsing {};
-
- CredentialFileReaderImpl( const Pathname & input_r, const ProcessCredentials & callback_r )
- : _input( input_r )
- , _callback( callback_r )
- {
- try
- {
- parse( input_r );
- }
- catch ( StopParsing )
- { /* NO error but consumer aborted parsing */ }
- }
-
- // NO-OP; new sections are opened in consume()
- virtual void beginParse()
- { /*EMPTY*/ }
-
- // start a new section [url]
- virtual void consume( const std::string & section_r )
- {
- endParse(); // close any open section
- _secret.reset( new AuthData );
- try
- {
- _secret->setUrl( Url(section_r) );
- }
- catch ( const url::UrlException & )
- {
- ERR << "Ignore invalid URL '" << section_r << "' in file " << _input << endl;
- _secret.reset(); // ignore this section
- }
- }
-
- virtual void consume( const std::string & section_r, const std::string & key_r, const std::string & value_r )
- {
- if ( !_secret && section_r.empty() )
- _secret.reset( new AuthData ); // a initial global section without [URL]
-
- if ( _secret )
- {
- if ( key_r == "username" )
- _secret->setUsername( value_r );
- else if ( key_r == "password" )
- _secret->setPassword( value_r );
- else
- WAR << "Ignore unknown attribute '" << key_r << "=" << value_r << "' in file " << _input << endl;
- }
- // else: ignored section due to wrong URL
- }
-
- // send any valid pending section
- virtual void endParse()
- {
- if ( _secret )
- {
- if ( _secret->valid() )
- {
- if ( !_callback( _secret ) )
- throw( StopParsing() );
- }
- else
- ERR << "Ignore invalid credentials for URL '" << _secret->url() << "' in file " << _input << endl;
- }
- }
-
- private:
- const Pathname & _input;
- const ProcessCredentials & _callback;
- AuthData_Ptr _secret;
- };
- } // namespace
- ///////////////////////////////////////////////////////////////////
-
- //////////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CredentialFileReader
- //
- //////////////////////////////////////////////////////////////////////
-
- CredentialFileReader::CredentialFileReader( const Pathname & crfile_r, const ProcessCredentials & callback_r )
- { CredentialFileReaderImpl( crfile_r, callback_r ); }
-
- CredentialFileReader::~CredentialFileReader()
- {}
-
- } // namespace media
+ if (it->first == "username")
+ credentials->setUsername(it->second);
+ else if (it->first == "password")
+ credentials->setPassword(it->second);
+ else
+ ERR << "Unknown attribute in [" << crfile << "]: "
+ << it->second << " ignored" << endl;
+ }
+
+ if (credentials->valid())
+ callback(credentials);
+ else
+ ERR << "invalid credentials in file: " << crfile << endl;
+ } // sections
+ }
+
+
+ CredentialFileReader::~CredentialFileReader()
+ {}
+
+
+ /////////////////////////////////////////////////////////////////
+ } // media
///////////////////////////////////////////////////////////////////
-} // namespace zypp
+ /////////////////////////////////////////////////////////////////
+} // zypp
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace zypp
-{
+{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace media
+ { /////////////////////////////////////////////////////////////////
+
+
+ //////////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CredentialFileReader
+ //
+ class CredentialFileReader
{
- //////////////////////////////////////////////////////////////////////
- /// \class CredentialFileReader
- /// \brief Parse credentials files and catalogs
- class CredentialFileReader
- {
- public:
- /** Callback invoked for each entry found in the file.
- * Return \c false to abort parsing.
- */
- typedef function<bool(AuthData_Ptr &)> ProcessCredentials;
-
- CredentialFileReader( const Pathname & crfile_r, const ProcessCredentials & callback_r );
- ~CredentialFileReader();
- private:
- ProcessCredentials _callback;
- };
- //////////////////////////////////////////////////////////////////////
-
- } // namespace media
+ public:
+ /**
+ * Callback definition.
+ * First parameter is the \ref Url with which the credentials are
+ * associated, the second are the credentials.
+ *
+ * Return false from the callback to get a \ref AbortRequestException
+ * to be thrown and the processing to be cancelled.
+ */
+ typedef function<bool(AuthData_Ptr &)> ProcessCredentials;
+
+ CredentialFileReader(const Pathname & crfile,
+ const ProcessCredentials & callback);
+ ~CredentialFileReader();
+ private:
+ ProcessCredentials _callback;
+ };
+ //////////////////////////////////////////////////////////////////////
+
+
+ /////////////////////////////////////////////////////////////////
+ } // media
///////////////////////////////////////////////////////////////////
-} // namespace zypp
+ /////////////////////////////////////////////////////////////////
+} // zypp
///////////////////////////////////////////////////////////////////
#endif /* ZYPP_MEDIA_CREDENTIALFILEREADER_H */
//
//////////////////////////////////////////////////////////////////////
- bool AuthDataComparator::operator()( const AuthData_Ptr & lhs, const AuthData_Ptr & rhs )
+ bool
+ AuthDataComparator::operator()(
+ const AuthData_Ptr & lhs, const AuthData_Ptr & rhs)
{
- static const url::ViewOption vopt = url::ViewOption::DEFAULTS
- - url::ViewOption::WITH_USERNAME
- - url::ViewOption::WITH_PASSWORD
- - url::ViewOption::WITH_QUERY_STR;
- // std::less semantic!
- int cmp = lhs->url().asString(vopt).compare( rhs->url().asString(vopt) );
- if ( ! cmp )
- cmp = lhs->username().compare( rhs->username() );
- return( cmp < 0 );
+ static const url::ViewOption vopt =
+ url::ViewOption::DEFAULTS
+ - url::ViewOption::WITH_USERNAME
+ - url::ViewOption::WITH_PASSWORD
+ - url::ViewOption::WITH_QUERY_STR;
+
+ if (lhs->username() != rhs->username())
+ return true;
+
+ if (lhs->url().asString(vopt) != rhs->url().asString(vopt))
+ return true;
+
+ return false;
}
//////////////////////////////////////////////////////////////////////
else
s.setClientCertificatePath(client_cert);
}
- Pathname client_key( url.getQueryParam("ssl_clientkey") );
- if( ! client_key.empty())
- {
- if( !PathInfo(client_key).isFile() || !client_key.absolute())
- ZYPP_THROW(MediaBadUrlException(url, "Invalid ssl_clientkey file"));
- else
- s.setClientKeyPath(client_key);
- }
param = url.getQueryParam( "proxy" );
if ( ! param.empty() )
// so that we don't add headers twice
TransferSettings vol_settings(_settings);
- // add custom headers for download.opensuse.org (bsc#955801)
- if ( _url.getHost() == "download.opensuse.org" )
- {
- vol_settings.addHeader(anonymousIdHeader());
- vol_settings.addHeader(distributionFlavorHeader());
- }
+ // add custom headers
+ vol_settings.addHeader(anonymousIdHeader());
+ vol_settings.addHeader(distributionFlavorHeader());
vol_settings.addHeader("Pragma:");
_settings.setTimeout(ZConfig::instance().download_transfer_timeout());
{
SET_OPTION(CURLOPT_SSLCERT, _settings.clientCertificatePath().c_str());
}
- if( ! _settings.clientKeyPath().empty() )
- {
- SET_OPTION(CURLOPT_SSLKEY, _settings.clientKeyPath().c_str());
- }
#ifdef CURLSSLOPT_ALLOW_BEAST
// see bnc#779177
break;
case CURLE_SSL_PEER_CERTIFICATE:
default:
- err = "Curl error " + str::numstring( code );
+ err = "Unrecognized error";
break;
}
* server is authentic against the chain of digital signatures
* found in <tt>ssl_capath</tt>.
* - <tt>ssl_clientcert</tt>
- * Path to the ssl client certificate for authentication to a repo (CURLOPT_SSLCERT).
- * - <tt>ssl_clientkey</tt>
- * Path to the ssl client key for authentication to a repo (CURLOPT_SSLKEY).
+ * Path to a ssl client certificate for authentication to a repo.
* - <tt>timeout</tt>:
* Transfer timeout in seconds between 0 and 3600, 0 disables
* the timeout, default timeout is 180 seconds.
std::ostream & AuthData::dumpOn( std::ostream & str ) const
{
- if (_url.isValid())
- str << "[" << _url.asString( url::ViewOptions() - url::ViewOptions::WITH_USERNAME - url::ViewOptions::WITH_PASSWORD ) << "]" << endl;
- else
- str << "[<no-url>]" << endl;
str << "username: '" << _username << "'" << std::endl
- << "password: " << (_password.empty() ? "<empty>" : "<non-empty>");
+ << "password: " << (_password.empty() ? "<empty>" : "<non-empty>")
+ << std::endl;
return str;
}
std::ostream & CurlAuthData::dumpOn( std::ostream & str ) const
{
- AuthData::dumpOn(str) << endl
- << " auth_type: " << _auth_type_str << " (" << _auth_type << ")";
+ AuthData::dumpOn(str) << " auth_type: " << _auth_type_str
+ << " (" << _auth_type << ")" << std::endl;
return str;
}
bool _verify_peer;
Pathname _ca_path;
Pathname _client_cert_path;
- Pathname _client_key_path;
// workarounds
bool _head_requests_allowed;
_impl->_client_cert_path = path;
}
-Pathname TransferSettings::clientKeyPath() const
-{
- return _impl->_client_key_path;
-}
-
-void TransferSettings::setClientKeyPath( const zypp::Pathname &path )
-{
- _impl->_client_key_path = path;
-}
-
void TransferSettings::setVerifyPeerEnabled( bool enabled )
{
*/
void setClientCertificatePath( const zypp::Pathname &path );
- /**
- * SSL client key file
- */
- Pathname clientKeyPath() const;
-
- /**
- * Sets the SSL client key file
- */
- void setClientKeyPath( const zypp::Pathname &path );
-
protected:
class Impl;
RWCOW_pointer<Impl> _impl;
namespace {
inline const std::string & keyGarbage()
{
- static const std::string & _val( ":/?|,\\" );
+ static const std::string & _val( ",|/\\" );
return _val;
}
} //namespace
if (trimmed[0] == '[')
{
- std::string::size_type pos = trimmed.rfind(']');
+ std::string::size_type pos = trimmed.find(']');
if ( pos != std::string::npos )
{
std::string section = trimmed.substr(1, pos-1);
{
if ( key_r == "baseurl" )
{
- _inMultiline = MultiLine::baseurl;
+ setInBaseurls( true );
_baseurls[section_r].push_back( Url(value_r) );
}
- else if ( key_r == "gpgkey" )
- {
- _inMultiline = MultiLine::gpgkey;
- legacyStoreUrl( _gpgkeys[section_r], value_r );
- }
else
{
- _inMultiline = MultiLine::none;
+ setInBaseurls( false );
IniDict::consume( section_r, key_r, value_r );
}
}
virtual void garbageLine( const std::string & section_r, const std::string & line_r )
{
- switch ( _inMultiline )
- {
- case MultiLine::baseurl:
- _baseurls[section_r].push_back( Url(line_r) );
- break;
-
- case MultiLine::gpgkey:
- legacyStoreUrl( _gpgkeys[section_r], line_r );
- break;
-
- case MultiLine::none:
- IniDict::garbageLine( section_r, line_r ); // throw
- break;
- }
+ if ( _inBaseurls )
+ _baseurls[section_r].push_back( Url(line_r) );
+ else
+ IniDict::garbageLine( section_r, line_r ); // throw
}
std::list<Url> & baseurls( const std::string & section_r )
{ return _baseurls[section_r]; }
- std::list<Url> & gpgkeys( const std::string & section_r )
- { return _gpgkeys[section_r]; }
-
private:
- void legacyStoreUrl( std::list<Url> & store_r, const std::string & line_r )
- {
- // Legacy:
- // commit 4ef65a442038caf7a1e310bc719e329b34dbdb67
- // - split the gpgkey line and take the first one as url to avoid
- // crash when creating an url from the line, as Fedora hat the
- // *BRILLIANT* idea of using more than one url per line.
- std::vector<std::string> keys;
- str::split( line_r, std::back_inserter(keys) );
- for ( auto && str : keys )
- store_r.push_back( Url(std::move(str)) );
- }
-
- enum class MultiLine { none, baseurl, gpgkey };
- MultiLine _inMultiline = MultiLine::none;
+ void setInBaseurls( bool yesno_r )
+ { if ( _inBaseurls != yesno_r ) _inBaseurls = yesno_r; }
+ DefaultIntegral<bool,false> _inBaseurls;
std::map<std::string,std::list<Url>> _baseurls;
- std::map<std::string,std::list<Url>> _gpgkeys;
};
} //namespace
info.setAutorefresh( str::strToTrue( it->second ) );
else if ( it->first == "mirrorlist" && !it->second.empty())
info.setMirrorListUrl(Url(it->second));
+ else if ( it->first == "gpgkey" && !it->second.empty())
+ {
+ std::vector<std::string> keys;
+ str::split( it->second, std::back_inserter(keys) );
+ if ( ! keys.empty() )
+ info.setGpgKeyUrl( Url(*keys.begin()) );
+ }
else if ( it->first == "gpgcheck" )
- info.setGpgCheck( str::strToTriBool( it->second ) );
- else if ( it->first == "repo_gpgcheck" )
- info.setRepoGpgCheck( str::strToTrue( it->second ) );
- else if ( it->first == "pkg_gpgcheck" )
- info.setPkgGpgCheck( str::strToTrue( it->second ) );
+ info.setGpgCheck( str::strToTrue( it->second ) );
else if ( it->first == "keeppackages" )
info.setKeepPackages( str::strToTrue( it->second ) );
else if ( it->first == "service" )
info.addBaseUrl( url );
}
- info.setGpgKeyUrls( std::move(dict.gpgkeys( *its )) );
-
info.setFilepath(is.path());
MIL << info << endl;
// add it to the list.
Pathname sigpath = masterIndex_r.extend( ".asc" );
Pathname keypath = masterIndex_r.extend( ".key" );
- // always download them, even if repoGpgCheck is disabled
+ SignatureFileChecker sigchecker;
+
enqueue( OnMediaLocation( sigpath, 1 ).setOptional( true ) );
- enqueue( OnMediaLocation( keypath, 1 ).setOptional( true ) );
start( destdir_r, media_r );
reset();
- FileChecker checker; // set to sigchecker if appropriate, else Null.
- SignatureFileChecker sigchecker;
- bool isSigned = PathInfo(destdir_r / sigpath).isExist();
+ // only add the signature if it exists
+ if ( PathInfo(destdir_r / sigpath).isExist() )
+ sigchecker = SignatureFileChecker( destdir_r / sigpath );
- if ( repoInfo().repoGpgCheck() )
- {
- if ( isSigned || !repoInfo().pkgGpgCheck() )
- {
- // only add the signature if it exists
- if ( isSigned )
- sigchecker = SignatureFileChecker( destdir_r / sigpath );
-
- KeyContext context;
- context.setRepoInfo( repoInfo() );
- // only add the key if it exists
- if ( PathInfo(destdir_r / keypath).isExist() )
- sigchecker.addPublicKey( destdir_r / keypath, context );
- else
- // set the checker context even if the key is not known (unsigned repo, key
- // file missing; bnc #495977)
- sigchecker.setKeyContext( context );
-
- checker = FileChecker( ref(sigchecker) ); // ref() to the local sigchecker is important as we want back fileValidated!
- }
- else
- {
- WAR << "Accept unsigned repository because pkgGpgCheck is on for " << repoInfo().alias() << endl;
- }
- }
+ enqueue( OnMediaLocation( keypath, 1 ).setOptional( true ) );
+ start( destdir_r, media_r );
+ reset();
+
+ KeyContext context;
+ context.setRepoInfo( repoInfo() );
+ // only add the key if it exists
+ if ( PathInfo(destdir_r / keypath).isExist() )
+ sigchecker.addPublicKey( destdir_r / keypath, context );
else
+ // set the checker context even if the key is not known (unsigned repo, key
+ // file missing; bnc #495977)
+ sigchecker.setKeyContext( context );
+
+ if ( ! repoInfo().gpgCheck() )
{
WAR << "Signature checking disabled in config of repository " << repoInfo().alias() << endl;
}
-
- enqueue( OnMediaLocation( masterIndex_r, 1 ), checker ? checker : FileChecker(NullFileChecker()) );
+ enqueue( OnMediaLocation( masterIndex_r, 1 ),
+ repoInfo().gpgCheck() ? FileChecker(sigchecker) : FileChecker(NullFileChecker()) );
start( destdir_r, media_r );
reset();
-
- // Accepted!
- _repoinfo.setMetadataPath( destdir_r );
- if ( isSigned )
- _repoinfo.setValidRepoSignature( sigchecker.fileValidated() );
- else
- _repoinfo.setValidRepoSignature( indeterminate );
}
#include "zypp/RepoInfo.h"
#include "zypp/RepoManager.h"
-#include "zypp/ZYppFactory.h"
-#include "zypp/Target.h"
-#include "zypp/target/rpm/RpmDb.h"
-#include "zypp/FileChecker.h"
-
using std::endl;
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
class PackageProvider::Impl : private base::NonCopyable
{
- typedef callback::UserData UserData;
public:
/** Ctor taking the Package to provide. */
Impl( RepoMediaAccess & access_r,
return true; // anyway a failure
}
- typedef target::rpm::RpmDb RpmDb;
-
- RpmDb::CheckPackageResult packageSigCheck( const Pathname & path_r, UserData & userData ) const
- {
- if ( !_target )
- _target = getZYpp()->getTarget();
-
- RpmDb::CheckPackageResult ret = RpmDb::CHK_ERROR;
- RpmDb::CheckPackageDetail detail;
- if ( _target )
- ret = _target->rpmDb().checkPackage( path_r, detail );
- else
- detail.push_back( RpmDb::CheckPackageDetail::value_type( ret, "OOps. Target is not initialized!" ) );
-
- userData.set( "CheckPackageResult", ret );
- userData.set( "CheckPackageDetail", std::move(detail) );
- return ret;
- }
-
- /** React on signature verrification error user action */
- void resolveSignatureErrorAction( repo::DownloadResolvableReport::Action action_r ) const
- {
- // TranslatorExplanation %s = package being checked for integrity
- switch ( action_r )
- {
- case repo::DownloadResolvableReport::RETRY:
- _retry = true;
- break;
- case repo::DownloadResolvableReport::IGNORE:
- WAR << _package->asUserString() << ": " << "User requested skip of insecure file" << endl;
- break;
- default:
- case repo::DownloadResolvableReport::ABORT:
- ZYPP_THROW(AbortRequestException("User requested to abort"));
- break;
- }
- }
-
- /** Default signature verrification error handling. */
- void defaultReportSignatureError( RpmDb::CheckPackageResult ret, const std::string & detail_r = std::string() ) const
- {
- str::Str msg;
- msg << _package->asUserString() << ": " << _("Signature verification failed") << " " << ret;
- if ( ! detail_r.empty() )
- msg << "\n" << detail_r;
- resolveSignatureErrorAction( report()->problem( _package, repo::DownloadResolvableReport::INVALID, msg.str() ) );
- }
-
protected:
PackageProviderPolicy _policy;
Package::constPtr _package;
mutable bool _retry;
mutable shared_ptr<Report> _report;
- mutable Target_Ptr _target;
};
///////////////////////////////////////////////////////////////////
Url url = * info.baseUrlsBegin();
do {
_retry = false;
- if ( ! ret->empty() )
- {
- ret.setDispose( filesystem::unlink );
- ret.reset();
- }
report()->start( _package, url );
- try
+ try // ELIMINATE try/catch by providing a log-guard
{
ret = doProvidePackage();
-
- if ( info.pkgGpgCheck() )
- {
- UserData userData( "pkgGpgCheck" );
- userData.set( "Package", _package );
- userData.set( "Localpath", ret.value() );
- RpmDb::CheckPackageResult res = packageSigCheck( ret, userData );
- // publish the checkresult, even if it is OK. Apps may want to report something...
- report()->pkgGpgCheck( userData );
-
- if ( res != RpmDb::CHK_OK )
- {
- if ( userData.hasvalue( "Action" ) ) // pkgGpgCheck report provided an user error action
- {
- resolveSignatureErrorAction( userData.get( "Action", repo::DownloadResolvableReport::ABORT ) );
- }
- else if ( userData.haskey( "Action" ) ) // pkgGpgCheck requests the default problem report (wo. details)
- {
- defaultReportSignatureError( res );
- }
- else // no advice from user => usedefaults
- {
- switch ( res )
- {
- case RpmDb::CHK_OK: // Signature is OK
- break;
-
- case RpmDb::CHK_NOKEY: // Public key is unavailable
- case RpmDb::CHK_NOTFOUND: // Signature is unknown type
- case RpmDb::CHK_FAIL: // Signature does not verify
- case RpmDb::CHK_NOTTRUSTED: // Signature is OK, but key is not trusted
- case RpmDb::CHK_ERROR: // File does not exist or can't be opened
- default:
- // report problem (w. details), throw if to abort, else retry/ignore
- defaultReportSignatureError( res, str::Str() << userData.get<RpmDb::CheckPackageDetail>( "CheckPackageDetail" ) );
- break;
- }
- }
- }
- }
}
catch ( const UserRequestException & excpt )
{
#include "zypp/base/String.h"
#include "zypp/base/Regex.h"
-#include "zypp/ZYppFactory.h"
#include "zypp/ZConfig.h"
#include "zypp/Target.h"
#include "zypp/Arch.h"
///////////////////////////////////////////////////////////////////
namespace
{
- inline std::string getReleaseverString()
- {
- std::string ret( env::ZYPP_REPO_RELEASEVER() );
- if( ret.empty() )
- {
- Target_Ptr trg( getZYpp()->getTarget() );
- if ( trg )
- ret = trg->distributionVersion();
- else
- ret = Target::distributionVersion( Pathname()/*guess*/ );
- }
- else
- WAR << "ENV overwrites $releasever=" << ret << endl;
-
- return ret;
- }
-
/** \brief Provide lazy initialized repo variables
*/
struct RepoVars : private zypp::base::NonCopyable
void assertReleaseverStr() const
{
- // check for changing releasever (bnc#943563)
- std::string check( getReleaseverString() );
- if ( check != _releasever )
+ if ( _releasever.empty() )
{
- _releasever = std::move(check);
+ _releasever = env::ZYPP_REPO_RELEASEVER();
+ if( _releasever.empty() )
+ _releasever = Target::distributionVersion( Pathname()/*guess*/ );
+ else
+ WAR << "ENV overwrites $releasever=" << _releasever << endl;
+
// split major/minor for SLE
std::string::size_type pos = _releasever.find( "." );
if ( pos == std::string::npos )
std::string Solvable::asUserString() const\
{
NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
- return str::form( "%s-%s.%s (%s)",
+ return str::form( "%s-%s.%s(%s)",
IdString( _solvable->name ).c_str(),
IdString( _solvable->evr ).c_str(),
IdString( _solvable->arch ).c_str(),
}
//---------------------------------------------------------------------------
-// forward flags too SATResolver
-#define ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER, ZVARNAME, ZVARDEFAULT ) \
- void Resolver::ZSETTER( TriBool state_r ) \
- { _satResolver->ZVARNAME = indeterminate(state_r) ? ZVARDEFAULT : bool(state_r); } \
- bool Resolver::ZGETTER() const \
- { return _satResolver->ZVARNAME; } \
-
-ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade, dupAllowDowngrade, _dup_allowdowngrade, true )
-ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange, dupAllowNameChange, _dup_allownamechange, true )
-ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange, dupAllowArchChange, _dup_allowarchchange, true )
-ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange, dupAllowVendorChange, _dup_allowvendorchange, true )
-
-#undef ZOLV_FLAG_TRIBOOL
-//---------------------------------------------------------------------------
void Resolver::setAllowVendorChange( TriBool state_r )
{
//----------------------------------------------------------------------------
// undo
+
void Resolver::undo()
{
UndoTransact info(ResStatus::APPL_LOW);
void setCleandepsOnRemove( TriBool state_r );
//@}
-#define ZOLV_FLAG_TRIBOOL( ZSETTER, ZGETTER ) \
- void ZSETTER( TriBool state_r ); \
- bool ZGETTER() const; \
-
- ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade, dupAllowDowngrade )
- ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange, dupAllowNameChange )
- ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange, dupAllowArchChange )
- ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange, dupAllowVendorChange )
-
-#undef ZOLV_FLAG_TRIBOOL
-
ResolverProblemList problems() const;
void applySolutions( const ProblemSolutionList & solutions );
, _allowarchchange(false)
, _allowvendorchange(ZConfig::instance().solver_allowVendorChange())
, _allowuninstall(false)
- , _dup_allowdowngrade( true )
- , _dup_allownamechange( true )
- , _dup_allowarchchange( true )
- , _dup_allowvendorchange( true )
, _updatesystem(false)
, _noupdateprovide(false)
, _dosplitprovides(true)
solver_set_flag(_solv, SOLVER_FLAG_SPLITPROVIDES, _dosplitprovides);
solver_set_flag(_solv, SOLVER_FLAG_NO_UPDATEPROVIDE, _noupdateprovide);
solver_set_flag(_solv, SOLVER_FLAG_IGNORE_RECOMMENDED, _onlyRequires);
- solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
- solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
- solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
- solver_set_flag(_solv, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, _dup_allowvendorchange );
-#if 1
+
#define HACKENV(X,D) solver_set_flag(_solv, X, env::HACKENV( #X, D ) );
- HACKENV( SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, _dup_allowdowngrade );
- HACKENV( SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, _dup_allownamechange );
- HACKENV( SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, _dup_allowarchchange );
- HACKENV( SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE,_dup_allowvendorchange );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, true );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE, true );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE,true );
+ HACKENV( SOLVER_FLAG_DUP_ALLOW_NAMECHANGE, true );
#undef HACKENV
-#endif
+
sat::Pool::instance().prepareForSolving();
// Solve !
// solve results
PoolItemList _result_items_to_install;
PoolItemList _result_items_to_remove;
- public:
- bool _fixsystem:1; // repair errors in rpm dependency graph
- bool _allowdowngrade:1; // allow to downgrade installed solvable
- bool _allowarchchange:1; // allow to change architecture of installed solvables
- bool _allowvendorchange:1; // allow to change vendor of installed solvables
- bool _allowuninstall:1; // allow removal of installed solvables
- bool _updatesystem:1; // update
- bool _noupdateprovide:1; // true: update packages needs not to provide old package
- bool _dosplitprovides:1; // true: consider legacy split provides
- bool _onlyRequires:1; // true: consider required packages only
- bool _ignorealreadyrecommended:1; // true: ignore recommended packages that were already recommended by the installed packages
- bool _distupgrade:1;
- bool _distupgrade_removeunsupported:1;
- bool _dup_allowdowngrade:1; // dup mode: allow to downgrade installed solvable
- bool _dup_allownamechange:1; // dup mode: allow to change name of installed solvable
- bool _dup_allowarchchange:1; // dup mode: allow to change architecture of installed solvables
- bool _dup_allowvendorchange:1; // dup mode: allow to change vendor of installed solvables
- bool _solveSrcPackages:1; // false: generate no job rule for source packages selected in the pool
- bool _cleandepsOnRemove:1; // whether removing a package should also remove no longer needed requirements
- private:
+ bool _fixsystem; // repair errors in rpm dependency graph
+ bool _allowdowngrade; // allow to downgrade installed solvable
+ bool _allowarchchange; // allow to change architecture of installed solvables
+ bool _allowvendorchange; // allow to change vendor of installed solvables
+ bool _allowuninstall; // allow removal of installed solvables
+ bool _updatesystem; // update
+ bool _noupdateprovide; // true: update packages needs not to provide old package
+ bool _dosplitprovides; // true: consider legacy split provides
+ bool _onlyRequires; // true: consider required packages only
+ bool _ignorealreadyrecommended; // true: ignore recommended packages that were already recommended by the installed packages
+ bool _distupgrade;
+ bool _distupgrade_removeunsupported;
+ bool _solveSrcPackages; // false: generate no job rule for source packages selected in the pool
+ bool _cleandepsOnRemove; // whether removing a package should also remove no longer needed requirements
+
// ---------------------------------- methods
std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
void resetItemTransaction (PoolItem item);
#include "zypp/sat/Pool.h"
#include "zypp/sat/Transaction.h"
-#include "zypp/PluginExecutor.h"
+#include "zypp/PluginScript.h"
using namespace std;
} // namespace
///////////////////////////////////////////////////////////////////
+ /** Helper for commit plugin execution.
+ * \ingroup g_RAII
+ */
+ class CommitPlugins : private base::NonCopyable
+ {
+ public:
+ /** Default ctor: Empty plugin list */
+ CommitPlugins()
+ {}
+
+ /** Dtor: Send PLUGINEND message and close plugins. */
+ ~CommitPlugins()
+ {
+ if ( ! _scripts.empty() )
+ send( PluginFrame( "PLUGINEND" ) );
+ // ~PluginScript will disconnect all remaining plugins!
+ }
+
+ /** Whether no plugins are waiting */
+ bool empty() const
+ { return _scripts.empty(); }
+
+
+ /** Send \ref PluginFrame to all open plugins.
+ * Failed plugins are removed from the execution list.
+ */
+ void send( const PluginFrame & frame_r )
+ {
+ DBG << "+++++++++++++++ send " << frame_r << endl;
+ for ( auto it = _scripts.begin(); it != _scripts.end(); )
+ {
+ doSend( *it, frame_r );
+ if ( it->isOpen() )
+ ++it;
+ else
+ it = _scripts.erase( it );
+ }
+ DBG << "--------------- send " << frame_r << endl;
+ }
+
+ /** Find and launch plugins sending PLUGINSTART message.
+ *
+ * If \a path_r is a directory all executable files whithin are
+ * expected to be plugins. Otherwise \a path_r must point to an
+ * executable plugin.
+ */
+ void load( const Pathname & path_r )
+ {
+ PathInfo pi( path_r );
+ DBG << "+++++++++++++++ load " << pi << endl;
+ if ( pi.isDir() )
+ {
+ std::list<Pathname> entries;
+ if ( filesystem::readdir( entries, pi.path(), false ) != 0 )
+ {
+ WAR << "Plugin dir is not readable: " << pi << endl;
+ return;
+ }
+ for_( it, entries.begin(), entries.end() )
+ {
+ PathInfo pii( *it );
+ if ( pii.isFile() && pii.userMayRX() )
+ doLoad( pii );
+ }
+ }
+ else if ( pi.isFile() )
+ {
+ if ( pi.userMayRX() )
+ doLoad( pi );
+ else
+ WAR << "Plugin file is not executable: " << pi << endl;
+ }
+ else
+ {
+ WAR << "Plugin path is neither dir nor file: " << pi << endl;
+ }
+ DBG << "--------------- load " << pi << endl;
+ }
+
+ private:
+ /** Send \ref PluginFrame and expect valid answer (ACK|_ENOMETHOD).
+ * Upon invalid answer or error, close the plugin. and remove it from the
+ * execution list.
+ * \returns the received \ref PluginFrame (empty Frame upon Exception)
+ */
+ PluginFrame doSend( PluginScript & script_r, const PluginFrame & frame_r )
+ {
+ PluginFrame ret;
+
+ try {
+ script_r.send( frame_r );
+ ret = script_r.receive();
+ }
+ catch( const zypp::Exception & e )
+ { ZYPP_CAUGHT(e); }
+
+ if ( ! ( ret.isAckCommand() || ret.isEnomethodCommand() ) )
+ {
+ WAR << "Bad plugin response from " << script_r << endl;
+ WAR << dump(ret) << endl;
+ script_r.close();
+ }
+
+ return ret;
+ }
+
+ /** Launch a plugin sending PLUGINSTART message. */
+ void doLoad( const PathInfo & pi_r )
+ {
+ MIL << "Load plugin: " << pi_r << endl;
+ try {
+ PluginScript plugin( pi_r.path() );
+ plugin.open();
+
+ PluginFrame frame( "PLUGINBEGIN" );
+ if ( ZConfig::instance().hasUserData() )
+ frame.setHeader( "userdata", ZConfig::instance().userData() );
+
+ doSend( plugin, frame ); // closes on error
+ if ( plugin.isOpen() )
+ _scripts.push_back( plugin );
+ }
+ catch( const zypp::Exception & e )
+ {
+ WAR << "Failed to load plugin " << pi_r << endl;
+ }
+ }
+
+ private:
+ std::list<PluginScript> _scripts;
+ };
+
+ void testCommitPlugins( const Pathname & path_r ) // for testing only
+ {
+ USR << "+++++" << endl;
+ {
+ CommitPlugins pl;
+ pl.load( path_r );
+ USR << "=====" << endl;
+ }
+ USR << "-----" << endl;
+ }
+
///////////////////////////////////////////////////////////////////
namespace
{
cmd << " > '" << tmpsolv.path() << "'";
- MIL << "Executing: " << cmd << endl;
+ MIL << "Executing: " << cmd.str() << endl;
ExternalProgram prog( cmd.str(), ExternalProgram::Stderr_To_Stdout );
cmd << endl;
// We keep it.
guard.resetDispose();
- // system-hook: Finally send notification to plugins
- if ( root() == "/" )
+ // Finally send notification to plugins
+ // NOTE: quick hack looking for spacewalk plugin only
{
- PluginExecutor plugins;
- plugins.load( ZConfig::instance().pluginsPath()/"system" );
- if ( plugins )
- plugins.send( PluginFrame( "PACKAGESETCHANGED" ) );
+ Pathname script( Pathname::assertprefix( _root, ZConfig::instance().pluginsPath()/"system/spacewalk" ) );
+ if ( PathInfo( script ).isX() )
+ try {
+ PluginScript spacewalk( script );
+ spacewalk.open();
+
+ PluginFrame notify( "PACKAGESETCHANGED" );
+ spacewalk.send( notify );
+
+ PluginFrame ret( spacewalk.receive() );
+ MIL << ret << endl;
+ if ( ret.command() == "ERROR" )
+ ret.writeTo( WAR ) << endl;
+ }
+ catch ( const Exception & excpt )
+ {
+ WAR << excpt.asUserHistory() << endl;
+ }
}
}
return build_rpm_solv;
///////////////////////////////////////////////////////////////////
// Prepare execution of commit plugins:
///////////////////////////////////////////////////////////////////
- PluginExecutor commitPlugins;
+ CommitPlugins commitPlugins;
if ( root() == "/" && ! policy_r.dryRun() )
{
- commitPlugins.load( ZConfig::instance().pluginsPath()/"commit" );
+ Pathname plugindir( Pathname::assertprefix( _root, ZConfig::instance().pluginsPath()/"commit" ) );
+ commitPlugins.load( plugindir );
}
- if ( commitPlugins )
+ if ( ! commitPlugins.empty() )
commitPlugins.send( transactionPluginFrame( "COMMITBEGIN", steps ) );
///////////////////////////////////////////////////////////////////
// Write out a testcase if we're in dist upgrade mode.
///////////////////////////////////////////////////////////////////
- if ( pool_r.resolver().upgradeMode() || pool_r.resolver().upgradingRepos() )
+ if ( getZYpp()->resolver()->upgradeMode() )
{
if ( ! policy_r.dryRun() )
{
///////////////////////////////////////////////////////////////////
// Send result to commit plugins:
///////////////////////////////////////////////////////////////////
- if ( commitPlugins )
+ if ( ! commitPlugins.empty() )
commitPlugins.send( transactionPluginFrame( "COMMITEND", steps ) );
///////////////////////////////////////////////////////////////////
// COMMIT internal
//
///////////////////////////////////////////////////////////////////
- namespace
- {
- struct NotifyAttemptToModify
- {
- NotifyAttemptToModify( ZYppCommitResult & result_r ) : _result( result_r ) {}
-
- void operator()()
- { if ( _guard ) { _result.attemptToModify( true ); _guard = false; } }
-
- TrueBool _guard;
- ZYppCommitResult & _result;
- };
- } // namespace
-
void TargetImpl::commit( const ZYppCommitPolicy & policy_r,
CommitPackageCache & packageCache_r,
ZYppCommitResult & result_r )
ZYppCommitResult::TransactionStepList & steps( result_r.rTransactionStepList() );
MIL << "TargetImpl::commit(<list>" << policy_r << ")" << steps.size() << endl;
- // Send notification once upon 1st call to rpm
- NotifyAttemptToModify attemptToModify( result_r );
-
bool abort = false;
-
RpmPostTransCollector postTransCollector( _root );
std::vector<sat::Solvable> successfullyInstalledPackages;
TargetImpl::PoolItemList remaining;
if (policy_r.rpmExcludeDocs()) flags |= rpm::RPMINST_EXCLUDEDOCS;
if (policy_r.rpmNoSignature()) flags |= rpm::RPMINST_NOSIGNATURE;
- attemptToModify();
try
{
progress.tryLevel( target::rpm::InstallResolvableReport::RPM_NODEPS_FORCE );
rpm::RpmInstFlags flags( policy_r.rpmInstFlags() & rpm::RPMINST_JUSTDB );
flags |= rpm::RPMINST_NODEPS;
if (policy_r.dryRun()) flags |= rpm::RPMINST_TEST;
-
- attemptToModify();
try
{
rpm().removePackage( p, flags );
// lambda receives progress trigger and translates into report
auto sendProgress = [&]( const ProgressData & progress_r )->bool {
if ( ! report->progress( progress_r, cb.noFilelist() ) )
- {
- progress.noSend(); // take care progress DTOR does not trigger a final report (2nd exeption)
ZYPP_THROW( AbortRequestException() );
- }
return true;
};
progress.sendTo( sendProgress );
*
*/
#include "librpm.h"
-extern "C"
-{
-#include <rpm/rpmcli.h>
-#include <rpm/rpmlog.h>
-}
+
#include <cstdlib>
#include <cstdio>
#include <ctime>
}
///////////////////////////////////////////////////////////////////
-namespace
-{
- struct RpmlogCapture : public std::string
- {
- RpmlogCapture()
- { rpmlog()._cap = this; }
-
- ~RpmlogCapture()
- { rpmlog()._cap = nullptr; }
-
- private:
- struct Rpmlog
- {
- Rpmlog()
- : _cap( nullptr )
- {
- rpmlogSetCallback( rpmLogCB, this );
- rpmSetVerbosity( RPMLOG_INFO );
- _f = ::fopen( "/dev/null","w");
- rpmlogSetFile( _f );
- }
-
- ~Rpmlog()
- { if ( _f ) ::fclose( _f ); }
-
- static int rpmLogCB( rpmlogRec rec_r, rpmlogCallbackData data_r )
- { return reinterpret_cast<Rpmlog*>(data_r)->rpmLog( rec_r ); }
-
- int rpmLog( rpmlogRec rec_r )
- {
- if ( _cap ) (*_cap) = rpmlogRecMessage( rec_r );
- return RPMLOG_DEFAULT;
- }
-
- FILE * _f;
- std::string * _cap;
- };
-
- static Rpmlog & rpmlog()
- { static Rpmlog _rpmlog; return _rpmlog; }
- };
-
-
-} // namespace
-///////////////////////////////////////////////////////////////////
//
// METHOD NAME : RpmDb::checkPackage
-// METHOD TYPE : RpmDb::CheckPackageResult
+// METHOD TYPE : RpmDb::checkPackageResult
//
-RpmDb::CheckPackageResult RpmDb::checkPackage( const Pathname & path_r, CheckPackageDetail & detail_r )
+RpmDb::checkPackageResult RpmDb::checkPackage( const Pathname & path_r )
{
PathInfo file( path_r );
if ( ! file.isFile() )
::Fclose( fd );
return CHK_ERROR;
}
+
rpmts ts = ::rpmtsCreate();
::rpmtsSetRootDir( ts, root().asString().c_str() );
::rpmtsSetVSFlags( ts, RPMVSF_DEFAULT );
-
- rpmQVKArguments_s qva;
- memset( &qva, 0, sizeof(rpmQVKArguments_s) );
- qva.qva_flags = (VERIFY_DIGEST|VERIFY_SIGNATURE);
-
- RpmlogCapture vresult;
- int res = ::rpmVerifySignatures( &qva, ts, fd, path_r.basename().c_str() );
-
+ int res = ::rpmReadPackageFile( ts, fd, path_r.asString().c_str(), NULL );
ts = rpmtsFree(ts);
- ::Fclose( fd );
+ ::Fclose( fd );
- if ( res == 0 )
+ switch ( res )
{
- detail_r.push_back( CheckPackageDetail::value_type( CHK_OK, std::move(vresult) ) );
+ case RPMRC_OK:
return CHK_OK;
+ break;
+ case RPMRC_NOTFOUND:
+ WAR << "Signature is unknown type. " << file << endl;
+ return CHK_NOTFOUND;
+ break;
+ case RPMRC_FAIL:
+ WAR << "Signature does not verify. " << file << endl;
+ return CHK_FAIL;
+ break;
+ case RPMRC_NOTTRUSTED:
+ WAR << "Signature is OK, but key is not trusted. " << file << endl;
+ return CHK_NOTTRUSTED;
+ break;
+ case RPMRC_NOKEY:
+ WAR << "Public key is unavailable. " << file << endl;
+ return CHK_NOKEY;
+ break;
}
-
- // results per line...
- WAR << vresult;
- std::vector<std::string> lines;
- str::split( vresult, std::back_inserter(lines), "\n" );
- unsigned count[6] = { 0, 0, 0, 0, 0, 0 };
-
- for ( unsigned i = 1; i < lines.size(); ++i )
- {
- std::string & line( lines[i] );
- CheckPackageResult lineres = CHK_ERROR;
- if ( line.find( ": OK" ) != std::string::npos )
- { lineres = CHK_OK; }
- else if ( line.find( ": NOKEY" ) != std::string::npos )
- { lineres = CHK_NOKEY; }
- else if ( line.find( ": BAD" ) != std::string::npos )
- { lineres = CHK_FAIL; }
- else if ( line.find( ": UNKNOWN" ) != std::string::npos )
- { lineres = CHK_NOTFOUND; }
- else if ( line.find( ": NOTRUSTED" ) != std::string::npos )
- { lineres = CHK_NOTTRUSTED; }
-
- ++count[lineres];
- detail_r.push_back( CheckPackageDetail::value_type( lineres, std::move(line) ) );
- }
-
- CheckPackageResult ret = CHK_ERROR;
- if ( count[CHK_FAIL] )
- ret = CHK_FAIL;
-
- else if ( count[CHK_NOTFOUND] )
- ret = CHK_NOTFOUND;
-
- else if ( count[CHK_NOKEY] )
- ret = CHK_NOKEY;
-
- else if ( count[CHK_NOTTRUSTED] )
- ret = CHK_NOTTRUSTED;
-
- return ret;
+ ERR << "Error reading header." << file << endl;
+ return CHK_ERROR;
}
-RpmDb::CheckPackageResult RpmDb::checkPackage( const Pathname & path_r )
-{ CheckPackageDetail dummy; return checkPackage( path_r, dummy ); }
-
-
// determine changed files of installed package
bool
RpmDb::queryChangedFiles(FileList & fileList, const string& packageName)
_backuppath = path;
}
-std::ostream & operator<<( std::ostream & str, RpmDb::CheckPackageResult obj )
-{
- switch ( obj )
- {
-#define OUTS(E,S) case RpmDb::E: return str << "["<< (unsigned)obj << "-"<< S << "]"; break
- // translators: possible rpm package signature check result [brief]
- OUTS( CHK_OK, _("Signature is OK") );
- // translators: possible rpm package signature check result [brief]
- OUTS( CHK_NOTFOUND, _("Unknown type of signature") );
- // translators: possible rpm package signature check result [brief]
- OUTS( CHK_FAIL, _("Signature does not verify") );
- // translators: possible rpm package signature check result [brief]
- OUTS( CHK_NOTTRUSTED, _("Signature is OK, but key is not trusted") );
- // translators: possible rpm package signature check result [brief]
- OUTS( CHK_NOKEY, _("Signatures public key is not available") );
- // translators: possible rpm package signature check result [brief]
- OUTS( CHK_ERROR, _("File does not exist or signature can't be checked") );
-#undef OUTS
- }
- return str << "UnknowSignatureCheckError("+str::numstring(obj)+")";
-}
-
-std::ostream & operator<<( std::ostream & str, const RpmDb::CheckPackageDetail & obj )
-{
- for ( const auto & el : obj )
- str << el.second << endl;
- return str;
-}
-
} // namespace rpm
} // namespace target
} // namespace zypp
* checkPackage result
* @see checkPackage
* */
- enum CheckPackageResult
+ enum checkPackageResult
{
CHK_OK = 0, /*!< Signature is OK. */
CHK_NOTFOUND = 1, /*!< Signature is unknown type. */
CHK_ERROR = 5 /*!< File does not exist or can't be opened. */
};
- /** Detailed rpm signature check log messages
- * A single multiline message if \ref CHK_OK. Otherwise each message line
- * together with it's \ref CheckPackageResult.
- */
- struct CheckPackageDetail : std::vector<std::pair<CheckPackageResult,std::string>>
- {};
-
/**
* Check signature of rpm file on disk.
*
- * @param path_r which file to check
- * @param detail_r Return detailed rpm log messages
+ * @param filename which file to check
*
- * @return CheckPackageResult
+ * @return checkPackageResult
*/
- CheckPackageResult checkPackage( const Pathname & path_r, CheckPackageDetail & detail_r );
- /** \overload Ignoring the \a datails_r */
- CheckPackageResult checkPackage( const Pathname & path_r );
+ checkPackageResult checkPackage( const Pathname & path_r );
/** install rpm package
*
void doRebuildDatabase(callback::SendReport<RebuildDBReport> & report);
};
-/** \relates RpmDb::CheckPackageResult Stream output */
-std::ostream & operator<<( std::ostream & str, RpmDb::CheckPackageResult obj );
-
-/** \relates RpmDb::checkPackageDetail Stream output */
-std::ostream & operator<<( std::ostream & str, const RpmDb::CheckPackageDetail & obj );
-
} // namespace rpm
} // namespace target
} // namespace zypp
//
std::ostream & RpmHeader::dumpOn( std::ostream & str ) const
{
- str << BinHeader::dumpOn( str ) << '{' << tag_name() << "-";
- if ( tag_epoch() != 0 )
- str << tag_epoch() << ":";
- str << tag_version()
- << (tag_release().empty()?"":(std::string("-")+tag_release()))
- << ( isSrc() ? ".src}" : "}");
- return str;
+ return BinHeader::dumpOn( str ) << '{' << tag_name() << "-"
+ << (tag_epoch()==0?"":(tag_epoch()+":"))
+ << tag_version()
+ << (tag_release().empty()?"":(std::string("-")+tag_release()))
+ << ( isSrc() ? ".src}" : "}");
}
config("rx_username", "^([" a_zA_Z "0-9!$&'\\(\\)*+=,;~\\._-]|%[a-fA-F0-9]{2})+$");
config("rx_password", "^([" a_zA_Z "0-9!$&'\\(\\)*+=,:;~\\._-]|%[a-fA-F0-9]{2})+$");
- config("rx_pathname", "^([" a_zA_Z "0-9!$&'\\(\\){}*+=,:@/~\\._-]|%[a-fA-F0-9]{2})+$");
- config("rx_pathparams", "^([" a_zA_Z "0-9!$&'\\(\\){}*+=,:;@/~\\._-]|%[a-fA-F0-9]{2})+$");
+ config("rx_pathname", "^([" a_zA_Z "0-9!$&'\\(\\)*+=,:@/~\\._-]|%[a-fA-F0-9]{2})+$");
+ config("rx_pathparams", "^([" a_zA_Z "0-9!$&'\\(\\)*+=,:;@/~\\._-]|%[a-fA-F0-9]{2})+$");
- config("rx_querystr", "^([" a_zA_Z "0-9!$&'\\(\\){}*+=,:;@/?~\\._-]|%[a-fA-F0-9]{2})+$");
- config("rx_fragment", "^([" a_zA_Z "0-9!$&'\\(\\){}*+=,:;@/?~\\._-]|%[a-fA-F0-9]{2})+$");
+ config("rx_querystr", "^([" a_zA_Z "0-9!$&'\\(\\)*+=,:;@/?~\\._-]|%[a-fA-F0-9]{2})+$");
+ config("rx_fragment", "^([" a_zA_Z "0-9!$&'\\(\\)*+=,:;@/?~\\._-]|%[a-fA-F0-9]{2})+$");
}
std::string skip("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789.~_-");
- static const std::string more(URL_SAFE_CHARS); // ":/?#[]@!$&'()*+,;="
+ std::string more(":/?#[]@!$&'()*+,;=");
size_t beg, pos, len;
std::string out;
#include <map>
/** Characters that are safe for URL without percent-encoding. */
-#define URL_SAFE_CHARS ":/?#[]@!$&'(){}*+,;="
+#define URL_SAFE_CHARS ":/?#[]@!$&'()*+,;="
//////////////////////////////////////////////////////////////////////
namespace zypp