Allow client control socket location to be overridden

Build options can now be used to replace the location of client
sockets for UNIX domain socket control interface:

CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/tmp\"
CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_PREFIX=\"wpa_ctrl_\"
This commit is contained in:
Jouni Malinen 2011-02-27 18:35:33 +02:00
parent b3f3865e0e
commit 73304dbf65

View file

@ -63,6 +63,14 @@ struct wpa_ctrl {
#ifdef CONFIG_CTRL_IFACE_UNIX #ifdef CONFIG_CTRL_IFACE_UNIX
#ifndef CONFIG_CTRL_IFACE_CLIENT_DIR
#define CONFIG_CTRL_IFACE_CLIENT_DIR "/tmp"
#endif /* CONFIG_CTRL_IFACE_CLIENT_DIR */
#ifndef CONFIG_CTRL_IFACE_CLIENT_PREFIX
#define CONFIG_CTRL_IFACE_CLIENT_PREFIX "wpa_ctrl_"
#endif /* CONFIG_CTRL_IFACE_CLIENT_PREFIX */
struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path) struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
{ {
struct wpa_ctrl *ctrl; struct wpa_ctrl *ctrl;
@ -86,7 +94,9 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
counter++; counter++;
try_again: try_again:
ret = os_snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path), ret = os_snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path),
"/tmp/wpa_ctrl_%d-%d", (int) getpid(), counter); CONFIG_CTRL_IFACE_CLIENT_DIR "/"
CONFIG_CTRL_IFACE_CLIENT_PREFIX "%d-%d",
(int) getpid(), counter);
if (ret < 0 || (size_t) ret >= sizeof(ctrl->local.sun_path)) { if (ret < 0 || (size_t) ret >= sizeof(ctrl->local.sun_path)) {
close(ctrl->s); close(ctrl->s);
os_free(ctrl); os_free(ctrl);