Accepting request 851854 from home:WernerFink:branches:hardware

- Add patch crda-default.patch as well as template file crda.default
  for /usr/etc/default/crda to support WLAN USB dongles as well as
  mostly raspberry WLAN drivers not knowing about kernel builtin
  support for WLAN regular country domains (boo#1179308)

OBS-URL: https://build.opensuse.org/request/show/851854
OBS-URL: https://build.opensuse.org/package/show/hardware/crda?expand=0&rev=37
This commit is contained in:
Stefan Seyfried 2020-12-01 11:54:18 +00:00 committed by Git OBS Bridge
parent 33cf9b66ca
commit 1f7d2fdf74
4 changed files with 131 additions and 1 deletions

103
crda-default.patch Normal file
View File

@ -0,0 +1,103 @@
Provide an option to specify a reg code in /etc/default/crda
and also try a distribution configuration /usr/etc/default/crda.
This solves bug boo#1179308
---
crda.8 | 17 ++++++++++++++++-
crda.c | 43 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/crda.8 b/crda.8
--- a/crda.8
+++ b/crda.8
@@ -68,7 +68,22 @@ An example udev rule which can be used (
.B /lib/udev/rules.d/85-regulatory.rules
):
-.I KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/sbin/crda"
+.I KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/usr/sbin/crda"
+
+.SS
+.SH Standard configuration
+in the file
+.I /usr/etc/default/crda
+the variable
+.B REGDOMAIN
+is set to the global WLAN default code
+.BR 00 .
+The local administrator might copy this file to
+.I /etc/default/crda
+and set the ISO / IEC 3166 alpha2 country code of the local area. Then
+any execution of
+.B crda
+will then send this as regulatory domain for that alpha2 to the kernel.
.SS
.SH Environment variable
diff --git a/crda.c b/crda.c
--- a/crda.c
+++ b/crda.c
@@ -4,6 +4,7 @@
* Userspace helper which sends regulatory domains to Linux via nl80211
*/
+#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
@@ -156,6 +157,11 @@ int main(int argc, char **argv)
struct nlattr *nl_reg_rules;
const struct ieee80211_regdomain *rd = NULL;
+ const char *default_paths[] = {
+ "/etc/default/crda", /* Users configuration if COUNTRY is not set */
+ "/usr/etc/default/crda", /* General configuration if COUNTRY is not set */
+ NULL
+ };
const char *regdb_paths[] = {
"/usr/local/lib/crda/regulatory.bin", /* Users/preloads can override */
"/usr/lib/crda/regulatory.bin", /* General distribution package usage */
@@ -171,8 +177,41 @@ int main(int argc, char **argv)
env_country = getenv("COUNTRY");
if (!env_country) {
- fprintf(stderr, "COUNTRY environment variable not set.\n");
- return -EINVAL;
+ const char **conf = default_paths;
+ while (*conf != NULL) {
+ fd = open(*conf, O_RDONLY);
+ if (fd >= 0)
+ break;
+ conf++;
+ }
+ if (fd >= 0) {
+ FILE *reg = fdopen(fd, "r");
+ if (reg) {
+ char *line = NULL;
+ ssize_t nread;
+ size_t len = 0;
+ while ((nread = getline(&line, &len, reg)) != -1) {
+ char *ptr = line;
+ if (*ptr == '#' || *ptr == '\n')
+ continue;
+ while (isspace(*ptr))
+ line++;
+ if (strncmp("REGDOMAIN=", ptr, 10) == 0) {
+ ptr += 10;
+ env_country = strndup(ptr, 2);
+ break;
+ }
+ }
+ if (line)
+ free(line);
+ fclose(reg);
+ } else
+ close(fd);
+ }
+ if (!env_country) {
+ fprintf(stderr, "COUNTRY environment variable not set.\n");
+ return -EINVAL;
+ }
}
if (!reglib_is_valid_regdom(env_country)) {

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Nov 30 13:40:28 UTC 2020 - Dr. Werner Fink <werner@suse.de>
- Add patch crda-default.patch as well as template file crda.default
for /usr/etc/default/crda to support WLAN USB dongles as well as
mostly raspberry WLAN drivers not knowing about kernel builtin
support for WLAN regular country domains (boo#1179308)
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Nov 17 13:43:31 UTC 2020 - Ludwig Nussel <lnussel@suse.de> Tue Nov 17 13:43:31 UTC 2020 - Ludwig Nussel <lnussel@suse.de>

8
crda.default Normal file
View File

@ -0,0 +1,8 @@
#
# Used by the crda(8) helper to set the country code for the WLAN
# location. Outside the US or without self-managed WLAN devices
# it is helpful to copy this file to /etc/default/ and set the
# two letter specific ISO / IEC 3166 alpha2 country code.
#
REGDOMAIN=00

View File

@ -26,7 +26,8 @@ Group: Hardware/Wifi
URL: https://github.com/mcgrof/crda/commits/master URL: https://github.com/mcgrof/crda/commits/master
Version: 4.14 Version: 4.14
Release: 0 Release: 0
Source: http://kernel.org/pub/software/network/crda/crda-%{version}.tar.gz Source0: http://kernel.org/pub/software/network/crda/crda-%{version}.tar.gz
Source1: crda.default
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: libgcrypt-devel BuildRequires: libgcrypt-devel
BuildRequires: pkg-config BuildRequires: pkg-config
@ -45,6 +46,8 @@ Patch1: crda-python3.patch
Patch2: crda-67f1e6ddbdfade357e234c9d58a30fe0a283fe60.patch Patch2: crda-67f1e6ddbdfade357e234c9d58a30fe0a283fe60.patch
# PATCH-FIX-UPSTREAM crda-f4ef2531698fb9ba006e8b31a223b3269be8bc7c.patch # PATCH-FIX-UPSTREAM crda-f4ef2531698fb9ba006e8b31a223b3269be8bc7c.patch
Patch3: crda-f4ef2531698fb9ba006e8b31a223b3269be8bc7c.patch Patch3: crda-f4ef2531698fb9ba006e8b31a223b3269be8bc7c.patch
# PATCH-FIX-SUSE crda-default.patch
Patch4: crda-default.patch
%description %description
The crda binary provides access to the wireless-regdb to the kernel The crda binary provides access to the wireless-regdb to the kernel
@ -56,6 +59,7 @@ through udev.
%patch1 -p1 %patch1 -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
%patch4 -p1
# make install calls 'ldconfig' and fails if it cannot run it... # make install calls 'ldconfig' and fails if it cannot run it...
ln -s /bin/true ldconfig ln -s /bin/true ldconfig
@ -67,6 +71,8 @@ make all_noverify %{?_smp_mflags} V=1
# to find ldconfig... # to find ldconfig...
export PATH=.:$PATH export PATH=.:$PATH
make DESTDIR=$RPM_BUILD_ROOT SBINDIR=%{_sbindir}/ UDEV_RULE_DIR=%{_udevrulesdir} LIBDIR=%{_libdir} install make DESTDIR=$RPM_BUILD_ROOT SBINDIR=%{_sbindir}/ UDEV_RULE_DIR=%{_udevrulesdir} LIBDIR=%{_libdir} install
mkdir -p %{buildroot}%{_prefix}%{_sysconfdir}/default
install -m 644 %{S:1} %{buildroot}%{_prefix}%{_sysconfdir}/default/%{name}
%if !0%{?usrmerged} %if !0%{?usrmerged}
mkdir $RPM_BUILD_ROOT/sbin mkdir $RPM_BUILD_ROOT/sbin
ln -sf %{_sbindir}/{crda,regdbdump} $RPM_BUILD_ROOT/sbin ln -sf %{_sbindir}/{crda,regdbdump} $RPM_BUILD_ROOT/sbin
@ -84,6 +90,11 @@ rm -r %{buildroot}/usr/include/reglib
/sbin/crda /sbin/crda
/sbin/regdbdump /sbin/regdbdump
%endif %endif
%if 0%{?suse_version} < 1550
%dir %{_prefix}%{_sysconfdir}/
%dir %{_prefix}%{_sysconfdir}/default/
%endif
%{_prefix}%{_sysconfdir}/default/%{name}
%{_udevrulesdir}/85-regulatory.rules %{_udevrulesdir}/85-regulatory.rules
%{_mandir}/man8/crda.8.gz %{_mandir}/man8/crda.8.gz
%{_mandir}/man8/regdbdump.8.gz %{_mandir}/man8/regdbdump.8.gz