/*
* This API in only for Appfw internally.
*/
-API int aul_sock_recv_result_with_fd(int fd);
+int aul_sock_recv_result_with_fd(int fd);
+/*
+ * This API in only for Appfw internally.
+ */
+int aul_sock_destroy_server(int fd);
return res;
}
+static void __delete_dir(const char *path)
+{
+ DIR *dp;
+ struct dirent *dentry = NULL;
+ char buf[PATH_MAX];
+ struct stat statbuf;
+ int ret;
+
+ if (path == NULL)
+ return;
+
+ dp = opendir(path);
+ if (dp == NULL)
+ return;
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!strcmp(dentry->d_name, ".") ||
+ !strcmp(dentry->d_name, ".."))
+ continue;
+
+ snprintf(buf, sizeof(buf), "%s/%s", path, dentry->d_name);
+ ret = stat(buf, &statbuf);
+ if (ret == 0) {
+ if (S_ISDIR(statbuf.st_mode))
+ __delete_dir(buf);
+ else
+ unlink(buf);
+ }
+ }
+
+ rmdir(path);
+ closedir(dp);
+}
+
+API int aul_sock_destroy_server(int fd)
+{
+ char path[PATH_MAX];
+
+ if (fd > 3)
+ close(fd);
+
+ if (getuid() >= REGULAR_UID_MIN) {
+ snprintf(path, sizeof(path),
+ "/run/aul/apps/%u/%d",
+ getuid(), getpid());
+ __delete_dir(path);
+ } else {
+ snprintf(path, sizeof(path),
+ "/run/aul/daemons/%u/.app-sock-%d",
+ getuid(), getpid());
+ unlink(path);
+ }
+
+ return 0;
+}