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);
" [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; \
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;
}
* 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;
}
/* 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__ */