Correct file permissions of mesh_hostapd.conf 85/189785/1
authorNishant Chaprana <n.chaprana@samsung.com>
Thu, 20 Sep 2018 11:38:34 +0000 (17:08 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Thu, 20 Sep 2018 11:38:34 +0000 (17:08 +0530)
Change-Id: I4282ac275f149ab4640baf272220008fb98730f2
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/wifi-mesh-manager.spec
src/wmesh-softap.c

index bbf0fd6..4cdfb8b 100644 (file)
@@ -2,7 +2,7 @@
 
 Name:          wifi-mesh-manager
 Summary:       Wi-Fi mesh network daemon
-Version:       0.0.3
+Version:       0.0.4
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
index f116fdd..93fe739 100644 (file)
@@ -120,7 +120,7 @@ static int __config_hostapd(const char *softap_interface, const char *ssid,
        char *conf = NULL;
        char *old_conf;
        char buf[HOSTAPD_CONF_LEN] = "";
-       FILE *fp = NULL;
+       int fd = -1;
        int ret;
        char key[MOBILE_AP_WIFI_KEY_MAX_LEN + 1];
        char *hw_mode = NULL;
@@ -174,8 +174,8 @@ static int __config_hostapd(const char *softap_interface, const char *ssid,
                WMESH_LOGD("Open connection [%s]", security); /* LCOV_EXCL_LINE */
        }
 
-       fp = fopen(HOSTAPD_MESH_CONF_FILE, "w");
-       if (NULL == fp) {
+       fd = open(HOSTAPD_MESH_CONF_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+       if (fd < 0) {
                /* LCOV_EXCL_START */
                WMESH_LOGE("Could not create the file [%s].", HOSTAPD_MESH_CONF_FILE);
                g_free(conf);
@@ -184,10 +184,11 @@ static int __config_hostapd(const char *softap_interface, const char *ssid,
        }
 
        if (conf) {
-               fputs(conf, fp);
+               write(fd, conf, strlen(conf));
                g_free(conf);
        }
-       fclose(fp);
+
+       close(fd);
 
        return WMESHD_ERROR_NONE;
 }