summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2021-11-04 12:07:31 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2021-11-04 15:25:51 +0900
commit3305ba9446da56ae4598298e7496f42370f04e9a (patch)
tree12ce1ac1bbc4adee178a1bac83154e3c6b0cf850
parent7e0fe22c6c897bfd937c4ceef9f92981ba803838 (diff)
downloadaul-1-3305ba9446da56ae4598298e7496f42370f04e9a.tar.gz
aul-1-3305ba9446da56ae4598298e7496f42370f04e9a.tar.bz2
aul-1-3305ba9446da56ae4598298e7496f42370f04e9a.zip
Remove socket link
While calling the aul_sock_destroy_server() function, the function removes the socket link if that exists. This patch is to remove the unnecessary link file. Change-Id: I4416a0965316fe0fc026ad06d556254a3a66049f Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--src/aul_sock.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/aul_sock.c b/src/aul_sock.c
index 49807581..6cd8dc7b 100644
--- a/src/aul_sock.c
+++ b/src/aul_sock.c
@@ -15,16 +15,17 @@
*/
#define _GNU_SOURCE
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdbool.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/xattr.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <ctype.h>
#include <tzplatform_config.h>
#include <glib.h>
#include <vconf.h>
@@ -46,6 +47,8 @@ typedef struct app_pkt_header_s {
} app_pkt_header_t;
static int socket_timeout_initialized;
+static int socket_link_created;
+static char socket_link_path[108];
static struct timeval tv = { 5, 200 * 1000 }; /* 5.2 */
@@ -217,7 +220,7 @@ API int aul_sock_set_sock_option(int fd, int cli)
static int __create_socket_dir(int pid, uid_t uid)
{
- char path[PATH_MAX];
+ char path[108];
if (uid < REGULAR_UID_MIN)
snprintf(path, sizeof(path), "/run/aul/daemons/%d", uid);
@@ -252,7 +255,7 @@ static void __create_socket_path(char *path_buf, int size, int pid, uid_t uid)
static void __create_socket_link(const char *socket_path, int pid, uid_t uid)
{
- char path[PATH_MAX];
+ char path[108];
if (__create_socket_dir(pid, uid) < 0)
return;
@@ -264,6 +267,9 @@ static void __create_socket_link(const char *socket_path, int pid, uid_t uid)
else
_E("path(%s) - unknown create error", path);
}
+
+ snprintf(socket_link_path, sizeof(socket_link_path), "%s", path);
+ socket_link_created = 1;
}
API int aul_sock_create_server(int pid, uid_t uid)
@@ -924,11 +930,21 @@ API int aul_sock_destroy_server(int fd)
"/run/aul/apps/%u/%d",
getuid(), getpid());
__delete_dir(path);
+
+ if (socket_link_created) {
+ __delete_dir(dirname(socket_link_path));
+ socket_link_created = 0;
+ }
} else {
snprintf(path, sizeof(path),
"/run/aul/daemons/%u/.app-sock-%d",
getuid(), getpid());
unlink(path);
+
+ if (socket_link_created) {
+ unlink(socket_link_path);
+ socket_link_created = 0;
+ }
}
return 0;