aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface_unix.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-05-18 08:00:05 (GMT)
committerJouni Malinen <j@w1.fi>2013-05-18 08:00:05 (GMT)
commit2925756575ae33b0137d5bd293482fade4f48e95 (patch)
tree3163fb74f2195e8e7c5dd1ac184a8fb66f76d7a0 /wpa_supplicant/ctrl_iface_unix.c
parentcf3bebf28cdac99e888b3bda1a3ad7e333d5f962 (diff)
downloadhostap-2925756575ae33b0137d5bd293482fade4f48e95.zip
hostap-2925756575ae33b0137d5bd293482fade4f48e95.tar.gz
hostap-2925756575ae33b0137d5bd293482fade4f48e95.tar.bz2
wpa_supplicant: Add -G argument to specify global ctrl group
The optional -G<group> command line argument can be used to specify the group that can access the global control interface. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/ctrl_iface_unix.c')
-rw-r--r--wpa_supplicant/ctrl_iface_unix.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
index f792863..73d3837 100644
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -1,6 +1,6 @@
/*
* WPA Supplicant / UNIX domain socket -based control interface
- * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2013, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -732,6 +732,41 @@ wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
}
}
+ if (global->params.ctrl_interface_group) {
+ char *gid_str = global->params.ctrl_interface_group;
+ gid_t gid = 0;
+ struct group *grp;
+ char *endp;
+
+ grp = getgrnam(gid_str);
+ if (grp) {
+ gid = grp->gr_gid;
+ wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d"
+ " (from group name '%s')",
+ (int) gid, gid_str);
+ } else {
+ /* Group name not found - try to parse this as gid */
+ gid = strtol(gid_str, &endp, 10);
+ if (*gid_str == '\0' || *endp != '\0') {
+ wpa_printf(MSG_ERROR, "CTRL: Invalid group "
+ "'%s'", gid_str);
+ goto fail;
+ }
+ wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d",
+ (int) gid);
+ }
+ if (chown(global->params.ctrl_interface, -1, gid) < 0) {
+ perror("chown[global_ctrl_interface/ifname]");
+ goto fail;
+ }
+
+ if (chmod(global->params.ctrl_interface, S_IRWXU | S_IRWXG) < 0)
+ {
+ perror("chmod[global_ctrl_interface/ifname]");
+ goto fail;
+ }
+ }
+
#ifdef ANDROID
havesock:
#endif /* ANDROID */