[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug in /etc/cron.daily/dpkg script



Hi all !

I just found a bug in the /etc/cron.daily/dpkg script : when one of the dbfiles does not
exist dbchanged is set to yes and the script performs the backup while it shouldn't happen

I detected this on a system for which I have a readonly root filesystem.

I attached a patch with a simple fix to this bug.

Have fun !

--- dpkg.orig	2019-10-03 14:35:10.137581211 +0200
+++ dpkg	2019-10-03 14:36:48.350579896 +0200
@@ -9,9 +9,11 @@
     dbchanged=no
     dbfiles="arch status diversions statoverride"
     for db in $dbfiles ; do
-        if ! cmp -s "dpkg.${db}.0" "$dbdir/$db"; then
-            dbchanged=yes
-            break;
+        if [ -e "$dbdir/$db" ] ; then
+            if ! cmp -s "dpkg.${db}.0" "$dbdir/$db"; then
+                dbchanged=yes
+                break;
+            fi
         fi
     done
     if [ "$dbchanged" = "yes" ] ; then


Reply to: