summaryrefslogtreecommitdiff
path: root/src/monitor
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-02-21 19:43:35 +0100
committerStephen Gallagher <sgallagh@redhat.com>2012-02-23 20:53:46 -0500
commita4421a4261f73718e6b4c18c7bb9f020255e15c7 (patch)
treeeb1b44740af49ada9f23dde5836d670e587f16f3 /src/monitor
parent744dff21cc626efdc646dd293c97c6a19a9f6ed5 (diff)
downloadsssd-a4421a4261f73718e6b4c18c7bb9f020255e15c7.tar.gz
sssd-a4421a4261f73718e6b4c18c7bb9f020255e15c7.tar.bz2
sssd-a4421a4261f73718e6b4c18c7bb9f020255e15c7.zip
libnl: fix the path to phy80211 subdirectory
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor_netlink.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c
index b8c39672..8455f688 100644
--- a/src/monitor/monitor_netlink.c
+++ b/src/monitor/monitor_netlink.c
@@ -60,13 +60,17 @@
#define nlw_object_match nl_object_match_filter
#define NLW_OK NL_OK
-#define SYSFS_IFACE_TEMPLATE "/sys/class/net/%s/type"
-#define SYSFS_IFACE_PATH_MAX (21+IFNAMSIZ)
+#define SYSFS_IFACE_TEMPLATE "/sys/class/net/%s"
+#define SYSFS_IFACE_PATH_MAX (16+IFNAMSIZ)
#define PHY_80211_SUBDIR "phy80211"
/* 9 = strlen(PHY_80211_SUBDIR)+1, 1 = path delimeter */
#define SYSFS_SUBDIR_PATH_MAX (SYSFS_IFACE_PATH_MAX+9+1)
+#define TYPE_FILE "type"
+/* 5 = strlen(TYPE_FILE)+1, 1 = path delimeter */
+#define SYSFS_TYPE_PATH_MAX (SYSFS_IFACE_PATH_MAX+5+1)
+
#define BUFSIZE 8
enum nlw_msg_type {
@@ -123,15 +127,27 @@ static bool has_wireless_extension(const char *ifname)
static bool has_ethernet_encapsulation(const char *sysfs_path)
{
+ char type_path[SYSFS_TYPE_PATH_MAX];
errno_t ret;
int fd = -1;
char buf[BUFSIZE];
- fd = open(sysfs_path, O_RDONLY);
+ ret = snprintf(type_path, SYSFS_TYPE_PATH_MAX,
+ "%s/%s", sysfs_path, TYPE_FILE);
+ if (ret < 0) {
+ DEBUG(SSSDBG_OP_FAILURE, ("snprintf failed\n"));
+ return false;
+ } else if (ret >= SYSFS_TYPE_PATH_MAX) {
+ DEBUG(SSSDBG_OP_FAILURE, ("path too long?!?!\n"));
+ return false;
+ }
+
+ errno = 0;
+ fd = open(type_path, O_RDONLY);
if (fd == -1) {
ret = errno;
DEBUG(SSSDBG_OP_FAILURE, ("Could not open sysfs file %s: [%d] %s\n",
- sysfs_path, ret, strerror(ret)));
+ type_path, ret, strerror(ret)));
return false;
}