Re: pkgbase checksums

From: Rosenke <rosenke_at_dssgmbh.de>
Date: Mon, 17 Jan 2022 15:12:38 UTC
On 13.01.22 13:57, Baptiste Daroussin wrote:
> On Thu, Jan 13, 2022 at 11:33:55AM +0100, Stefan Esser wrote:
>> Am 13.01.22 um 10:36 schrieb Henrik Rosenke:
>>> Hello,
>>>
>>> what is the correct way to handle pkg checksum mismatches in pkgbase? (pkg
>>> check -sa)
>>> For example after installing bash or editing /etc/hosts there are checksum
>>> mismatches:
>>>
>>>      FreeBSD-clibs-12.2.s20220105232846: checksum mismatch for /etc/hosts
>>>      FreeBSD-clibs-12.2.s20220105232846: checksum mismatch for /etc/shells
>>>
>>> I workaround this after setting up the jail by executing pkg check -r but this
>>> doesnt seem right to me. Also this doesnt handle modifications made afterwards.
>>> In normal pkgs we got the ability to provide a default and modify this, for
>>> this files no checksums are stored from what i know.
>> I'm not a pkgbase user, but I'd think that this could be fixed
>> by using @sample to have e.g. /etc/hosts.sample with a checksum,
>> which is copied to /etc/hosts if that file does not exist during
>> installation.
>>
>> This logic works great for ports, but had the disadvantage of
>> doubling the number of files in /etc that are installed that way,
>> since the .sample file will have to stay as part of the installed
>> pkgbase package and may occasionally be updated.
>>
>> That would also allow a special version of etcupdate to detect
>> changed .sample files and to perform a 3-way merge on the installed
>> files as is possible when building from source.
>>
>> Regards, STefan
> We have @config for base were pkg will do a 3 way merge, just those files are
> probably not marked as @config and should.
>
> (@config is native while @sample is external and define only in the ports tree)
>
> if they are marked as such, then it means we have a bug in pkg checksum as it
> should not check the checksum of the files marked @config
>
> Best regards,
> Bapt
I tried it again with pkg 1.17.5 and FreeBSD 12.3 packages but got the 
same Error. The @config section is included in the packages:
pkg info -R FreeBSD-clibs
config: [
     "/etc/nsswitch.conf",
     "/etc/libmap.conf",
     "/etc/hosts",
     "/etc/protocols",
     "/etc/netconfig",
     "/etc/hosts.equiv",
     "/etc/rpc",
     "/etc/mac.conf",
     "/etc/shells",
     "/etc/networks"
]

In total these are now 9 cheksum mismatches in the pkgbase jail:
=== root@dsssrvt4j1 (pts/2) ~ 19(3) -> pkg check -sa
Checking all packages:   1%
FreeBSD-clibs-12.2.s20220114103031: checksum mismatch for /etc/hosts
FreeBSD-clibs-12.2.s20220114103031: checksum mismatch for /etc/shells
Checking all packages:  78%
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /.profile
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /etc/locate.rc
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /etc/login.conf
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /etc/sysctl.conf
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /etc/syslog.conf
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /etc/ttys
FreeBSD-runtime-12.2.s20220114103031: checksum mismatch for /root/.profile
Checking all packages: 100%

-- 
Regards,
Henrik Rosenke