summaryrefslogtreecommitdiff
path: root/iwinfo_wl.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-07-31 20:09:02 +0200
committerJo-Philipp Wich <jo@mein.io>2018-07-31 20:09:02 +0200
commit3c30b171707858256306db36627649ddfd03bc43 (patch)
tree127fd75be7863802834a2ba01a0fcc22a7a48d48 /iwinfo_wl.c
parenta51413988caaff7001f47c8a62bff11a72ca48bc (diff)
downloadiwinfo-3c30b171707858256306db36627649ddfd03bc43.tar.gz
wl: only invoke nvram executable if it exists
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'iwinfo_wl.c')
-rw-r--r--iwinfo_wl.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/iwinfo_wl.c b/iwinfo_wl.c
index c7517ec..80d3d7e 100644
--- a/iwinfo_wl.c
+++ b/iwinfo_wl.c
@@ -18,6 +18,9 @@
* This code is based on the wlc.c utility published by OpenWrt.org .
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+
#include "iwinfo.h"
#include "api/broadcom.h"
@@ -702,15 +705,19 @@ static int wl_get_txpower_offset(const char *ifname, int *buf)
{
FILE *p;
char off[8];
+ struct stat s;
*buf = 0;
- if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+ if (!stat("/usr/sbin/nvram", &s) && (s.st_mode & S_IXUSR))
{
- if (fread(off, 1, sizeof(off), p))
- *buf = strtoul(off, NULL, 16);
+ if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+ {
+ if (fread(off, 1, sizeof(off), p))
+ *buf = strtoul(off, NULL, 16);
- pclose(p);
+ pclose(p);
+ }
}
return 0;