Imported Upstream version 16.4.3 upstream/16.4.3
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 2 Sep 2019 07:11:59 +0000 (16:11 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 2 Sep 2019 07:11:59 +0000 (16:11 +0900)
VERSION.cmake
package/libzypp.changes
tests/zypp/Target_test.cc
zypp/PublicKey.cc
zypp/TmpPath.h
zypp/media/TransferSettings.cc
zypp/sat/Solvable.cc
zypp/target/TargetImpl.cc
zypp/zypp_detail/ZYppImpl.cc

index 19b1ab8..19be5e8 100644 (file)
@@ -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)
 #=======
index c2f66e0..147347f 100644 (file)
@@ -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)
index cfb6ecd..e7d8985 100644 (file)
@@ -1,5 +1,5 @@
-
 #include <iostream>
+#include <fstream>
 #include <list>
 #include <string>
 
@@ -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");
index fa17b79..3b9302d 100644 (file)
@@ -24,9 +24,6 @@
 #include "zypp/base/Exception.h"
 #include "zypp/base/LogTools.h"
 #include "zypp/Date.h"
-#include "zypp/TmpPath.h"
-
-#include <ctime>
 
 /** \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[] =
index 39f6371..8d84bfd 100644 (file)
@@ -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
index f5edfb6..81262c7 100644 (file)
@@ -95,6 +95,7 @@ void TransferSettings::reset()
 
 void TransferSettings::addHeader( const std::string &header )
 {
+  if ( ! header.empty() )
     _impl->_headers.push_back(header);
 }
 
index 5e6f051..967f3d5 100644 (file)
@@ -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.
        */
index 74f7644..4ae4b5d 100644 (file)
@@ -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) );
     }
 
     ///////////////////////////////////////////////////////////////////
index 8af290a..3446014 100644 (file)
@@ -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
 ///////////////////////////////////////////////////////////////////