Skip to contentSkip to conversation

allow to recompile wireless-regdb

PATCH New Kurt Van Dijck 3 participants 10 messages Jun 12, 2020 – Jun 25, 2020

lore
Share & tools
lore
#0 lore raw

cover allow to recompile wireless-regdb

This series adds an option to recompile wireless-regdb. This became necessary in our product for outdoor use. In some countries, different regulations apply for indoor and outdoor use. The precompiled version of wireless-regdb is appropriate for indoor use only.

For this to work, we compile using python3, and added host-python3-m2crypto prerequisite in buildroot.

Finally, we patched wireless-regdb for hiding the username of the build-server.

Kind regards,
Kurt

#1 lore raw

PATCH 1/3 python3-m2crypto: import package

---
 package/python3-m2crypto/python3-m2crypto.mk | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 package/python3-m2crypto/python3-m2crypto.mk
package/python3-m2crypto/python3-m2crypto.mk new file +21 -0
new file mode 100644
index 0000000000..4394226067
@@ -0,0 +1,21 @@
+################################################################################
+#
+# python3-m2crypto
+#
+################################################################################
+
+# Please keep in sync with
+PYTHON3_M2CRYPTO_VERSION = 0.35.2
+PYTHON3_M2CRYPTO_SOURCE = M2Crypto-$(PYTHON3_M2CRYPTO_VERSION).tar.gz
+PYTHON3_M2CRYPTO_SITE = https://files.pythonhosted.org/packages/74/18/3beedd4ac48b52d1a4d12f2a8c5cf0ae342ce974859fba838cbbc1580249
+PYTHON3_M2CRYPTO_SETUP_TYPE = setuptools
+PYTHON3_M2CRYPTO_LICENSE = MIT
+PYTHON3_M2CRYPTO_LICENSE_FILES = LICENSE
+HOST_PYTHON3_M2CRYPTO_DL_SUBDIR = python-m2crypto
+HOST_PYTHON3_M2CRYPTO_NEEDS_HOST_PYTHON = python3
+
+HOST_PYTHON3_M2CRYPTO_DEPENDENCIES = host-swig
+
+HOST_PYTHON3_M2CRYPTO_BUILD_OPTS = --openssl $(HOST_DIR)
+
+$(eval $(host-python-package))
Signature · 1 line
2.25.0
#2 lore raw

PATCH 1/3 python3-m2crypto: import package

Hello Kurt,

Thanks for this contribution. The commit title needs to be:

package/python3-m2crypto: new package

It should be mentioned that we used to have a python-m2crypto package, which was removed in commit 484c04878e5e76cdc0cc33c7646f98ab41698a7e because it was only used by crda, and crda no longer needed it.

Quoted 4 lines · On Fri, 12 Jun 2020 07:31:08 +0200 Kurt Van Dijck…
---
 package/python3-m2crypto/python3-m2crypto.mk | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)

You're missing a .hash file, as well as an entry in the DEVELOPERS file.

Quoted 8 lines
 create mode 100644 package/python3-m2crypto/python3-m2crypto.mk
package/python3-m2crypto/python3-m2crypto.mk new file +0 -0
new file mode 100644
index 0000000000..4394226067

package/python3-m2crypto/python3-m2crypto.mk line 7

Quoted 7 lines
package/python3-m2crypto/python3-m2crypto.mk new file +7 -0
@@ -0,0 +1,21 @@
+################################################################################
+#
+# python3-m2crypto
+#
+################################################################################
+
+# Please keep in sync with

in sync with ?

package/python3-m2crypto/python3-m2crypto.mk line 19

Quoted 12 lines
package/python3-m2crypto/python3-m2crypto.mk new file +12 -0
+PYTHON3_M2CRYPTO_VERSION = 0.35.2
+PYTHON3_M2CRYPTO_SOURCE = M2Crypto-$(PYTHON3_M2CRYPTO_VERSION).tar.gz
+PYTHON3_M2CRYPTO_SITE = https://files.pythonhosted.org/packages/74/18/3beedd4ac48b52d1a4d12f2a8c5cf0ae342ce974859fba838cbbc1580249
+PYTHON3_M2CRYPTO_SETUP_TYPE = setuptools
+PYTHON3_M2CRYPTO_LICENSE = MIT
+PYTHON3_M2CRYPTO_LICENSE_FILES = LICENSE
+HOST_PYTHON3_M2CRYPTO_DL_SUBDIR = python-m2crypto
+HOST_PYTHON3_M2CRYPTO_NEEDS_HOST_PYTHON = python3
+
+HOST_PYTHON3_M2CRYPTO_DEPENDENCIES = host-swig
+
+HOST_PYTHON3_M2CRYPTO_BUILD_OPTS = --openssl $(HOST_DIR)

It needs OpenSSL ? Then I guess host-openssl should be in the dependencies, no ?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 2/3 wireless-regdb: add option to rebuild

In reply to Kurt Van Dijck
---
 package/wireless-regdb/0003-python3.patch | 24 +++++++++++++++++++++++
 package/wireless-regdb/Config.in          | 10 ++++++++++
 package/wireless-regdb/wireless-regdb.mk  | 13 ++++++++++--
 3 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 package/wireless-regdb/0003-python3.patch
package/wireless-regdb/0003-python3.patch new file +24 -0
new file mode 100644
index 0000000000..87226b763f
@@ -0,0 +1,24 @@
+--- a/db2bin.py	2020-06-04 12:10:59.825073819 +0200
++++ b/db2bin.py	2020-06-04 12:11:52.355229867 +0200
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ 
+ from io import BytesIO, open
+ import struct
+--- a/db2fw.py	2020-06-04 12:10:59.825073819 +0200
++++ b/db2fw.py	2020-06-04 12:11:52.365229898 +0200
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ 
+ from io import BytesIO, open
+ import struct
+--- a/dbparse.py	2020-06-04 12:10:59.825073819 +0200
++++ b/dbparse.py	2020-06-04 12:11:52.365229898 +0200
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ 
+ from builtins import bytes
+ from functools import total_ordering
package/wireless-regdb/Config.in +10 -0
index 17350a41d8..cb8ec20977 100644
@@ -12,3 +12,13 @@ config BR2_PACKAGE_WIRELESS_REGDB
 	  application is needed.
 
 	  https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb
+
+if BR2_PACKAGE_WIRELESS_REGDB
+
+config BR2_WIRELESS_REGDB_REBUILD
+	bool "rebuild wireless-regdb"
+	help
+	  Say no to use the pre-built wireless regdb.
+
+	  Say yes to rebuild, and make sure to deploy your wireless-regdb public key.
+endif
package/wireless-regdb/wireless-regdb.mk +11 -2
index 31b62e36e1..d3b30c7fce 100644
@@ -10,12 +10,21 @@ WIRELESS_REGDB_SITE = $(BR2_KERNEL_MIRROR)/software/network/wireless-regdb
 WIRELESS_REGDB_LICENSE = ISC
 WIRELESS_REGDB_LICENSE_FILES = LICENSE
 
+ifeq ($(BR2_WIRELESS_REGDB_REBUILD),y)
+WIRELESS_REGDB_DEPENDENCIES += host-python3-m2crypto
+define WIRELESS_REGDB_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) clean
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
+endef
+endif
+
 ifeq ($(BR2_PACKAGE_CRDA),y)
 define  WIRELESS_REGDB_INSTALL_CRDA_TARGET_CMDS
 	$(INSTALL) -m 644 -D -T $(@D)/regulatory.bin \
 		$(TARGET_DIR)/usr/lib/crda/regulatory.bin
-	$(INSTALL) -m 644 -D -T $(@D)/sforshee.key.pub.pem \
-		$(TARGET_DIR)/etc/wireless-regdb/pubkeys/sforshee.key.pub.pem
+	$(INSTALL) -d $(TARGET_DIR)/etc/wireless-regdb/pubkeys
+	$(INSTALL) -m 644 $(wildcard $(@D)/*.key.pub.pem) \
+		$(TARGET_DIR)/etc/wireless-regdb/pubkeys/
 endef
 endif
 
Signature · 1 line
2.25.0
#4 lore raw

PATCH 2/3 wireless-regdb: add option to rebuild

Hello Kurt,

Quoted 1 line · On Fri, 12 Jun 2020 07:31:09 +0200 Kurt Van Dijck…

Could you expand the commit log to explain why rebuilding the wireless regdb might be necessary ?

package/wireless-regdb/0003-python3.patch

Quoted 3 lines
package/wireless-regdb/0003-python3.patch new file +0 -0
new file mode 100644
index 0000000000..87226b763f

We need all patches to have a description + Signed-off-by line, and be generated using "git format-patch -N" if the upstream project uses Git.

Quoted 7 lines
package/wireless-regdb/Config.in +0 -0
index 17350a41d8..cb8ec20977 100644
@@ -12,3 +12,13 @@ config BR2_PACKAGE_WIRELESS_REGDB
 	  application is needed.
 

package/wireless-regdb/Config.in config BR2_PACKAGE_WIRELESS_REGDB · line 23

Quoted 10 lines
package/wireless-regdb/Config.in +9 -0
 	  https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb
+
+if BR2_PACKAGE_WIRELESS_REGDB
+
+config BR2_WIRELESS_REGDB_REBUILD
+	bool "rebuild wireless-regdb"
+	help
+	  Say no to use the pre-built wireless regdb.
+
+	  Say yes to rebuild, and make sure to deploy your wireless-regdb public key.

Lines are too long.

Could you give a bit of background about this wireless-regdb public key? I see that the Makefile is using some private/public key pair from the user home directory, this looks absolutely horrible in the context of Buildroot. Should we instead have Config.in options to provide the path to the private/public key pair ?

Quoted 6 lines
package/wireless-regdb/Config.in +1 -0
+endif
package/wireless-regdb/wireless-regdb.mk +0 -0
index 31b62e36e1..d3b30c7fce 100644

package/wireless-regdb/wireless-regdb.mk WIRELESS_REGDB_SITE = $(BR2_KERNEL_MIRROR)/software/network/wireless-regdb · line 17

Quoted 8 lines
package/wireless-regdb/wireless-regdb.mk +5 -0
@@ -10,12 +10,21 @@ WIRELESS_REGDB_SITE = $(BR2_KERNEL_MIRROR)/software/network/wireless-regdb
 WIRELESS_REGDB_LICENSE = ISC
 WIRELESS_REGDB_LICENSE_FILES = LICENSE
 
+ifeq ($(BR2_WIRELESS_REGDB_REBUILD),y)
+WIRELESS_REGDB_DEPENDENCIES += host-python3-m2crypto
+define WIRELESS_REGDB_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) clean
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)

Why do you need the "clean" step here ? To force removing the pre-generated wireless regdb, and therefore have the next make invocation re-generate it ?

package/wireless-regdb/wireless-regdb.mk WIRELESS_REGDB_SITE = $(BR2_KERNEL_MIRROR)/software/network/wireless-regdb · line 27

Quoted 12 lines
package/wireless-regdb/wireless-regdb.mk +6 -2
+endef
+endif
+
 ifeq ($(BR2_PACKAGE_CRDA),y)
 define  WIRELESS_REGDB_INSTALL_CRDA_TARGET_CMDS
 	$(INSTALL) -m 644 -D -T $(@D)/regulatory.bin \
 		$(TARGET_DIR)/usr/lib/crda/regulatory.bin
-	$(INSTALL) -m 644 -D -T $(@D)/sforshee.key.pub.pem \
-		$(TARGET_DIR)/etc/wireless-regdb/pubkeys/sforshee.key.pub.pem
+	$(INSTALL) -d $(TARGET_DIR)/etc/wireless-regdb/pubkeys
+	$(INSTALL) -m 644 $(wildcard $(@D)/*.key.pub.pem) \
+		$(TARGET_DIR)/etc/wireless-regdb/pubkeys/

So here you install all public keys. But how are they going to end up in the wireless-regdb build directory ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 3/3 wireless-regdb: omit author info from private key in home directory

In reply to Kurt Van Dijck
---
 .../002-no-author-from-user-privkey.patch            | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 package/wireless-regdb/002-no-author-from-user-privkey.patch
package/wireless-regdb/002-no-author-from-user-privkey.patch new file +12 -0
new file mode 100644
index 0000000000..8cab1e169c
@@ -0,0 +1,12 @@
+diff -Naur wireless-regdb.orig/Makefile wireless-regdb/Makefile
+--- wireless-regdb.orig/Makefile	2017-03-07 14:13:09.000000000 +0100
++++ wireless-regdb/Makefile	2019-01-07 14:15:14.296020922 +0100
+@@ -29,7 +29,7 @@
+ 			echo custom-user; \
+ 		fi)
+ 
+-REGDB_PRIVKEY ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
++REGDB_PRIVKEY ?= ~/.wireless-regdb.key.priv.pem
+ REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
+ 
+ REGDB_UPSTREAM_PUBKEY ?= sforshee.key.pub.pem
Signature · 1 line
2.25.0
#6 lore raw

PATCH 3/3 wireless-regdb: omit author info from private key in home directory

Hello,

Quoted 14 lines · On Fri, 12 Jun 2020 07:31:10 +0200 Kurt Van Dijck…
---
 .../002-no-author-from-user-privkey.patch            | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 package/wireless-regdb/002-no-author-from-user-privkey.patch
package/wireless-regdb/002-no-author-from-user-privkey.patch new file +2 -0
new file mode 100644
index 0000000000..8cab1e169c
@@ -0,0 +1,12 @@
+diff -Naur wireless-regdb.orig/Makefile wireless-regdb/Makefile
+--- wireless-regdb.orig/Makefile	2017-03-07 14:13:09.000000000 +0100

package/wireless-regdb/002-no-author-from-user-privkey.patch line 12

Quoted 10 lines
package/wireless-regdb/002-no-author-from-user-privkey.patch new file +10 -0
++++ wireless-regdb/Makefile	2019-01-07 14:15:14.296020922 +0100
+@@ -29,7 +29,7 @@
+ 			echo custom-user; \
+ 		fi)
+ 
+-REGDB_PRIVKEY ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
++REGDB_PRIVKEY ?= ~/.wireless-regdb.key.priv.pem
+ REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
+ 
+ REGDB_UPSTREAM_PUBKEY ?= sforshee.key.pub.pem

All patches need a description and Signed-off-by line. But what about passing REGDB_AUTHOR=buildroot from wireless-regdb.mk, or something like that ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

PATCH 3/3 wireless-regdb: omit author info from private key in home directory

Hey Thomas,

Quoted 5 lines · Thomas Petazzoni

Hello,

On Fri, 12 Jun 2020 07:31:10 +0200
Kurt Van Dijck <[email protected]> wrote:

...

Quoted 9 lines
Quoted 5 lines

+-REGDB_PRIVKEY ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem ++REGDB_PRIVKEY ?= ~/.wireless-regdb.key.priv.pem
+ REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
+
+ REGDB_UPSTREAM_PUBKEY ?= sforshee.key.pub.pem

All patches need a description and Signed-off-by line. But what about passing REGDB_AUTHOR=buildroot from wireless-regdb.mk, or something like that ?

I'm in the process of discovering that the crda-less system requires the keys in the kernel (a good choice) which can best be accomplished by your suggestion here.

I have a few things for a rework
1. put some more comments
2. avoid a python3 patch and use python-m2crypto.
3. prepare for an explicit priv key for both wireless-regdb and kernel

Thanks for the review.
Kurt

#8 lore raw

cover allow to recompile wireless-regdb

In reply to Kurt Van Dijck

Kurt,

Quoted 6 lines · Kurt Van Dijck

This series adds an option to recompile wireless-regdb. This became necessary in our product for outdoor use. In some countries, different regulations apply for indoor and outdoor use. The precompiled version of wireless-regdb is appropriate for indoor use only.

Thanks for sending this series!

We ran into a similar situation but never tried to upstream an approach with the wireless-regdb project to have an outdoor profile. Have you guys looked to see if that would be possible? With how the product wireless certs go it could be beneficial to have the outdoor profile as a standard configuration.

Best Regards,
Matt

#9 lore raw

cover allow to recompile wireless-regdb

Quoted 12 lines · Matthew Weber

Kurt,

Quoted 6 lines · Kurt Van Dijck

This series adds an option to recompile wireless-regdb. This became necessary in our product for outdoor use. In some countries, different regulations apply for indoor and outdoor use. The precompiled version of wireless-regdb is appropriate for indoor use only.

Quoted 5 lines

Thanks for sending this series!

We ran into a similar situation but never tried to upstream an approach with the wireless-regdb project to have an outdoor profile. Have you guys looked to see if that would be possible?

We did not attempt to change wireless-regdb itself.
If I remember well, it could in theory support indoor and outdoor regulations, but you need to tell the driver to do so, and that seemed not really implemented for our driver (ralink).
Our specific usecase where the differences apply, are in Japan, where
* the regulations db was not yet up to date with the outdoor restrictions
* we wanted to avoid the risks of incomplete implementations

Since wireless-regdb supports recompiling your own db, we figured that that stripping the indoor-only bands from the db alltogether was the simplest and safest way to success.

Only recently, our new build-server stumbled over python2/python3 and our modification became too big.

Quoted 3 lines

With how the
product wireless certs go it could be beneficial to have the outdoor profile as a standard configuration.

We remove the indoor-only bands from the db. That seems quite good. I wasn't involved in the actual certification, but I can't imagine how our device would have used the indoor-only bands.

Kurt