diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-10-22 00:05:40 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-10-22 00:05:40 +0200 |
commit | e845cde33c5d13a0e2dd924a388705a0738d4f96 (patch) | |
tree | 95bc8e098b0281444c56ee1e298cfb2b042f605f | |
parent | 1924b1e513b0619c177565d17475ea3747983f4f (diff) | |
download | apt-e845cde33c5d13a0e2dd924a388705a0738d4f96.tar.gz |
check that auth.conf exists before chowning it
Git-Dch: Ignore
-rw-r--r-- | apt-pkg/acquire.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 033fa9bd3..1e20b74be 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -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) |