Patchwork hostapd: Don't chown control interface to root

login
register
mail settings
Submitter Pontus Fuchs
Date Dec. 14, 2012, 11:58 a.m.
Message ID <1355486281-23143-1-git-send-email-pontus.fuchs@gmail.com>
Download mbox | patch
Permalink /patch/206410/
State Accepted
Commit 9cbd5845d062ab0bc1de4678bc4f0b85bc0d32a9
Headers show

Comments

Pontus Fuchs - Dec. 14, 2012, 11:58 a.m.
If ctrl_interface_group in the config file is set hostapd tries to
chown the dir and socket to uid 0. This causes the chown to fail
if hostapd is run as non-root.

Signed-hostap: Pontus Fuchs <pontus.fuchs@gmail.com>
---
 hostapd/ctrl_iface.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Jouni Malinen - Dec. 17, 2012, 2:27 p.m.
On Fri, Dec 14, 2012 at 12:58:00PM +0100, Pontus Fuchs wrote:
> If ctrl_interface_group in the config file is set hostapd tries to
> chown the dir and socket to uid 0. This causes the chown to fail
> if hostapd is run as non-root.

Thanks, applied.

Patch

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index ccc018e..1d4fe0d 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -997,7 +997,7 @@  int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
 	}
 
 	if (hapd->conf->ctrl_interface_gid_set &&
-	    chown(hapd->conf->ctrl_interface, 0,
+	    chown(hapd->conf->ctrl_interface, -1,
 		  hapd->conf->ctrl_interface_gid) < 0) {
 		perror("chown[ctrl_interface]");
 		return -1;
@@ -1055,7 +1055,7 @@  int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
 	}
 
 	if (hapd->conf->ctrl_interface_gid_set &&
-	    chown(fname, 0, hapd->conf->ctrl_interface_gid) < 0) {
+	    chown(fname, -1, hapd->conf->ctrl_interface_gid) < 0) {
 		perror("chown[ctrl_interface/ifname]");
 		goto fail;
 	}