|
|
6237e8 |
diff -upr libqb-1.0.1.orig/configure.ac libqb-1.0.1/configure.ac
|
|
|
6237e8 |
--- libqb-1.0.1.orig/configure.ac 2016-11-08 11:15:16.000000000 +0000
|
|
|
6237e8 |
+++ libqb-1.0.1/configure.ac 2017-05-15 10:47:39.042145452 +0100
|
|
|
6237e8 |
@@ -482,6 +482,11 @@ AC_ARG_WITH([socket-dir],
|
|
|
6237e8 |
[ SOCKETDIR="$withval" ],
|
|
|
6237e8 |
[ SOCKETDIR="$localstatedir/run" ])
|
|
|
6237e8 |
|
|
|
6237e8 |
+AC_ARG_WITH([force-sockets-config-file],
|
|
|
6237e8 |
+ [AS_HELP_STRING([--with-force-sockets-config-file=FILE],[config file to force IPC to use filesystem sockets (Linux & Cygwin only) @<:@SYSCONFDIR/libqb/force-filesystem-sockets@:>@])],
|
|
|
6237e8 |
+ [ FORCESOCKETSFILE="$withval" ],
|
|
|
6237e8 |
+ [ FORCESOCKETSFILE="$sysconfdir/libqb/force-filesystem-sockets" ])
|
|
|
6237e8 |
+
|
|
|
6237e8 |
AC_SUBST(CP)
|
|
|
6237e8 |
# *FLAGS handling goes here
|
|
|
6237e8 |
|
|
|
6237e8 |
@@ -643,11 +648,14 @@ AM_CONDITIONAL([HAVE_DICT_WORDS], [test
|
|
|
6237e8 |
# substitute what we need:
|
|
|
6237e8 |
AC_SUBST([SOCKETDIR])
|
|
|
6237e8 |
AC_SUBST([LINT_FLAGS])
|
|
|
6237e8 |
+AC_SUBST([FORCESOCKETSFILE])
|
|
|
6237e8 |
|
|
|
6237e8 |
AC_DEFINE_UNQUOTED([SOCKETDIR], "$(eval echo ${SOCKETDIR})", [Socket directory])
|
|
|
6237e8 |
AC_DEFINE_UNQUOTED([LOCALSTATEDIR], "$(eval echo ${localstatedir})", [localstate directory])
|
|
|
6237e8 |
AC_DEFINE_UNQUOTED([PACKAGE_FEATURES], "${PACKAGE_FEATURES}", [quarterback built-in features])
|
|
|
6237e8 |
|
|
|
6237e8 |
+AC_DEFINE_UNQUOTED([FORCESOCKETSFILE], "$(eval echo ${FORCESOCKETSFILE})", [for sockets config file])
|
|
|
6237e8 |
+
|
|
|
6237e8 |
# version parsing (for qbconfig.h)
|
|
|
6237e8 |
AC_DEFINE_UNQUOTED([QB_VER_MAJOR],
|
|
|
6237e8 |
[$(echo "${VERSION}" \
|
|
|
6237e8 |
Only in libqb-1.0.1: configure.ac.orig
|
|
|
6237e8 |
diff -upr libqb-1.0.1.orig/docs/mainpage.h libqb-1.0.1/docs/mainpage.h
|
|
|
6237e8 |
--- libqb-1.0.1.orig/docs/mainpage.h 2016-11-08 10:10:23.000000000 +0000
|
|
|
6237e8 |
+++ libqb-1.0.1/docs/mainpage.h 2017-05-15 10:47:39.042145452 +0100
|
|
|
6237e8 |
@@ -101,6 +101,19 @@
|
|
|
6237e8 |
* a single one pushed throughout its lifecycle just with a single thread;
|
|
|
6237e8 |
* anything else would likely warrant external synchronization enforcement.
|
|
|
6237e8 |
*
|
|
|
6237e8 |
+ * @par IPC sockets (Linux only)
|
|
|
6237e8 |
+ * On Linux IPC, abstract (non-filesystem) sockets are used by default. If you
|
|
|
6237e8 |
+ * need to override this (say in a net=host container) and use sockets that reside
|
|
|
6237e8 |
+ * in the filesystem, then create a file called /etc/libqb/force-filesystem-sockets
|
|
|
6237e8 |
+ * - this is the default name and can be changed at ./configure time.
|
|
|
6237e8 |
+ * The file need contain no text, it's not a configuration file as such, just its
|
|
|
6237e8 |
+ * presence will activate the feature.
|
|
|
6237e8 |
+ *
|
|
|
6237e8 |
+ * Note that this is a global option and read each time a new IPC connection
|
|
|
6237e8 |
+ * (client or server) is created. So, to avoid having clients that cannot
|
|
|
6237e8 |
+ * connect to running servers it is STRONGLY recommended to only create or remove
|
|
|
6237e8 |
+ * this file prior to a system reboot or container restart.
|
|
|
6237e8 |
+ *
|
|
|
6237e8 |
* @par Client API
|
|
|
6237e8 |
* @copydoc qbipcc.h
|
|
|
6237e8 |
* @see qbipcc.h
|
|
|
6237e8 |
Only in libqb-1.0.1/docs: mainpage.h.orig
|
|
|
6237e8 |
diff -upr libqb-1.0.1.orig/lib/ipc_int.h libqb-1.0.1/lib/ipc_int.h
|
|
|
6237e8 |
--- libqb-1.0.1.orig/lib/ipc_int.h 2016-02-22 16:01:51.000000000 +0000
|
|
|
6237e8 |
+++ libqb-1.0.1/lib/ipc_int.h 2017-05-15 10:47:39.042145452 +0100
|
|
|
6237e8 |
@@ -205,4 +205,6 @@ int32_t qb_ipcs_process_request(struct q
|
|
|
6237e8 |
|
|
|
6237e8 |
int32_t qb_ipc_us_sock_error_is_disconnected(int err);
|
|
|
6237e8 |
|
|
|
6237e8 |
+int use_filesystem_sockets(void);
|
|
|
6237e8 |
+
|
|
|
6237e8 |
#endif /* QB_IPC_INT_H_DEFINED */
|
|
|
6237e8 |
diff -upr libqb-1.0.1.orig/lib/ipc_setup.c libqb-1.0.1/lib/ipc_setup.c
|
|
|
6237e8 |
--- libqb-1.0.1.orig/lib/ipc_setup.c 2016-11-08 10:10:23.000000000 +0000
|
|
|
6237e8 |
+++ libqb-1.0.1/lib/ipc_setup.c 2017-05-15 10:47:39.042145452 +0100
|
|
|
6237e8 |
@@ -69,7 +69,6 @@ struct ipc_auth_data {
|
|
|
6237e8 |
|
|
|
6237e8 |
};
|
|
|
6237e8 |
|
|
|
6237e8 |
-
|
|
|
6237e8 |
static int32_t qb_ipcs_us_connection_acceptor(int fd, int revent, void *data);
|
|
|
6237e8 |
|
|
|
6237e8 |
ssize_t
|
|
|
6237e8 |
@@ -286,12 +285,13 @@ qb_ipcc_stream_sock_connect(const char *
|
|
|
6237e8 |
address.sun_len = QB_SUN_LEN(&address);
|
|
|
6237e8 |
#endif
|
|
|
6237e8 |
|
|
|
6237e8 |
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
|
|
|
6237e8 |
- snprintf(address.sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
|
|
|
6237e8 |
-#else
|
|
|
6237e8 |
- snprintf(address.sun_path, sizeof(address.sun_path), "%s/%s", SOCKETDIR,
|
|
|
6237e8 |
- socket_name);
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
+ if (!use_filesystem_sockets()) {
|
|
|
6237e8 |
+ snprintf(address.sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
|
|
|
6237e8 |
+ } else {
|
|
|
6237e8 |
+ snprintf(address.sun_path, sizeof(address.sun_path), "%s/%s", SOCKETDIR,
|
|
|
6237e8 |
+ socket_name);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+
|
|
|
6237e8 |
if (connect(request_fd, (struct sockaddr *)&address,
|
|
|
6237e8 |
QB_SUN_LEN(&address)) == -1) {
|
|
|
6237e8 |
res = -errno;
|
|
|
6237e8 |
@@ -535,10 +535,11 @@ qb_ipcs_us_publish(struct qb_ipcs_servic
|
|
|
6237e8 |
#endif
|
|
|
6237e8 |
|
|
|
6237e8 |
qb_util_log(LOG_INFO, "server name: %s", s->name);
|
|
|
6237e8 |
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
|
|
|
6237e8 |
- snprintf(un_addr.sun_path + 1, UNIX_PATH_MAX - 1, "%s", s->name);
|
|
|
6237e8 |
-#else
|
|
|
6237e8 |
- {
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ if (!use_filesystem_sockets()) {
|
|
|
6237e8 |
+ snprintf(un_addr.sun_path + 1, UNIX_PATH_MAX - 1, "%s", s->name);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+ else {
|
|
|
6237e8 |
struct stat stat_out;
|
|
|
6237e8 |
res = stat(SOCKETDIR, &stat_out);
|
|
|
6237e8 |
if (res == -1 || (res == 0 && !S_ISDIR(stat_out.st_mode))) {
|
|
|
6237e8 |
@@ -552,7 +553,6 @@ qb_ipcs_us_publish(struct qb_ipcs_servic
|
|
|
6237e8 |
s->name);
|
|
|
6237e8 |
unlink(un_addr.sun_path);
|
|
|
6237e8 |
}
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
|
|
|
6237e8 |
res = bind(s->server_sock, (struct sockaddr *)&un_addr,
|
|
|
6237e8 |
QB_SUN_LEN(&un_addr));
|
|
|
6237e8 |
@@ -561,15 +561,15 @@ qb_ipcs_us_publish(struct qb_ipcs_servic
|
|
|
6237e8 |
qb_util_perror(LOG_ERR, "Could not bind AF_UNIX (%s)",
|
|
|
6237e8 |
un_addr.sun_path);
|
|
|
6237e8 |
goto error_close;
|
|
|
6237e8 |
- }
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
|
|
|
6237e8 |
/*
|
|
|
6237e8 |
* Allow everyone to write to the socket since the IPC layer handles
|
|
|
6237e8 |
* security automatically
|
|
|
6237e8 |
*/
|
|
|
6237e8 |
-#if !defined(QB_LINUX) && !defined(QB_CYGWIN)
|
|
|
6237e8 |
- res = chmod(un_addr.sun_path, S_IRWXU | S_IRWXG | S_IRWXO);
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ res = chmod(un_addr.sun_path, S_IRWXU | S_IRWXG | S_IRWXO);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
#ifdef SO_PASSCRED
|
|
|
6237e8 |
setsockopt(s->server_sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
|
|
|
6237e8 |
#endif
|
|
|
6237e8 |
@@ -593,6 +593,16 @@ qb_ipcs_us_withdraw(struct qb_ipcs_servi
|
|
|
6237e8 |
qb_util_log(LOG_INFO, "withdrawing server sockets");
|
|
|
6237e8 |
(void)s->poll_fns.dispatch_del(s->server_sock);
|
|
|
6237e8 |
shutdown(s->server_sock, SHUT_RDWR);
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ struct sockaddr_un sockname;
|
|
|
6237e8 |
+ socklen_t socklen = sizeof(sockname);
|
|
|
6237e8 |
+ if ((getsockname(s->server_sock, (struct sockaddr *)&sockname, &socklen) == 0) &&
|
|
|
6237e8 |
+ sockname.sun_family == AF_UNIX) {
|
|
|
6237e8 |
+ unlink(sockname.sun_path);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+
|
|
|
6237e8 |
close(s->server_sock);
|
|
|
6237e8 |
s->server_sock = -1;
|
|
|
6237e8 |
return 0;
|
|
|
6237e8 |
diff -upr libqb-1.0.1.orig/lib/ipc_socket.c libqb-1.0.1/lib/ipc_socket.c
|
|
|
6237e8 |
--- libqb-1.0.1.orig/lib/ipc_socket.c 2016-11-08 10:10:23.000000000 +0000
|
|
|
6237e8 |
+++ libqb-1.0.1/lib/ipc_socket.c 2017-05-15 10:47:39.043145455 +0100
|
|
|
6237e8 |
@@ -42,6 +42,26 @@ struct ipc_us_control {
|
|
|
6237e8 |
};
|
|
|
6237e8 |
#define SHM_CONTROL_SIZE (3 * sizeof(struct ipc_us_control))
|
|
|
6237e8 |
|
|
|
6237e8 |
+int use_filesystem_sockets(void)
|
|
|
6237e8 |
+{
|
|
|
6237e8 |
+ static int need_init = 1;
|
|
|
6237e8 |
+ static int filesystem_sockets = 0;
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ if (need_init) {
|
|
|
6237e8 |
+ struct stat buf;
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ need_init = 0;
|
|
|
6237e8 |
+#if defined(QB_LINUX) || defined(QB_CYGWIN)
|
|
|
6237e8 |
+ if (stat(FORCESOCKETSFILE, &buf) == 0) {
|
|
|
6237e8 |
+ filesystem_sockets = 1;
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+#else
|
|
|
6237e8 |
+ filesystem_sockets = 1;
|
|
|
6237e8 |
+#endif
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+ return filesystem_sockets;
|
|
|
6237e8 |
+}
|
|
|
6237e8 |
+
|
|
|
6237e8 |
static void
|
|
|
6237e8 |
set_sock_addr(struct sockaddr_un *address, const char *socket_name)
|
|
|
6237e8 |
{
|
|
|
6237e8 |
@@ -51,12 +71,12 @@ set_sock_addr(struct sockaddr_un *addres
|
|
|
6237e8 |
address->sun_len = QB_SUN_LEN(address);
|
|
|
6237e8 |
#endif
|
|
|
6237e8 |
|
|
|
6237e8 |
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
|
|
|
6237e8 |
- snprintf(address->sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
|
|
|
6237e8 |
-#else
|
|
|
6237e8 |
- snprintf(address->sun_path, sizeof(address->sun_path), "%s/%s", SOCKETDIR,
|
|
|
6237e8 |
- socket_name);
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
+ if (!use_filesystem_sockets()) {
|
|
|
6237e8 |
+ snprintf(address->sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
|
|
|
6237e8 |
+ } else {
|
|
|
6237e8 |
+ snprintf(address->sun_path, sizeof(address->sun_path), "%s/%s", SOCKETDIR,
|
|
|
6237e8 |
+ socket_name);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
}
|
|
|
6237e8 |
|
|
|
6237e8 |
static int32_t
|
|
|
6237e8 |
@@ -81,15 +101,16 @@ qb_ipc_dgram_sock_setup(const char *base
|
|
|
6237e8 |
}
|
|
|
6237e8 |
snprintf(sock_path, PATH_MAX, "%s-%s", base_name, service_name);
|
|
|
6237e8 |
set_sock_addr(&local_address, sock_path);
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- res = unlink(local_address.sun_path);
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ res = unlink(local_address.sun_path);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
res = bind(request_fd, (struct sockaddr *)&local_address,
|
|
|
6237e8 |
sizeof(local_address));
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- chmod(local_address.sun_path, 0660);
|
|
|
6237e8 |
- chown(local_address.sun_path, -1, gid);
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ chmod(local_address.sun_path, 0660);
|
|
|
6237e8 |
+ chown(local_address.sun_path, -1, gid);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
if (res < 0) {
|
|
|
6237e8 |
goto error_connect;
|
|
|
6237e8 |
}
|
|
|
6237e8 |
@@ -316,36 +337,33 @@ _finish_connecting(struct qb_ipc_one_way
|
|
|
6237e8 |
static void
|
|
|
6237e8 |
qb_ipcc_us_disconnect(struct qb_ipcc_connection *c)
|
|
|
6237e8 |
{
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- struct sockaddr_un un_addr;
|
|
|
6237e8 |
- socklen_t un_addr_len = sizeof(struct sockaddr_un);
|
|
|
6237e8 |
- char *base_name;
|
|
|
6237e8 |
- char sock_name[PATH_MAX];
|
|
|
6237e8 |
- size_t length;
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
-
|
|
|
6237e8 |
munmap(c->request.u.us.shared_data, SHM_CONTROL_SIZE);
|
|
|
6237e8 |
unlink(c->request.u.us.shared_file_name);
|
|
|
6237e8 |
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- if (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {
|
|
|
6237e8 |
- length = strlen(un_addr.sun_path);
|
|
|
6237e8 |
- base_name = strndup(un_addr.sun_path,length-9);
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlinking socket bound files with base_name=%s length=%d",base_name,length);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"request");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event-tx");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"response");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- }
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ struct sockaddr_un un_addr;
|
|
|
6237e8 |
+ socklen_t un_addr_len = sizeof(struct sockaddr_un);
|
|
|
6237e8 |
+ char *base_name;
|
|
|
6237e8 |
+ char sock_name[PATH_MAX];
|
|
|
6237e8 |
+ size_t length;
|
|
|
6237e8 |
+ if (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {
|
|
|
6237e8 |
+ length = strlen(un_addr.sun_path);
|
|
|
6237e8 |
+ base_name = strndup(un_addr.sun_path,length-9);
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlinking socket bound files with base_name=%s length=%d",base_name,length);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"request");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event-tx");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"response");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
qb_ipcc_us_sock_close(c->event.u.us.sock);
|
|
|
6237e8 |
qb_ipcc_us_sock_close(c->request.u.us.sock);
|
|
|
6237e8 |
qb_ipcc_us_sock_close(c->setup.u.us.sock);
|
|
|
6237e8 |
@@ -451,11 +469,11 @@ retry_peek:
|
|
|
6237e8 |
|
|
|
6237e8 |
if (errno != EAGAIN) {
|
|
|
6237e8 |
final_rc = -errno;
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- if (errno == ECONNRESET || errno == EPIPE) {
|
|
|
6237e8 |
- final_rc = -ENOTCONN;
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ if (errno == ECONNRESET || errno == EPIPE) {
|
|
|
6237e8 |
+ final_rc = -ENOTCONN;
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
}
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
goto cleanup_sigpipe;
|
|
|
6237e8 |
}
|
|
|
6237e8 |
|
|
|
6237e8 |
@@ -686,38 +704,36 @@ _sock_rm_from_mainloop(struct qb_ipcs_co
|
|
|
6237e8 |
static void
|
|
|
6237e8 |
qb_ipcs_us_disconnect(struct qb_ipcs_connection *c)
|
|
|
6237e8 |
{
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- struct sockaddr_un un_addr;
|
|
|
6237e8 |
- socklen_t un_addr_len = sizeof(struct sockaddr_un);
|
|
|
6237e8 |
- char *base_name;
|
|
|
6237e8 |
- char sock_name[PATH_MAX];
|
|
|
6237e8 |
- size_t length;
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
qb_enter();
|
|
|
6237e8 |
|
|
|
6237e8 |
if (c->state == QB_IPCS_CONNECTION_ESTABLISHED ||
|
|
|
6237e8 |
c->state == QB_IPCS_CONNECTION_ACTIVE) {
|
|
|
6237e8 |
_sock_rm_from_mainloop(c);
|
|
|
6237e8 |
|
|
|
6237e8 |
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
|
|
|
6237e8 |
- if (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {
|
|
|
6237e8 |
- length = strlen(un_addr.sun_path);
|
|
|
6237e8 |
- base_name = strndup(un_addr.sun_path,length-8);
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlinking socket bound files with base_name=%s length=%d",base_name,length);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"request");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event-tx");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
- snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"response");
|
|
|
6237e8 |
- qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
- unlink(sock_name);
|
|
|
6237e8 |
+ if (use_filesystem_sockets()) {
|
|
|
6237e8 |
+ struct sockaddr_un un_addr;
|
|
|
6237e8 |
+ socklen_t un_addr_len = sizeof(struct sockaddr_un);
|
|
|
6237e8 |
+ char *base_name;
|
|
|
6237e8 |
+ char sock_name[PATH_MAX];
|
|
|
6237e8 |
+ size_t length;
|
|
|
6237e8 |
+ if (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {
|
|
|
6237e8 |
+ length = strlen(un_addr.sun_path);
|
|
|
6237e8 |
+ base_name = strndup(un_addr.sun_path,length-8);
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlinking socket bound files with base_name=%s length=%d",base_name,length);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"request");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"event-tx");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ snprintf(sock_name,PATH_MAX,"%s-%s",base_name,"response");
|
|
|
6237e8 |
+ qb_util_log(LOG_DEBUG, "unlink sock_name=%s",sock_name);
|
|
|
6237e8 |
+ unlink(sock_name);
|
|
|
6237e8 |
+ }
|
|
|
6237e8 |
}
|
|
|
6237e8 |
-#endif
|
|
|
6237e8 |
qb_ipcc_us_sock_close(c->setup.u.us.sock);
|
|
|
6237e8 |
qb_ipcc_us_sock_close(c->request.u.us.sock);
|
|
|
6237e8 |
qb_ipcc_us_sock_close(c->event.u.us.sock);
|
|
|
6237e8 |
Only in libqb-1.0.1/lib: ipc_socket.c.orig
|
|
|
6237e8 |
diff -upr libqb-1.0.1.orig/tests/check_ipc.c libqb-1.0.1/tests/check_ipc.c
|
|
|
6237e8 |
--- libqb-1.0.1.orig/tests/check_ipc.c 2016-11-08 11:15:16.000000000 +0000
|
|
|
6237e8 |
+++ libqb-1.0.1/tests/check_ipc.c 2017-05-15 10:47:39.043145455 +0100
|
|
|
6237e8 |
@@ -1417,10 +1417,17 @@ END_TEST
|
|
|
6237e8 |
#ifdef HAVE_FAILURE_INJECTION
|
|
|
6237e8 |
START_TEST(test_ipcc_truncate_when_unlink_fails_shm)
|
|
|
6237e8 |
{
|
|
|
6237e8 |
+ char sock_file[PATH_MAX];
|
|
|
6237e8 |
qb_enter();
|
|
|
6237e8 |
- _fi_unlink_inject_failure = QB_TRUE;
|
|
|
6237e8 |
ipc_type = QB_IPC_SHM;
|
|
|
6237e8 |
set_ipc_name(__func__);
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ sprintf(sock_file, "%s/%s", SOCKETDIR, ipc_name);
|
|
|
6237e8 |
+ /* If there's an old socket left from a previous run this test will fail
|
|
|
6237e8 |
+ unexpectedly, so try to remove it first */
|
|
|
6237e8 |
+ unlink(sock_file);
|
|
|
6237e8 |
+
|
|
|
6237e8 |
+ _fi_unlink_inject_failure = QB_TRUE;
|
|
|
6237e8 |
test_ipc_server_fail();
|
|
|
6237e8 |
_fi_unlink_inject_failure = QB_FALSE;
|
|
|
6237e8 |
qb_leave();
|
|
|
6237e8 |
Only in libqb-1.0.1/tests: check_ipc.c.orig
|