summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-10-21 11:19:45 -0400
committerMichael Vogt <mvo@debian.org>2014-10-21 11:19:45 -0400
commit1924b1e513b0619c177565d17475ea3747983f4f (patch)
tree14393aa64d9170adfeb349ed31b0e8cc00d6b6c3 /apt-pkg/acquire.cc
parentcbb1005a0a2e026e4a7361b0ff86888af192ee85 (diff)
Ensure /etc/apt/auth.conf has _apt:root owner
Ensure in SetupAPTPartialDirectory() that the /etc/apt/auth.conf file can be read by the priv sep apt methods.
Diffstat (limited to 'apt-pkg/acquire.cc')
-rw-r--r--apt-pkg/acquire.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 1aa709381..033fa9bd3 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -86,8 +86,16 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const
std::string SandboxUser = _config->Find("APT::Sandbox::User");
struct passwd *pw = getpwnam(SandboxUser.c_str());
struct group *gr = getgrnam("root");
- if (pw != NULL && gr != NULL && 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());
+ if (pw != NULL && gr != NULL)
+ {
+ // chown the partial dir
+ 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());
+ }
}
if (chmod(partial.c_str(), 0700) != 0)
_error->WarningE("SetupAPTPartialDirectory", "chmod 0700 of directory %s failed", partial.c_str());