diff options
-rw-r--r-- | src/aul_sock.c | 30 |
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; |