Advances in Debian's package manager
At the 2015 edition of DebConf in Heidelberg, Germany, David Kalnischkies provided an update on several recent enhancements to the Apt package-management tool that plays such a key role in Debian and its derivatives. His talk dealt with the upcoming 1.1 release, which was recently uploaded to Debian experimental. The new branch features a number of security enhancements and implements some oft-requested features. As he put it, the Apt team is setting its sights on higher-level package managers like Aptitude.
Kalnischkies began by pointing out that one of the top
search-engine suggestions to complete the phrase "apt-get is " was the
rather unflattering
"broken." While that was discouraging, he pointed out that
searching for a description of the program also turns up Justin Rye's
somewhat rosier summary:
"It's a 100% bug-free solution to all life's problems, requiring
no human intervention at any stage
". Somewhere in between the
two extremes, he settled on his title: "Apt has super(cow) powers."
The "cow" is a reference to one of Apt's best-known Easter eggs: typing apt moo generates an ASCII-art cow image. But most people are unaware, he said, that there are actually multiple cow-related Easter eggs in the tool (which he proceeded to demonstrate). Similarly, many Apt users are unaware of everything that the program does behind the scenes. Though it is most frequently used to simply install Debian packages, it also handles resolving package lists from multiple repositories and local sources, as well as figuring out the proper order to install or remove dependencies, and handling security checking.
In the dark ages of 1997, he said, it was first conceived as a replacement for the dselect tool—which was hard to use and confusing for novices. Apt only reached 1.0 in 2014, when the developers decided that it finally met all of the functional and ease-of-use criteria set out in 1997. With that milestone out of the way, the project has now undertaken new work and experimental features. At DebCamp the week before DebConf, he said, the team closed more than 300 outstanding issues—some of which were quite old.
Security
Kalnischkies then turned to the new features that users could try out in the 1.1 development branch. Many are network-security enhancements, he said. First, downloads are now performed as the unprivileged user "_apt" rather than as root. Second, there are many more hash checks performed—namely, every package's hash is checked when the file is downloaded and again when it is uncompressed. Earlier releases only checked uncompressed hashes, and only on some files—a disparity that was confusing for developers as well as being insecure.
![David Kalnischkies [David Kalnischkies at DebConf]](https://static.lwn.net/images/2015/09-debconf-apt-sm.jpg)
The new version also checks for the presence of every file it expects to see before starting a download, rather than assuming that what it expects is present in the repository. In old releases, the assumption that certain files were present was only made for auxiliary files like Translation-* files, but it was a minor security hole nevertheless. Those URLs were predictable, and there was some chance that an attacker could exploit them to make Apt download something malicious. Speaking of auxiliary files, Apt can now download any arbitrary file. Apt front-ends like Aptitude and apt-file had been implementing their own downloading code in order to handle things like screenshots and AppData metadata files, he explained. By performing those downloads itself, Apt can at least verify that the downloads are being done securely.
At DebConf, attendees were encouraged to use an on-site mirror of the Debian archive in order to conserve bandwidth. Kalnischkies did a live demonstration next, to illustrate that Apt now reports back to the user which mirror it is using. Doing so provides a bit of added security (against man-in-the-middle attacks), but it is also practical: users can now report any errors to the administrator of the correct mirror. Apt also checks for signatures on each repository's Release file, and issues a warning if no signature is present. In the future, he said, "it will get harder and harder to run an unsigned repository," until they are deprecated entirely.
At that point, an audience member asked if requiring such signed files would make it impossible to use a local package repository—which is often needed when bootstrapping a new system. Kalnischkies replied that an unsigned local repository can be marked as "trusted" in the Apt configuration file and the bootstrapper can thus avert any trouble.
Additional features
The list of other new features is a long one; Kalnischkies highlighted just a few. Using PDiffs (package diffs, which are binary deltas of updated packages) now works for everyone, and Kalnischkies demonstrated that downloading with PDiffs is, in fact, faster than downloading without them—something that Apt's critics had often said was not true in the past.
Similarly, a change that landed during the DebCamp hacking sessions was a fix for pinning packages (that is, designating that a particular, installed version of a package should not be updated even when a new release appears). In prior releases, the pinning algorithm could get confused by details like packages that changed their name or their version-number format between releases. "Pinning now works as advertised," he said. "I could fill a whole session just discussing how pinning works; right now you'll just have to trust me."
The new version of Apt will also support several additional parameters for the repository entries in sources.list files. Among the new options is a reference to an OpenPGP key or keyring; adding the parameter locks the repository to a specific key for signature checking. That allows the user to do a form of key pinning, which would help alert them if an attacker compromised a repository and tampered with its packages. Under the current system, the attacker could simply upload a new Releases.gpg file signed by their own key, and an Apt user would not know that the old key had been replaced.
Other new parameters include an indicator that the repository includes other content types (such as the AppData files mentioned earlier) and one disabling the check on a repository's "Valid Until" setting. Users that run tests against old packages in historical Debian archives asked for the validity-date disabling feature in order to silence the deluge of warnings Apt would throw when it thought that a repository was past its expiration date.
Apt can also be used to install individual Debian packages from their .deb files, he continued; in the past, users had to use dpkg to install a package from a standalone file, then immediately run apt install -f (for "fix broken"), which was far from ideal. Apt has also gained the ability to automatically detect and download the build dependencies of a source package—whereas, in previous releases, the build-dep command only worked on binary packages. Thus, the user would have to manually locate the dependencies by reading through the source package's control files.
There were additional new features he wanted to discuss, Kalnischkies said, but he cut the presentation short to reserve plenty of time for questions. A number of attendees wanted to know how the enhancements to Apt would affect other programs, such as gdebi. He replied that some of those programs may go away in the future, but would not do so soon. One advantage of gdebi, he said, was its set of language bindings, which Apt would have to add in order to be a direct competitor.
Another attendee asked if there was any advantage to using dpkg instead of Apt. He replied that Apt attempts to handle complex things like dependency resolution, but that sometimes it decides it cannot do what the user requests. In those situations, if the user really does know what the answer is, they can do it with dpkg.
On the whole, though, Apt is making improvements in many areas where it was regarded as weak in the past. It may not be perfect yet, but the strides it has taken are significant.
[The author would like to thank the Debian project for travel
assistance to attend DebConf 2015.]
Index entries for this article | |
---|---|
Conference | DebConf/2015 |
Posted Sep 3, 2015 3:42 UTC (Thu)
by dune73 (guest, #17225)
[Link] (5 responses)
Posted Sep 6, 2015 10:13 UTC (Sun)
by jospoortvliet (guest, #33164)
[Link] (4 responses)
Well, I guess it was impressive back then but I think it's been overtaken since. When I moved to openSUSE (from Arch, previously Ubuntu) I was amazed at how nice zypper was. Had no idea as nobody seems to talk about it. But, after playing again with apt distributions on a Banana Pi, I appreciate zypper even more. Part of it is simply that it has a very clever, sane command line interface - efficient and logical, with built in help. Doing zypper could always handle RPM's directly and offered solutions rather than just giving up when there were conflicts. Things I greatly missed in APT and it is nice that it is added there. Once APT has built in search and repository management and a cleaned up command list, Debian-based distro's are at least an option for me again. The one thing apt has going for it, for me, is its ability to automatically clean unused packages from the system. That just plain rocks...
Posted Sep 11, 2015 16:26 UTC (Fri)
by ploxiln (subscriber, #58395)
[Link] (1 responses)
Posted Sep 13, 2015 6:41 UTC (Sun)
by jospoortvliet (guest, #33164)
[Link]
Posted Sep 23, 2015 19:10 UTC (Wed)
by juliank (guest, #45896)
[Link] (1 responses)
There are far more packages
The order of alternatives defines a preference for the first element in an or-group. That makes the whole thing much more predictable, but also does not allow us to simply plug-in a "SAT" solver.
Posted Oct 11, 2015 20:20 UTC (Sun)
by jospoortvliet (guest, #33164)
[Link]
Posted Sep 3, 2015 6:26 UTC (Thu)
by danielkza (subscriber, #66161)
[Link] (1 responses)
Posted Sep 9, 2015 18:18 UTC (Wed)
by robert_s (subscriber, #42402)
[Link]
I just wish nixpkgs were of generally higher quality - they're maintained by *very* few maintainers it appears. If only Nix had the weight that debian (which is still my general distribution of choice) has behind it. Then we'd be going somewhere.
Posted Sep 3, 2015 7:39 UTC (Thu)
by salimma (subscriber, #34460)
[Link] (4 responses)
I wonder if that's fixed? Yum handles that use case much more seamlessly.
Posted Sep 3, 2015 12:35 UTC (Thu)
by k8to (guest, #15413)
[Link] (1 responses)
You end up with a package list that disagrees with available packages, leading to upgrade failures with inscrutible errors, or worse mismatched versions of packages (on repeated attempts to get things to work) which cause even more confusing failures.
Posted Sep 23, 2015 19:13 UTC (Wed)
by juliank (guest, #45896)
[Link]
Posted Sep 27, 2015 16:32 UTC (Sun)
by yoe (guest, #25743)
[Link]
However, you can easily add several URIs to the sources.list file, and if at least one of them works when you do apt update, you're good.
Posted Oct 24, 2015 15:17 UTC (Sat)
by pabs (subscriber, #43278)
[Link]
Posted Sep 3, 2015 8:00 UTC (Thu)
by sdalley (subscriber, #18550)
[Link] (5 responses)
Posted Sep 3, 2015 22:41 UTC (Thu)
by flussence (guest, #85566)
[Link] (4 responses)
Posted Sep 4, 2015 20:27 UTC (Fri)
by xz (guest, #86176)
[Link] (2 responses)
In case of conflict, apt-get usually produces a bunch of useless resolutions which either propose to delete every conceivable package, or do nothing. This is especially the case when the users try to downgrade/upgrade packages from different releases (mixing stable and testing/unstable, or mixing Ubuntu releases).
With aptitude, specific conflicts and their requirements can be inspected, and alternative versions of packages can be selected, creating a preview of possible conflict resolution before finally applying it.
Together with apt pinning, it is very easy with aptitude to create a "distro" based on stable releases, and hand pick select packages from testing/unstable. All packages will not be automatically updated to unstable versions, but the latest versions are always available one scroll down the interface.
Posted Sep 4, 2015 21:32 UTC (Fri)
by dashesy (guest, #74652)
[Link]
Posted Sep 7, 2015 17:26 UTC (Mon)
by niner (subscriber, #26151)
[Link]
Posted Sep 8, 2015 15:53 UTC (Tue)
by hrw (subscriber, #44826)
[Link]
Posted Sep 3, 2015 12:05 UTC (Thu)
by fsateler (subscriber, #65497)
[Link]
1. The mirror has always been reported. What was not being reported is if the mirror did a redirect to another server. This is important due to the popularity of mirror redirectors like http://httpredir.debian.org , which choose a (hopefully) appropriate mirror based on location.
2. PDiffs are not binary deltas of packages. They are diffs of the Packages file (which is the text index of all the packages in the repository). They were previously slow because the algorithm to use them was to download and apply the diffs sequentially to the stored Packages file. Now the diffs are all downloaded, combined into a single diff and then that resulting diff is applied to the Packages file, which turns out to be much faster.
Posted Sep 3, 2015 19:09 UTC (Thu)
by adelcast (guest, #94927)
[Link] (7 responses)
Posted Sep 4, 2015 9:37 UTC (Fri)
by jwilk (subscriber, #63328)
[Link]
Posted Sep 23, 2015 19:17 UTC (Wed)
by juliank (guest, #45896)
[Link] (5 responses)
The developers also claim that it's a SAT solver, despite SAT solvers not being suitable for dependency solving where some dependencies are optional or more preferred than others.
Posted Sep 23, 2015 20:00 UTC (Wed)
by rahulsundaram (subscriber, #21946)
[Link] (4 responses)
http://www.rpm.org/wiki/Releases/4.13.0
More semantic rules can be added if necessary.
Posted Sep 23, 2015 20:08 UTC (Wed)
by juliank (guest, #45896)
[Link] (3 responses)
Example 1: So for a package that depends on A | B, it would happily choose B, while the user (and in Debian's case, policy) requires it to choose A, unless B is already installed.
Example 2: A package depends on a virtual package. A pure SAT solver could choose any of the packages providing it, whereas you most likely want the smallest one or the one with the fewest dependencies.
Anything else is not a pure SAT solver by definition, but some kind of MAX SAT solver. I'd love to see them clear up their notes to explain what they actually do.
Posted Sep 23, 2015 20:10 UTC (Wed)
by rahulsundaram (subscriber, #21946)
[Link] (2 responses)
Posted Sep 23, 2015 20:16 UTC (Wed)
by juliank (guest, #45896)
[Link] (1 responses)
And as I also wrote, they also duplicate a lot of package management stuff instead of focusing on solving (they deal with repositories, and also read in databases and stuff), which I don't like.
What I want is an API where I can feed everything in a package manager agnostic way via C calls and then let it calculate a solution, without the solver needing to generate its own cache file after refreshing the sources.
Posted Sep 23, 2015 20:33 UTC (Wed)
by rahulsundaram (subscriber, #21946)
[Link]
Posted Sep 14, 2015 10:14 UTC (Mon)
by robbe (guest, #16131)
[Link] (1 responses)
Just replacing Release.gpg with one signed by any old key was never possible (as long as this feature exists at all). The attacker had to have a key that is in the victim's trusted-for-apt set of keys. apt-key manipulates these.
Until you utilize the new key-pinning feature, you have the problem, that the key of any repository that you trust can sign any other repository's Release.gpg. That's ye olde CA problem all over again.
So let's imagine the evil lizardmen want to distribute a trojanised coreutils package. If they are able to place arbirary files on a mirror, they would still have to force (for example) Christian Marillat, who maintains and signs the popular deb-multimedia.org repo, to sign their bad Release file. All victims trusting the deb-multimedia.org key would not see any corruption under the old regime. With key-pinning this is no longer possible.
But our vulnerable victims were trusting deb-multimedia.org! There is nothing preventing the lizardmen from putting their coreutils there, if they already have Christian Marillat in their clutches. Does key-pinning protect me here? Can a package that came from a repository signed by key X be replace by a newer version from a repostitory signed by key Y?
Posted Sep 23, 2015 19:19 UTC (Wed)
by juliank (guest, #45896)
[Link]
If you use it, you're supposed to pin it to 1 and then whitelist only the packages you want by pinning them to 100 or 1000 or whatever you want.
Advances in Debian's package manager
Advances in Debian's package manager
zypper list
lists repositories and zypper help list
tells you how to use it and what switches are available. That's great. I also like the short versions of each command (li = list, se = search, up = upgrade, dup = dist-upgrade etc). I wish all command line tools worked that way.Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
Advances in Debian's package manager
> Releases.gpg file signed by their own key, and an Apt user would
> not know that the old key had been replaced.
Advances in Debian's package manager