]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire.cc
ensure valid or remove destination file in file method
[apt.git] / apt-pkg / acquire.cc
index 2c89c2deade4c42e02019d160fb12990a22ddf20..0c815c005bbc2a3710075b3344f626a716e89f72 100644 (file)
@@ -92,8 +92,11 @@ void pkgAcquire::Initialize()
 static bool SetupAPTPartialDirectory(std::string const &grand, std::string const &parent)
 {
    std::string const partial = parent + "partial";
-   if (CreateAPTDirectoryIfNeeded(grand, partial) == false &&
-        CreateAPTDirectoryIfNeeded(parent, partial) == false)
+   mode_t const mode = umask(S_IWGRP | S_IWOTH);
+   bool const creation_fail = (CreateAPTDirectoryIfNeeded(grand, partial) == false &&
+        CreateAPTDirectoryIfNeeded(parent, partial) == false);
+   umask(mode);
+   if (creation_fail == true)
       return false;
 
    std::string const SandboxUser = _config->Find("APT::Sandbox::User");
@@ -152,6 +155,8 @@ bool pkgAcquire::GetLock(std::string const &Lock)
       return true;
 
    // Lock the directory this acquire object will work in
+   if (LockFD != -1)
+      close(LockFD);
    LockFD = ::GetLock(flCombine(Lock, "lock"));
    if (LockFD == -1)
       return _error->Error(_("Unable to lock directory %s"), Lock.c_str());