Hello community, here is the log from the commit of package libzypp for openSUSE:12.1:Update:Test checked in at 2011-12-01 14:36:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:12.1:Update:Test/libzypp (Old) and /work/SRC/openSUSE:12.1:Update:Test/.libzypp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libzypp", Maintainer is "[email protected]" Changes: -------- --- /work/SRC/openSUSE:12.1:Update:Test/libzypp/libzypp.changes 2011-11-25 16:22:15.000000000 +0100 +++ /work/SRC/openSUSE:12.1:Update:Test/.libzypp.new/libzypp.changes 2011-12-01 14:36:23.000000000 +0100 @@ -1,0 +2,14 @@ +Mon Nov 28 18:08:42 CET 2011 - [email protected] + +- 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 - [email protected] + +- 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.lmFMYx/_old 2011-12-01 14:36:23.000000000 +0100 +++ /var/tmp/diff_new_pack.lmFMYx/_new 2011-12-01 14:36:23.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-23 11:30:33.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-23 11:30:35.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 <zypp/TmpPath.h> #include <zypp/ResPoolProxy.h> #include <zypp/repo/PackageProvider.h> +#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 <zypp/ZYppCallbacks.h> + + struct DownloadProgressReceive : public callback::ReceiveReport<media::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::ReceiveReport<repo::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/mkChangelog new/libzypp-10.3.5/mkChangelog --- old/libzypp-10.3.4/mkChangelog 2011-11-23 11:30:33.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 <<EOF - -Usage: $(basename $0) [OPTIONS] -Options: -h,-?,--help This page. - -$(basename $0) will load the changes file '$CHANGESFILE' -into your editor (\$EDITOR=$EDITOR), providing a new changes -entry template: + cat <<EOF + Usage: + $(basename $0) [OPTIONS] + + Options: + -h,-?,--help This page. + -n Dryrun. + +Prepare a new changes file entry preloaded with all commits since the last +changes tag and load it into \$EDITOR (vi). If the version file was changed, +optionally submitt and tag the new changes. Otherwise simply leave the changes +in place. - ------------------------------------------------------------------- - Wed Jul 30 18:20:06 CEST 2008 - [email protected] - - - - #---delete-or-release---# LAST RELEASED: 5.3.2 (2) NEW RELEASE: 5.4.0 (4) - -The line '#---delete-or-release---#...' shows the last version submitted -to autobuild ('# LAST RELEASED:; tag in $VERSIONFILE). And also the current -version, asuming you already updated the $VERSIONFILE according to your changes. -(The number in parenthesis is _COMPATMINOR) - - -- Delete the line if you don't want to submit the package to autobuild. - -- Leave the line in place if you want to submit the package. - - -Closing the editor you are prompted: - - #---delete-or-release---# LAST RELEASED: 5.3.2 (2) NEW RELEASE: 5.4.0 (4) - (a)bort, (c)ontinue, (e)dit : - -Choosing (c)ontinue will write the new changes file. The '#---delete-or-release---#' -line is missing in case you deleted it. It's presence will remind you -that it is going to be converted into: - - - version 5.4.0 - -and the '# LAST RELEASED:; tag in $VERSIONFILE will be updated accordingly. -Now check the result, check in your changes, build the package and submit -to autobuild. - -Released by accident? Don't mind. Nothing bad will happen. If you want to -undo the change, restore the 'LAST RELEASED: ' entry in $VERSIONFILE and -delete the '- version' line in $CHANGESFILE'. +Don't forgett to push created tags as well: git push --tags EOF exit 1 } +DRYRUN=0 + case "$1" in + -[n]*) + DRYRUN=1 + ;; -[hH?]*) usage ;; @@ -83,6 +45,19 @@ ;; esac + +export LC_ALL="" +export LANG="en" +EDITOR=${EDITOR:-vi} + +EMAIL="$(git config --get user.email)" + +CHANGESFILE=$(ls package/*.changes) +test -f "$CHANGESFILE" || errexit "No changes file '$CHANGESFILE'" + +VERSIONFILE="VERSION.cmake" +test -f "$VERSIONFILE" || errexit "No version file '$VERSIONFILE'" + function getversion() { cat "$VERSIONFILE" \ | awk ' @@ -94,66 +69,127 @@ /^ *SET *\( *LIBZYPP_MINOR *"[0-9]+" *\)/ {getnum();minor=$0} /^ *SET *\( *LIBZYPP_PATCH *"[0-9]+" *\)/ {getnum();patch=$0} /^ *SET *\( *LIBZYPP_COMPATMINOR *"[0-9]+" *\)/ {getnum();compatminor=$0} - /^# LAST RELEASED:/ {gsub("^.*RELEASED: *","");gsub(" +$","");gsub(" +\\("," (");lastrelease=$0} + /^# LAST RELEASED:/ { + gsub("^.*RELEASED: *",""); + gsub(" +$",""); + lastcompat=$0 + gsub(".*\\(","",lastcompat) + gsub("\\).*","",lastcompat) + gsub(" +\\(.*",""); + lastrelease=$0 + } END { thisrelease = major"."minor"."patch" ("compatminor")" - if ( thisrelease == lastrelease ) - print "#---delete-or-release---# LAST RELEASED: "lastrelease" UNCHANGED RELEASE: "thisrelease - else - print "#---delete-or-release---# LAST RELEASED: "lastrelease" NEW RELEASE: "thisrelease + printf "LAST_RELEASE='%s'\n", lastrelease + printf "LAST_COMPAT='%s'\n", lastcompat + printf "THIS_RELEASE='%s'\n", major"."minor"."patch + printf "THIS_COMPAT='%s'\n", compatminor } ' } -test -r /etc/sysconfig/mail && source /etc/sysconfig/mail -EMAIL="${USER}@${FROM_HEADER:-$(hostname -f)}" +function sameVersion() { + test "$LAST_RELEASE" == "$THIS_RELEASE" -a "$LAST_COMPAT" == "$THIS_COMPAT" +} + +function getchanges() { + git log --no-merges --pretty=format:'- %s' "$LAST_RELEASE"..HEAD | grep -v 'po.tar.bz2' +} + +function newchangesentry() { + echo "-------------------------------------------------------------------" + echo "$(date) - $EMAIL" + echo "" + echo "$(getchanges)" + sameVersion || { + echo "- version $THIS_RELEASE ($THIS_COMPAT)" + } + echo "" +} + +git status --porcelain | grep '^[^ ]' | grep -v "$VERSIONFILE\|$CHANGESFILE" && { + Becho "!!! Files other than version and changes are added to the index." + Becho "!!! Doing dryrun..." + DRYRUN=1 +} +if [ "$DRYRUN" == "1" ]; then + eval $(getversion) + newchangesentry + sameVersion && { + Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)." + } + exit 0 +fi -GOTVERSION="$(getversion)" +# check version file +# +while true; do + # $LAST_RELEASE + # $LAST_COMPAT + # $THIS_RELEASE + # $THIS_COMPAT + eval $(getversion) + sameVersion && { + newchangesentry + Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)." + read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (e)dit version: ")" RES + echo + case "$RES" in + [eE]*) + $EDITOR $VERSIONFILE + continue + ;; + [cC]) + Becho "!!! Leave $VERSIONFILE untouched" + break + ;; + *) + errexit "aborted" + ;; + esac + } + break +done + +# prepare changes file +# TMPFILE=$(mktemp) -exec 3>&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-23 11:30:33.000000000 +0100 +++ new/libzypp-10.3.5/package/libzypp.changes 2011-11-29 15:09:29.000000000 +0100 @@ -1,4 +1,18 @@ ------------------------------------------------------------------- +Mon Nov 28 18:08:42 CET 2011 - [email protected] + +- 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 - [email protected] + +- Update zypp-po.tar.bz2 + +------------------------------------------------------------------- Thu Nov 17 01:13:15 CET 2011 - [email protected] - Update zypp-po.tar.bz2 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-23 11:30:35.000000000 +0100 +++ new/libzypp-10.3.5/tests/zypp/CMakeLists.txt 2011-11-29 15:09:29.000000000 +0100 @@ -21,6 +21,7 @@ Locks MediaSetAccess PathInfo + Pathname PluginFrame PoolQuery ProgressData 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 <boost/test/auto_unit_test.hpp> + +#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/zypp/PathInfo.cc new/libzypp-10.3.5/zypp/PathInfo.cc --- old/libzypp-10.3.4/zypp/PathInfo.cc 2011-11-23 11:30:35.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-23 11:30:35.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-23 11:30:36.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-23 11:30:36.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*> file( ::fopen( file_r.c_str(), "r" ), ::fclose ); + AutoDispose<FILE*> 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*> file( ::popen( command.c_str(), "r" ), ::pclose ); + AutoDispose<FILE*> 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-23 11:30:36.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-23 11:30:35.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/Random.cc new/libzypp-10.3.5/zypp/base/Random.cc --- old/libzypp-10.3.4/zypp/base/Random.cc 2011-11-23 11:30:35.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-23 11:30:35.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-23 11:30:35.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-23 11:30:35.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-23 11:30:35.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-23 11:30:35.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: [email protected] For additional commands, e-mail: [email protected]
