This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
commit c2715071aa64807c9b95edd7c6e4cd8c3eb4ad8c Author: Guillem Jover <guil...@debian.org> Date: Wed Apr 4 02:48:32 2018 +0200 dpkg-divert: Warn when using --rename on a file from an Essential package Renaming a file from dpkg-divert for an Essential package is very dangerous, because that file will not be available until dpkg has unpacked the diverting package, which might render the system non-functional. --- debian/changelog | 1 + src/divertcmd.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/debian/changelog b/debian/changelog index f6ad3a5..123ef67 100644 --- a/debian/changelog +++ b/debian/changelog @@ -50,6 +50,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium * Add a new --no-rename option to dpkg-divert. This is the current default behavior, but it will make it possible to do a default switch in 1.20.x. * Warn when using dpkg-divert --add or --remove w/o --rename or --no-rename. + * Warn when using dpkg-divert --rename on a file from an Essential package. * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo <m...@debian.org> diff --git a/src/divertcmd.c b/src/divertcmd.c index d46331f..e7bb5ad 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -399,6 +399,33 @@ divertdb_write(void) } static bool +diversion_is_essential(struct filenamenode *namenode) +{ + struct pkginfo *pkg; + struct pkgiterator *pkg_iter; + struct filepackages_iterator *iter; + bool essential = false; + + pkg_iter = pkg_db_iter_new(); + while ((pkg = pkg_db_iter_next_pkg(pkg_iter))) { + if (pkg->installed.essential) + ensure_packagefiles_available(pkg); + } + pkg_db_iter_free(pkg_iter); + + iter = filepackages_iter_new(namenode); + while ((pkg = filepackages_iter_next(iter))) { + if (pkg->installed.essential) { + essential = true; + break; + } + } + filepackages_iter_free(iter); + + return essential; +} + +static bool diversion_is_owned_by_self(struct pkgset *set, struct filenamenode *namenode) { struct pkginfo *pkg; @@ -514,6 +541,9 @@ diversion_add(const char *const *argv) filename, pkgset->name); opt_rename = false; } + if (opt_rename && diversion_is_essential(fnn_from)) + warning(_("diverting file '%s' from an Essential package with " + "rename is dangerous, use --no-rename"), filename); if (!opt_test) { divertdb_write(); if (opt_rename) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/dpkg/dpkg.git