diff --git a/src/basic/chattr-util.c b/src/basic/chattr-util.c index 13d46f26aa..9677e9a35a 100644 --- a/src/basic/chattr-util.c +++ b/src/basic/chattr-util.c @@ -6,6 +6,7 @@ #include #include +#include "bitfield.h" #include "chattr-util.h" #include "errno-util.h" #include "fd-util.h" @@ -93,11 +94,9 @@ int chattr_full( * supported, and we can ignore it too */ unsigned current_attr = old_attr; - for (unsigned i = 0; i < sizeof(unsigned) * 8; i++) { - unsigned new_one, mask_one = 1u << i; - if (!FLAGS_SET(mask, mask_one)) - continue; + BIT_FOREACH(i, mask) { + unsigned new_one, mask_one = 1u << i; new_one = UPDATE_FLAG(current_attr, mask_one, FLAGS_SET(value, mask_one)); if (new_one == current_attr) @@ -138,6 +137,7 @@ int read_attr_fd(int fd, unsigned *ret) { struct stat st; assert(fd >= 0); + assert(ret); if (fstat(fd, &st) < 0) return -errno; @@ -156,7 +156,7 @@ int read_attr_at(int dir_fd, const char *path, unsigned *ret) { assert(ret); if (isempty(path)) { - fd = fd_reopen_condition(dir_fd, O_RDONLY|O_CLOEXEC, O_PATH, &fd_close); /* drop O_PATH if it is set */ + fd = fd_reopen_condition(dir_fd, O_RDONLY|O_CLOEXEC|O_NOCTTY, O_PATH, &fd_close); /* drop O_PATH if it is set */ if (fd < 0) return fd; } else { diff --git a/src/core/manager.c b/src/core/manager.c index 85ab09be2a..2dddc79722 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -101,8 +101,8 @@ #include "virt.h" #include "watchdog.h" -#define NOTIFY_RCVBUF_SIZE (8*1024*1024) -#define CGROUPS_AGENT_RCVBUF_SIZE (8*1024*1024) +/* Make sure clients notifying us don't block */ +#define MANAGER_SOCKET_RCVBUF_SIZE (8*U64_MB) /* Initial delay and the interval for printing status messages about running jobs */ #define JOBS_IN_PROGRESS_WAIT_USEC (2*USEC_PER_SEC) @@ -1081,7 +1081,7 @@ static int manager_setup_notify(Manager *m) { if (fd < 0) return log_error_errno(errno, "Failed to allocate notification socket: %m"); - (void) fd_increase_rxbuf(fd, NOTIFY_RCVBUF_SIZE); + (void) fd_increase_rxbuf(fd, MANAGER_SOCKET_RCVBUF_SIZE); m->notify_socket = path_join(m->prefix[EXEC_DIRECTORY_RUNTIME], "systemd/notify"); if (!m->notify_socket) @@ -1174,7 +1174,7 @@ static int manager_setup_cgroups_agent(Manager *m) { if (fd < 0) return log_error_errno(errno, "Failed to allocate cgroups agent socket: %m"); - fd_increase_rxbuf(fd, CGROUPS_AGENT_RCVBUF_SIZE); + (void) fd_increase_rxbuf(fd, MANAGER_SOCKET_RCVBUF_SIZE); (void) sockaddr_un_unlink(&sa.un); @@ -1238,7 +1238,7 @@ static int manager_setup_user_lookup_fd(Manager *m) { if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, m->user_lookup_fds) < 0) return log_error_errno(errno, "Failed to allocate user lookup socket: %m"); - (void) fd_increase_rxbuf(m->user_lookup_fds[0], NOTIFY_RCVBUF_SIZE); + (void) fd_increase_rxbuf(m->user_lookup_fds[0], MANAGER_SOCKET_RCVBUF_SIZE); } if (!m->user_lookup_event_source) { @@ -1274,7 +1274,7 @@ static int manager_setup_handoff_timestamp_fd(Manager *m) { return log_error_errno(errno, "Failed to allocate handoff timestamp socket: %m"); /* Make sure children never have to block */ - (void) fd_increase_rxbuf(m->handoff_timestamp_fds[0], NOTIFY_RCVBUF_SIZE); + (void) fd_increase_rxbuf(m->handoff_timestamp_fds[0], MANAGER_SOCKET_RCVBUF_SIZE); r = setsockopt_int(m->handoff_timestamp_fds[0], SOL_SOCKET, SO_PASSCRED, true); if (r < 0) @@ -3707,21 +3707,14 @@ int manager_reload(Manager *m) { manager_clear_jobs_and_units(m); lookup_paths_flush_generator(&m->lookup_paths); - lookup_paths_done(&m->lookup_paths); exec_shared_runtime_vacuum(m); dynamic_user_vacuum(m, false); m->uid_refs = hashmap_free(m->uid_refs); m->gid_refs = hashmap_free(m->gid_refs); - r = lookup_paths_init_or_warn(&m->lookup_paths, m->runtime_scope, 0, NULL); - if (r < 0) - return r; - (void) manager_run_environment_generators(m); (void) manager_run_generators(m); - lookup_paths_log(&m->lookup_paths); - /* We flushed out generated files, for which we don't watch mtime, so we should flush the old map. */ manager_free_unit_name_maps(m); m->unit_file_state_outdated = false; diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 885c1b1dc2..481a41208e 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -247,7 +247,7 @@ static int varlink_connect_auto(sd_varlink **ret, const char *where) { if (arg_timeout != 0) { r = sd_varlink_set_relative_timeout(vl, arg_timeout); if (r < 0) - log_error_errno(r, "Failed to set Varlink timeout: %m"); + log_warning_errno(r, "Failed to set Varlink timeout, ignoring: %m"); } *ret = TAKE_PTR(vl);