All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH lttng-tools 2/2] Revert stubbing of runas functions
       [not found] <20181129212207.8611-1-mjeanson@efficios.com>
@ 2018-11-29 21:22 ` Michael Jeanson
  2019-01-22 19:33 ` [PATCH lttng-tools 1/2] Revert stubbing of unix socket functions Jérémie Galarneau
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Jeanson @ 2018-11-29 21:22 UTC (permalink / raw)
  To: lttng-dev; +Cc: jgalar

All the runas functions were stubbed on builds were the sessiond isn't
built which is the case of all platforms except Linux. This was done
because of 2 new commands that require elf.h which is not present on
MacOSX. However the other commands can be used by the relayd.

Revert this and and only stub the relevant commands when "elf.h" is not
present on the system.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
---
 configure.ac            |  7 ++---
 src/common/Makefile.am  | 12 ++++----
 src/common/lttng-elf.c  |  6 ++--
 src/common/runas-stub.c | 62 -----------------------------------------
 src/common/runas.c      | 18 ++++++++++++
 5 files changed, 29 insertions(+), 76 deletions(-)
 delete mode 100644 src/common/runas-stub.c

diff --git a/configure.ac b/configure.ac
index bc92b5bd..bf1ef6f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,9 +194,11 @@ AC_CHECK_HEADERS([ \
 	signal.h stdlib.h sys/un.h sys/socket.h stdlib.h stdio.h \
 	getopt.h sys/ipc.h sys/shm.h popt.h grp.h arpa/inet.h \
 	netdb.h netinet/in.h paths.h stddef.h sys/file.h sys/ioctl.h \
-	sys/mount.h sys/param.h sys/time.h
+	sys/mount.h sys/param.h sys/time.h elf.h
 ])
 
+AM_CONDITIONAL([HAVE_ELF_H], [test x$ac_cv_header_elf_h = xyes])
+
 # Basic functions check
 AC_CHECK_FUNCS([ \
 	atexit bzero clock_gettime dup2 fdatasync fls ftruncate \
@@ -873,7 +875,6 @@ build_lib_compat=no
 build_lib_consumer=no
 build_lib_hashtable=no
 build_lib_health=no
-build_lib_runas=no
 build_lib_index=no
 build_lib_kernel_consumer=no
 build_lib_kernel_ctl=no
@@ -930,7 +931,6 @@ AS_IF([test x$enable_bin_lttng_sessiond != xno],
        build_lib_relayd=yes
        build_lib_testpoint=yes
        build_lib_health=yes
-       build_lib_runas=yes
       ]
 )
 
@@ -1039,7 +1039,6 @@ AM_CONDITIONAL([BUILD_LIB_CONFIG], [test x$build_lib_config = xyes])
 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_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])
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index d754924d..1824fe46 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -12,7 +12,7 @@ DIST_SUBDIRS = compat health hashtable kernel-ctl sessiond-comm relayd \
 noinst_LTLIBRARIES = libcommon.la
 EXTRA_DIST = mi-lttng-3.0.xsd
 
-libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.h \
+libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.h runas.c \
                        common.h futex.c futex.h uri.c uri.h defaults.c \
                        pipe.c pipe.h readwrite.c readwrite.h \
                        mi-lttng.h mi-lttng.c \
@@ -29,16 +29,14 @@ libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.h \
                        waiter.h waiter.c \
                        userspace-probe.c event.c
 
+if HAVE_ELF_H
+libcommon_la_SOURCES += lttng-elf.h lttng-elf.c
+endif
+
 libcommon_la_LIBADD = \
 		$(top_builddir)/src/common/config/libconfig.la \
 		$(UUID_LIBS)
 
-if BUILD_LIB_RUNAS
-libcommon_la_SOURCES += runas.c lttng-elf.h lttng-elf.c
-else
-libcommon_la_SOURCES += runas-stub.c
-endif
-
 if BUILD_LIB_COMPAT
 SUBDIRS += compat
 endif
diff --git a/src/common/lttng-elf.c b/src/common/lttng-elf.c
index cb01f7bb..cd10632c 100644
--- a/src/common/lttng-elf.c
+++ b/src/common/lttng-elf.c
@@ -56,13 +56,13 @@
 	do {					\
 		switch (sizeof(x)) {		\
 		case 8:				\
-			x = be64toh(x);		\
+			x = be64toh((uint64_t)x);		\
 			break;			\
 		case 4:				\
-			x = be32toh(x);		\
+			x = be32toh((uint32_t)x);		\
 			break;			\
 		case 2:				\
-			x = be16toh(x);		\
+			x = be16toh((uint16_t)x);		\
 			break;			\
 		case 1:				\
 			break;			\
diff --git a/src/common/runas-stub.c b/src/common/runas-stub.c
deleted file mode 100644
index 7af8b6e0..00000000
--- a/src/common/runas-stub.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef _RUNAS_STUB_H
-#define _RUNAS_STUB_H
-
-/*
- * 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.
- */
-
-#include <sys/types.h>
-#include <stdint.h>
-
-int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid)
-{
-	return -1;
-}
-int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid)
-{
-	return -1;
-}
-int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
-{
-	return -1;
-}
-int run_as_unlink(const char *path, uid_t uid, gid_t gid)
-{
-	return -1;
-}
-int run_as_rmdir_recursive(const char *path, uid_t uid, gid_t gid)
-{
-	return -1;
-}
-int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset)
-{
-	return -1;
-}
-int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
-		const char *probe_name, uint64_t **offsets, uint32_t *nb_probe)
-{
-	return -1;
-}
-int run_as_create_worker(char *procname)
-{
-	return -1;
-}
-void run_as_destroy_worker(void)
-{
-	return;
-}
-
-#endif /* _RUNAS_STUB_H */
diff --git a/src/common/runas.c b/src/common/runas.c
index 00c729fd..1487eb15 100644
--- a/src/common/runas.c
+++ b/src/common/runas.c
@@ -240,6 +240,7 @@ int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
 	return ret_value->u.rmdir_recursive.ret;
 }
 
+#ifdef HAVE_ELF_H
 static
 int _extract_elf_symbol_offset(struct run_as_data *data,
 		struct run_as_ret *ret_value)
@@ -298,6 +299,23 @@ free_offset:
 end:
 	return ret;
 }
+#else
+static
+int _extract_elf_symbol_offset(struct run_as_data *data,
+		struct run_as_ret *ret_value)
+{
+	ERR("Unimplemented runas command RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET");
+	return -1;
+}
+
+static
+int _extract_sdt_probe_offsets(struct run_as_data *data,
+		struct run_as_ret *ret_value)
+{
+	ERR("Unimplemented runas command RUN_AS_EXTRACT_SDT_PROBE_OFFSETS");
+	return -1;
+}
+#endif
 
 static
 run_as_fct run_as_enum_to_fct(enum run_as_cmd cmd)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH lttng-tools 1/2] Revert stubbing of unix socket functions
       [not found] <20181129212207.8611-1-mjeanson@efficios.com>
  2018-11-29 21:22 ` [PATCH lttng-tools 2/2] Revert stubbing of runas functions Michael Jeanson
@ 2019-01-22 19:33 ` Jérémie Galarneau
  1 sibling, 0 replies; 3+ messages in thread
From: Jérémie Galarneau @ 2019-01-22 19:33 UTC (permalink / raw)
  To: Michael Jeanson; +Cc: lttng-dev, Jeremie Galarneau

Both patches of the series were merged in master and stable-2.11.

Thanks!
Jérémie

On Thu, 29 Nov 2018 at 16:22, Michael Jeanson <mjeanson@efficios.com> wrote:
>
> Instead of stubing 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>
> ---
>  configure.ac           |  3 --
>  src/common/Makefile.am |  8 +---
>  src/common/unix-stub.c | 86 ------------------------------------------
>  src/common/unix.c      | 12 +++++-
>  4 files changed, 11 insertions(+), 98 deletions(-)
>  delete mode 100644 src/common/unix-stub.c
>
> diff --git a/configure.ac b/configure.ac
> index 69a9d776..bc92b5bd 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -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])
> diff --git a/src/common/Makefile.am b/src/common/Makefile.am
> index b9d344b8..d754924d 100644
> --- a/src/common/Makefile.am
> +++ b/src/common/Makefile.am
> @@ -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
> index 5cc62964..00000000
> --- a/src/common/unix-stub.c
> +++ /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 */
> diff --git a/src/common/unix.c b/src/common/unix.c
> index edca02ab..d37313c5 100644
> --- a/src/common/unix.c
> +++ b/src/common/unix.c
> @@ -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;
> --
> 2.17.1
>


-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH lttng-tools 1/2] Revert stubbing of unix socket functions
@ 2018-11-29 21:22 Michael Jeanson
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Jeanson @ 2018-11-29 21:22 UTC (permalink / raw)
  To: lttng-dev; +Cc: jgalar

Instead of stubing 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>
---
 configure.ac           |  3 --
 src/common/Makefile.am |  8 +---
 src/common/unix-stub.c | 86 ------------------------------------------
 src/common/unix.c      | 12 +++++-
 4 files changed, 11 insertions(+), 98 deletions(-)
 delete mode 100644 src/common/unix-stub.c

diff --git a/configure.ac b/configure.ac
index 69a9d776..bc92b5bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index b9d344b8..d754924d 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -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
index 5cc62964..00000000
--- a/src/common/unix-stub.c
+++ /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 */
diff --git a/src/common/unix.c b/src/common/unix.c
index edca02ab..d37313c5 100644
--- a/src/common/unix.c
+++ b/src/common/unix.c
@@ -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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-22 19:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20181129212207.8611-1-mjeanson@efficios.com>
2018-11-29 21:22 ` [PATCH lttng-tools 2/2] Revert stubbing of runas functions Michael Jeanson
2019-01-22 19:33 ` [PATCH lttng-tools 1/2] Revert stubbing of unix socket functions Jérémie Galarneau
2018-11-29 21:22 Michael Jeanson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.