- Create missing directories when saving config files. (bnc #395026)
authorMichael Andres <ma@suse.de>
Wed, 28 May 2008 13:33:50 +0000 (13:33 +0000)
committerMichael Andres <ma@suse.de>
Wed, 28 May 2008 13:33:50 +0000 (13:33 +0000)
- Fix undefined behaviour in RepoManager.

devel/devel.ma/Tools.h
package/libzypp.changes
zypp/RepoManager.cc
zypp/TmpPath.cc
zypp/TmpPath.h

index 3f958ac..1683fee 100644 (file)
@@ -112,6 +112,7 @@ template<class _Container>
 
 inline RepoManager makeRepoManager( const Pathname & mgrdir_r )
 {
+  return RepoManager();
 
   RepoManagerOptions mgropt;
   mgropt.repoCachePath    = mgrdir_r/"cache";
index d3beb62..4fe2e67 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Wed May 28 15:30:24 CEST 2008 - ma@suse.de
+
+- Create missing directories when saving config files. (bnc #395026)
+- Fix undefined behaviour in RepoManager.
+- revision 10255
+
+-------------------------------------------------------------------
 Wed May 28 15:23:44 CEST 2008 - schubi@suse.de
 
 - SOLVER_ERASE_SOLVABLE_NAME: As we do not know, if this request has come
index defb77e..8a2c6f0 100644 (file)
@@ -772,16 +772,18 @@ namespace zypp
         ManagedFile guard( solvfile, filesystem::unlink );
 
         ostringstream cmd;
-        const char *toFile = str::gsub(solvfile.asString(),"\"","\\\"").c_str();
+        std::string toFile( str::gsub(solvfile.asString(),"\"","\\\"") );
         if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e )
         {
-          const char * from = str::gsub(
-            info.baseUrlsBegin()->getPathName(),"\"","\\\"").c_str();
-          cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", from , toFile );
-        } else
+          cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"",
+                            str::gsub( info.baseUrlsBegin()->getPathName(),"\"","\\\"" ).c_str(),
+                            toFile.c_str() );
+        }
+        else
         {
-          const char * from = str::gsub(rawpath.asString(),"\"","\\\"").c_str();
-          cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"", from, toFile );
+          cmd << str::form( "repo2solv.sh \"%s\" > \"%s\"",
+                            str::gsub( rawpath.asString(),"\"","\\\"" ).c_str(),
+                            toFile.c_str() );
         }
         MIL << "Executing: " << cmd.str() << endl;
         ExternalProgram prog( cmd.str(), ExternalProgram::Stderr_To_Stdout );
index 246d180..b8e89c7 100644 (file)
@@ -175,8 +175,13 @@ namespace zypp {
       PathInfo p( inParentDir_r );
       if ( ! p.isDir() )
         {
-          ERR << "Parent directory does not exist: " << p << endl;
-          return;
+          filesystem::assert_dir( inParentDir_r );
+          p(); // re-stat
+          if ( ! p.isDir() )
+          {
+            ERR << "Parent directory can't be created: " << p << endl;
+            return;
+          }
         }
 
       // create the temp file
@@ -185,6 +190,7 @@ namespace zypp {
       if ( ! buf )
         {
           ERR << "Out of memory" << endl;
+          ::free( buf );
           return;
         }
 
@@ -248,8 +254,13 @@ namespace zypp {
       PathInfo p( inParentDir_r );
       if ( ! p.isDir() )
         {
-          ERR << "Parent directory does not exist: " << p << endl;
-          return;
+          filesystem::assert_dir( inParentDir_r );
+          p(); // re-stat
+          if ( ! p.isDir() )
+          {
+            ERR << "Parent directory does not exist: " << p << endl;
+            return;
+          }
         }
 
       // create the temp dir
index ad2b6ce..bab81e3 100644 (file)
@@ -109,7 +109,6 @@ namespace zypp {
      * name unique. Different location and file prefix may be passed to
      * the ctor. TmpFile is created with mode 0600.
      *
-     * The directory where the temporary file is to be created must exist.
      * TmpFile provides the Pathname of the temporary file, or an empty
      * path in case of any error.
      **/
@@ -154,7 +153,6 @@ namespace zypp {
      * the  name unique. Different location and file prefix may be passed
      * to the ctor. TmpDir is created with mode 0700.
      *
-     * The directory where the temporary directory is to be created must exist.
      * TmpDir provides the Pathname of the temporary directory , or an empty
      * path in case of any error.
      **/