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
build_lib_testpoint=yes
build_lib_health=yes
build_lib_runas=yes
- build_lib_unix=yes
]
)
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])
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 \
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
+++ /dev/null
-/*
- * 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 */
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;
ret = sizeof_fds;
goto end;
}
+#ifdef __linux__
if (cmsg->cmsg_type == SCM_CREDENTIALS) {
/*
* Expect credentials to be sent when expecting fds even
*/
ret = -1;
}
+#endif /* __linux__ */
}
end:
return ret;