Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit d08b0e098637e57a26ea8076bbedfeb3aa2aa172 Author: Andrew Lunn andrew@lunn.ch Date: Wed Mar 16 20:51:12 2016 +0100
alfred: Mount debugfs before reducing capabilities
The debugfs helper code has the ability to mount the debugfs file system if it is not already mounted. However, it cannot do this after the capabilities have been dropped. So perform the mount early, and remove all the other attempts to do the mount.
Signed-off-by: Andrew Lunn andrew@lunn.ch [sw@simonwunderlich.de: removed namespace references from commit msg] Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
d08b0e098637e57a26ea8076bbedfeb3aa2aa172 batadv_query.c | 17 ----------------- main.c | 4 ++++ 2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/batadv_query.c b/batadv_query.c index 6dc2cf4..a5fa565 100644 --- a/batadv_query.c +++ b/batadv_query.c @@ -94,16 +94,9 @@ int ipv6_to_mac(const struct in6_addr *addr, struct ether_addr *mac)
int batadv_interface_check(const char *mesh_iface) { - char *debugfs_mnt; char full_path[MAX_PATH + 1]; FILE *f;
- debugfs_mnt = debugfs_mount(NULL); - if (!debugfs_mnt) { - fprintf(stderr, "Could not find debugfs path\n"); - return -1; - } - debugfs_make_path(DEBUG_BATIF_PATH_FMT "/" DEBUG_TRANSTABLE_GLOBAL, mesh_iface, full_path, sizeof(full_path)); f = fopen(full_path, "r"); @@ -138,7 +131,6 @@ struct ether_addr *translate_mac(const char *mesh_iface, struct ether_addr *mac) tg_originator, } pos; char full_path[MAX_PATH + 1]; - char *debugfs_mnt; static struct ether_addr in_mac; struct ether_addr *mac_result, *mac_tmp; FILE *f = NULL; @@ -150,10 +142,6 @@ struct ether_addr *translate_mac(const char *mesh_iface, struct ether_addr *mac) memcpy(&in_mac, mac, sizeof(in_mac)); mac_result = &in_mac;
- debugfs_mnt = debugfs_mount(NULL); - if (!debugfs_mnt) - goto out; - debugfs_make_path(DEBUG_BATIF_PATH_FMT "/" DEBUG_TRANSTABLE_GLOBAL, mesh_iface, full_path, sizeof(full_path));
@@ -220,7 +208,6 @@ uint8_t get_tq(const char *mesh_iface, struct ether_addr *mac) orig_tqvalue, } pos; char full_path[MAX_PATH + 1]; - char *debugfs_mnt; static struct ether_addr in_mac; struct ether_addr *mac_tmp; FILE *f = NULL; @@ -232,10 +219,6 @@ uint8_t get_tq(const char *mesh_iface, struct ether_addr *mac)
memcpy(&in_mac, mac, sizeof(in_mac));
- debugfs_mnt = debugfs_mount(NULL); - if (!debugfs_mnt) - goto out; - debugfs_make_path(DEBUG_BATIF_PATH_FMT "/" DEBUG_ORIGINATORS, mesh_iface, full_path, sizeof(full_path));
diff --git a/main.c b/main.c index 9610398..52dca97 100644 --- a/main.c +++ b/main.c @@ -30,6 +30,7 @@ #include <unistd.h> #endif #include "alfred.h" +#include "debugfs.h" #include "packet.h" #include "list.h"
@@ -160,6 +161,9 @@ static struct globals *alfred_init(int argc, char *argv[]) {NULL, 0, NULL, 0}, };
+ /* We need full capabilities to mount debugfs, so do that now */ + debugfs_mount(NULL); + ret = reduce_capabilities(); if (ret < 0) return NULL;