Commit 24bf7fc4 authored by Dmitry Shmidt's avatar Dmitry Shmidt
Browse files

Fix wpa_supplicant.conf permissions (0660)


Change-Id: I62e6711f706af88d4447f2885f7a0ce3f30a8a2e
Signed-off-by: default avatarDmitry Shmidt <dimitrysh@google.com>
parent 2bb990bf
......@@ -239,7 +239,7 @@ int ensure_config_file_exists()
return -1;
}
destfd = open(SUPP_CONFIG_FILE, O_CREAT|O_WRONLY, 0660);
destfd = open(SUPP_CONFIG_FILE, O_CREAT|O_RDWR, 0660);
if (destfd < 0) {
close(srcfd);
LOGE("Cannot create \"%s\": %s", SUPP_CONFIG_FILE, strerror(errno));
......@@ -260,6 +260,14 @@ int ensure_config_file_exists()
close(destfd);
close(srcfd);
/* chmod is needed because open() didn't set permisions properly */
if (chmod(SUPP_CONFIG_FILE, 0660) < 0) {
LOGE("Error changing permissions of %s to 0660: %s",
SUPP_CONFIG_FILE, strerror(errno));
unlink(SUPP_CONFIG_FILE);
return -1;
}
if (chown(SUPP_CONFIG_FILE, AID_SYSTEM, AID_WIFI) < 0) {
LOGE("Error changing group ownership of %s to %d: %s",
SUPP_CONFIG_FILE, AID_WIFI, strerror(errno));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment