summaryrefslogtreecommitdiff
path: root/src/trigproc.c
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2011-06-17 23:22:55 +0200
committerRaphaël Hertzog <hertzog@debian.org>2011-06-17 23:50:39 +0200
commita36cadba41b19d5908bdfcb658cf01af07c1436a (patch)
tree8ef42d198da31d4779856657ae0bcdfa153d8315 /src/trigproc.c
parent1165f6821681075eeed66ca9cf1e889a057f636c (diff)
downloaddpkg-a36cadba41b19d5908bdfcb658cf01af07c1436a.tar.gz
dpkg: ensure that trig_transitional_activate() doesn't introduce bad data
trig_transitional_activate() is emptying Triggers-Pending without ensuring that the status is set back to something which is not triggers-pending. In theory it's ok because the trig_parse_ci() call is supposed to reactivate all the triggers. But if there's no triggers file any more then we're effectively introducing a skew which is going to be fatal the next time we try to write down the status file. The disparition of the triggers file can happen with file system problems, bad user manipulation or even an old dpkg bug that kept triggers alive when in fact the trigger was dropped from the package. Or the triggers file has effectively been removed in the package but the user has restored an old status file with a triggers-pending status that the current package should no longer be able to generate. In other words, properly resetting the status in trig_transitional_activate() makes dpkg more robust.
Diffstat (limited to 'src/trigproc.c')
-rw-r--r--src/trigproc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/trigproc.c b/src/trigproc.c
index 07bf346be..2c34caebc 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -387,6 +387,13 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
cstatus >= msdbrw_write ?
transitional_interest_callback :
transitional_interest_callback_ro, NULL, pkg);
+ /* Ensure we're not creating incoherent data that can't
+ * be written down. This should never happen in theory but
+ * can happen if you restore an old status file that is
+ * not in sync with the infodb files. */
+ pkg->status = pkg->trigaw.head ? stat_triggersawaited :
+ pkg->trigpend_head ? stat_triggerspending :
+ stat_installed;
}
pkg_db_iter_free(it);