projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add common util to set thread name
[lttng-tools.git]
/
src
/
common
/
runas.c
diff --git
a/src/common/runas.c
b/src/common/runas.c
index e30871c5c8fc4f8b4fb30d42c64fdd60292b3034..b1a4b4836a63324b246940fb02f2727a1be90c05 100644
(file)
--- a/
src/common/runas.c
+++ b/
src/common/runas.c
@@
-27,10
+27,10
@@
#include <common/common.h>
#include <common/utils.h>
#include <common/compat/getenv.h>
#include <common/common.h>
#include <common/utils.h>
#include <common/compat/getenv.h>
-#include <common/compat/prctl.h>
#include <common/unix.h>
#include <common/defaults.h>
#include <common/lttng-elf.h>
#include <common/unix.h>
#include <common/defaults.h>
#include <common/lttng-elf.h>
+#include <common/thread.h>
#include <lttng/constant.h>
#include <lttng/constant.h>
@@
-695,9
+695,9
@@
int do_recv_fds(int sock, int *fds, unsigned int fd_count)
ERR("Invalid file descriptor received from worker (fd = %i)", fds[i]);
/* Return 0 as this is not a fatal error. */
}
ERR("Invalid file descriptor received from worker (fd = %i)", fds[i]);
/* Return 0 as this is not a fatal error. */
}
-
}
+ }
end:
end:
-
return ret;
+ return ret;
}
static
}
static
@@
-718,9
+718,9
@@
int send_fds_to_worker(const struct run_as_worker *worker,
ret = -1;
goto end;
}
ret = -1;
goto end;
}
-
}
+ }
-
ret = do_send_fds(worker->sockpair[0], COMMAND_IN_FDS(data),
+ ret = do_send_fds(worker->sockpair[0], COMMAND_IN_FDS(data),
COMMAND_IN_FD_COUNT(data));
if (ret < 0) {
PERROR("Failed to send file descriptor to run-as worker");
COMMAND_IN_FD_COUNT(data));
if (ret < 0) {
PERROR("Failed to send file descriptor to run-as worker");
@@
-830,10
+830,10
@@
static
int handle_one_cmd(struct run_as_worker *worker)
{
int ret = 0;
int handle_one_cmd(struct run_as_worker *worker)
{
int ret = 0;
-
struct run_as_data data = {};
-
ssize_t readlen, writelen;
-
struct run_as_ret sendret = {};
-
run_as_fct cmd;
+ struct run_as_data data = {};
+ ssize_t readlen, writelen;
+ struct run_as_ret sendret = {};
+ run_as_fct cmd;
uid_t prev_euid;
/*
uid_t prev_euid;
/*
@@
-958,11
+958,10
@@
int run_as_worker(struct run_as_worker *worker)
memset(worker->procname, 0, proc_orig_len);
strncpy(worker->procname, DEFAULT_RUN_AS_WORKER_NAME, proc_orig_len);
memset(worker->procname, 0, proc_orig_len);
strncpy(worker->procname, DEFAULT_RUN_AS_WORKER_NAME, proc_orig_len);
- ret = lttng_prctl(PR_SET_NAME,
- (unsigned long) DEFAULT_RUN_AS_WORKER_NAME, 0, 0, 0);
+ ret = lttng_thread_setname(DEFAULT_RUN_AS_WORKER_NAME);
if (ret && ret != -ENOSYS) {
/* Don't fail as this is not essential. */
if (ret && ret != -ENOSYS) {
/* Don't fail as this is not essential. */
-
PERROR("prctl PR_SET_NAME
");
+
DBG("Failed to set pthread name attribute
");
}
memset(&sendret, 0, sizeof(sendret));
}
memset(&sendret, 0, sizeof(sendret));
@@
-1258,7
+1257,7
@@
int run_as_create_worker_no_lock(const char *procname,
ret = -1;
}
worker->sockpair[1] = -1;
ret = -1;
}
worker->sockpair[1] = -1;
- free(worker->procname);
+ free(worker->procname);
free(worker);
LOG(ret ? PRINT_ERR : PRINT_DBG, "run_as worker exiting (ret = %d)", ret);
exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
free(worker);
LOG(ret ? PRINT_ERR : PRINT_DBG, "run_as worker exiting (ret = %d)", ret);
exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
@@
-1337,7
+1336,7
@@
void run_as_destroy_worker_no_lock(void)
if (WIFEXITED(status)) {
LOG(WEXITSTATUS(status) == 0 ? PRINT_DBG : PRINT_ERR,
DEFAULT_RUN_AS_WORKER_NAME " terminated with status code %d",
if (WIFEXITED(status)) {
LOG(WEXITSTATUS(status) == 0 ? PRINT_DBG : PRINT_ERR,
DEFAULT_RUN_AS_WORKER_NAME " terminated with status code %d",
- WEXITSTATUS(status));
+ WEXITSTATUS(status));
break;
} else if (WIFSIGNALED(status)) {
ERR(DEFAULT_RUN_AS_WORKER_NAME " was killed by signal %d",
break;
} else if (WIFSIGNALED(status)) {
ERR(DEFAULT_RUN_AS_WORKER_NAME " was killed by signal %d",
@@
-1479,7
+1478,7
@@
error:
LTTNG_HIDDEN
int run_as_open(const char *path, int flags, mode_t mode, uid_t uid,
LTTNG_HIDDEN
int run_as_open(const char *path, int flags, mode_t mode, uid_t uid,
-
gid_t gid)
+ gid_t gid)
{
return run_as_openat(AT_FDCWD, path, flags, mode, uid, gid);
}
{
return run_as_openat(AT_FDCWD, path, flags, mode, uid, gid);
}
@@
-1489,8
+1488,8
@@
int run_as_openat(int dirfd, const char *path, int flags, mode_t mode,
uid_t uid, gid_t gid)
{
int ret;
uid_t uid, gid_t gid)
{
int ret;
-
struct run_as_data data = {};
-
struct run_as_ret run_as_ret = {};
+ struct run_as_data data = {};
+ struct run_as_ret run_as_ret = {};
DBG3("openat() fd = %d%s, path = %s, flags = %X, mode = %d, uid %d, gid %d",
dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
DBG3("openat() fd = %d%s, path = %s, flags = %X, mode = %d, uid %d, gid %d",
dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
@@
-1650,7
+1649,7
@@
int run_as_extract_elf_symbol_offset(int fd, const char* function,
{
int ret;
struct run_as_data data = {};
{
int ret;
struct run_as_data data = {};
-
struct run_as_ret run_as_ret = {};
+ struct run_as_ret run_as_ret = {};
DBG3("extract_elf_symbol_offset() on fd=%d and function=%s "
"with for uid %d and gid %d", fd, function,
DBG3("extract_elf_symbol_offset() on fd=%d and function=%s "
"with for uid %d and gid %d", fd, function,
This page took
0.026375 seconds
and
4
git commands to generate.