]> git.saurik.com Git - apt.git/commitdiff
check that auth.conf exists before chowning it
authorDavid Kalnischkies <david@kalnischkies.de>
Tue, 21 Oct 2014 22:05:40 +0000 (00:05 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Tue, 21 Oct 2014 22:05:40 +0000 (00:05 +0200)
Git-Dch: Ignore

apt-pkg/acquire.cc

index 033fa9bd3caabed826cc86744d6e1cb8ad0a0fdc..1e20b74be3ab48fabfae946b34c5dede0e44a617 100644 (file)
@@ -92,9 +92,10 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const
          if(chown(partial.c_str(), pw->pw_uid, gr->gr_gid) != 0)
             _error->WarningE("SetupAPTPartialDirectory", "chown to %s:root of directory %s failed", SandboxUser.c_str(), partial.c_str());
          // chown the auth.conf file
-         std::string AuthConf = _config->FindFile("Dir::Etc::netrc");
-         if(chown(AuthConf.c_str(), pw->pw_uid, gr->gr_gid) != 0)
-            _error->WarningE("SetupAPTPartialDirectory", "chown to %s:root of file %s failed", SandboxUser.c_str(), AuthConf.c_str());
+         std::string const AuthConf = _config->FindFile("Dir::Etc::netrc");
+        if(AuthConf.empty() == false && RealFileExists(AuthConf) &&
+              chown(AuthConf.c_str(), pw->pw_uid, gr->gr_gid) != 0)
+           _error->WarningE("SetupAPTPartialDirectory", "chown to %s:root of file %s failed", SandboxUser.c_str(), AuthConf.c_str());
       }
    }
    if (chmod(partial.c_str(), 0700) != 0)