#1012601 wireless-regdb: alternative broken on debian-installer install

Package:
wireless-regdb
Source:
wireless-regdb
Submitter:
Dominique Martinet
Date:
2022-06-30 00:24:03 UTC
Severity:
important
Tags:
#1012601#5
Date:
2022-06-10 00:39:46 UTC
From:
To:
Package: wireless-regdb
Version: 2021.08.28-1
Severity: important
Tags: d-i
X-Debbugs-Cc: debian-boot@lists.debian.org

Dear Maintainer,

I've noticed after installing wireless-regdb on a fresh install the
package-provided file is not actually used (older version from
wireless-regdb-udeb is used), and update-alternative to select the
upstream version of the regdb also fails


(debian-boot@l.d.o: sorry for the explicit cc, I'm not really sure what
the d-i tag implies)


The problem is that the installer copies /lib/firmware/regulatory.db and
/lib/firmware/regulatory.db.p7s from the installer, and wireless-regdb
postinstall script does not overwrite these if they exist.

This can be reproduced in a minimal container:
root@00e7025e1eeb:/# mkdir /lib/firmware
root@00e7025e1eeb:/# touch /lib/firmware/regulatory.db
root@00e7025e1eeb:/# apt install -y wireless-regdb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  crda
The following NEW packages will be installed:
  wireless-regdb
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.9 kB of archives.
After this operation, 42.0 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 wireless-regdb all 2020.04.29-2 [13.9 kB]
Fetched 13.9 kB in 0s (222 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package wireless-regdb.
(Reading database ... 6662 files and directories currently installed.)
Preparing to unpack .../wireless-regdb_2020.04.29-2_all.deb ...
Unpacking wireless-regdb (2020.04.29-2) ...
Setting up wireless-regdb (2020.04.29-2) ...
update-alternatives: using /lib/firmware/regulatory.db-debian to provide /lib/firmware/regulatory.db (regulatory.db) in auto mode
update-alternatives: warning: not replacing /lib/firmware/regulatory.db with a link
update-alternatives: warning: forcing reinstallation of alternative /lib/firmware/regulatory.db-debian because link group regulatory.db is broken
update-alternatives: warning: not replacing /lib/firmware/regulatory.db with a link
root@00e7025e1eeb:/# ls -l /lib/firmware/regulatory.db*
-rw-r--r-- 1 root root    0 Jun 10 00:21 /lib/firmware/regulatory.db
-rw-r--r-- 1 root root 3764 Jun 30  2020 /lib/firmware/regulatory.db-debian
-rw-r--r-- 1 root root 3764 Jun 30  2020 /lib/firmware/regulatory.db-upstream
lrwxrwxrwx 1 root root   35 Jun 10 00:21 /lib/firmware/regulatory.db.p7s -> /etc/alternatives/regulatory.db.p7s
-rw-r--r-- 1 root root 1249 Jun 30  2020 /lib/firmware/regulatory.db.p7s-debian
-rw-r--r-- 1 root root 1182 Jun 30  2020 /lib/firmware/regulatory.db.p7s-upstream
root@00e7025e1eeb:/# update-alternatives --config regulatory.db
There are 2 choices for the alternative regulatory.db (providing /lib/firmware/regulatory.db).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
  0            /lib/firmware/regulatory.db-debian     100       auto mode
* 1            /lib/firmware/regulatory.db-debian     100       manual mode
  2            /lib/firmware/regulatory.db-upstream   50        manual mode

Press <enter> to keep the current choice[*], or type selection number:
update-alternatives: warning: forcing reinstallation of alternative /lib/firmware/regulatory.db-debian because link group regulatory.db is broken
update-alternatives: warning: not replacing /lib/firmware/regulatory.db with a link
root@00e7025e1eeb:/# ls -l /lib/firmware/regulatory.db
-rw-r--r-- 1 root root    0 Jun 10 00:21 /lib/firmware/regulatory.db


Running with --force removes the original file with a warning and works:
root@00e7025e1eeb:/# update-alternatives --force --config regulatory.db
There are 2 choices for the alternative regulatory.db (providing /lib/firmware/regulatory.db).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
  0            /lib/firmware/regulatory.db-debian     100       auto mode
* 1            /lib/firmware/regulatory.db-debian     100       manual mode
  2            /lib/firmware/regulatory.db-upstream   50        manual mode

Press <enter> to keep the current choice[*], or type selection number:
update-alternatives: warning: forcing reinstallation of alternative /lib/firmware/regulatory.db-debian because link group regulatory.db is broken
root@00e7025e1eeb:/# ls -l /lib/firmware/regulatory.db
lrwxrwxrwx 1 root root 31 Jun 10 00:23 /lib/firmware/regulatory.db -> /etc/alternatives/regulatory.db




The original cause for this is that deian-installer copies the files
because of the combinaison of these two:
https://salsa.debian.org/installer-team/debian-installer/-/blob/master/build/pkg-lists/base#L34
 - wireless-regdb-udeb contains the firmwares as regular files
https://salsa.debian.org/installer-team/hw-detect/-/blob/master/hw-detect.post-base-installer.d/50install-firmware#L14
 - it copies /lib/firmware content in base post-install step

the udeb regdb is also slightly obsolete, I'm not sure why it was needed
in the first place but it might be possible to use the normal package
instead?

That won't fix existing systems though.
If wireless-regdb had been owning the files in dpkg it would be fair
game to just overwrite the files (dpkg overwrites any untracked file
when installing a package that provides the path).

Would it make sense to include regulatory.db -> regulatory.db-debian
(+same for p7s) links in the package itself, so package installation
overwrites these and the post update-alternative step fixes it?
It seems to fix "broken" links without force in this case.
(or push real links to /etc/alternatives/regulatory.db would work too)


Thanks,

#1012601#10
Date:
2022-06-13 14:39:23 UTC
From:
To:
On Fri, 2022-06-10 at 09:39 +0900, Dominique Martinet wrote:
[...]

I didn't realise the installer was copying firmware files over.  It
should be installing the relevant packages instead where possible.

Why do you think it's obsolete?  It is useful to have this file present
in the installer.

I don't think it's right to include symlinks in the package that are
supposed to be managed by update-alternatives.  I would rather fix this
up in the postinst script.

Ben.

#1012601#15
Date:
2022-06-13 23:27:17 UTC
From:
To:
Ben Hutchings wrote on Mon, Jun 13, 2022 at 04:39:23PM +0200:
just that it is old: wireless-regdb-udeb hasn't been updated in two
years, while the main wireless-regdb package keeps getting updates
regularly.

That means it's possible a firmware that requires the updated version
to work for new band regulations will not have access to these bands
for IR.

Note that for clients (installer usecase), it _also_ doesn't matter: if
an AP uses regulated bands, the client will (should?) rightfully use
these. Regulations mean a wireless emetter cannot start broadcasting on
regulated bands unless they know it's safe, but if an access point or
other clients use the band they can tell it's OK and will allow it.
The regdb will thus only matter for people setting up hotspots or AP on
their system, or perhaps if the remote AP is also missing its regdb but
I'm not sure how the ssid would come up then.
(At least, the marvell/NXP chip I've tested this with does that
properly; there can be other aspects to regdb I'm not aware of or didn't
understand)

In that sense, removing the firmware from installer also should not make
a difference to most users, but I'm not suggesting to remove it in this
bug as I'm sure there was a reason for it to be added in the first place.

I'd just like post-install systems which install the package to get the
new version :)

Yeah, it probably makes more sense to just remove whatever was there in
the post-install script.
I'll leave the resolution to you unless you want/need help with
something.

#1012601#20
Date:
2022-06-29 23:32:25 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
wireless-regdb, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1012601@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Ben Hutchings <benh@debian.org> (supplier of updated wireless-regdb package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Thu, 30 Jun 2022 00:01:25 +0200
Source: wireless-regdb
Architecture: source
Version: 2022.04.08-2
Distribution: unstable
Urgency: medium
Maintainer: Debian kernel team <debian-kernel@lists.debian.org>
Changed-By: Ben Hutchings <benh@debian.org>
Closes: 1012601
Changes:
 wireless-regdb (2022.04.08-2) unstable; urgency=medium
 .
   * debian/tests: Add check that regulatory.db signatures are valid
   * d/wireless-regdb.postinst: Remove regular files installed by d-i
     (Closes: #1012601)
Checksums-Sha1:
 2b06505f5dbd8ae3582a324dd9b539580c2d05ca 2270 wireless-regdb_2022.04.08-2.dsc
 d6ebdaa8826a4bfaea2f9bcfe6bb2ac4413f5e05 18504 wireless-regdb_2022.04.08-2.debian.tar.xz
 2b0f8edd556e3e6448c086a9b68f4b580ebc0e73 7427 wireless-regdb_2022.04.08-2_source.buildinfo
Checksums-Sha256:
 7ccbf0f383389ee308f2ed07bdf6cdea1b210ce57ad0f86c3171abc03e5a92e7 2270 wireless-regdb_2022.04.08-2.dsc
 e502b481a3431fa8ac6970dd9cc258758d1660616938302a4c4336f20dbfe6bd 18504 wireless-regdb_2022.04.08-2.debian.tar.xz
 6d93e1f912b9944f62f413008f15f3e8b2ad1b6091a2e5490ea95cfeabb12b48 7427 wireless-regdb_2022.04.08-2_source.buildinfo
Files:
 a36033f129f73a1dad095343c001c31d 2270 net optional wireless-regdb_2022.04.08-2.dsc
 a90611177003018ff19e2e92f303a9e6 18504 net optional wireless-regdb_2022.04.08-2.debian.tar.xz
 30b375065455cad58af4180da57a6f43 7427 net optional wireless-regdb_2022.04.08-2_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEErCspvTSmr92z9o8157/I7JWGEQkFAmK8y+cACgkQ57/I7JWG
EQnphhAAwyuNMrFir05nTTxw7KeiWIYM05sL978L7afZvIshK0PuansqHivJHngA
YIq2Py8CG8MaX5+KMCT7ouN44/cWgtl/2r7UMMKYMsib7s41PpijahIPkzxll5NG
uvANpssqsKTnhzfq3zgFLyhJDN461Sj9Y8k0dIPY2wI1kbhGTtlqpwZOAbfkISbb
t+LpWiviMiMjmupioyVBOvuE+RD+X0DDrYqqubQYtBtJOyF90Exlf3yU7fVL4I9m
ximGg1PDNFPcQsKS654eBKvdmHK0kV/DCdu2bUnl7EeYDvDlyNdbj7UZsDNKOMjf
cssIYjz4S2pRedE4lZ+PDTUnb9A0hYDUGbgizYdH5IfmFinmnQR4s+H9FlAAR4/f
PSnqkqXgXypLeommeUEzVfxYyuYgDC0VvjGrORCpO6PEgSo7mXxd3jhP2QA9G+GE
zqrHB2sbBx6ACBQyxNg+mxgH00BZxxqsW99/ovSfhLV1ZMz4lGU0OqSGRFHNAsUV
9LQHwISWkcqrzoE8PPkcGygliunRME9KmY31RafU35P2RNxmHVM3w3NGehv+90cx
VB7rz4Z4UIzkwRsUc4kVqp6vlDmPQNQrv1U8nHoysif0UKkNxWc75Q9cI+HHRBaU
oAPxTyXt+lOd9BlJoq5sUVZfsrJqhvASXmMY44s0QJu1orWwK6E=
=BWCX
-----END PGP SIGNATURE-----

#1012601#25
Date:
2022-06-30 00:08:24 UTC
From:
To:
You are comparing wireless-regdb-udeb in stable with wireless-regdb in
unstable.

Both the regular and udeb packages are outdated in stable, but this
should be fixed in the next point release.

[...]

Yes, I think this is generally what happens.  But the kernel wants to
load regulatory.db regardless of what mode is being used, so it seemed
like a good idea to include it in the installer.

This bug shows that that didn't have an entirely positive effect, but
it will be fixed.

[...]

That is what I've now implemented.

Ben.

#1012601#30
Date:
2022-06-30 00:20:40 UTC
From:
To:
Ben Hutchings wrote on Thu, Jun 30, 2022 at 02:08:24AM +0200:

Ah, sorry I didn't realize they had the same source package.

I've had a look at the postinst script[1] after the automated
notification and it looks good to me, thank you.

[1] https://salsa.debian.org/kernel-team/wireless-regdb/-/blob/master/debian/wireless-regdb.postinst