Skip to contentSkip to conversation

crda: allow loading of regulatory.bin from /lib/crda in addition to /usr/lib/crda

PATCH In review Helmut Schaa 3 participants 3 messages Feb 24, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crda: allow loading of regulatory.bin from /lib/crda in addition to /usr/lib/crda

As crda is typically installed in /sbin it might be worth to install regulatory.bin into /lib/crda instead of /usr/lib/crda. Hence, extend crda to try both paths for loading the database.

---

crda.c +13 -3
index f2c471f..55632a6 100644
@@ -143,7 +143,7 @@ nla_put_failure:
 
 int main(int argc, char **argv)
 {
-	int fd;
+	int fd = -1;
 	struct stat stat;
 	__u8 *db;
 	struct regdb_file_header *header;
@@ -162,7 +162,12 @@ int main(int argc, char **argv)
 	struct nlattr *nl_reg_rules;
 	int num_rules;
 
-	const char regdb[] = "/usr/lib/crda/regulatory.bin";
+	const char *regdb_paths[] = {
+		"/usr/lib/crda/regulatory.bin",
+		"/lib/crda/regulatory.bin",
+		NULL
+	};
+	const char **regdb = regdb_paths;
 
 	if (argc != 1) {
 		fprintf(stderr, "Usage: %s\n", argv[0]);
@@ -183,7 +188,12 @@ int main(int argc, char **argv)
 
 	memcpy(alpha2, env_country, 2);
 
-	fd = open(regdb, O_RDONLY);
+	while (*regdb != NULL) {
+		fd = open(*regdb, O_RDONLY);
+		if (fd >= 0)
+			break;
+		regdb++;
+	}
 	if (fd < 0) {
 		perror("failed to open db file");
 		return -ENOENT;
#1 lore raw
Quoted 5 lines · Helmut Schaa

As crda is typically installed in /sbin it might be worth to install regulatory.bin into /lib/crda instead of /usr/lib/crda. Hence, extend crda to try both paths for loading the database.

Is it worthwhile to add /usr/local/lib/crda too? That way a user could override the regulatory.bin without disturbing the distro's packaging.

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#2 lore raw
Quoted 3 lines · John W. Linville
Quoted 2 lines · Helmut Schaa

As crda is typically installed in /sbin it might be worth to install regulatory.bin into /lib/crda instead of /usr/lib/crda. Hence, exten=

d

Quoted 3 lines
Quoted 3 lines

crda to try both paths for loading the database.

Thanks Helmut, applied.

Quoted 1 line

Is it worthwhile to add /usr/local/lib/crda too? =C2=A0That way a use=

r could

Quoted 1 line

override the regulatory.bin without disturbing the distro's packaging=

=2E

Added that as well and added that first in the path.

Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html