wifi: Ensure RW for wpa_supplicant.conf

Change-Id: Icaeac0ee2239333be5f3be10024824ada6da18d5
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
Dmitry Shmidt 2011-03-07 15:30:53 -08:00
parent fafb18fb31
commit 89ae703cd6

View file

@ -229,8 +229,15 @@ int ensure_config_file_exists()
int srcfd, destfd;
struct stat sb;
int nread;
int ret;
if (access(SUPP_CONFIG_FILE, R_OK|W_OK) == 0) {
ret = access(SUPP_CONFIG_FILE, R_OK|W_OK);
if ((ret == 0) || (errno == EACCES)) {
if ((ret != 0) &&
(chmod(SUPP_CONFIG_FILE, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) != 0)) {
LOGE("Cannot set RW to \"%s\": %s", SUPP_CONFIG_FILE, strerror(errno));
return -1;
}
/* return if filesize is at least 10 bytes */
if (stat(SUPP_CONFIG_FILE, &sb) == 0 && sb.st_size > 10) {
pbuf = malloc(sb.st_size + PROPERTY_VALUE_MAX);