aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/hs20_supplicant.c
diff options
context:
space:
mode:
authorASHUTOSH NARAYAN <ashutoshx.narayan@intel.com>2015-01-19 01:45:01 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-20 00:26:16 (GMT)
commitd10b01d299bdded9552b2c89cada963c991b5d1c (patch)
treefe54908c22e804d1fcc66db4e0c4faf4e6d669eb /wpa_supplicant/hs20_supplicant.c
parent73f1ee024362d67e4475c3eced36b3941b42627a (diff)
downloadhostap-d10b01d299bdded9552b2c89cada963c991b5d1c.zip
hostap-d10b01d299bdded9552b2c89cada963c991b5d1c.tar.gz
hostap-d10b01d299bdded9552b2c89cada963c991b5d1c.tar.bz2
HS20: Provide appropriate permission to the OSU related files
The icon files and the osu-providers.txt that are generated may not have proper permission for external programs to access. Set the access permissions to the same as the permissions for osu_dir. Signed-off-by: ASHUTOSH NARAYAN <ashutoshx.narayan@intel.com>
Diffstat (limited to 'wpa_supplicant/hs20_supplicant.c')
-rw-r--r--wpa_supplicant/hs20_supplicant.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/wpa_supplicant/hs20_supplicant.c b/wpa_supplicant/hs20_supplicant.c
index 53c7d63..eb18ed2 100644
--- a/wpa_supplicant/hs20_supplicant.c
+++ b/wpa_supplicant/hs20_supplicant.c
@@ -7,6 +7,7 @@
*/
#include "includes.h"
+#include <sys/stat.h>
#include "common.h"
#include "eloop.h"
@@ -216,6 +217,30 @@ int hs20_anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, u32 stypes,
}
+static void hs20_set_osu_access_permission(const char *osu_dir,
+ const char *fname)
+{
+ struct stat statbuf;
+
+ /* Get OSU directory information */
+ if (stat(osu_dir, &statbuf) < 0) {
+ wpa_printf(MSG_WARNING, "Cannot stat the OSU directory %s",
+ osu_dir);
+ return;
+ }
+
+ if (chmod(fname, statbuf.st_mode) < 0) {
+ wpa_printf(MSG_WARNING,
+ "Cannot change the permissions for %s", fname);
+ return;
+ }
+
+ if (chown(fname, statbuf.st_uid, statbuf.st_gid) < 0) {
+ wpa_printf(MSG_WARNING, "Cannot change the ownership for %s",
+ fname);
+ }
+}
+
static int hs20_process_icon_binary_file(struct wpa_supplicant *wpa_s,
const u8 *sa, const u8 *pos,
size_t slen)
@@ -278,6 +303,9 @@ static int hs20_process_icon_binary_file(struct wpa_supplicant *wpa_s,
f = fopen(fname, "wb");
if (f == NULL)
return -1;
+
+ hs20_set_osu_access_permission(wpa_s->conf->osu_dir, fname);
+
if (fwrite(pos, slen, 1, f) != 1) {
fclose(f);
unlink(fname);
@@ -479,6 +507,9 @@ static void hs20_osu_fetch_done(struct wpa_supplicant *wpa_s)
hs20_free_osu_prov(wpa_s);
return;
}
+
+ hs20_set_osu_access_permission(wpa_s->conf->osu_dir, fname);
+
for (i = 0; i < wpa_s->osu_prov_count; i++) {
struct osu_provider *osu = &wpa_s->osu_prov[i];
if (i > 0)