From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from master.debian.org (master.debian.org [IPv6:2001:41b8:202:deb:216:36ff:fe40:4001]) by sourceware.org (Postfix) with ESMTPS id 6B60D3858D37 for ; Tue, 24 Oct 2023 12:09:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B60D3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=master.debian.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B60D3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:41b8:202:deb:216:36ff:fe40:4001 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698149360; cv=none; b=Cl87wRr6zYOCtzt+dnnS/CvMM09Rt8X+iW2fU4K9DyXZ9cnV74YyP2YahUzOB5X3fendKQxqezuV5a4+E/CUIhoLyJYtOg4bSgjise6Ox/8fmkgolYW4/6AM6P9TxnaZW8ZZkNEEwv/fOKBS7AFTGz94sD+7nGGWWojAK4ltbLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698149360; c=relaxed/simple; bh=NU12/eeMpv5S1epsQgc1st8e4rDCFQ8uOZDJ4AdWRqM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=MyK7dauNrsXRO00YgdLnD1vT/WTJml5Sa6Tuia6Io1AwiUMvHhrd52IIdht1x/UHn1EFTB7Y23AFZvl1j/wpGMtTo5sfPjQ0R3Az7I1M1gq2UcgXSgxep/uvM+J78lsS5+/xYUrgbQYUxtqQ5uWRSt4Qlx4F6jaIsJDA4ySWiV4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.master; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description; bh=MSeGG0PQkL1AVRtb0xgHb+Mx2EFCxL+/FtFmOw3awds=; b=eewhpUWedUcd9ZU43PXvN4FkyY FlXx1CDf5waJMN18qTxUR1E3m0Z7N3pcMGavoePXlHZSUa6tP60e7hn87U9RCDWzv8aXtrm8zE8OP /aQQfM8edRY3pRVrWM+jpMy9ksb+CPaD64lQf8MK1F0qeWHcHTlOAQ0OCMVY+Smmqqo+oouUzwtbA OS1oA3PbtvBWh/LZYib8D+k0Fe/B7GtelQ2GScDTYLG3kDbkyfumDTbc0TQE2XqnvL8J7Ry/QRE2b /vHT6GB0CJfwBRsaRI3BSLs0j+gsvm4vyyl/pziY0OnXaKGW24Kf4P+iVrcnXSD1vdHU1trf+Ir3i /89NqbPw==; Received: from guillem by master.debian.org with local (Exim 4.94.2) (envelope-from ) id 1qvFqc-006DLr-Mi; Tue, 24 Oct 2023 11:45:22 +0000 Date: Tue, 24 Oct 2023 13:45:21 +0200 From: Guillem Jover To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] ldconfig: Actually ignore dpkg-related temporarily files Message-ID: References: <87edhlwq6y.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="z28aFG4KrPhxETD3" Content-Disposition: inline In-Reply-To: <87edhlwq6y.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --z28aFG4KrPhxETD3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi! On Mon, 2023-10-23 at 13:09:25 +0200, Florian Weimer wrote: > These files actually end in .dpkg-new and .dpkg-tmp, not .tmp > as I mistakenly assumed. > > Fixes commit 2aa0974d2573441bffd59 ("elf: ldconfig should skip > temporary files created by package managers"). > > --- > elf/ldconfig.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/elf/ldconfig.c b/elf/ldconfig.c > index 02387a169c..4abde26e60 100644 > --- a/elf/ldconfig.c > +++ b/elf/ldconfig.c > @@ -661,6 +661,17 @@ struct dlib_entry > struct dlib_entry *next; > }; > > +/* Return true if the N bytes at NAME end with with the characters in > + the string SUFFIX. (NAME[N + 1] does not have to be a null byte.) > + Expected to be called with a string literal for SUFFIX. */ > +static inline bool > +endswithn (const char *name, size_t n, const char *suffix) > +{ > + return (n >= strlen (suffix) > + && memcmp (name + n - strlen (suffix), suffix, > + strlen (suffix)) == 0); > +} > + > /* Skip some temporary DSO files. These files may be partially written > and lead to ldconfig crashes when examined. */ > static bool > @@ -670,8 +681,7 @@ skip_dso_based_on_name (const char *name, size_t len) > names like these are never really DSOs we want to look at. */ > if (len >= sizeof (".#prelink#") - 1) > { > - if (strcmp (name + len - sizeof (".#prelink#") + 1, > - ".#prelink#") == 0) > + if (endswithn (name, len, ".#prelink#")) > return true; > if (len >= sizeof (".#prelink#.XXXXXX") - 1 > && memcmp (name + len - sizeof (".#prelink#.XXXXXX") > @@ -682,7 +692,8 @@ skip_dso_based_on_name (const char *name, size_t len) > if (memchr (name, len, ';') != NULL) > return true; > /* Skip temporary files created by dpkg. */ > - if (len > 4 && memcmp (name + len - 4, ".tmp", 4) == 0) > + if (endswithn (name, len, ".dpkg-new") > + || endswithn (name, len, ".dpkg-tmp")) > return true; > return false; > } > > base-commit: 2aa0974d2573441bffd596b07bff8698b1f2f18c Thanks, LGTM! I've tentatively queued the attached patch (will review it further for correctness later today) trying to document these files in dpkg(1), as I noticed this does not seem to be documented anywhere (except in code comments), in the hopes it will help the next person. :) Thanks, Guillem --z28aFG4KrPhxETD3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-man-Document-the-intermediary-files-used-during-unpa.patch" Content-Transfer-Encoding: quoted-printable =46rom 6e30d7f80b32a09511c1b849e392f87768ddcaef Mon Sep 17 00:00:00 2001 =46rom: Guillem Jover Date: Sun, 22 Oct 2023 12:50:49 +0200 Subject: [PATCH] man: Document the intermediary files used during unpack and configure There did not seem to be any explicit documentation anywhere about these files nor their functions. Prompted-by: Florian Weimer Ref: https://sourceware.org/pipermail/libc-alpha/2023-October/152245.html --- man/dpkg.pod | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/man/dpkg.pod b/man/dpkg.pod index 8594e8e71..78383c50d 100644 --- a/man/dpkg.pod +++ b/man/dpkg.pod @@ -1448,6 +1448,51 @@ useful if it's lost or corrupted due to filesystems = troubles. =20 The format and contents of a binary package are described in L. =20 +=3Dhead2 Filesystem files + +During unpacking and configuration B uses various files for backup +and rollback purposes. + +=3Dover + +=3Ditem F<*.dpkg-new> + +During unpack, B extracts all new filesystem objects +into IB<.dpkg-new> +(except for new directories which go directly into I, +or existing directories or symlinks to directories which get skipped), +once that is done and after having performed backups of the old objects, +eventually all get renamed to I. + +=3Ditem F<*.dpkg-tmp> + +During unpack, B makes backups of the old filesystem objects +into IB<.dpkg-tmp> after extracting the new files. +These backups are not performed for conffiles as they are processed +at a later stage. +Otherwise these backups are performed as either a rename for directories +(but only if they switch file type), +a new symlink copy for symlinks, +or a hard link for any other filesystem object. + +In case of needing to rollback, these backups get used to restore the +previous contents of the objects. +These get removed automatically after the installation is complete. + +=3Ditem F<*.dpkg-old> + +During configuration, when installing a new version, +B cam make a backup of the previous modified conffile into +IB<.dpkg-old>. + +=3Ditem F<*.dpkg-dist> + +During configuration, when keeping the old version, +B can make a backup of the new unmodified conffile into +IB<.dpkg-dist>. + +=3Dback + =3Dhead1 SECURITY =20 Any operation that needs write access to the database or the filesystem --=20 2.42.0 --z28aFG4KrPhxETD3--