[libiwinfo] apply FD_CLOEXEC on internal ioctl and netlink sockets
This commit is contained in:
parent
e3570b7b0d
commit
2c9b1c4a1b
11 changed files with 37 additions and 7 deletions
|
@ -7,7 +7,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libiwinfo
|
||||
PKG_RELEASE:=3
|
||||
PKG_RELEASE:=4
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
|
|
@ -202,7 +202,10 @@ static int madwifi_ioctl(struct iwreq *wrq, const char *ifname, int cmd, void *d
|
|||
{
|
||||
/* prepare socket */
|
||||
if( ioctl_socket == -1 )
|
||||
{
|
||||
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
|
||||
}
|
||||
|
||||
strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef __IWINFO_MADWIFI_H_
|
||||
#define __IWINFO_MADWIFI_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "iwinfo.h"
|
||||
#include "include/madwifi.h"
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ static struct nl80211_state *nls = NULL;
|
|||
|
||||
static int nl80211_init(void)
|
||||
{
|
||||
int err;
|
||||
int err, fd;
|
||||
|
||||
if( !nls )
|
||||
{
|
||||
|
@ -53,6 +53,13 @@ static int nl80211_init(void)
|
|||
goto err;
|
||||
}
|
||||
|
||||
fd = nl_socket_get_fd(nls->nl_sock);
|
||||
if( fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) < 0 )
|
||||
{
|
||||
err = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if( genl_ctrl_alloc_cache(nls->nl_sock, &nls->nl_cache)) {
|
||||
err = -ENOMEM;
|
||||
goto err;
|
||||
|
@ -332,6 +339,9 @@ static char * nl80211_wpasupp_info(const char *ifname, const char *cmd)
|
|||
remote_length = sizeof(remote.sun_family) + sprintf(remote.sun_path,
|
||||
"/var/run/wpa_supplicant-%s/%s", ifname, ifname);
|
||||
|
||||
if( fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC) < 0 )
|
||||
goto out;
|
||||
|
||||
if( connect(sock, (struct sockaddr *) &remote, remote_length) )
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define __IWINFO_NL80211_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
|
@ -89,7 +89,10 @@ static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
|
|||
{
|
||||
/* prepare socket */
|
||||
if( ioctl_socket == -1 )
|
||||
{
|
||||
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
|
||||
}
|
||||
|
||||
if( !strncmp(ifname, "mon.", 4) )
|
||||
strncpy(wrq->ifr_name, &ifname[4], IFNAMSIZ);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef __IWINFO_WEXT_H_
|
||||
#define __IWINFO_WEXT_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "iwinfo.h"
|
||||
#include "include/wext.h"
|
||||
|
||||
|
|
|
@ -29,7 +29,10 @@ static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
|
|||
{
|
||||
/* prepare socket */
|
||||
if( ioctl_socket == -1 )
|
||||
{
|
||||
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
|
||||
}
|
||||
|
||||
strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
|
||||
return ioctl(ioctl_socket, cmd, wrq);
|
||||
|
@ -650,4 +653,3 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len)
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef __IWINFO_WEXT_SCAN_H_
|
||||
#define __IWINFO_WEXT_SCAN_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "iwinfo.h"
|
||||
#include "include/wext.h"
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ static int wl_ioctl(const char *name, int cmd, void *buf, int len)
|
|||
|
||||
/* prepare socket */
|
||||
if( ioctl_socket == -1 )
|
||||
{
|
||||
ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
fcntl(ioctl_socket, F_SETFD, fcntl(ioctl_socket, F_GETFD) | FD_CLOEXEC);
|
||||
}
|
||||
|
||||
/* do it */
|
||||
ioc.cmd = cmd;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef __IWINFO_WL_H_
|
||||
#define __IWINFO_WL_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "iwinfo.h"
|
||||
#include "include/broadcom.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue