Hello community,
here is the log from the commit of package libzypp for openSUSE:Factory checked in at 2011-12-02 09:27:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libzypp (Old)
and /work/SRC/openSUSE:Factory/.libzypp.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libzypp", Maintainer is "ma@suse.com"
Changes:
--------
--- /work/SRC/openSUSE:Factory/libzypp/libzypp.changes 2011-11-14 13:17:00.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.libzypp.new/libzypp.changes 2011-12-02 09:27:40.000000000 +0100
@@ -1,0 +2,19 @@
+Mon Nov 28 18:08:42 CET 2011 - ma@suse.de
+
+- Fix and optimize Pathname ctor and provide testcases (bnc#721128)
+- Open all file descriptors with O_CLOEXEC to avoid leaks and races
+- Some improvements to the services documentation
+- Fix RW_pointer comparison with underlying smart pointer type.
+- version 10.3.5 (3)
+
+-------------------------------------------------------------------
+Sun Nov 27 01:13:10 CET 2011 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
+Thu Nov 17 01:13:15 CET 2011 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
Old:
----
libzypp-10.3.4.tar.bz2
New:
----
libzypp-10.3.5.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libzypp.spec ++++++
--- /var/tmp/diff_new_pack.fcjOtT/_old 2011-12-02 09:27:41.000000000 +0100
+++ /var/tmp/diff_new_pack.fcjOtT/_new 2011-12-02 09:27:41.000000000 +0100
@@ -23,7 +23,7 @@
Group: System/Packages
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: Package, Patch, Pattern, and Product Management
-Version: 10.3.4
+Version: 10.3.5
Release: 1
Source: %{name}-%{version}.tar.bz2
Source1: %{name}-rpmlintrc
++++++ libzypp-10.3.4.tar.bz2 -> libzypp-10.3.5.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/VERSION.cmake new/libzypp-10.3.5/VERSION.cmake
--- old/libzypp-10.3.4/VERSION.cmake 2011-11-11 13:47:39.000000000 +0100
+++ new/libzypp-10.3.5/VERSION.cmake 2011-11-29 15:09:29.000000000 +0100
@@ -45,24 +45,24 @@
# ==================================================
#=======
-# - Update version according to your changes,
-# but based on 'LAST RELEASED:' below. I.e
-# there's no need to increase LIBZYPP_MINOR
-# if it already differs from 'LAST RELEASED:'.
-#
# - MOST IMPORTANT:
-# Before you submitt to autobuild, rmember the
-# new version in 'LAST RELEASED:', and add a
-# note in the changes file.
+# - Before you submitt to git:
+# - Remember the new version in 'LAST RELEASED:'
+# - State the new version in the changes file by adding a line
+# "- version MAJOR.MINOR.PATCH (COMPATMINOR)"
+# - Commit changes and version files together in a separate
+# commit using -m 'changes MAJOR.MINOR.PATCH (COMPATMINOR)'
+# - Tag the above commit with 'MAJOR.MINOR.PATCH' using
+# -m "tagging MAJOR.
#
-# - Consider calling ./mkChangelog to edit the
-# changes file. See './mkChangelog -h' for help.
+# - Consider calling ./mkChangelog to assist you.
+# See './mkChangelog -h' for help.
#
SET(LIBZYPP_MAJOR "10")
SET(LIBZYPP_COMPATMINOR "3")
SET(LIBZYPP_MINOR "3")
-SET(LIBZYPP_PATCH "4")
+SET(LIBZYPP_PATCH "5")
#
-# LAST RELEASED: 10.3.4 (3)
+# LAST RELEASED: 10.3.5 (3)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
#=======
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/devel/devel.ma/Basic.cc new/libzypp-10.3.5/devel/devel.ma/Basic.cc
--- old/libzypp-10.3.4/devel/devel.ma/Basic.cc 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/devel/devel.ma/Basic.cc 2011-11-29 15:09:30.000000000 +0100
@@ -11,6 +11,9 @@
#include
#include
#include
+#include "zypp/media/MediaManager.h"
+#include "zypp/MediaSetAccess.h"
+#include "zypp/Fetcher.h"
static const Pathname sysRoot( "/" );
@@ -18,6 +21,190 @@
using namespace zypp;
using namespace zypp::ui;
+
+#include
+
+ struct DownloadProgressReceive : public callback::ReceiveReportmedia::DownloadProgressReport
+ {
+ DownloadProgressReceive()
+ { connect(); }
+#if 0
+ enum Action {
+ ABORT, // abort and return error
+ RETRY, // retry
+ IGNORE // ignore the failure
+ };
+
+ enum Error {
+ NO_ERROR,
+ NOT_FOUND, // the requested Url was not found
+ IO, // IO error
+ ACCESS_DENIED, // user authent. failed while accessing restricted file
+ ERROR // other error
+ };
+#endif
+ virtual void start( const Url & file, Pathname localfile )
+ {
+ USR << "DP +++ " << file << endl;
+ lp = 0;
+ }
+
+ virtual bool progress(int value, const Url &file, double dbps_avg = -1, double dbps_current = -1)
+ {
+ if ( abs(value-lp) >= 20 || value == 100 && lp != 100 )
+ {
+ USR << "DP " << file << " " << value << "%" << endl;
+ lp = value;
+ }
+ return true;
+
+ }
+
+ virtual Action problem( const Url &file , Error error , const std::string &description )
+ {
+ USR << "DP !!! " << file << " (" << error << ")" << endl;
+ return ABORT;
+
+ }
+
+ virtual void finish( const Url &file , Error error , const std::string &reason )
+ {
+ USR << "DP --- " << file << " (" << error << ")" << endl;
+ }
+
+ int lp;
+ };
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ //////////////////////////////////////////////////////////////////
+
+ struct DownloadResolvableReceive : public callback::ReceiveReportrepo::DownloadResolvableReport
+ {
+ DownloadResolvableReceive()
+ { connect(); }
+#if 0
+ enum Action {
+ ABORT, // abort and return error
+ RETRY, // retry
+ IGNORE, // ignore this resolvable but continue
+ };
+
+ enum Error {
+ NO_ERROR,
+ NOT_FOUND, // the requested Url was not found
+ IO, // IO error
+ INVALID // the downloaded file is invalid
+ };
+#endif
+ virtual void start( Resolvable::constPtr resolvable_ptr, const Url &url )
+ {
+ USR << "+++ " << resolvable_ptr << endl;
+ }
+
+
+ // Dowmload delta rpm:
+ // - path below url reported on start()
+ // - expected download size (0 if unknown)
+ // - download is interruptable
+ // - problems are just informal
+ virtual void startDeltaDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual bool progressDeltaDownload( int /*value*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ return true;
+ }
+
+ virtual void problemDeltaDownload( const std::string &/*description*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual void finishDeltaDownload()
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ // Apply delta rpm:
+ // - local path of downloaded delta
+ // - aplpy is not interruptable
+ // - problems are just informal
+ virtual void startDeltaApply( const Pathname & /*filename*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual void progressDeltaApply( int /*value*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual void problemDeltaApply( const std::string &/*description*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual void finishDeltaApply()
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ // Dowmload patch rpm:
+ // - path below url reported on start()
+ // - expected download size (0 if unknown)
+ // - download is interruptable
+ virtual void startPatchDownload( const Pathname & /*filename*/, const ByteCount & /*downloadsize*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual bool progressPatchDownload( int /*value*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ return true;
+ }
+
+ virtual void problemPatchDownload( const std::string &/*description*/ )
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+ virtual void finishPatchDownload()
+ {
+ USR << __PRETTY_FUNCTION__ << endl;
+ }
+
+
+ // return false if the download should be aborted right now
+ virtual bool progress(int value, Resolvable::constPtr resolvable_ptr)
+ {
+ if ( 1 || abs(value-lp) >= 20 || value == 100 && lp != 100 )
+ {
+ USR << resolvable_ptr << " " << value << "%" << endl;
+ lp = value;
+ }
+ return true;
+ }
+
+ virtual Action problem( Resolvable::constPtr resolvable_ptr , Error error , const std::string &/*description*/ )
+ {
+ USR << "!!! " << resolvable_ptr << " (" << error << ")" << endl;
+ return ABORT;
+ }
+
+ virtual void finish(Resolvable::constPtr resolvable_ptr , Error error , const std::string &/*reason*/ )
+ {
+ USR << "--- " << resolvable_ptr << " (" << error << ")" << endl;
+ }
+
+ int lp;
+ };
+
+
bool queryInstalledEditionHelper( const std::string & name_r,
const Edition & ed_r,
const Arch & arch_r )
@@ -66,6 +253,10 @@
INT << "===[START]==========================================" << endl;
::unsetenv( "ZYPP_CONF" );
ZConfig::instance();
+
+ DownloadProgressReceive _dpr;
+ DownloadResolvableReceive _drr;
+
TestSetup::LoadSystemAt( sysRoot );
///////////////////////////////////////////////////////////////////
ResPool pool( ResPool::instance() );
@@ -74,13 +265,44 @@
dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() ) << endl;
USR << "pool: " << pool << endl;
- PoolItem pi( getPi<Package>( "amarok" ) );
- SEC << pi << endl;
- ManagedFile f( repoProvidePackage( pi ) );
- SEC << f << endl;
- //f.resetDispose();
- ExternalProgram("find /tmp/var") >> DBG;
- DBG << endl;
+ if ( 0 ) {
+ PoolItem pi( getPi<Package>( "CDT", "amarok", Edition(), Arch_empty ) );
+ SEC << pi << endl;
+ ManagedFile f( repoProvidePackage( pi ) );
+ SEC << f << endl;
+ }
+ {
+ Url url("cd:///?devices=/dev/sr0");
+ Pathname path(url.getPathName());
+ url.setPathName ("/");
+ MediaSetAccess access(url);
+ Pathname local = access.provideFile(path);
+ SEC << local << endl;
+ }
+ if ( 0 ) {
+ Url url("http://download.opensuse.org/debug/distribution/11.4/repo/oss/content.asc");
+ url.setPathName ("/");
+ MediaSetAccess access(url);
+
+ zypp::Fetcher fch;
+ fch.reset();
+ fch.setOptions(zypp::Fetcher::AutoAddIndexes);
+
+ // path - add "/" to the beginning if it's missing there
+ std::string media_path("/debug/distribution/11.4/repo/oss/content.ascx");
+ zypp::OnMediaLocation mloc(media_path, 1);
+ mloc.setOptional(true);
+
+ zypp::filesystem::TmpDir tmpdir( zypp::filesystem::TmpDir::defaultLocation() );
+ fch.addIndex(mloc);
+ fch.start(tmpdir.path(), access);
+ }
+
+
+
+// f.resetDispose();
+// ExternalProgram("find /tmp/var") >> DBG;
+// DBG << endl;
INT << "===[END]============================================" << endl;
zypp::base::LogControl::instance().logNothing();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/doc/autoinclude/Services.doc new/libzypp-10.3.5/doc/autoinclude/Services.doc
--- old/libzypp-10.3.4/doc/autoinclude/Services.doc 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/doc/autoinclude/Services.doc 2011-11-29 15:09:30.000000000 +0100
@@ -4,7 +4,7 @@
\author Duncan Mac-Vicar P.
-Services provide a list of repositories. So when the service is refreshed, the repositories belonging to this service are synced.
+Services provide a list of repositories. So when the service is refreshed, the repositories specified by the service service is synced with the local repository list.
\section service-types Classes of services
@@ -42,7 +42,46 @@
\subsection services-plugin Plugin Services
-\ref plugin-services "Plugin services" are simple scripts that return a list of repositories. They are installed by packages. For each script installed ZYpp will “see” a service of type “plugin”. When you refresh the service, the repositories this script returns will be added (or removed and kept in sync if they change afterwards).
+\ref plugin-services "Plugin services" are simple scripts that return a list of repositories. They are installed locally in the system using packages. For each script installed ZYpp will “see” a service of type “plugin”. When you refresh the service, the repositories this script returns as output will be added (or removed and kept in sync if they change afterwards).
+
+A plugin service is a program installed in /usr/lib/zypp/plugins/services.
+
+Once a program called "foobar" is installed, listing services will show it:
+
+\verbatim
+> zypper ls
+# | Alias | Name | Enabled | Refresh | Type
+---+------------------+--------------+---------+---------+-------
+1 | foobar | foobar | Yes | Yes | plugin
+...
+...
+\endverbatim
+
+When this service is refreshed, the program will be executed and it will return
+the list of repositories in the same .repo files format that can be found in
+/etc/zypp/repos.d:
+
+\verbatim
+# output returned by the plugin
+
+[repo-oss]
+name=oss
+enabled=1
+autorefresh=0
+baseurl=http://download.opensuse.org//distribution/11.4/repo/oss
+type=yast2
+keeppackages=0
+
+...
+\endverbatim
+
+As you can see, the main advantage of plugin services is that they can read information from the client and calculate the repository list from there. Nothing prevents a plugin service to still interact with a server to get the repository list.
+
+The main disadvantage is that you have logic in the client side that in case of bugs or changes, needs to be updated.
+
+Spacewalk integration is implemented using plugin services. The plugin talks XML-RPC to the server and asks for the list of channels the system is subscribed to. The plugin needs to read the server address and perform the login.
+
+However, the spacewalk plugin service does have an extra indirection, as the repository list returned are not plain urls, but urls of the type plugin:$name?params, which use the urlresolver plugin to get the real url. This is not necessary, and here it is done because it allows to add custom headers to the HTTP requests. You can read more about urlresolver plugins \ref plugin-url-resolver here.
\section service-refresh Refreshing services
@@ -70,11 +109,11 @@
This is actually where services where originated. Services were present in Novell ZenWorks. How it works?
-The service url nu.novell.com is added to the system. But in this url also a customer id is present as a http username. When you registered, Novell knows the product this customer is linked to, and can return a dynamic list of update repositories based on the customer preferences, products and entitlements and the customer does not need to keep them in sync.
+The service url nu.novell.com is added to the system. But in this url also a customer id is present as a http username. When you registered, Novell knows the subscription and products this system is linked to and what entitlements the customer has. The service can then return a dynamic list of repositories based on the customer preferences, products and entitlements. The customer does not need to keep them manually in sync.
-Now that we don’t have Zenworks in the base system, we still want this cool functionality for our customers.
+Now that we don’t have Zenworks in the base system, we still want this cool functionality for our customers, therefore ZYpp now implements services natively.
-Technically, this even allows us to offer hotfixes to L3 supported customers on the fly!
+Technically, this even allows us to offer hotfixes to L3 supported customers on the fly: the system is marked on the server side as being hotfixed, and an extra temporary repository with the PTF (Problem Temporary Fix) packages is added to this system list of repositories.
\subsection services-usecase-3 Usecase #3: Dynamic repository collections
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/mkChangelog new/libzypp-10.3.5/mkChangelog
--- old/libzypp-10.3.4/mkChangelog 2011-11-11 13:47:39.000000000 +0100
+++ new/libzypp-10.3.5/mkChangelog 2011-11-29 15:09:29.000000000 +0100
@@ -1,80 +1,42 @@
#! /bin/bash
-#
+
+function Recho() { echo -e "\e[0;31m""$@""\e[0m"; }
+function Gecho() { echo -e "\e[0;32m""$@""\e[0m"; }
+function Becho() { echo -e "\e[0;34m""$@""\e[0m"; }
function errexit() {
exec >&2
- echo "Error: $@"
+ Recho "Error: $@"
exit 1
}
-export LC_ALL=""
-EDITOR=${EDITOR:-vi}
-
-TDIR=$(dirname $0)
-test -n "$TDIR" && cd $TDIR
-
-CHANGESFILE=$(ls package/*.changes)
-test -f "$CHANGESFILE" || errexit "No changes file '$CHANGESFILE'"
-
-VERSIONFILE="VERSION.cmake"
-test -f "$VERSIONFILE" || errexit "No version file '$VERSIONFILE'"
-
-LANG="en"
-
-## Version.cmake tags in getversion() are still zypp specific.
-
function usage() {
exec >&2
-cat <&1-
-exec >$TMPFILE
-echo "-------------------------------------------------------------------"
-echo "$(date) - $EMAIL"
-echo ""
-echo "- "
-echo "$GOTVERSION"
-echo ""
-cat $CHANGESFILE
-exec >&3
+trap " [ -f \"$TMPFILE\" ] && /bin/rm -f -- \"$TMPFILE\" " 0 1 2 3 13 15
+{ newchangesentry; cat $CHANGESFILE; } >$TMPFILE
RES=e
while [ "$RES" == "e" ]; do
$EDITOR $TMPFILE
echo
- NEWREL=$(grep '#---delete-or-release---#' $TMPFILE)
- test -n "$NEWREL" && echo "$NEWREL"
- read -n 1 -p "(a)bort, (c)ontinue, (e)dit : " RES
- 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 : ")" RES
echo
case "$RES" in
[eE]*)
RES=e
;;
- [cC])
- test -n "$NEWREL" && {
- echo "Remember new release in $VERSIONFILE"
- sed -i 's/^.*#---delete-or-release---#.*RELEASE:/- version/' $TMPFILE
- NEWREL=$(sed 's/^.*#---delete-or-release---#.*RELEASE:/# LAST RELEASED:/' <<<"$NEWREL")
- sed -i "s/^# LAST RELEASED:.*$/$NEWREL/" $VERSIONFILE
+ [cCsS])
+ Becho "!!! Store new $CHANGESFILE"
+ mv $TMPFILE $CHANGESFILE
+
+ test "$RES" == "s" && {
+ if [ "$LAST_RELEASE" == "$THIS_RELEASE" ]; then
+ git add "$CHANGESFILE" && git commit -m "changes"
+ else
+ Becho "!!! Remember new version $THIS_RELEASE in $VERSIONFILE"
+ sed -i "s/^# LAST RELEASED:.*$/# LAST RELEASED: $THIS_RELEASE ($THIS_COMPAT)/" $VERSIONFILE
+ git add "$CHANGESFILE" "$VERSIONFILE" \
+ && git commit -m "changes $THIS_RELEASE ($THIS_COMPAT)" \
+ && git tag -m "tagging $THIS_RELEASE" "$THIS_RELEASE" HEAD
+ Becho "!!!"
+ Becho "!!! Do not forget to push the commit and the tag: $(Gecho git push --tags)"
+ Becho "!!!"
+ fi
}
-
- echo "Store new $CHANGESFILE"
- cp $TMPFILE $CHANGESFILE
-
- echo "$(sed 's/^.*#---delete-or-release---#.*RELEASE:/# CURRENT RELEASE:/' <<<"$GOTVERSION")"
- awk '{print}/^----------/{n=n+1; if ( n == 2 ) exit 0; }' $CHANGESFILE
-
;;
*)
- echo "Leave $CHANGESFILE untouched"
+ Becho "!!! Leave $CHANGESFILE untouched"
;;
esac
done
-
-rm -f $TMPFILE
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/package/libzypp.changes new/libzypp-10.3.5/package/libzypp.changes
--- old/libzypp-10.3.4/package/libzypp.changes 2011-11-11 13:47:39.000000000 +0100
+++ new/libzypp-10.3.5/package/libzypp.changes 2011-11-29 15:09:29.000000000 +0100
@@ -1,4 +1,23 @@
-------------------------------------------------------------------
+Mon Nov 28 18:08:42 CET 2011 - ma@suse.de
+
+- Fix and optimize Pathname ctor and provide testcases (bnc#721128)
+- Open all file descriptors with O_CLOEXEC to avoid leaks and races
+- Some improvements to the services documentation
+- Fix RW_pointer comparison with underlying smart pointer type.
+- version 10.3.5 (3)
+
+-------------------------------------------------------------------
+Sun Nov 27 01:13:10 CET 2011 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
+Thu Nov 17 01:13:15 CET 2011 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
Fri Nov 11 13:38:42 CET 2011 - ma@suse.de
- Try to find and use some CD/DVD device even if HAL/UDEV detection
Files old/libzypp-10.3.4/po/zypp-po.tar.bz2 and new/libzypp-10.3.5/po/zypp-po.tar.bz2 differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/tests/zypp/CMakeLists.txt new/libzypp-10.3.5/tests/zypp/CMakeLists.txt
--- old/libzypp-10.3.4/tests/zypp/CMakeLists.txt 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/tests/zypp/CMakeLists.txt 2011-11-29 15:09:29.000000000 +0100
@@ -21,9 +21,11 @@
Locks
MediaSetAccess
PathInfo
+ Pathname
PluginFrame
PoolQuery
ProgressData
+ PtrTypes
PublicKey
RWPtr
RepoInfo
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/tests/zypp/Pathname_test.cc new/libzypp-10.3.5/tests/zypp/Pathname_test.cc
--- old/libzypp-10.3.4/tests/zypp/Pathname_test.cc 1970-01-01 01:00:00.000000000 +0100
+++ new/libzypp-10.3.5/tests/zypp/Pathname_test.cc 2011-11-29 15:09:29.000000000 +0100
@@ -0,0 +1,151 @@
+#include <iostream>
+#include <string>
+
+#include
+
+#include "zypp/base/LogTools.h"
+#include "zypp/Pathname.h"
+
+using boost::unit_test::test_suite;
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+
+BOOST_AUTO_TEST_CASE(pathname_default_ctor)
+{
+ Pathname p;
+
+ BOOST_CHECK_EQUAL(p.empty(), true );
+ BOOST_CHECK_EQUAL(p.absolute(), false );
+ BOOST_CHECK_EQUAL(p.relative(), false );
+ BOOST_CHECK_EQUAL(p.dirname(), "" );
+ BOOST_CHECK_EQUAL(p.basename(), "" );
+ BOOST_CHECK_EQUAL(p.extension(), "" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "" );
+ BOOST_CHECK_EQUAL(p.relativename(), "" );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_root)
+{
+ Pathname p("/");
+
+ BOOST_CHECK_EQUAL(p.empty(), false );
+ BOOST_CHECK_EQUAL(p.absolute(), true );
+ BOOST_CHECK_EQUAL(p.relative(), false );
+ BOOST_CHECK_EQUAL(p.dirname(), "/" );
+ BOOST_CHECK_EQUAL(p.basename(), "/" );
+ BOOST_CHECK_EQUAL(p.extension(), "" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "/" );
+ BOOST_CHECK_EQUAL(p.relativename(), "./" );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_this)
+{
+ Pathname p(".");
+
+ BOOST_CHECK_EQUAL(p.empty(), false );
+ BOOST_CHECK_EQUAL(p.absolute(), false );
+ BOOST_CHECK_EQUAL(p.relative(), true );
+ BOOST_CHECK_EQUAL(p.dirname(), "." );
+ BOOST_CHECK_EQUAL(p.basename(), "." );
+ BOOST_CHECK_EQUAL(p.extension(), "" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "/" );
+ BOOST_CHECK_EQUAL(p.relativename(), "." );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_up)
+{
+ Pathname p("..");
+
+ BOOST_CHECK_EQUAL(p.empty(), false );
+ BOOST_CHECK_EQUAL(p.absolute(), false );
+ BOOST_CHECK_EQUAL(p.relative(), true );
+ BOOST_CHECK_EQUAL(p.dirname(), "." );
+ BOOST_CHECK_EQUAL(p.basename(), ".." );
+ BOOST_CHECK_EQUAL(p.extension(), "" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "/" );
+ BOOST_CHECK_EQUAL(p.relativename(), ".." );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_abs)
+{
+ Pathname p("/foo/baa.ka");
+
+ BOOST_CHECK_EQUAL(p.empty(), false );
+ BOOST_CHECK_EQUAL(p.absolute(), true );
+ BOOST_CHECK_EQUAL(p.relative(), false );
+ BOOST_CHECK_EQUAL(p.dirname(), "/foo" );
+ BOOST_CHECK_EQUAL(p.basename(), "baa.ka" );
+ BOOST_CHECK_EQUAL(p.extension(), ".ka" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "/foo/baa.ka" );
+ BOOST_CHECK_EQUAL(p.relativename(), "./foo/baa.ka" );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_rel)
+{
+ Pathname p("./foo/./../baa.ka");
+
+ BOOST_CHECK_EQUAL(p.empty(), false );
+ BOOST_CHECK_EQUAL(p.absolute(), false );
+ BOOST_CHECK_EQUAL(p.relative(), true );
+ BOOST_CHECK_EQUAL(p.dirname(), "." );
+ BOOST_CHECK_EQUAL(p.basename(), "baa.ka" );
+ BOOST_CHECK_EQUAL(p.extension(), ".ka" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "/baa.ka" );
+ BOOST_CHECK_EQUAL(p.relativename(), "./baa.ka" );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_relup)
+{
+ Pathname p("./../foo/./../baa");
+
+ BOOST_CHECK_EQUAL(p.empty(), false );
+ BOOST_CHECK_EQUAL(p.absolute(), false );
+ BOOST_CHECK_EQUAL(p.relative(), true );
+ BOOST_CHECK_EQUAL(p.dirname(), ".." );
+ BOOST_CHECK_EQUAL(p.basename(), "baa" );
+ BOOST_CHECK_EQUAL(p.extension(), "" );
+ BOOST_CHECK_EQUAL(p.absolutename(), "/baa" );
+ BOOST_CHECK_EQUAL(p.relativename(), "../baa" );
+}
+
+BOOST_AUTO_TEST_CASE(pathname_strval)
+{
+ BOOST_CHECK_EQUAL(Pathname("").asString(), "" );
+ BOOST_CHECK_EQUAL(Pathname("/////./").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("./").asString(), "." );
+ BOOST_CHECK_EQUAL(Pathname("/.").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("./..").asString(), "./.." ); // ? ..
+ BOOST_CHECK_EQUAL(Pathname("../").asString(), "./.." ); // ? ..
+ BOOST_CHECK_EQUAL(Pathname(".././..").asString(), "./../.." ); // ? ../..
+
+
+ BOOST_CHECK_EQUAL(Pathname("//baa").asString(), "/baa" );
+ BOOST_CHECK_EQUAL(Pathname("/./baa").asString(), "/baa" );
+ BOOST_CHECK_EQUAL(Pathname("/baa/..").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/baa/../baa").asString(), "/baa" );
+ BOOST_CHECK_EQUAL(Pathname("/./../foo/./../baa").asString(), "/baa" );
+
+ BOOST_CHECK_EQUAL(Pathname("/").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname(".").asString(), "." );
+ BOOST_CHECK_EQUAL(Pathname("..").asString(), "./.." );
+ BOOST_CHECK_EQUAL(Pathname("/.").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/..").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/./.").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/./..").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/../.").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/../..").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/././").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/./../").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/.././").asString(), "/" );
+ BOOST_CHECK_EQUAL(Pathname("/../../").asString(), "/" );
+
+ BOOST_CHECK_EQUAL(Pathname("a\\b").asString(), "./a\\b" );
+ BOOST_CHECK_EQUAL(Pathname("a/b").asString(), "./a/b" );
+ BOOST_CHECK_EQUAL(Pathname("c:a\\b").asString(), "./c:a\\b" );
+ BOOST_CHECK_EQUAL(Pathname("c:a/b").asString(), "./c:a/b" );
+ BOOST_CHECK_EQUAL(Pathname("cc:a\\b").asString(), "./cc:a\\b" );
+ BOOST_CHECK_EQUAL(Pathname("cc:a/b").asString(), "./cc:a/b" );
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/tests/zypp/PtrTypes_test.cc new/libzypp-10.3.5/tests/zypp/PtrTypes_test.cc
--- old/libzypp-10.3.4/tests/zypp/PtrTypes_test.cc 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/tests/zypp/PtrTypes_test.cc 2011-11-29 15:09:30.000000000 +0100
@@ -50,6 +50,7 @@
{ return new Intrusive( *rhs ); }
}
+
/******************************************************************
**
*/
@@ -57,8 +58,9 @@
#define T_NOT_NULL assert( ptr )
#define T_UNIQUE assert( ptr.unique() ); assert( ptr.use_count() < 2 )
#define T_NOT_UNIQUE assert( !ptr.unique() ); assert( ptr.use_count() >= 2 )
-#define T_EQ(a,b) assert( a == b )
-#define T_NE(a,b) assert( a != b )
+// Also comapre with underlying shared ptr type.
+#define T_EQ(a,b) assert( a == b ); assert( a == b.cgetPtr() ); assert( a.cgetPtr() == b ); assert( a.cgetPtr() == b.cgetPtr() );
+#define T_NE(a,b) assert( a != b ); assert( a != b.cgetPtr() ); assert( a.cgetPtr() != b ); assert( a.cgetPtr() != b.cgetPtr() );
template<class _RW>
void test()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/PathInfo.cc new/libzypp-10.3.5/zypp/PathInfo.cc
--- old/libzypp-10.3.4/zypp/PathInfo.cc 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/zypp/PathInfo.cc 2011-11-29 15:09:30.000000000 +0100
@@ -1058,7 +1058,7 @@
{
ZIP_TYPE ret = ZT_NONE;
- int fd = open( file.asString().c_str(), O_RDONLY );
+ int fd = open( file.asString().c_str(), O_RDONLY|O_CLOEXEC );
if ( fd != -1 ) {
const int magicSize = 3;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/Pathname.cc new/libzypp-10.3.5/zypp/Pathname.cc
--- old/libzypp-10.3.4/zypp/Pathname.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/Pathname.cc 2011-11-29 15:09:30.000000000 +0100
@@ -25,105 +25,6 @@
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- namespace
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : DirStack
- //
- /** silly helper to build Pathnames.
- */
- class DirStack {
-
- struct Dir {
-
- Dir * up;
- Dir * dn;
- string name;
-
- Dir( const string & n = "" ) {
- name = n;
- up = dn = 0;
- }
-
- ~Dir() {
- if ( up )
- up->dn = dn;
- if ( dn )
- dn->up = up;
- }
- };
-
- Dir * top;
- Dir * bot;
-
- void Pop() {
- if ( !top )
- return;
- top = top->dn;
- if ( top )
- delete top->up;
- else {
- delete bot;
- bot = 0;
- }
- }
-
- public:
-
- DirStack() { top = bot = 0; }
- ~DirStack() {
- while ( bot )
- Pop();
- }
-
- void Push( const string & n ) {
- if ( n.empty() || n == "." ) { // '.' or '/' only for bot
- if ( bot )
- return;
- } else if ( n == ".." && top ) {
- if ( top->name == "" ) // "/.." ==> "/"
- return;
-
- if ( top->name != "." && top->name != ".." ) { // "somedir/.." ==> ""
- Pop();
- return;
- }
- // "../.." "./.." stays
- }
-
- Dir * d = new Dir( n );
- if ( !top )
- top = bot = d;
- else {
- top->up = d;
- d->dn = top;
- d->up = 0;
- top = d;
- }
- }
-
- string str() {
- if ( !bot )
- return "";
- string ret;
- for ( Dir * d = bot; d; d = d->up ) {
- if ( d != bot )
- ret += "/";
- ret += d->name;
- }
- if ( ret.empty() )
- return "/";
- return ret;
- }
- };
-
- /////////////////////////////////////////////////////////////////
- } // namespace
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Pathname::_assign
// METHOD TYPE : void
@@ -131,55 +32,93 @@
void Pathname::_assign( const string & name_tv )
{
prfx_i = 0;
- name_t = name_tv;
-
- if ( name_t.empty() )
+ name_t.clear();
+ if ( name_tv.empty() )
return;
+ name_t.reserve( name_tv.size() );
- string Tprfx;
- DirStack Stack_Ci;
-
- char * Buf_aci = new char[name_tv.length() + 1];
- char * W_pci = Buf_aci;
- const char * R_pci = name_tv.c_str();
-
- // check for prefix
- if ( name_t.length() >= 2
- && name_t[1] == ':'
- && ( ( 'a' <= name_t[0] && name_t[0] <= 'z' )
- || ( 'A' <= name_t[0] && name_t[0] <= 'Z' ) ) ) {
- Tprfx = name_t.substr( 0, 2 );
- prfx_i = 2;
- R_pci += 2;
+ // Collect up to "/.."
+ enum Pending {
+ P_none = 0, // ""
+ P_slash = 1, // "/"
+ P_dot1 = 2, // "/."
+ P_dot2 = 3 // "/.."
+ } pending = P_none;
+
+ // Assert relative path starting with "./"
+ // We rely on this below!
+ if ( name_tv[0] != '/' )
+ {
+ name_t += '.';
+ pending = P_slash;
}
- // rel or abs path
- if ( *R_pci == '/' ) {
- Stack_Ci.Push( "" );
- ++R_pci;
- } else {
- Stack_Ci.Push( "." );
- }
+ // Lambda handling the "/.." case:
+ // [] + "/.." ==> []
+ // [.] + "/.." ==> [./..]
+ // [foo] is always [./foo] due to init above
+ // [*/..] + "/.." ==> [*/../..]
+ // [*/foo] + "/.." ==> [*]
+ auto goParent_f = [&](){
+ if ( name_t.empty() )
+ /*NOOP*/;
+ else if ( name_t.size() == 1 ) // content is '.'
+ name_t += "/..";
+ else
+ {
+ std::string::size_type pos = name_t.rfind( "/" );
+ if ( pos == name_t.size() - 3 && name_t[pos+1] == '.' && name_t[pos+2] == '.' )
+ name_t += "/..";
+ else
+ name_t.erase( pos );
+ }
+ };
- do {
- switch ( *R_pci ) {
- case '/':
- case '\0':
- if ( W_pci != Buf_aci ) {
- *W_pci = '\0';
- W_pci = Buf_aci;
- Stack_Ci.Push( Buf_aci );
- }
- break;
-
- default:
- *W_pci++ = *R_pci;
- break;
- }
- } while( *R_pci++ );
+ for ( auto ch : name_tv )
+ {
+ switch ( ch )
+ {
+ case '/':
+ switch ( pending )
+ {
+ case P_none: pending = P_slash; break;
+ case P_slash: break;
+ case P_dot1: pending = P_slash; break;
+ case P_dot2: goParent_f(); pending = P_slash; break;
+ }
+ break;
+
+ case '.':
+ switch ( pending )
+ {
+ case P_none: name_t += '.'; break;
+ case P_slash: pending = P_dot1; break;
+ case P_dot1: pending = P_dot2; break;
+ case P_dot2: name_t += "/..."; pending = P_none; break;
+ }
+ break;
+
+ default:
+ switch ( pending )
+ {
+ case P_none: break;
+ case P_slash: name_t += '/'; pending = P_none; break;
+ case P_dot1: name_t += "/."; pending = P_none; break;
+ case P_dot2: name_t += "/.."; pending = P_none; break;
+ }
+ name_t += ch;
+ break;
+ }
+ }
- delete[] Buf_aci;
- name_t = Tprfx + Stack_Ci.str();
+ switch ( pending )
+ {
+ case P_none: break;
+ case P_slash: if ( name_t.empty() ) name_t = "/"; break;
+ case P_dot1: if ( name_t.empty() ) name_t = "/"; break;
+ case P_dot2: goParent_f(); if ( name_t.empty() ) name_t = "/"; break;
+ }
+ return;
}
///////////////////////////////////////////////////////////////////
@@ -190,17 +129,15 @@
Pathname Pathname::dirname( const Pathname & name_tv )
{
if ( name_tv.empty() )
- return "";
+ return Pathname();
Pathname ret_t( name_tv );
string::size_type idx = ret_t.name_t.find_last_of( '/' );
if ( idx == string::npos ) {
- ret_t.name_t.erase( ret_t.prfx_i );
- ret_t.name_t += ".";
- } else if ( idx == ret_t.prfx_i ) {
- ret_t.name_t.erase( ret_t.prfx_i );
- ret_t.name_t += "/";
+ ret_t.name_t = ".";
+ } else if ( idx == 0 ) {
+ ret_t.name_t = "/";
} else {
ret_t.name_t.erase( idx );
}
@@ -219,9 +156,8 @@
return string();
string ret_t( name_tv.asString() );
- ret_t.erase( 0, name_tv.prfx_i );
string::size_type idx = ret_t.find_last_of( '/' );
- if ( idx != string::npos ) {
+ if ( idx != string::npos && ( idx != 0 || ret_t.size() != 1 ) ) {
ret_t.erase( 0, idx+1 );
}
@@ -264,8 +200,20 @@
string base( basename( name_tv ) );
string::size_type pos = base.rfind( '.' );
- if ( pos == string::npos )
- return string();
+ switch ( pos )
+ {
+ case 0:
+ if ( base.size() == 1 ) // .
+ return string();
+ break;
+ case 1:
+ if ( base.size() == 2 && base[0] == '.' ) // ..
+ return string();
+ break;
+ case string::npos:
+ return string();
+ break;
+ }
return base.substr( pos );
}
@@ -295,10 +243,10 @@
if ( name_tv.empty() )
return add_tv;
- string ret_ti( add_tv.asString() );
- ret_ti.replace( 0, add_tv.prfx_i, "/" );
-
- return name_tv.asString() + ret_ti;
+ string ret_ti( name_tv.name_t );
+ if( add_tv.name_t[0] != '/' )
+ ret_ti += '/';
+ return ret_ti + add_tv.name_t;
}
///////////////////////////////////////////////////////////////////
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/Pathname.h new/libzypp-10.3.5/zypp/Pathname.h
--- old/libzypp-10.3.4/zypp/Pathname.h 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/Pathname.h 2011-11-29 15:09:30.000000000 +0100
@@ -40,7 +40,7 @@
* \todo Add support for handling extensions incl. stripping
* extensions from basename (basename("/path/foo.baa", ".baa") ==> "foo")
* \todo Review. Maybe use COW pimpl, check storage.
- * \todo \b EXPLICIT ctors.
+ * \todo remove prfx_i
*/
class Pathname
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/Repository.cc new/libzypp-10.3.5/zypp/Repository.cc
--- old/libzypp-10.3.4/zypp/Repository.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/Repository.cc 2011-11-29 15:09:30.000000000 +0100
@@ -248,7 +248,7 @@
{
NO_REPOSITORY_THROW( Exception( "Can't add solvables to norepo." ) );
- AutoDispose file( ::fopen( file_r.c_str(), "r" ), ::fclose );
+ AutoDispose file( ::fopen( file_r.c_str(), "re" ), ::fclose );
if ( file == NULL )
{
file.resetDispose();
@@ -270,7 +270,7 @@
std::string command( file_r.extension() == ".gz" ? "zcat " : "cat " );
command += file_r.asString();
- AutoDispose file( ::popen( command.c_str(), "r" ), ::pclose );
+ AutoDispose file( ::popen( command.c_str(), "re" ), ::pclose );
if ( file == NULL )
{
file.resetDispose();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/TmpPath.cc new/libzypp-10.3.5/zypp/TmpPath.cc
--- old/libzypp-10.3.4/zypp/TmpPath.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/TmpPath.cc 2011-11-29 15:09:30.000000000 +0100
@@ -187,7 +187,7 @@
return;
}
- int tmpFd = ::mkstemp( buf );
+ int tmpFd = ::mkostemp( buf, O_CLOEXEC );
if ( tmpFd != -1 )
{
// success; create _impl
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/base/GzStream.cc new/libzypp-10.3.5/zypp/base/GzStream.cc
--- old/libzypp-10.3.4/zypp/base/GzStream.cc 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/zypp/base/GzStream.cc 2011-11-29 15:09:30.000000000 +0100
@@ -79,12 +79,12 @@
// we expect gzdopen to handle errors of ::open
if ( mode_r == std::ios_base::in )
{
- _fd = ::open( name_r, O_RDONLY );
+ _fd = ::open( name_r, O_RDONLY | O_CLOEXEC );
_file = gzdopen( _fd, "rb" );
}
else if ( mode_r == std::ios_base::out )
{
- _fd = ::open( name_r, O_WRONLY|O_CREAT, 0666 );
+ _fd = ::open( name_r, O_WRONLY|O_CREAT|O_CLOEXEC, 0666 );
_file = gzdopen( _fd, "wb" );
}
// else: not supported
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/base/PtrTypes.h new/libzypp-10.3.5/zypp/base/PtrTypes.h
--- old/libzypp-10.3.4/zypp/base/PtrTypes.h 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/zypp/base/PtrTypes.h 2011-11-29 15:09:30.000000000 +0100
@@ -324,6 +324,9 @@
_Ptr getPtr()
{ return _dptr; }
+ _constPtr cgetPtr()
+ { return _dptr; }
+
private:
_Ptr _dptr;
};
@@ -335,8 +338,7 @@
* if the pointer is \c NULL.
*/
template
- inline std::ostream &
- operator<<( std::ostream & str, const RW_pointer<_D, _Ptr> & obj )
+ inline std::ostream & operator<<( std::ostream & str, const RW_pointer<_D, _Ptr> & obj )
{
if ( obj.get() )
return str << *obj.get();
@@ -345,19 +347,46 @@
/** \relates RW_pointer */
template
- inline bool
- operator==( const RW_pointer<_D, _Ptr> & lhs, const RW_pointer<_D, _Ptr> & rhs )
- {
- return( lhs.get() == rhs.get() );
- }
+ inline bool operator==( const RW_pointer<_D, _Ptr> & lhs, const RW_pointer<_D, _Ptr> & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator==( const RW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_Ptr & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator==( const typename _Ptr::_Ptr & lhs, const RW_pointer<_D, _Ptr> & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator==( const RW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_constPtr & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator==( const typename _Ptr::_constPtr & lhs, const RW_pointer<_D, _Ptr> & rhs )
+ { return( lhs.get() == rhs.get() ); }
+
/** \relates RW_pointer */
template
- inline bool
- operator!=( const RW_pointer<_D, _Ptr> & lhs, const RW_pointer<_D, _Ptr> & rhs )
- {
- return ! ( lhs == rhs );
- }
+ inline bool operator!=( const RW_pointer<_D, _Ptr> & lhs, const RW_pointer<_D, _Ptr> & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator!=( const RW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_Ptr & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator!=( const typename _Ptr::_Ptr & lhs, const RW_pointer<_D, _Ptr> & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator!=( const RW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_constPtr & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RW_pointer */
+ template
+ inline bool operator!=( const typename _Ptr::_constPtr & lhs, const RW_pointer<_D, _Ptr> & rhs )
+ { return ! ( lhs == rhs ); }
///////////////////////////////////////////////////////////////////
@@ -435,6 +464,9 @@
_Ptr getPtr()
{ assertUnshared(); return _dptr; }
+ _constPtr cgetPtr()
+ { return _dptr; }
+
private:
void assertUnshared()
@@ -465,8 +497,7 @@
* if the pointer is \c NULL.
*/
template
- inline std::ostream &
- operator<<( std::ostream & str, const RWCOW_pointer<_D, _Ptr> & obj )
+ inline std::ostream & operator<<( std::ostream & str, const RWCOW_pointer<_D, _Ptr> & obj )
{
if ( obj.get() )
return str << *obj.get();
@@ -475,19 +506,45 @@
/** \relates RWCOW_pointer */
template
- inline bool
- operator==( const RWCOW_pointer<_D, _Ptr> & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
- {
- return( lhs.get() == rhs.get() );
- }
+ inline bool operator==( const RWCOW_pointer<_D, _Ptr> & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator==( const RWCOW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_Ptr & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator==( const typename _Ptr::_Ptr & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator==( const RWCOW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_constPtr & rhs )
+ { return( lhs.get() == rhs.get() ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator==( const typename _Ptr::_constPtr & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
+ { return( lhs.get() == rhs.get() ); }
/** \relates RWCOW_pointer */
template
- inline bool
- operator!=( const RWCOW_pointer<_D, _Ptr> & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
- {
- return ! ( lhs == rhs );
- }
+ inline bool operator!=( const RWCOW_pointer<_D, _Ptr> & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator!=( const RWCOW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_Ptr & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator!=( const typename _Ptr::_Ptr & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator!=( const RWCOW_pointer<_D, _Ptr> & lhs, const typename _Ptr::_constPtr & rhs )
+ { return ! ( lhs == rhs ); }
+ /** \relates RWCOW_pointer */
+ template
+ inline bool operator!=( const typename _Ptr::_constPtr & lhs, const RWCOW_pointer<_D, _Ptr> & rhs )
+ { return ! ( lhs == rhs ); }
///////////////////////////////////////////////////////////////////
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/base/Random.cc new/libzypp-10.3.5/zypp/base/Random.cc
--- old/libzypp-10.3.4/zypp/base/Random.cc 2011-11-11 13:47:40.000000000 +0100
+++ new/libzypp-10.3.5/zypp/base/Random.cc 2011-11-29 15:09:30.000000000 +0100
@@ -17,7 +17,7 @@
{
unsigned int seed;
init = true;
- int fd = open("/dev/urandom", O_RDONLY);
+ int fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC);
if (fd < 0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed))
{
// No /dev/urandom... try something else.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/media/MediaCD.cc new/libzypp-10.3.5/zypp/media/MediaCD.cc
--- old/libzypp-10.3.4/zypp/media/MediaCD.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/media/MediaCD.cc 2011-11-29 15:09:30.000000000 +0100
@@ -249,7 +249,7 @@
//
bool MediaCD::openTray( const std::string & device_r )
{
- int fd = ::open( device_r.c_str(), O_RDONLY|O_NONBLOCK );
+ int fd = ::open( device_r.c_str(), O_RDONLY|O_NONBLOCK|O_CLOEXEC );
int res = -1;
if ( fd != -1)
@@ -308,7 +308,7 @@
//
bool MediaCD::closeTray( const std::string & device_r )
{
- int fd = ::open( device_r.c_str(), O_RDONLY|O_NONBLOCK );
+ int fd = ::open( device_r.c_str(), O_RDONLY|O_NONBLOCK|O_CLOEXEC );
if ( fd == -1 ) {
WAR << "Unable to open '" << device_r << "' (" << ::strerror( errno ) << ")" << endl;
return false;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/media/MediaCurl.cc new/libzypp-10.3.5/zypp/media/MediaCurl.cc
--- old/libzypp-10.3.4/zypp/media/MediaCurl.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/media/MediaCurl.cc 2011-11-29 15:09:30.000000000 +0100
@@ -1220,7 +1220,7 @@
ZYPP_THROW(MediaSystemException(url, "out of memory for temp file name"));
}
- int tmp_fd = ::mkstemp( buf );
+ int tmp_fd = ::mkostemp( buf, O_CLOEXEC );
if( tmp_fd == -1)
{
free( buf);
@@ -1230,7 +1230,7 @@
destNew = buf;
free( buf);
- FILE *file = ::fdopen( tmp_fd, "w" );
+ FILE *file = ::fdopen( tmp_fd, "we" );
if ( !file ) {
::close( tmp_fd);
filesystem::unlink( destNew );
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/media/MediaMultiCurl.cc new/libzypp-10.3.5/zypp/media/MediaMultiCurl.cc
--- old/libzypp-10.3.4/zypp/media/MediaMultiCurl.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/media/MediaMultiCurl.cc 2011-11-29 15:09:30.000000000 +0100
@@ -479,7 +479,7 @@
struct addrinfo *ai, aihints;
memset(&aihints, 0, sizeof(aihints));
aihints.ai_family = PF_UNSPEC;
- int tstsock = socket(PF_INET6, SOCK_DGRAM, 0);
+ int tstsock = socket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (tstsock == -1)
aihints.ai_family = PF_INET;
else
@@ -1203,7 +1203,7 @@
{
char buf[256], *p;
int fd, l;
- if ((fd = open(file.asString().c_str(), O_RDONLY)) == -1)
+ if ((fd = open(file.asString().c_str(), O_RDONLY|O_CLOEXEC)) == -1)
return false;
while ((l = read(fd, buf, sizeof(buf) - 1)) == -1 && errno == EINTR)
;
@@ -1246,7 +1246,7 @@
ZYPP_THROW(MediaSystemException(url, "out of memory for temp file name"));
}
- int tmp_fd = ::mkstemp( buf );
+ int tmp_fd = ::mkostemp( buf, O_CLOEXEC );
if( tmp_fd == -1)
{
free( buf);
@@ -1256,7 +1256,7 @@
destNew = buf;
free( buf);
- FILE *file = ::fdopen( tmp_fd, "w" );
+ FILE *file = ::fdopen( tmp_fd, "we" );
if ( !file ) {
::close( tmp_fd);
filesystem::unlink( destNew );
@@ -1344,7 +1344,7 @@
MediaBlockList bl = mlp.getBlockList();
vector<Url> urls = mlp.getUrls();
DBG << bl << endl;
- file = fopen(destNew.c_str(), "w+");
+ file = fopen(destNew.c_str(), "w+e");
if (!file)
ZYPP_THROW(MediaWriteException(destNew));
if (PathInfo(target).isExist())
@@ -1393,7 +1393,7 @@
filesystem::unlink(destNew);
ZYPP_RETHROW(ex);
}
- file = fopen(destNew.c_str(), "w+");
+ file = fopen(destNew.c_str(), "w+e");
if (!file)
ZYPP_THROW(MediaWriteException(destNew));
MediaCurl::doGetFileCopyFile(filename, dest, file, report, options | OPTION_NO_REPORT_START);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/media/Mount.cc new/libzypp-10.3.5/zypp/media/Mount.cc
--- old/libzypp-10.3.4/zypp/media/Mount.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/media/Mount.cc 2011-11-29 15:09:30.000000000 +0100
@@ -302,7 +302,7 @@
{
DBG << "Reading mount table from '" << *t << "'" << std::endl;
}
- FILE *fp = setmntent(t->c_str(), "r");
+ FILE *fp = setmntent(t->c_str(), "re");
if( fp)
{
char buf[PATH_MAX * 4];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-10.3.4/zypp/target/modalias/Modalias.cc new/libzypp-10.3.5/zypp/target/modalias/Modalias.cc
--- old/libzypp-10.3.4/zypp/target/modalias/Modalias.cc 2011-11-11 13:47:41.000000000 +0100
+++ new/libzypp-10.3.5/zypp/target/modalias/Modalias.cc 2011-11-29 15:09:30.000000000 +0100
@@ -115,7 +115,7 @@
return 0;
}
snprintf(path, sizeof(path), "%s/%s", dir, file);
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY|O_CLOEXEC)) == -1)
return 0;
len = read(fd, modalias, sizeof(modalias) - 1);
if (len < 0)
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org