Browse Source

dpkg: ensure that post_postinst_tasks() doesn't introduce bad data

The pending triggers were removed because the postinst has just been
run, unfortunately in some cases it would restore the status to
pending-triggers. This is notably the case when a package is
removed while being in triggers-pending and when the prerm fails.

In fact it was not correct to remove the pending triggers in this
function because only "postinst configure" should clear the pending
triggers. Thus move the removal of the pending triggers to
deferred_configure() in src/configure.c and reset the status
to its "normal" value when the target status is one of triggers-awaited,
triggers-pending or installed.

With this change, it's no longer possible to have a status of
triggers-pending without any pending trigger in trigpend_head.

Note that despite this change, the pending triggers are lost
during a failed removal because dpkg switches the package to
halfconfigured before running "prerm remove" and modstatdb_note()
drops the pending triggers in that situation.
Raphaël Hertzog 15 years ago
parent
commit
3c3dce2484
3 changed files with 8 additions and 4 deletions
  1. 2 2
      debian/changelog
  2. 1 0
      src/configure.c
  3. 5 2
      src/help.c

+ 2 - 2
debian/changelog

@@ -38,8 +38,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     debian/source/patch-header. Closes: #629582
     debian/source/patch-header. Closes: #629582
   * Changed dpkg-source --after-build to automatically unapply patches that it
   * Changed dpkg-source --after-build to automatically unapply patches that it
     has applied during --before-build.
     has applied during --before-build.
-  * Fix one possible cause for the assertion failure "pigp->trigpend_head".
-    LP: #798793
+  * Fix two possible causes for the assertion failure "pigp->trigpend_head".
+    LP: #798793, #424358 Closes: #560251
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 1 - 0
src/configure.c

@@ -355,6 +355,7 @@ deferred_configure(struct pkginfo *pkg)
 	                           NULL);
 	                           NULL);
 
 
 	pkg->eflag = eflag_ok;
 	pkg->eflag = eflag_ok;
+	pkg->trigpend_head = NULL;
 	post_postinst_tasks(pkg, stat_installed);
 	post_postinst_tasks(pkg, stat_installed);
 }
 }
 
 

+ 5 - 2
src/help.c

@@ -214,8 +214,11 @@ preexecscript(struct command *cmd)
 void
 void
 post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status)
 post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status)
 {
 {
-  pkg->trigpend_head = NULL;
-  pkg->status = pkg->trigaw.head ? stat_triggersawaited : new_status;
+  if (new_status < stat_triggersawaited)
+    pkg->status = new_status;
+  else
+    pkg->status = pkg->trigaw.head ? stat_triggersawaited :
+                  pkg->trigpend_head ? stat_triggerspending : stat_installed;
 
 
   post_postinst_tasks_core(pkg);
   post_postinst_tasks_core(pkg);
 }
 }