diff options
Diffstat (limited to 'src')
56 files changed, 278 insertions, 107 deletions
diff --git a/src/basic/blkid-util.h b/src/basic/blkid-util.h index 7aa75eb091..1b9cace040 100644 --- a/src/basic/blkid-util.h +++ b/src/basic/blkid-util.h @@ -20,7 +20,7 @@ ***/ #ifdef HAVE_BLKID -#include <blkid/blkid.h> +#include <blkid.h> #endif #include "util.h" diff --git a/src/basic/def.h b/src/basic/def.h index 200ea973c1..b1a3bc190b 100644 --- a/src/basic/def.h +++ b/src/basic/def.h @@ -67,10 +67,6 @@ .un.sun_path = "\0/org/freedesktop/plymouthd", \ } -#ifndef TTY_GID -#define TTY_GID 5 -#endif - #define NOTIFY_FD_MAX 768 #define NOTIFY_BUFFER_MAX PIPE_BUF diff --git a/src/basic/log.c b/src/basic/log.c index 36efc9ac7d..0d0ced00bd 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -553,7 +553,7 @@ static int write_to_journal( return 1; } -static int log_dispatch( +int log_dispatch_internal( int level, int error, const char *file, @@ -653,7 +653,7 @@ int log_dump_internal( if (_likely_(LOG_PRI(level) > log_max_level)) return -error; - return log_dispatch(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer); + return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer); } int log_internalv( @@ -680,7 +680,7 @@ int log_internalv( vsnprintf(buffer, sizeof(buffer), format, ap); - return log_dispatch(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer); + return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer); } int log_internal( @@ -744,7 +744,8 @@ int log_object_internalv( vsnprintf(b, l, format, ap); - return log_dispatch(level, error, file, line, func, object_field, object, extra_field, extra, buffer); + return log_dispatch_internal(level, error, file, line, func, + object_field, object, extra_field, extra, buffer); } int log_object_internal( @@ -788,7 +789,7 @@ static void log_assert( log_abort_msg = buffer; - log_dispatch(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer); + log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer); } noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) { @@ -943,7 +944,7 @@ int log_struct_internal( if (!found) return -error; - return log_dispatch(level, error, file, line, func, NULL, NULL, NULL, NULL, buf + 8); + return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buf + 8); } int log_set_target_from_string(const char *e) { diff --git a/src/basic/log.h b/src/basic/log.h index 72714e02e5..b3e4060b5d 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -75,6 +75,18 @@ void log_close_console(void); void log_parse_environment(void); +int log_dispatch_internal( + int level, + int error, + const char *file, + int line, + const char *func, + const char *object_field, + const char *object, + const char *extra, + const char *extra_field, + char *buffer); + int log_internal( int level, int error, @@ -115,7 +127,7 @@ int log_object_internalv( const char *extra_field, const char *extra, const char *format, - va_list ap) _printf_(9,0); + va_list ap) _printf_(10,0); int log_struct_internal( int level, @@ -137,7 +149,7 @@ int log_format_iovec( bool newline_separator, int error, const char *format, - va_list ap); + va_list ap) _printf_(6, 0); /* This modifies the buffer passed! */ int log_dump_internal( @@ -167,6 +179,9 @@ void log_assert_failed_return( int line, const char *func); +#define log_dispatch(level, error, buffer) \ + log_dispatch_internal(level, error, __FILE__, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer) + /* Logging with level */ #define log_full_errno(level, error, ...) \ ({ \ diff --git a/src/basic/missing.h b/src/basic/missing.h index 284cbaffc0..e860fa7c2c 100644 --- a/src/basic/missing.h +++ b/src/basic/missing.h @@ -68,8 +68,6 @@ struct sockaddr_vm { }; #endif /* !HAVE_LINUX_VM_SOCKETS_H */ -#include "macro.h" - #ifndef RLIMIT_RTTIME #define RLIMIT_RTTIME 15 #endif diff --git a/src/basic/random-util.c b/src/basic/random-util.c index ad7b3eedf2..b216be579d 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -27,7 +27,13 @@ #include <stdint.h> #ifdef HAVE_SYS_AUXV_H -#include <sys/auxv.h> +# include <sys/auxv.h> +#endif + +#ifdef USE_SYS_RANDOM_H +# include <sys/random.h> +#else +# include <linux/random.h> #endif #include "fd-util.h" diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 155bf278b2..3358dc32a5 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -19,7 +19,7 @@ ***/ #include <assert.h> -#include <blkid/blkid.h> +#include <blkid.h> #include <ctype.h> #include <dirent.h> #include <errno.h> diff --git a/src/core/execute.c b/src/core/execute.c index d7798387c5..2056e2273c 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -2887,9 +2887,9 @@ static int exec_child( if (line) { log_open(); log_struct(LOG_DEBUG, - LOG_UNIT_ID(unit), "EXECUTABLE=%s", command->path, LOG_UNIT_MESSAGE(unit, "Executing: %s", line), + LOG_UNIT_ID(unit), NULL); log_close(); } @@ -2953,9 +2953,9 @@ int exec_spawn(Unit *unit, return log_oom(); log_struct(LOG_DEBUG, - LOG_UNIT_ID(unit), LOG_UNIT_MESSAGE(unit, "About to execute: %s", line), "EXECUTABLE=%s", command->path, + LOG_UNIT_ID(unit), NULL); pid = fork(); if (pid < 0) @@ -2989,6 +2989,14 @@ int exec_spawn(Unit *unit, error_message), "EXECUTABLE=%s", command->path, NULL); + else if (r == -ENOENT && command->ignore) + log_struct_errno(LOG_INFO, r, + "MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR, + LOG_UNIT_ID(unit), + LOG_UNIT_MESSAGE(unit, "Skipped spawning %s: %m", + command->path), + "EXECUTABLE=%s", command->path, + NULL); else log_struct_errno(LOG_ERR, r, "MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR, diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c index 94ae429f46..7b5c98a57c 100644 --- a/src/core/ima-setup.c +++ b/src/core/ima-setup.c @@ -49,6 +49,11 @@ int ima_setup(void) { return 0; } + if (access(IMA_POLICY_PATH, F_OK) < 0) { + log_debug("No IMA custom policy file "IMA_POLICY_PATH", ignoring."); + return 0; + } + imafd = open(IMA_SECFS_POLICY, O_WRONLY|O_CLOEXEC); if (imafd < 0) { log_error_errno(errno, "Failed to open the IMA kernel interface "IMA_SECFS_POLICY", ignoring: %m"); @@ -62,8 +67,7 @@ int ima_setup(void) { /* fall back to copying the policy line-by-line */ input = fopen(IMA_POLICY_PATH, "re"); if (!input) { - log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, errno, - "Failed to open the IMA custom policy file "IMA_POLICY_PATH", ignoring: %m"); + log_warning_errno(errno, "Failed to open the IMA custom policy file "IMA_POLICY_PATH", ignoring: %m"); return 0; } diff --git a/src/core/job.c b/src/core/job.c index e2349830a8..a02f1bb2bc 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -800,18 +800,18 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) { default: log_struct(job_result_log_level[result], - LOG_UNIT_ID(u), LOG_MESSAGE("%s", buf), "RESULT=%s", job_result_to_string(result), + LOG_UNIT_ID(u), NULL); return; } log_struct(job_result_log_level[result], - mid, - LOG_UNIT_ID(u), LOG_MESSAGE("%s", buf), "RESULT=%s", job_result_to_string(result), + LOG_UNIT_ID(u), + mid, NULL); } diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 5b7471c0d0..8cd79c3c9d 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3907,6 +3907,7 @@ int config_parse_bind_paths( void *userdata) { ExecContext *c = data; + Unit *u = userdata; const char *p; int r; @@ -3926,6 +3927,7 @@ int config_parse_bind_paths( p = rvalue; for (;;) { _cleanup_free_ char *source = NULL, *destination = NULL; + _cleanup_free_ char *sresolved = NULL, *dresolved = NULL; char *s = NULL, *d = NULL; bool rbind = true, ignore_enoent = false; @@ -3939,7 +3941,14 @@ int config_parse_bind_paths( return 0; } - s = source; + r = unit_full_printf(u, source, &sresolved); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to resolved specifiers in \"%s\", ignoring: %m", source); + return 0; + } + + s = sresolved; if (s[0] == '-') { ignore_enoent = true; s++; @@ -3970,16 +3979,23 @@ int config_parse_bind_paths( return 0; } - if (!utf8_is_valid(destination)) { - log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, destination); + r = unit_full_printf(u, destination, &dresolved); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to resolved specifiers in \"%s\", ignoring: %m", destination); + return 0; + } + + if (!utf8_is_valid(dresolved)) { + log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, dresolved); return 0; } - if (!path_is_absolute(destination)) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Not an absolute destination path, ignoring: %s", destination); + if (!path_is_absolute(dresolved)) { + log_syntax(unit, LOG_ERR, filename, line, 0, "Not an absolute destination path, ignoring: %s", dresolved); return 0; } - d = path_kill_slashes(destination); + d = path_kill_slashes(dresolved); /* Optionally, there's also a short option string specified */ if (p && p[-1] == ':') { diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index 2b96a9551b..0f8a2d68e2 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -135,7 +135,12 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) { fmt2 = strjoina("selinux: ", fmt); va_start(ap, fmt); - log_internalv(LOG_AUTH | callback_type_to_priority(type), 0, __FILE__, __LINE__, __FUNCTION__, fmt2, ap); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + log_internalv(LOG_AUTH | callback_type_to_priority(type), + 0, __FILE__, __LINE__, __FUNCTION__, + fmt2, ap); +#pragma GCC diagnostic pop va_end(ap); return 0; diff --git a/src/core/service.c b/src/core/service.c index 5e681fb715..a63c6d8bc3 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2859,7 +2859,6 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { log_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : (code == CLD_EXITED ? LOG_NOTICE : LOG_WARNING), - LOG_UNIT_ID(u), LOG_UNIT_MESSAGE(u, "Main process exited, code=%s, status=%i/%s", sigchld_code_to_string(code), status, strna(code == CLD_EXITED @@ -2867,6 +2866,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { : signal_to_string(status))), "EXIT_CODE=%s", sigchld_code_to_string(code), "EXIT_STATUS=%i", status, + LOG_UNIT_ID(u), NULL); if (s->result == SERVICE_SUCCESS) diff --git a/src/core/target.c b/src/core/target.c index ff0d764fb5..2a58dd394d 100644 --- a/src/core/target.c +++ b/src/core/target.c @@ -63,6 +63,9 @@ static int target_add_default_dependencies(Target *t) { assert(t); + if (!UNIT(t)->default_dependencies) + return 0; + /* Imply ordering for requirement dependencies on target * units. Note that when the user created a contradicting * ordering manually we won't add anything in here to make @@ -93,7 +96,7 @@ static int target_load(Unit *u) { return r; /* This is a new unit? Then let's add in some extras */ - if (u->load_state == UNIT_LOADED && u->default_dependencies) { + if (u->load_state == UNIT_LOADED) { r = target_add_default_dependencies(t); if (r < 0) return r; diff --git a/src/core/unit.c b/src/core/unit.c index f76b6c30a8..25ea5a8591 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1497,9 +1497,9 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) { * possible, which means we should avoid the low-level unit * name. */ log_struct(LOG_INFO, - mid, - LOG_UNIT_ID(u), LOG_MESSAGE("%s", buf), + LOG_UNIT_ID(u), + mid, NULL); } diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 5828e949e3..a2c62e55a5 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -144,10 +144,10 @@ static int parse_config(void) { }; return config_parse_many_nulstr(PKGSYSCONFDIR "/coredump.conf", - CONF_PATHS_NULSTR("systemd/coredump.conf.d"), - "Coredump\0", - config_item_table_lookup, items, - false, NULL); + CONF_PATHS_NULSTR("systemd/coredump.conf.d"), + "Coredump\0", + config_item_table_lookup, items, + false, NULL); } static inline uint64_t storage_size_max(void) { @@ -800,12 +800,11 @@ log: if (journald_crash) { /* We cannot log to the journal, so just print the MESSAGE. * The target was set previously to something safe. */ - log_struct(LOG_ERR, core_message, NULL); + log_dispatch(LOG_ERR, 0, core_message); return 0; } - if (core_message) - IOVEC_SET_STRING(iovec[n_iovec++], core_message); + IOVEC_SET_STRING(iovec[n_iovec++], core_message); if (truncated) IOVEC_SET_STRING(iovec[n_iovec++], "COREDUMP_TRUNCATED=1"); diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 2677a3fb32..50d350fce8 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -358,7 +358,7 @@ static int add_mount( "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n", source); - if (!noauto && !nofail && !automount) + if (!nofail && !automount) fprintf(f, "Before=%s\n", post); if (!automount && opts) { diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 80f676e477..3578e2513c 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -17,7 +17,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <blkid/blkid.h> +#include <blkid.h> #include <stdlib.h> #include <sys/statfs.h> #include <unistd.h> diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 202a5a3f97..36c1a32dcd 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -529,7 +529,7 @@ static int process_http_upload( log_warning("Failed to process data for connection %p", connection); if (r == -E2BIG) return mhd_respondf(connection, - r, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, + r, MHD_HTTP_PAYLOAD_TOO_LARGE, "Entry is too large, maximum is " STRINGIFY(DATA_SIZE_MAX) " bytes."); else return mhd_respondf(connection, @@ -1200,9 +1200,9 @@ static int parse_config(void) { {}}; return config_parse_many_nulstr(PKGSYSCONFDIR "/journal-remote.conf", - CONF_PATHS_NULSTR("systemd/journal-remote.conf.d"), - "Remote\0", config_item_table_lookup, items, - false, NULL); + CONF_PATHS_NULSTR("systemd/journal-remote.conf.d"), + "Remote\0", config_item_table_lookup, items, + false, NULL); } static void help(void) { diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 371b6acc64..e0858dda7b 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -541,9 +541,9 @@ static int parse_config(void) { {}}; return config_parse_many_nulstr(PKGSYSCONFDIR "/journal-upload.conf", - CONF_PATHS_NULSTR("systemd/journal-upload.conf.d"), - "Upload\0", config_item_table_lookup, items, - false, NULL); + CONF_PATHS_NULSTR("systemd/journal-upload.conf.d"), + "Upload\0", config_item_table_lookup, items, + false, NULL); } static void help(void) { diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c index cae10203c6..f5d2d7967a 100644 --- a/src/journal-remote/microhttpd-util.c +++ b/src/journal-remote/microhttpd-util.c @@ -103,7 +103,10 @@ int mhd_respondf(struct MHD_Connection *connection, errno = -error; fmt = strjoina(format, "\n"); va_start(ap, format); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" r = vasprintf(&m, fmt, ap); +#pragma GCC diagnostic pop va_end(ap); if (r < 0) diff --git a/src/journal-remote/microhttpd-util.h b/src/journal-remote/microhttpd-util.h index 49def4f630..7f88c2cb7d 100644 --- a/src/journal-remote/microhttpd-util.h +++ b/src/journal-remote/microhttpd-util.h @@ -31,14 +31,21 @@ # define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE #endif +/* Renamed in µhttpd 0.9.51 */ +#ifndef MHD_USE_PIPE_FOR_SHUTDOWN +# define MHD_USE_ITC MHD_USE_PIPE_FOR_SHUTDOWN +#endif + /* Renamed in µhttpd 0.9.52 */ #ifndef MHD_USE_EPOLL_LINUX_ONLY # define MHD_USE_EPOLL MHD_USE_EPOLL_LINUX_ONLY #endif -/* Renamed in µhttpd 0.9.51 */ -#ifndef MHD_USE_PIPE_FOR_SHUTDOWN -# define MHD_USE_ITC MHD_USE_PIPE_FOR_SHUTDOWN +/* Both the old and new names are defines, check for the new one. */ + +/* Renamed in µhttpd 0.9.53 */ +#ifndef MHD_HTTP_PAYLOAD_TOO_LARGE +# define MHD_HTTP_PAYLOAD_TOO_LARGE MHD_HTTP_REQUEST_ENTITY_TOO_LARGE #endif #if MHD_VERSION < 0x00094203 diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 6466e46ccc..667dfa00ff 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1637,10 +1637,10 @@ static int server_parse_config_file(Server *s) { assert(s); return config_parse_many_nulstr(PKGSYSCONFDIR "/journald.conf", - CONF_PATHS_NULSTR("systemd/journald.conf.d"), - "Journal\0", - config_item_perf_lookup, journald_gperf_lookup, - false, s); + CONF_PATHS_NULSTR("systemd/journald.conf.d"), + "Journal\0", + config_item_perf_lookup, journald_gperf_lookup, + false, s); } static int server_dispatch_sync(sd_event_source *es, usec_t t, void *userdata) { diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 71967a0f33..86afb4985d 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2424,6 +2424,7 @@ _public_ int sd_journal_process(sd_journal *j) { assert_return(!journal_pid_changed(j), -ECHILD); j->last_process_usec = now(CLOCK_MONOTONIC); + j->last_invalidate_counter = j->current_invalidate_counter; for (;;) { union inotify_event_buffer buffer; diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index 6f6d71435d..4fb93ded73 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -30,6 +30,8 @@ typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, typedef int (decompress_t)(const void *src, uint64_t src_size, void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max); +#if defined(HAVE_XZ) || defined(HAVE_LZ4) + static usec_t arg_duration = 2 * USEC_PER_SEC; static size_t arg_start; @@ -151,8 +153,10 @@ static void test_compress_decompress(const char* label, const char* type, 100 - compressed * 100. / total, skipped); } +#endif int main(int argc, char *argv[]) { +#if defined(HAVE_XZ) || defined(HAVE_LZ4) const char *i; log_set_max_level(LOG_INFO); @@ -177,4 +181,7 @@ int main(int argc, char *argv[]) { #endif } return 0; +#else + return EXIT_TEST_SKIP; +#endif } diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index 44a2cf5217..92108a84b3 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -54,6 +54,7 @@ typedef int (decompress_sw_t)(const void *src, uint64_t src_size, typedef int (compress_stream_t)(int fdf, int fdt, uint64_t max_bytes); typedef int (decompress_stream_t)(int fdf, int fdt, uint64_t max_size); +#if defined(HAVE_XZ) || defined(HAVE_LZ4) static void test_compress_decompress(int compression, compress_blob_t compress, decompress_blob_t decompress, @@ -203,6 +204,7 @@ static void test_compress_stream(int compression, assert_se(unlink(pattern) == 0); assert_se(unlink(pattern2) == 0); } +#endif #ifdef HAVE_LZ4 static void test_lz4_decompress_partial(void) { @@ -247,6 +249,7 @@ static void test_lz4_decompress_partial(void) { #endif int main(int argc, char *argv[]) { +#if defined(HAVE_XZ) || defined(HAVE_LZ4) const char text[] = "text\0foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF" "foofoofoofoo AAAA aaaaaaaaa ghost busters barbarbar FFF"; @@ -312,4 +315,7 @@ int main(int argc, char *argv[]) { #endif return 0; +#else + return EXIT_TEST_SKIP; +#endif } diff --git a/src/kernel-install/50-depmod.install b/src/kernel-install/50-depmod.install index 68c24bed7a..56925c8a5d 100644 --- a/src/kernel-install/50-depmod.install +++ b/src/kernel-install/50-depmod.install @@ -2,7 +2,15 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -[[ $1 == "add" ]] || exit 0 [[ $2 ]] || exit 1 -exec depmod -a "$2" +case "$1" in + add) + exec depmod -a "$2" + ;; + remove) + exec rm -f /lib/modules/"$2"/modules.{alias{,.bin},builtin.bin,dep{,.bin},devname,softdep,symbols{,.bin}} + ;; + *) + exit 0 +esac diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c index 4beb61f05a..06c6167511 100644 --- a/src/libsystemd/sd-bus/test-bus-track.c +++ b/src/libsystemd/sd-bus/test-bus-track.c @@ -17,7 +17,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <sd-bus.h> +#include "sd-bus.h" #include "macro.h" diff --git a/src/locale/localed.c b/src/locale/localed.c index 1cb049e74a..b4798d674c 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -436,7 +436,10 @@ static void log_xkb(struct xkb_context *ctx, enum xkb_log_level lvl, const char const char *fmt; fmt = strjoina("libxkbcommon: ", format); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" log_internalv(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, fmt, args); +#pragma GCC diagnostic pop } #define LOAD_SYMBOL(symbol, dl, name) \ diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 7dea5c0859..68cac4cb08 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -929,7 +929,7 @@ static int show_session(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_free_ char *path = NULL; - r = get_session_path(bus, argv[1], &error, &path); + r = get_session_path(bus, argv[i], &error, &path); if (r < 0) { log_error("Failed to get session path: %s", bus_error_message(&error, r)); return r; diff --git a/src/login/logind.c b/src/login/logind.c index 19bae294a4..1e2acc838b 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -1004,10 +1004,10 @@ static int manager_parse_config_file(Manager *m) { assert(m); return config_parse_many_nulstr(PKGSYSCONFDIR "/logind.conf", - CONF_PATHS_NULSTR("systemd/logind.conf.d"), - "Login\0", - config_item_perf_lookup, logind_gperf_lookup, - false, m); + CONF_PATHS_NULSTR("systemd/logind.conf.d"), + "Login\0", + config_item_perf_lookup, logind_gperf_lookup, + false, m); } static int manager_dispatch_reload_signal(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) { diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf index 925af1c579..077fbc1d5c 100644 --- a/src/network/netdev/netdev-gperf.gperf +++ b/src/network/netdev/netdev-gperf.gperf @@ -36,6 +36,7 @@ NetDev.Kind, config_parse_netdev_kind, 0, NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu) NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac) VLAN.Id, config_parse_vlanid, 0, offsetof(VLan, id) +VLAN.GVRP, config_parse_tristate, 0, offsetof(VLan, gvrp) MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode) MACVTAP.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode) IPVLAN.Mode, config_parse_ipvlan_mode, 0, offsetof(IPVlan, mode) diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c index 28c061fa4f..718b627b2b 100644 --- a/src/network/netdev/vlan.c +++ b/src/network/netdev/vlan.c @@ -17,12 +17,14 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ +#include <linux/if_vlan.h> #include <net/if.h> #include "netdev/vlan.h" #include "vlan-util.h" static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { + struct ifla_vlan_flags flags = {}; VLan *v; int r; @@ -38,6 +40,19 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_ID attribute: %m"); + if (v->gvrp != -1) { + flags.mask |= VLAN_FLAG_GVRP; + + if (v->gvrp) + flags.flags |= VLAN_FLAG_GVRP; + else + flags.flags &= ~VLAN_FLAG_GVRP; + } + + r = sd_netlink_message_append_data(req, IFLA_VLAN_FLAGS, &flags, sizeof(struct ifla_vlan_flags)); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_FLAGS attribute: %m"); + return 0; } @@ -66,6 +81,7 @@ static void vlan_init(NetDev *netdev) { assert(v); v->id = VLANID_INVALID; + v->gvrp = -1; } const NetDevVTable vlan_vtable = { diff --git a/src/network/netdev/vlan.h b/src/network/netdev/vlan.h index fade899997..19a62b76c1 100644 --- a/src/network/netdev/vlan.h +++ b/src/network/netdev/vlan.h @@ -27,6 +27,8 @@ struct VLan { NetDev meta; uint16_t id; + + int gvrp; }; DEFINE_NETDEV_CAST(VLAN, VLan); diff --git a/src/network/networkd-conf.c b/src/network/networkd-conf.c index aaa27f311d..e28e018116 100644 --- a/src/network/networkd-conf.c +++ b/src/network/networkd-conf.c @@ -32,10 +32,10 @@ int manager_parse_config_file(Manager *m) { assert(m); return config_parse_many_nulstr(PKGSYSCONFDIR "/networkd.conf", - CONF_PATHS_NULSTR("systemd/networkd.conf.d"), - "DHCP\0", - config_item_perf_lookup, networkd_gperf_lookup, - false, m); + CONF_PATHS_NULSTR("systemd/networkd.conf.d"), + "DHCP\0", + config_item_perf_lookup, networkd_gperf_lookup, + false, m); } static const char* const duid_type_table[_DUID_TYPE_MAX] = { diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 0c1229336b..1797f144b6 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1325,6 +1325,11 @@ static int link_set_bridge(Link *link) { if (r < 0) return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_COST attribute: %m"); } + if (link->network->priority != LINK_BRIDGE_PORT_PRIORITY_INVALID) { + r = sd_netlink_message_append_u16(req, IFLA_BRPORT_PRIORITY, link->network->priority); + if (r < 0) + return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_PRIORITY attribute: %m"); + } r = sd_netlink_message_close_container(req); if (r < 0) diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index e6190fbe57..010b38248a 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -33,6 +33,8 @@ #include "list.h" #include "set.h" +#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128 + typedef enum LinkState { LINK_STATE_PENDING, LINK_STATE_ENSLAVING, diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 68052ba544..abd921ee1a 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -86,6 +86,7 @@ Route.Metric, config_parse_route_priority, Route.Scope, config_parse_route_scope, 0, 0 Route.PreferredSource, config_parse_preferred_src, 0, 0 Route.Table, config_parse_route_table, 0, 0 +Route.GatewayOnlink, config_parse_gateway_onlink, 0, 0 DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier) DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns) DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp) @@ -119,12 +120,13 @@ DHCPServer.EmitTimezone, config_parse_bool, DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone) DHCPServer.PoolOffset, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_offset) DHCPServer.PoolSize, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_size) -Bridge.Cost, config_parse_unsigned, 0, offsetof(Network, cost) +Bridge.Cost, config_parse_uint32, 0, offsetof(Network, cost) Bridge.UseBPDU, config_parse_bool, 0, offsetof(Network, use_bpdu) Bridge.HairPin, config_parse_bool, 0, offsetof(Network, hairpin) Bridge.FastLeave, config_parse_bool, 0, offsetof(Network, fast_leave) Bridge.AllowPortToBeRoot, config_parse_bool, 0, offsetof(Network, allow_port_to_be_root) Bridge.UnicastFlood, config_parse_bool, 0, offsetof(Network, unicast_flood) +Bridge.Priority, config_parse_uint16, 0, offsetof(Network, priority) BridgeFDB.MACAddress, config_parse_fdb_hwaddr, 0, 0 BridgeFDB.VLANId, config_parse_fdb_vlan_id, 0, 0 BridgeVLAN.PVID, config_parse_brvlan_pvid, 0, 0 diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index fac42d8478..dd29b4ca48 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -165,6 +165,7 @@ static int network_load_one(Manager *manager, const char *filename) { network->use_bpdu = true; network->allow_port_to_be_root = true; network->unicast_flood = true; + network->priority = LINK_BRIDGE_PORT_PRIORITY_INVALID; network->lldp_mode = LLDP_MODE_ROUTERS_ONLY; diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 4ce066a764..d6f418d521 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -163,7 +163,8 @@ struct Network { bool fast_leave; bool allow_port_to_be_root; bool unicast_flood; - unsigned cost; + uint32_t cost; + uint16_t priority; bool use_br_vlan; uint16_t pvid; diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 570083f180..e2a5c77ed1 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -939,3 +939,44 @@ int config_parse_route_table(const char *unit, return 0; } + +int config_parse_gateway_onlink(const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + Network *network = userdata; + _cleanup_route_free_ Route *n = NULL; + int r; + + assert(filename); + assert(section); + assert(lvalue); + assert(rvalue); + assert(data); + + r = route_new_static(network, filename, section_line, &n); + if (r < 0) + return r; + + r = parse_boolean(rvalue); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Could not parse gateway onlink \"%s\", ignoring assignment: %m", rvalue); + return 0; + } + + if (r) + n->flags |= RTNH_F_ONLINK; + else + n->flags &= ~RTNH_F_ONLINK; + + n = NULL; + + return 0; +} diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index 4ebfa0f0bd..e2446b3e92 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -75,3 +75,4 @@ int config_parse_destination(const char *unit, const char *filename, unsigned li int config_parse_route_priority(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_route_scope(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_route_table(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); +int config_parse_gateway_onlink(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index bce26a383b..fd00d0957a 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -18,7 +18,7 @@ ***/ #ifdef HAVE_BLKID -#include <blkid/blkid.h> +#include <blkid.h> #endif #include <errno.h> #include <getopt.h> diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index b704ca3b4b..db3bf5bd21 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -28,14 +28,6 @@ #include "string-util.h" #include "util.h" -#ifndef RC_LOCAL_SCRIPT_PATH_START -#define RC_LOCAL_SCRIPT_PATH_START "/etc/rc.d/rc.local" -#endif - -#ifndef RC_LOCAL_SCRIPT_PATH_STOP -#define RC_LOCAL_SCRIPT_PATH_STOP "/sbin/halt.local" -#endif - static const char *arg_dest = "/tmp"; static int add_symlink(const char *service, const char *where) { diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index abf3263178..97334a0af7 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -233,10 +233,10 @@ int manager_parse_config_file(Manager *m) { assert(m); r = config_parse_many_nulstr(PKGSYSCONFDIR "/resolved.conf", - CONF_PATHS_NULSTR("systemd/resolved.conf.d"), - "Resolve\0", - config_item_perf_lookup, resolved_gperf_lookup, - false, m); + CONF_PATHS_NULSTR("systemd/resolved.conf.d"), + "Resolve\0", + config_item_perf_lookup, resolved_gperf_lookup, + false, m); if (r < 0) return r; diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index 5498f7b9cb..63cb6a5bda 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -17,7 +17,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <sd-messages.h> +#include "sd-messages.h" #include "alloc-util.h" #include "resolved-dns-server.h" diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index ff2ad9c1de..3075f62b5e 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -17,7 +17,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <sd-messages.h> +#include "sd-messages.h" #include "af-list.h" #include "alloc-util.h" diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c index 7e9f9e5a20..dda9875063 100644 --- a/src/resolve/resolved-dns-trust-anchor.c +++ b/src/resolve/resolved-dns-trust-anchor.c @@ -17,7 +17,7 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <sd-messages.h> +#include "sd-messages.h" #include "alloc-util.h" #include "conf-files.h" diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index 8765cf2f49..436130edea 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -24,8 +24,6 @@ #include <stdlib.h> #include <string.h> -#include <systemd/sd-bus.h> - #include "alloc-util.h" #include "bus-error.h" #include "bus-util.h" diff --git a/src/shared/cgroup-show.h b/src/shared/cgroup-show.h index 736f0f34c8..1764f76744 100644 --- a/src/shared/cgroup-show.h +++ b/src/shared/cgroup-show.h @@ -22,7 +22,7 @@ #include <stdbool.h> #include <sys/types.h> -#include <systemd/sd-bus.h> +#include "sd-bus.h" #include "logs-show.h" #include "output-mode.h" diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 36c94ac71b..163995c1e5 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -42,8 +42,8 @@ #include "udev-util.h" #include "xattr-util.h" +_unused_ static int probe_filesystem(const char *node, char **ret_fstype) { #ifdef HAVE_BLKID -static int probe_filesystem(const char *node, char **ret_fstype) { _cleanup_blkid_free_probe_ blkid_probe b = NULL; const char *fstype; int r; @@ -80,8 +80,10 @@ static int probe_filesystem(const char *node, char **ret_fstype) { not_found: *ret_fstype = NULL; return 0; -} +#else + return -EOPNOTSUPP; #endif +} int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectImageFlags flags, DissectedImage **ret) { @@ -949,7 +951,7 @@ int dissected_image_decrypt( * * = 0 → There was nothing to decrypt * > 0 → Decrypted successfully - * -ENOKEY → There's some to decrypt but no key was supplied + * -ENOKEY → There's something to decrypt but no key was supplied * -EKEYREJECTED → Passed key was not correct */ diff --git a/src/shared/pager.c b/src/shared/pager.c index c1480a718b..2501a53c19 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -53,6 +53,11 @@ noreturn static void pager_fallback(void) { _exit(EXIT_SUCCESS); } +static int stored_stdout = -1; +static int stored_stderr = -1; +static bool stdout_redirected = false; +static bool stderr_redirected = false; + int pager_open(bool no_pager, bool jump_to_end) { _cleanup_close_pair_ int fd[2] = { -1, -1 }; const char *pager; @@ -147,10 +152,19 @@ int pager_open(bool no_pager, bool jump_to_end) { } /* Return in the parent */ - if (dup2(fd[1], STDOUT_FILENO) < 0) + stored_stdout = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 3); + if (dup2(fd[1], STDOUT_FILENO) < 0) { + stored_stdout = safe_close(stored_stdout); return log_error_errno(errno, "Failed to duplicate pager pipe: %m"); - if (dup2(fd[1], STDERR_FILENO) < 0) + } + stdout_redirected = true; + + stored_stderr = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 3); + if (dup2(fd[1], STDERR_FILENO) < 0) { + stored_stderr = safe_close(stored_stderr); return log_error_errno(errno, "Failed to duplicate pager pipe: %m"); + } + stderr_redirected = true; return 1; } @@ -161,8 +175,15 @@ void pager_close(void) { return; /* Inform pager that we are done */ - safe_fclose(stdout); - safe_fclose(stderr); + (void) fflush(stdout); + if (stdout_redirected && (stored_stdout < 0 || dup2(stored_stdout, STDOUT_FILENO)) < 0) + (void) close(STDOUT_FILENO); + stored_stdout = safe_close(stored_stdout); + (void) fflush(stderr); + if (stderr_redirected && (stored_stderr < 0 || dup2(stored_stderr, STDERR_FILENO)) < 0) + (void) close(STDERR_FILENO); + stored_stderr = safe_close(stored_stderr); + stdout_redirected = stderr_redirected = false; (void) kill(pager_pid, SIGCONT); (void) wait_for_terminate(pager_pid, NULL); diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index ed31a80c8d..8c1624ff46 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -59,9 +59,9 @@ int parse_sleep_config(const char *verb, char ***_modes, char ***_states) { }; config_parse_many_nulstr(PKGSYSCONFDIR "/sleep.conf", - CONF_PATHS_NULSTR("systemd/sleep.conf.d"), - "Sleep\0", config_item_table_lookup, items, - false, NULL); + CONF_PATHS_NULSTR("systemd/sleep.conf.d"), + "Sleep\0", config_item_table_lookup, items, + false, NULL); if (streq(verb, "suspend")) { /* empty by default */ diff --git a/src/test/test-exec-util.c b/src/test/test-exec-util.c index 482b0751b9..30c92019d9 100644 --- a/src/test/test-exec-util.c +++ b/src/test/test-exec-util.c @@ -223,7 +223,7 @@ static int gather_stdout_three(int fd, void *arg) { return 0; } -const gather_stdout_callback_t const gather_stdout[] = { +const gather_stdout_callback_t gather_stdout[] = { gather_stdout_one, gather_stdout_two, gather_stdout_three, diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c index bf25b112e1..99bdb55e98 100644 --- a/src/timesync/timesyncd-conf.c +++ b/src/timesync/timesyncd-conf.c @@ -99,8 +99,8 @@ int manager_parse_config_file(Manager *m) { assert(m); return config_parse_many_nulstr(PKGSYSCONFDIR "/timesyncd.conf", - CONF_PATHS_NULSTR("systemd/timesyncd.conf.d"), - "Time\0", - config_item_perf_lookup, timesyncd_gperf_lookup, - false, m); + CONF_PATHS_NULSTR("systemd/timesyncd.conf.d"), + "Time\0", + config_item_perf_lookup, timesyncd_gperf_lookup, + false, m); } diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 9037aa1304..6319403620 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <blkid/blkid.h> +#include <blkid.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> |