diff options
author | Julian Andres Klode <jak@debian.org> | 2017-01-29 13:05:18 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2018-09-28 13:11:08 +0200 |
commit | 6c0c94ed32b8e679b14b0f89b51c1c336dc0ab9c (patch) | |
tree | 71e50645d0876d37cf9978e095e4ea9578cda690 /apt-private/private-install.cc | |
parent | 409ceec9ed30cbebd8ece1ef7ce667ab5a32f9df (diff) |
Add support for dpkg frontend lock
The dpkg frontend lock is a lock dpkg tries to acquire
except if the frontend already acquires it.
This fixes a race condition in the install command where the
dpkg lock is not held for a short period of time between
different dpkg invocations.
For this reason we also define an environment variable
DPKG_FRONTEND_LOCKED for dpkg invocations so dpkg knows
not to try to acquire the frontend lock because it's held
by a parent process.
We can set DPKG_FRONTEND_LOCKED only if the frontend lock
really is held; that is, if our lock count is greater than 0
- otherwise an apt client not using the LockInner family of
functions would run dpkg without the frontend lock set, but
with DPKG_FRONTEND_LOCKED set. Such a process has a weaker
guarantee: Because dpkg would not lock the frontend lock
either, the process is prone to the existing races, and,
more importantly, so is a new style process.
Closes: #869546
[fixups: fix error messages, add public IsLocked() method, and
make {Un,}LockInner return an error on !debSystem]
(cherry picked from commit c2c8b4787b0882234ba2772ec7513afbf97b563a)
LP: #1781169
Diffstat (limited to 'apt-private/private-install.cc')
-rw-r--r-- | apt-private/private-install.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index e1beb21c6..041acce0e 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -346,7 +346,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety) } auto const progress = APT::Progress::PackageManagerProgressFactory(); - _system->UnLock(); + _system->UnLockInner(); pkgPackageManager::OrderResult const Res = PM->DoInstall(progress); delete progress; @@ -355,7 +355,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety) if (Res == pkgPackageManager::Completed) break; - _system->Lock(); + _system->LockInner(); // Reload the fetcher object and loop again for media swapping Fetcher.Shutdown(); |