[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#752327: apt: Passes full path to .deb to mkstemp



On Sun, Jun 22, 2014 at 06:25:12PM +0200, Axel Beckert wrote:
> Package: apt
> Version: 1.1~exp1
> Severity: normal

Thanks for your bugreport.
 
> first let me say Yay for "apt install file.deb". We can finally get rid
> of gdebi! ;-)

:)
 
> Playing around with this new feature, I ran into the following issue:
> 
> # apt install /var/cache/apt/archives/bc_1.06.95-9_amd64.deb
> Reading package lists... Error!
> E: Unable to mkstemp /tmp/deb-file-/var/cache/apt/archives/bc_1.06.95-9_amd64.deb.dqKFUj - GetTempFile (2: No such file or directory)
> E: The package lists or status file could not be parsed or opened.
> 
> I think, only the file name but not the full path should be passed to
> mkstemp.

Yeah, thanks for reporting. Currently it can only install in cwd
because of the issue you found and also because "/" is used as a
commandline modified for "normal" packages.

Attached is a patch that fixes it. It would be nice if David could
have a look before I commit, I was pondering if the CacheSet should
have a new ::FromFile() or something instead of putting it into
VersionContainerInterface::FromString.

Cheers,
 Michael
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index 5d7f285..346bad3 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -24,6 +24,7 @@
 #include <apt-pkg/depcache.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/fileutl.h>
 
 #include <stddef.h>
 #include <stdio.h>
@@ -445,6 +446,13 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
 					   pkgCacheFile &Cache, std::string pkg,
 					   Version const &fallback, CacheSetHelper &helper,
 					   bool const onlyFromName) {
+        PackageSet pkgset;
+        if(FileExists(pkg))
+        {
+                PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
+                return VersionContainerInterface::FromPackage(vci, Cache, pkgset.begin(), fallback, helper);
+        }
+
 	std::string ver;
 	bool verIsRel = false;
 	size_t const vertag = pkg.find_last_of("/=");
@@ -453,7 +461,6 @@ bool VersionContainerInterface::FromString(VersionContainerInterface * const vci
 		verIsRel = (pkg[vertag] == '/');
 		pkg.erase(vertag);
 	}
-	PackageSet pkgset;
 	if (onlyFromName == false)
 		PackageContainerInterface::FromString(&pkgset, Cache, pkg, helper);
 	else {
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index c1c2b72..5717b01 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -710,7 +710,7 @@ bool debDebPkgFileIndex::Merge(pkgCacheGenerator& Gen, OpProgress* Prog) const
    ExecWait(Child, "Popen");
 
    // now write the control data to a tempfile
-   SPtr<FileFd> DebControl = GetTempFile("deb-file-" + DebFile);
+   SPtr<FileFd> DebControl = GetTempFile("deb-file-" + flNotDir(DebFile));
    if(DebControl == NULL)
       return false;
    DebControl->Write(buf, n);

Reply to: