From 00e29839bc7da21275438adb8c8fc73bfa295460 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Mon, 2 Sep 2019 16:11:59 +0900 Subject: [PATCH] Imported Upstream version 16.4.3 --- VERSION.cmake | 4 ++-- package/libzypp.changes | 7 +++++++ tests/zypp/Target_test.cc | 14 +++++++++++--- zypp/PublicKey.cc | 9 ++++----- zypp/TmpPath.h | 4 ++++ zypp/media/TransferSettings.cc | 1 + zypp/sat/Solvable.cc | 4 ++-- zypp/target/TargetImpl.cc | 26 +++++++++++++++++++++----- zypp/zypp_detail/ZYppImpl.cc | 12 ++++++++---- 9 files changed, 60 insertions(+), 21 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index 19b1ab8..19be5e8 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -61,8 +61,8 @@ SET(LIBZYPP_MAJOR "16") SET(LIBZYPP_COMPATMINOR "0") SET(LIBZYPP_MINOR "4") -SET(LIBZYPP_PATCH "2") +SET(LIBZYPP_PATCH "3") # -# LAST RELEASED: 16.4.2 (0) +# LAST RELEASED: 16.4.3 (0) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff --git a/package/libzypp.changes b/package/libzypp.changes index c2f66e0..147347f 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Mon Feb 20 10:10:43 CET 2017 - ma@suse.de + +- PublicKey: Create tmpdirs inside ZYpp::tmpPath (bsc#926844) +- Don't create AnonymousUniqueId in chroot (bsc#1024741) +- version 16.4.3 (0) + +------------------------------------------------------------------- Tue Feb 14 12:07:14 CET 2017 - ma@suse.de - dumpAsXmlOnL: xml escape node content (bsc#1024909) diff --git a/tests/zypp/Target_test.cc b/tests/zypp/Target_test.cc index cfb6ecd..e7d8985 100644 --- a/tests/zypp/Target_test.cc +++ b/tests/zypp/Target_test.cc @@ -1,5 +1,5 @@ - #include +#include #include #include @@ -34,9 +34,17 @@ BOOST_AUTO_TEST_CASE(target_test) z->initializeTarget( tmp.path() ); - BOOST_CHECK( ! z->target()->anonymousUniqueId().empty() ); + // bsc#1024741: Omit creating a new uid for chrooted systems (if it already has one, fine) + BOOST_CHECK( ! PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").isExist() ); + // create an artificial one + { + Pathname f( tmp.path() / "/var/lib/zypp" ); + filesystem::assert_dir( f ); + std::ofstream o( (f/"AnonymousUniqueId").c_str() ); + o << "AnonymousUniqueId"; + } BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").isExist() ); - BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").size() > 0 ); + BOOST_CHECK_EQUAL( z->target()->anonymousUniqueId(), "AnonymousUniqueId" ); // now check the base product BOOST_CHECK_EQUAL( z->target()->targetDistribution(), "sle-10-i586"); diff --git a/zypp/PublicKey.cc b/zypp/PublicKey.cc index fa17b79..3b9302d 100644 --- a/zypp/PublicKey.cc +++ b/zypp/PublicKey.cc @@ -24,9 +24,6 @@ #include "zypp/base/Exception.h" #include "zypp/base/LogTools.h" #include "zypp/Date.h" -#include "zypp/TmpPath.h" - -#include /** \todo Fix duplicate define in PublicKey/KeyRing */ #define GPG_BINARY "/usr/bin/gpg2" @@ -344,13 +341,15 @@ namespace zypp { return _hiddenKeys; } protected: + std::string _initHomeDir() ///< readFromFile helper to prepare the 'gpg --homedir' + { Pathname ret( zypp::myTmpDir() / "PublicKey" ); filesystem::assert_dir( ret ); return ret.asString(); } + void readFromFile() { PathInfo info( _dataFile.path() ); MIL << "Reading pubkey from " << info.path() << " of size " << info.size() << " and sha1 " << filesystem::checksum(info.path(), "sha1") << endl; - static filesystem::TmpDir dir; - std::string tmppath( dir.path().asString() ); + static std::string tmppath( _initHomeDir() ); std::string datapath( _dataFile.path().asString() ); const char* argv[] = diff --git a/zypp/TmpPath.h b/zypp/TmpPath.h index 39f6371..8d84bfd 100644 --- a/zypp/TmpPath.h +++ b/zypp/TmpPath.h @@ -196,6 +196,10 @@ namespace zypp { /////////////////////////////////////////////////////////////////// } // namespace filesystem + + /** Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded) */ + Pathname myTmpDir(); // implemented in ZYppImpl.cc + } // namespace zypp #endif // ZYPP_TMPPATH_H diff --git a/zypp/media/TransferSettings.cc b/zypp/media/TransferSettings.cc index f5edfb6..81262c7 100644 --- a/zypp/media/TransferSettings.cc +++ b/zypp/media/TransferSettings.cc @@ -95,6 +95,7 @@ void TransferSettings::reset() void TransferSettings::addHeader( const std::string &header ) { + if ( ! header.empty() ) _impl->_headers.push_back(header); } diff --git a/zypp/sat/Solvable.cc b/zypp/sat/Solvable.cc index 5e6f051..967f3d5 100644 --- a/zypp/sat/Solvable.cc +++ b/zypp/sat/Solvable.cc @@ -525,7 +525,7 @@ namespace zypp /////////////////////////////////////////////////////////////////// namespace { - /** Expand \ref Capability and call \c fnc_r for each namescpace:language + /** Expand \ref Capability and call \c fnc_r for each namespace:language * dependency. Return #invocations of fnc_r, negative if fnc_r returned * false to indicate abort. */ @@ -566,7 +566,7 @@ namespace zypp return 0; } - /** Expand \ref Capability and call \c fnc_r for each namescpace:language + /** Expand \ref Capability and call \c fnc_r for each namespace:language * dependency. Return #invocations of fnc_r, negative if fnc_r returned * false to indicate abort. */ diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 74f7644..4ae4b5d 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -751,9 +751,11 @@ namespace zypp void TargetImpl::createAnonymousId() const { + // bsc#1024741: Omit creating a new uid for chrooted systems (if it already has one, fine) + if ( root() != "/" ) + return; - // create the anonymous unique id - // this value is used for statistics + // Create the anonymous unique id, used for download statistics Pathname idpath( home() / "AnonymousUniqueId"); try @@ -1709,7 +1711,7 @@ namespace zypp } return std::string(); } - } // namescpace + } // namespace /////////////////////////////////////////////////////////////////// Product::constPtr TargetImpl::baseProduct() const @@ -1830,15 +1832,29 @@ namespace zypp } /////////////////////////////////////////////////////////////////// + namespace + { + std::string guessAnonymousUniqueId( const Pathname & root_r ) + { + // bsc#1024741: Omit creating a new uid for chrooted systems (if it already has one, fine) + std::string ret( firstNonEmptyLineIn( root_r / "/var/lib/zypp/AnonymousUniqueId" ) ); + if ( ret.empty() && root_r != "/" ) + { + // if it has nonoe, use the outer systems one + ret = firstNonEmptyLineIn( "/var/lib/zypp/AnonymousUniqueId" ); + } + return ret; + } + } std::string TargetImpl::anonymousUniqueId() const { - return firstNonEmptyLineIn( home() / "AnonymousUniqueId" ); + return guessAnonymousUniqueId( root() ); } // static version: std::string TargetImpl::anonymousUniqueId( const Pathname & root_r ) { - return firstNonEmptyLineIn( staticGuessRoot(root_r) / "/var/lib/zypp/AnonymousUniqueId" ); + return guessAnonymousUniqueId( staticGuessRoot(root_r) ); } /////////////////////////////////////////////////////////////////// diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index 8af290a..3446014 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -204,10 +204,7 @@ namespace zypp { _home_path = path; } Pathname ZYppImpl::tmpPath() const - { - static TmpDir zypp_tmp_dir( TmpPath::defaultLocation(), "zypp." ); - return zypp_tmp_dir.path(); - } + { return zypp::myTmpDir(); } /****************************************************************** ** @@ -222,6 +219,13 @@ namespace zypp ///////////////////////////////////////////////////////////////// } // namespace zypp_detail /////////////////////////////////////////////////////////////////// + + Pathname myTmpDir() // from TmpPath.h + { + static filesystem::TmpDir _tmpdir( TmpPath::defaultLocation(), "zypp." ); + return _tmpdir.path(); + } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// -- 2.7.4