|
@@ -21,6 +21,7 @@
|
|
|
#endif /* CONFIG_CTRL_IFACE_UNIX */
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
+#include <dirent.h>
|
|
|
#include <cutils/sockets.h>
|
|
|
#include "private/android_filesystem_config.h"
|
|
|
#endif /* ANDROID */
|
|
@@ -175,6 +176,56 @@ void wpa_ctrl_close(struct wpa_ctrl *ctrl)
|
|
|
os_free(ctrl);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+#ifdef ANDROID
|
|
|
+/**
|
|
|
+ * wpa_ctrl_cleanup() - Delete any local UNIX domain socket files that
|
|
|
+ * may be left over from clients that were previously connected to
|
|
|
+ * wpa_supplicant. This keeps these files from being orphaned in the
|
|
|
+ * event of crashes that prevented them from being removed as part
|
|
|
+ * of the normal orderly shutdown.
|
|
|
+ */
|
|
|
+void wpa_ctrl_cleanup(void)
|
|
|
+{
|
|
|
+ DIR *dir;
|
|
|
+ struct dirent entry;
|
|
|
+ struct dirent *result;
|
|
|
+ size_t dirnamelen;
|
|
|
+ int prefixlen = os_strlen(CONFIG_CTRL_IFACE_CLIENT_PREFIX);
|
|
|
+ size_t maxcopy;
|
|
|
+ char pathname[PATH_MAX];
|
|
|
+ char *namep;
|
|
|
+
|
|
|
+ if ((dir = opendir(CONFIG_CTRL_IFACE_CLIENT_DIR)) == NULL)
|
|
|
+ return;
|
|
|
+
|
|
|
+ dirnamelen = (size_t) os_snprintf(pathname, sizeof(pathname), "%s/",
|
|
|
+ CONFIG_CTRL_IFACE_CLIENT_DIR);
|
|
|
+ if (dirnamelen >= sizeof(pathname)) {
|
|
|
+ closedir(dir);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ namep = pathname + dirnamelen;
|
|
|
+ maxcopy = PATH_MAX - dirnamelen;
|
|
|
+ while (readdir_r(dir, &entry, &result) == 0 && result != NULL) {
|
|
|
+ if (os_strncmp(entry.d_name, CONFIG_CTRL_IFACE_CLIENT_PREFIX,
|
|
|
+ prefixlen) == 0) {
|
|
|
+ if (os_strlcpy(namep, entry.d_name, maxcopy) < maxcopy)
|
|
|
+ unlink(pathname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closedir(dir);
|
|
|
+}
|
|
|
+#endif /* ANDROID */
|
|
|
+
|
|
|
+#else /* CONFIG_CTRL_IFACE_UNIX */
|
|
|
+
|
|
|
+#ifdef ANDROID
|
|
|
+void wpa_ctrl_cleanup(void)
|
|
|
+{
|
|
|
+}
|
|
|
+#endif /* ANDROID */
|
|
|
+
|
|
|
#endif /* CONFIG_CTRL_IFACE_UNIX */
|
|
|
|
|
|
|