diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2019-02-05 16:57:47 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2019-03-01 10:04:22 +0100 |
commit | 58ebfeb08cf979c1702dfca44c258e2f176e4212 (patch) | |
tree | 9ea86bad7912cacefc146b301646a4dd9d719613 /apt-pkg | |
parent | 08e35a30d5c1829580b155d8951314168c859456 (diff) |
Add support for /etc/apt/auth.conf.d/*.conf (netrcparts)
This allows us to install matching auth files for sources.list.d
files, for example; very useful.
The chmod() stuff we inherited from auth.conf handling is awful, but
what can we do? It's not needed anymore in later versions, as they open
files before dropping privileges, but ugh, not backporting that.
(parts cherry-picked from commit feed3ec105cd6be7b5d23da14c6cfca8572ee725)
LP: #1811120
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire.cc | 10 | ||||
-rw-r--r-- | apt-pkg/init.cc | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index ed0ddf7ac..bf1c3a4fe 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -87,6 +87,16 @@ void pkgAcquire::Initialize() 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()); + + std::string const AuthParts = _config->FindDir("Dir::Etc::netrcparts"); + if (AuthParts.empty() == false && DirectoryExists(AuthParts)) + { + for (auto const &AuthConf : GetListOfFilesInDir(AuthParts, "conf", true, true)) + { + if (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()); + } + } } } } diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index f5ca43465..645df044e 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -63,6 +63,7 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.CndSet("Dir::Etc::sourceparts","sources.list.d"); Cnf.CndSet("Dir::Etc::main","apt.conf"); Cnf.CndSet("Dir::Etc::netrc", "auth.conf"); + Cnf.CndSet("Dir::Etc::netrcparts", "auth.conf.d"); Cnf.CndSet("Dir::Etc::parts","apt.conf.d"); Cnf.CndSet("Dir::Etc::preferences","preferences"); Cnf.CndSet("Dir::Etc::preferencesparts","preferences.d"); |