X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Frunas.c;h=28bcff30a5c550ba7800f2b74aa249362d0c24ec;hp=71d4016c8ae24d912ad8ac41b877a78afa52173a;hb=55cb0d6f5c8f1b793b0ed66cb4aaa7d18c612c36;hpb=cbf53d23cecaca9c6ec71582663c4a8254a9f285 diff --git a/src/common/runas.c b/src/common/runas.c index 71d4016c8..28bcff30a 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -1,20 +1,10 @@ /* - * Copyright (C) 2011 - David Goulet - * Mathieu Desnoyers - * 2019 - Jérémie Galarneau + * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 Mathieu Desnoyers + * Copyright (C) 2019 Jérémie Galarneau * - * 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. + * SPDX-License-Identifier: GPL-2.0-only * - * 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. */ #define _LGPL_SOURCE @@ -677,9 +667,9 @@ int do_send_fds(int sock, const int *fds, unsigned int fd_count) /* Return 0 as this is not a fatal error. */ return 0; } - } + } - len = lttcomm_send_fds_unix_sock(sock, fds, fd_count); + len = lttcomm_send_fds_unix_sock(sock, fds, fd_count); return len < 0 ? -1 : 0; } @@ -705,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. */ } - } + } end: - return ret; + return ret; } static @@ -728,9 +718,9 @@ int send_fds_to_worker(const struct run_as_worker *worker, 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"); @@ -840,10 +830,10 @@ static 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; /* @@ -1268,7 +1258,7 @@ int run_as_create_worker_no_lock(const char *procname, 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); @@ -1347,7 +1337,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", - WEXITSTATUS(status)); + WEXITSTATUS(status)); break; } else if (WIFSIGNALED(status)) { ERR(DEFAULT_RUN_AS_WORKER_NAME " was killed by signal %d", @@ -1489,7 +1479,7 @@ error: 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); } @@ -1499,8 +1489,8 @@ int run_as_openat(int dirfd, const char *path, int flags, mode_t mode, 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)" : "", @@ -1660,7 +1650,7 @@ int run_as_extract_elf_symbol_offset(int fd, const char* function, { 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,