diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/dbus-cgroup.c | 4 | ||||
-rw-r--r-- | src/core/dbus-manager.c | 7 | ||||
-rw-r--r-- | src/core/execute.c | 12 | ||||
-rw-r--r-- | src/core/load-fragment.c | 8 | ||||
-rw-r--r-- | src/core/main.c | 6 | ||||
-rw-r--r-- | src/core/manager.c | 13 | ||||
-rw-r--r-- | src/core/mount.c | 6 | ||||
-rw-r--r-- | src/core/selinux-access.c | 12 | ||||
-rw-r--r-- | src/core/snapshot.c | 3 | ||||
-rw-r--r-- | src/core/socket.c | 6 |
10 files changed, 34 insertions, 43 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 4a9df06016..9dcc51f240 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -433,9 +433,9 @@ int bus_cgroup_set_property( if (!f) return -ENOMEM; - if (read) { + if (read) { fputs("BlockIOReadBandwidth=\n", f); - LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths) + LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths) if (a->read) fprintf(f, "BlockIOReadBandwidth=%s %" PRIu64 "\n", a->path, a->bandwidth); } else { diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index d8b39bdf5f..5722e3c2bb 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -1069,10 +1069,9 @@ static int method_dump(sd_bus_message *message, void *userdata, sd_bus_error *er manager_dump_units(m, f, NULL); manager_dump_jobs(m, f, NULL); - fflush(f); - - if (ferror(f)) - return -ENOMEM; + r = fflush_and_check(f); + if (r < 0) + return r; return sd_bus_reply_method_return(message, "s", dump); } diff --git a/src/core/execute.c b/src/core/execute.c index 21721dc240..125cb0dbd4 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1719,7 +1719,15 @@ static int exec_child( } #ifdef SMACK_DEFAULT_PROCESS_LABEL else { - r = mac_smack_apply_pid(0, SMACK_DEFAULT_PROCESS_LABEL); + _cleanup_free_ char *exec_label = NULL; + + r = mac_smack_read(command->path, SMACK_ATTR_EXEC, &exec_label); + if (r < 0 && r != -ENODATA && r != -EOPNOTSUPP) { + *exit_status = EXIT_SMACK_PROCESS_LABEL; + return r; + } + + r = mac_smack_apply_pid(0, exec_label ? : SMACK_DEFAULT_PROCESS_LABEL); if (r < 0) { *exit_status = EXIT_SMACK_PROCESS_LABEL; return r; @@ -2203,7 +2211,7 @@ int exec_context_load_environment(Unit *unit, const ExecContext *c, char ***l) { static bool tty_may_match_dev_console(const char *tty) { _cleanup_free_ char *active = NULL; - char *console; + char *console; if (startswith(tty, "/dev/")) tty += 5; diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index a48cb4029a..ba73cc410e 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3508,9 +3508,7 @@ static int load_from_path(Unit *u, const char *path) { r = open_follow(&filename, &f, symlink_names, &id); if (r < 0) { - free(filename); - filename = NULL; - + filename = mfree(filename); if (r != -ENOENT) return r; } @@ -3534,9 +3532,7 @@ static int load_from_path(Unit *u, const char *path) { r = open_follow(&filename, &f, symlink_names, &id); if (r < 0) { - free(filename); - filename = NULL; - + filename = mfree(filename); if (r != -ENOENT) return r; diff --git a/src/core/main.c b/src/core/main.c index 6ae8b51544..a66fb18418 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1844,13 +1844,11 @@ finish: arg_default_rlimit[j] = NULL; } - free(arg_default_unit); - arg_default_unit = NULL; + arg_default_unit = mfree(arg_default_unit); free_join_controllers(); - strv_free(arg_default_environment); - arg_default_environment = NULL; + arg_default_environment = strv_free(arg_default_environment); set_free(arg_syscall_archs); arg_syscall_archs = NULL; diff --git a/src/core/manager.c b/src/core/manager.c index a1f37bbbb3..ba107d4615 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1701,6 +1701,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t ssize_t n; struct signalfd_siginfo sfsi; bool sigchld = false; + int r; assert(m); assert(m->signal_fd == fd); @@ -1809,20 +1810,16 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t f = open_memstream(&dump, &size); if (!f) { - log_warning("Failed to allocate memory stream."); + log_warning_errno(errno, "Failed to allocate memory stream: %m"); break; } manager_dump_units(m, f, "\t"); manager_dump_jobs(m, f, "\t"); - if (ferror(f)) { - log_warning("Failed to write status stream"); - break; - } - - if (fflush(f)) { - log_warning("Failed to flush status stream"); + r = fflush_and_check(f); + if (r < 0) { + log_warning_errno(r, "Failed to write status stream: %m"); break; } diff --git a/src/core/mount.c b/src/core/mount.c index bf8e52bf0e..c0d1cdfbd4 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -834,8 +834,6 @@ static void mount_enter_unmounting(Mount *m) { m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT; r = exec_command_set(m->control_command, UMOUNT_PATH, m->where, NULL); - if (r >= 0 && UNIT(m)->manager->running_as == MANAGER_SYSTEM) - r = exec_command_append(m->control_command, "-n", NULL); if (r < 0) goto fail; @@ -886,8 +884,6 @@ static void mount_enter_mounting(Mount *m) { r = exec_command_set(m->control_command, MOUNT_PATH, m->parameters_fragment.what, m->where, NULL); - if (r >= 0 && UNIT(m)->manager->running_as == MANAGER_SYSTEM) - r = exec_command_append(m->control_command, "-n", NULL); if (r >= 0 && m->sloppy_options) r = exec_command_append(m->control_command, "-s", NULL); if (r >= 0 && m->parameters_fragment.fstype) @@ -934,8 +930,6 @@ static void mount_enter_remounting(Mount *m) { r = exec_command_set(m->control_command, MOUNT_PATH, m->parameters_fragment.what, m->where, "-o", o, NULL); - if (r >= 0 && UNIT(m)->manager->running_as == MANAGER_SYSTEM) - r = exec_command_append(m->control_command, "-n", NULL); if (r >= 0 && m->sloppy_options) r = exec_command_append(m->control_command, "-s", NULL); if (r >= 0 && m->parameters_fragment.fstype) diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index e9a9a020de..50a90b0bac 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -302,12 +302,12 @@ int mac_selinux_unit_access_check_strv( int r; STRV_FOREACH(i, units) { - u = manager_get_unit(m, *i); - if (u) { - r = mac_selinux_unit_access_check(u, message, permission, error); - if (r < 0) - return r; - } + r = manager_load_unit(m, *i, NULL, error, &u); + if (r < 0) + return r; + r = mac_selinux_unit_access_check(u, message, permission, error); + if (r < 0) + return r; } #endif return 0; diff --git a/src/core/snapshot.c b/src/core/snapshot.c index 1e634b9bc1..9518e21f36 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -217,8 +217,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e, break; } - free(n); - n = NULL; + n = mfree(n); } } diff --git a/src/core/socket.c b/src/core/socket.c index 87631f8753..a387057473 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -923,13 +923,13 @@ static void socket_apply_socket_options(Socket *s, int fd) { log_unit_warning_errno(UNIT(s), errno, "TCP_CONGESTION failed: %m"); if (s->smack_ip_in) { - r = mac_smack_apply_ip_in_fd(fd, s->smack_ip_in); + r = mac_smack_apply_fd(fd, SMACK_ATTR_IPIN, s->smack_ip_in); if (r < 0) log_unit_error_errno(UNIT(s), r, "mac_smack_apply_ip_in_fd: %m"); } if (s->smack_ip_out) { - r = mac_smack_apply_ip_out_fd(fd, s->smack_ip_out); + r = mac_smack_apply_fd(fd, SMACK_ATTR_IPOUT, s->smack_ip_out); if (r < 0) log_unit_error_errno(UNIT(s), r, "mac_smack_apply_ip_out_fd: %m"); } @@ -946,7 +946,7 @@ static void socket_apply_fifo_options(Socket *s, int fd) { log_unit_warning_errno(UNIT(s), errno, "F_SETPIPE_SZ: %m"); if (s->smack) { - r = mac_smack_apply_fd(fd, s->smack); + r = mac_smack_apply_fd(fd, SMACK_ATTR_ACCESS, s->smack); if (r < 0) log_unit_error_errno(UNIT(s), r, "mac_smack_apply_fd: %m"); } |