summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2009-02-24 15:31:50 +0100
committerLuis R. Rodriguez <lrodriguez@atheros.com>2009-02-24 11:42:16 -0800
commit345096cf8ca2b312c53407985f34c81b2cfd0bc7 (patch)
tree63562d91a66c9857d96731316a9594770269bc3f
parentdcd6a8dfe03386bb3b696d2561f2dd57b8f0309b (diff)
downloadcrda-345096cf8ca2b312c53407985f34c81b2cfd0bc7.tar.gz
crda-345096cf8ca2b312c53407985f34c81b2cfd0bc7.tar.bz2
crda-345096cf8ca2b312c53407985f34c81b2cfd0bc7.zip
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. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
-rw-r--r--crda.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/crda.c b/crda.c
index f2c471f..8e7db65 100644
--- a/crda.c
+++ b/crda.c
@@ -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;