Revert stubbing of unix socket functions
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 29 Nov 2018 21:22:06 +0000 (16:22 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Dec 2018 22:20:39 +0000 (17:20 -0500)
Instead of stubbing useful UNIX socket functions to work around
Linux-only credential passing, ifdef the relevant parts like it was
already done for other functions.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
src/common/Makefile.am
src/common/unix-stub.c [deleted file]
src/common/unix.c

index 69a9d776acfce3772829aae9e2ab7890d18b5a46..bc92b5bd039ce4f7ac23eecc89d7d32f4ddda9be 100644 (file)
@@ -874,7 +874,6 @@ build_lib_consumer=no
 build_lib_hashtable=no
 build_lib_health=no
 build_lib_runas=no
-build_lib_unix=no
 build_lib_index=no
 build_lib_kernel_consumer=no
 build_lib_kernel_ctl=no
@@ -932,7 +931,6 @@ AS_IF([test x$enable_bin_lttng_sessiond != xno],
        build_lib_testpoint=yes
        build_lib_health=yes
        build_lib_runas=yes
-       build_lib_unix=yes
       ]
 )
 
@@ -1042,7 +1040,6 @@ AM_CONDITIONAL([BUILD_LIB_CONSUMER], [test x$build_lib_consumer = xyes])
 AM_CONDITIONAL([BUILD_LIB_HASHTABLE], [test x$build_lib_hashtable = xyes])
 AM_CONDITIONAL([BUILD_LIB_HEALTH], [test x$build_lib_health = xyes])
 AM_CONDITIONAL([BUILD_LIB_RUNAS], [test x$build_lib_runas = xyes])
-AM_CONDITIONAL([BUILD_LIB_UNIX], [test x$build_lib_unix = xyes])
 AM_CONDITIONAL([BUILD_LIB_INDEX], [test x$build_lib_index = xyes])
 AM_CONDITIONAL([BUILD_LIB_KERNEL_CONSUMER], [test x$build_lib_kernel_consumer = xyes])
 AM_CONDITIONAL([BUILD_LIB_KERNEL_CTL], [test x$build_lib_kernel_ctl = xyes])
index b9d344b88a59bd2616269ce7500da1cf480e5dea..d754924ddb58f503f445ad8ae37422afa2932e04 100644 (file)
@@ -17,7 +17,7 @@ libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.h \
                        pipe.c pipe.h readwrite.c readwrite.h \
                        mi-lttng.h mi-lttng.c \
                        daemonize.c daemonize.h \
-                       unix.h \
+                       unix.c unix.h \
                        filter.c filter.h context.c context.h \
                        action.c notify.c condition.c buffer-usage.c \
                        session-consumed-size.c \
@@ -39,12 +39,6 @@ else
 libcommon_la_SOURCES += runas-stub.c
 endif
 
-if BUILD_LIB_UNIX
-libcommon_la_SOURCES += unix.c
-else
-libcommon_la_SOURCES += unix-stub.c
-endif
-
 if BUILD_LIB_COMPAT
 SUBDIRS += compat
 endif
diff --git a/src/common/unix-stub.c b/src/common/unix-stub.c
deleted file mode 100644 (file)
index 5cc6296..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef _UNIX_STUB_H
-#define _UNIX_STUB_H
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <common/compat/socket.h>
-
-int lttcomm_create_unix_sock(const char *pathname)
-{
-       return -1;
-}
-int lttcomm_create_anon_unix_socketpair(int *fds)
-{
-       return -1;
-}
-int lttcomm_connect_unix_sock(const char *pathname)
-{
-       return -1;
-}
-int lttcomm_accept_unix_sock(int sock)
-{
-       return -1;
-}
-int lttcomm_listen_unix_sock(int sock)
-{
-       return -1;
-}
-int lttcomm_close_unix_sock(int sock)
-{
-       return -1;
-}
-ssize_t lttcomm_send_fds_unix_sock(int sock, const int *fds, size_t nb_fd)
-{
-       return -1;
-}
-ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
-{
-       return -1;
-}
-ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len)
-{
-       return -1;
-}
-ssize_t lttcomm_recv_unix_sock_non_block(int sock, void *buf, size_t len)
-{
-       return -1;
-}
-ssize_t lttcomm_send_unix_sock(int sock, const void *buf, size_t len)
-{
-       return -1;
-}
-ssize_t lttcomm_send_unix_sock_non_block(int sock, const void *buf, size_t len)
-{
-       return -1;
-}
-ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len)
-{
-       return -1;
-}
-ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
-               lttng_sock_cred *creds)
-{
-       return -1;
-}
-int lttcomm_setsockopt_creds_unix_sock(int sock)
-{
-       return -1;
-}
-#endif /* _UNIX_STUB_H */
index edca02abf4fa246ad3d33b399ddbd0be252060b8..d37313c5aed87ee6600b1953ce6ba84a97d6f660 100644 (file)
@@ -441,8 +441,14 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
        struct cmsghdr *cmsg;
        size_t sizeof_fds = nb_fd * sizeof(int);
 
-       /* Account for the struct ucred cmsg in the buffer size */
-       char recv_buf[CMSG_SPACE(sizeof_fds) + CMSG_SPACE(sizeof(struct ucred))];
+#ifdef __linux__
+/* Account for the struct ucred cmsg in the buffer size */
+#define LTTNG_SOCK_RECV_FDS_BUF_SIZE CMSG_SPACE(sizeof_fds) + CMSG_SPACE(sizeof(struct ucred))
+#else
+#define LTTNG_SOCK_RECV_FDS_BUF_SIZE CMSG_SPACE(sizeof_fds)
+#endif /* __linux__ */
+
+       char recv_buf[LTTNG_SOCK_RECV_FDS_BUF_SIZE];
        struct msghdr msg;
        char dummy;
 
@@ -512,6 +518,7 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
                        ret = sizeof_fds;
                        goto end;
                }
+#ifdef __linux__
                if (cmsg->cmsg_type == SCM_CREDENTIALS) {
                        /*
                         * Expect credentials to be sent when expecting fds even
@@ -520,6 +527,7 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
                         */
                        ret = -1;
                }
+#endif /* __linux__ */
        }
 end:
        return ret;
This page took 0.040026 seconds and 4 git commands to generate.