From: David Goulet Date: Fri, 2 Mar 2012 20:00:16 +0000 (-0500) Subject: Merge branch 'master' of git://git.lttng.org/lttng-tools X-Git-Tag: v2.0.0-rc3~19 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e71aad1fa4b06a5f91ddceace42366f3d79bd77e;p=lttng-tools.git Merge branch 'master' of git://git.lttng.org/lttng-tools --- e71aad1fa4b06a5f91ddceace42366f3d79bd77e diff --cc src/bin/lttng-sessiond/shm.c index 55d00e67f,ce1844fe8..432d07ece --- a/src/bin/lttng-sessiond/shm.c +++ b/src/bin/lttng-sessiond/shm.c @@@ -104,15 -104,11 +104,15 @@@ static int get_wait_shm(char *shm_path exit(EXIT_FAILURE); } +#ifndef __FreeBSD__ ret = fchmod(wait_shm_fd, mode); if (ret < 0) { - perror("fchmod"); + PERROR("fchmod"); exit(EXIT_FAILURE); } +#else +#warning "FreeBSD does not support setting file mode on shm FD. Remember that for secure use, lttng-sessiond should be started before applications linked on lttng-ust." +#endif DBG("Got the wait shm fd %d", wait_shm_fd); diff --cc src/common/error.h index 14b5e7c67,93c947c0d..e5255e4a4 --- a/src/common/error.h +++ b/src/common/error.h @@@ -75,22 -80,9 +80,23 @@@ extern int opt_verbose " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) #define _PERROR(fmt, args...) \ - __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args) + __lttng_print(PRINT_ERR, "PERROR: " fmt \ + " [in %s() at " __FILE__ ":" XSTR(__LINE__) "]\n", ## args, __func__) +#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE)) +/* + * Version using XSI strerror_r. + */ +#define PERROR(call, args...) \ + do { \ + char buf[200]; \ + strerror_r(errno, buf, sizeof(buf)); \ + _PERROR(call ": %s", ## args, buf); \ + } while(0); +#else +/* + * Version using GNU strerror_r, for linux with appropriate defines. + */ #define PERROR(call, args...) \ do { \ char *buf; \ diff --cc src/common/runas.c index 4742a792e,60e02a2bf..e0c317c4e --- a/src/common/runas.c +++ b/src/common/runas.c @@@ -238,10 -225,10 +238,10 @@@ int run_as_clone(int (*cmd)(void *data) run_as_data.retval_pipe = retval_pipe[1]; /* write end */ child_stack = mmap(NULL, RUNAS_CHILD_STACK_SIZE, PROT_WRITE | PROT_READ, - MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | MAP_STACK, + MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS | LTTNG_MAP_STACK, -1, 0); if (child_stack == MAP_FAILED) { - perror("mmap"); + PERROR("mmap"); retval.i = -ENOMEM; goto close_pipe; } @@@ -249,10 -236,11 +249,10 @@@ * Pointing to the middle of the stack to support architectures * where the stack grows up (HPPA). */ - pid = clone(child_run_as, child_stack + (RUNAS_CHILD_STACK_SIZE / 2), - CLONE_FILES | SIGCHLD, - &run_as_data, NULL); + pid = lttng_clone_files(child_run_as, child_stack + (RUNAS_CHILD_STACK_SIZE / 2), + &run_as_data); if (pid < 0) { - perror("clone"); + PERROR("clone"); retval.i = pid; goto unmap_stack; } diff --cc src/common/sessiond-comm/sessiond-comm.c index 3b224c6ff,8a5ff1d3f..aa24e82dd --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@@ -568,15 -553,8 +574,15 @@@ int lttcomm_setsockopt_creds_unix_sock( /* Set socket for credentials retrieval */ ret = setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); if (ret < 0) { - perror("setsockopt creds unix sock"); + PERROR("setsockopt creds unix sock"); } - return ret; } +#elif defined(__FreeBSD__) +int lttcomm_setsockopt_creds_unix_sock(int sock) +{ + return 0; +} +#else +#error "Please implement credential support for your OS." +#endif /* __linux__ */