summaryrefslogtreecommitdiffstats
path: root/wifi/wifi.c
diff options
context:
space:
mode:
Diffstat (limited to 'wifi/wifi.c')
-rw-r--r--wifi/wifi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/wifi/wifi.c b/wifi/wifi.c
index 9a2cbbd..885f3ec 100644
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -135,7 +135,7 @@ const char *get_dhcp_error_string() {
return dhcp_lasterror();
}
-static int check_driver_loaded() {
+int is_wifi_driver_loaded() {
char driver_status[PROPERTY_VALUE_MAX];
FILE *proc;
char line[sizeof(DRIVER_MODULE_TAG)+10];
@@ -171,7 +171,7 @@ int wifi_load_driver()
char driver_status[PROPERTY_VALUE_MAX];
int count = 100; /* wait at most 20 seconds for completion */
- if (check_driver_loaded()) {
+ if (is_wifi_driver_loaded()) {
return 0;
}
@@ -208,7 +208,7 @@ int wifi_unload_driver()
if (rmmod(DRIVER_MODULE_NAME) == 0) {
while (count-- > 0) {
- if (!check_driver_loaded())
+ if (!is_wifi_driver_loaded())
break;
usleep(500000);
}
@@ -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));