diff options
29 files changed, 560 insertions, 571 deletions
@@ -64,8 +64,6 @@ Features: * sd-bus: make message handlers take an sd_bus_error and generate error replies automatically if they are set -* sd-bus: when replying to a bus message we should not need to specify the bus again - * sd-bus: see if we can drop more message validation on the sending side * sd-bus: introduce sd_bus_creds object and attach it to messages as well as allow querying it for names diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index e774383793..bdb9096e42 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -62,7 +62,7 @@ static int method_cancel(sd_bus *bus, sd_bus_message *message, void *userdata) { SELINUX_UNIT_ACCESS_CHECK(j->unit, bus, message, "stop"); job_finish_and_invalidate(j, JOB_CANCELED, true); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable bus_job_vtable[] = { diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 2e4de2e431..12b24c123b 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -303,19 +303,19 @@ static int method_get_unit(sd_bus *bus, sd_bus_message *message, void *userdata) r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); u = manager_get_unit(m, name); if (!u) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", name); SELINUX_UNIT_ACCESS_CHECK(u, bus, message, "status"); path = unit_dbus_path(u); if (!path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", path); + return sd_bus_reply_method_return(message, "o", path); } static int method_get_unit_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -333,25 +333,25 @@ static int method_get_unit_by_pid(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read(message, "u", &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (pid == 0) { r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } u = manager_get_unit_by_pid(m, pid); if (!u) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_UNIT_FOR_PID, "PID %u does not belong to any loaded unit.", pid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_UNIT_FOR_PID, "PID %u does not belong to any loaded unit.", pid); SELINUX_UNIT_ACCESS_CHECK(u, bus, message, "status"); path = unit_dbus_path(u); if (!path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", path); + return sd_bus_reply_method_return(message, "o", path); } static int method_load_unit(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -368,19 +368,19 @@ static int method_load_unit(sd_bus *bus, sd_bus_message *message, void *userdata r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = manager_load_unit(m, name, NULL, &error, &u); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); SELINUX_UNIT_ACCESS_CHECK(u, bus, message, "status"); path = unit_dbus_path(u); if (!path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", path); + return sd_bus_reply_method_return(message, "o", path); } static int method_start_unit_generic(sd_bus *bus, sd_bus_message *message, Manager *m, JobType job_type, bool reload_if_possible) { @@ -395,11 +395,11 @@ static int method_start_unit_generic(sd_bus *bus, sd_bus_message *message, Manag r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = manager_load_unit(m, name, NULL, &error, &u); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); return bus_unit_method_start_generic(bus, message, u, job_type, reload_if_possible); } @@ -444,11 +444,11 @@ static int method_start_unit_replace(sd_bus *bus, sd_bus_message *message, void r = sd_bus_message_read(message, "s", &old_name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); u = manager_get_unit(m, old_name); if (!u || !u->job || u->job->type != JOB_START) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_JOB, "No job queued for unit %s", old_name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_JOB, "No job queued for unit %s", old_name); return method_start_unit_generic(bus, message, m, JOB_START, false); } @@ -465,11 +465,11 @@ static int method_kill_unit(sd_bus *bus, sd_bus_message *message, void *userdata r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); u = manager_get_unit(m, name); if (!u) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); return bus_unit_method_kill(bus, message, u); } @@ -486,11 +486,11 @@ static int method_reset_failed_unit(sd_bus *bus, sd_bus_message *message, void * r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); u = manager_get_unit(m, name); if (!u) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); return bus_unit_method_reset_failed(bus, message, u); } @@ -507,11 +507,11 @@ static int method_set_unit_properties(sd_bus *bus, sd_bus_message *message, void r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); u = manager_get_unit(m, name); if (!u) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); return bus_unit_method_set_properties(bus, message, u); } @@ -531,43 +531,43 @@ static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, voi r = sd_bus_message_read(message, "ss", &name, &smode); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); t = unit_name_to_type(name); if (t < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit type."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit type."); if (!unit_vtable[t]->can_transient) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Unit type %s does not support transient units."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Unit type %s does not support transient units."); mode = job_mode_from_string(smode); if (mode < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s is invalid.", smode); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s is invalid.", smode); r = manager_load_unit(m, name, NULL, &error, &u); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); SELINUX_UNIT_ACCESS_CHECK(u, bus, message, "start"); if (u->load_state != UNIT_NOT_FOUND || set_size(u->dependencies[UNIT_REFERENCED_BY]) > 0) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_UNIT_EXISTS, "Unit %s already exists.", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_UNIT_EXISTS, "Unit %s already exists.", name); /* OK, the unit failed to load and is unreferenced, now let's * fill in the transient data instead */ r = unit_make_transient(u); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); /* Set our properties */ r = bus_unit_set_properties(u, message, UNIT_RUNTIME, false, &error); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); /* And load this stub fully */ r = unit_load(u); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); manager_dispatch_load_queue(m); @@ -588,19 +588,19 @@ static int method_get_job(sd_bus *bus, sd_bus_message *message, void *userdata) r = sd_bus_message_read(message, "u", &id); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); j = manager_get_job(m, id); if (!j) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id); SELINUX_UNIT_ACCESS_CHECK(j->unit, bus, message, "status"); path = job_dbus_path(j); if (!path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", path); + return sd_bus_reply_method_return(message, "o", path); } static int method_cancel_job(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -615,17 +615,17 @@ static int method_cancel_job(sd_bus *bus, sd_bus_message *message, void *userdat r = sd_bus_message_read(message, "u", &id); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); j = manager_get_job(m, id); if (!j) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id); SELINUX_UNIT_ACCESS_CHECK(j->unit, bus, message, "stop"); job_finish_and_invalidate(j, JOB_CANCELED, true); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_clear_jobs(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -638,7 +638,7 @@ static int method_clear_jobs(sd_bus *bus, sd_bus_message *message, void *userdat SELINUX_ACCESS_CHECK(bus, message, "reboot"); manager_clear_jobs(m); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -651,7 +651,7 @@ static int method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userd SELINUX_ACCESS_CHECK(bus, message, "reload"); manager_reset_failed(m); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -668,13 +668,13 @@ static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdat SELINUX_ACCESS_CHECK(bus, message, "status"); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(ssssssouso)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH_KEY(u, k, m->units, i) { _cleanup_free_ char *unit_path = NULL, *job_path = NULL; @@ -687,12 +687,12 @@ static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdat unit_path = unit_dbus_path(u); if (!unit_path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); if (u->job) { job_path = job_dbus_path(u->job); if (!job_path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); } r = sd_bus_message_append( @@ -708,12 +708,12 @@ static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdat u->job ? job_type_to_string(u->job->type) : "", job_path ? job_path : "/"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -731,24 +731,24 @@ static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata SELINUX_ACCESS_CHECK(bus, message, "status"); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(usssoo)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH(j, m->jobs, i) { _cleanup_free_ char *unit_path = NULL, *job_path = NULL; job_path = job_dbus_path(j); if (!job_path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); unit_path = unit_dbus_path(j->unit); if (!unit_path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); r = sd_bus_message_append( reply, "(usssoo)", @@ -758,12 +758,12 @@ static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata job_path, unit_path); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -780,11 +780,11 @@ static int method_subscribe(sd_bus *bus, sd_bus_message *message, void *userdata r = bus_client_track(&m->subscribed, bus, sd_bus_message_get_sender(message)); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (r == 0) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_ALREADY_SUBSCRIBED, "Client is already subscribed."); + return sd_bus_reply_method_errorf(message, BUS_ERROR_ALREADY_SUBSCRIBED, "Client is already subscribed."); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_unsubscribe(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -799,11 +799,11 @@ static int method_unsubscribe(sd_bus *bus, sd_bus_message *message, void *userda r = bus_client_untrack(m->subscribed, bus, sd_bus_message_get_sender(message)); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (r == 0) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NOT_SUBSCRIBED, "Client is not subscribed."); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NOT_SUBSCRIBED, "Client is not subscribed."); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_dump(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -820,7 +820,7 @@ static int method_dump(sd_bus *bus, sd_bus_message *message, void *userdata) { f = open_memstream(&dump, &size); if (!f) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); manager_dump_units(m, f, NULL); manager_dump_jobs(m, f, NULL); @@ -828,9 +828,9 @@ static int method_dump(sd_bus *bus, sd_bus_message *message, void *userdata) { fflush(f); if (ferror(f)) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "s", dump); + return sd_bus_reply_method_return(message, "s", dump); } static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -850,20 +850,20 @@ static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read(message, "sb", &name, &cleanup); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(name)) name = NULL; r = snapshot_create(m, name, cleanup, &error, &s); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); path = unit_dbus_path(UNIT(s)); if (!path) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", path); + return sd_bus_reply_method_return(message, "o", path); } static int method_remove_snapshot(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -880,14 +880,14 @@ static int method_remove_snapshot(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); u = manager_get_unit(m, name); if (!u) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s does not exist.", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s does not exist.", name); if (u->type != UNIT_SNAPSHOT) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not a snapshot", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not a snapshot", name); return bus_snapshot_method_remove(bus, message, u); } @@ -908,9 +908,9 @@ static int method_reload(sd_bus *bus, sd_bus_message *message, void *userdata) { * finished. */ assert(!m->queued_message); - r = sd_bus_message_new_method_return(bus, message, &m->queued_message); + r = sd_bus_message_new_method_return(message, &m->queued_message); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); m->queued_message_bus = sd_bus_ref(bus); m->exit_code = MANAGER_RELOAD; @@ -944,11 +944,11 @@ static int method_exit(sd_bus *bus, sd_bus_message *message, void *userdata) { SELINUX_ACCESS_CHECK(bus, message, "halt"); if (m->running_as == SYSTEMD_SYSTEM) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers."); m->exit_code = MANAGER_EXIT; - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -961,11 +961,11 @@ static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata) { SELINUX_ACCESS_CHECK(bus, message, "reboot"); if (m->running_as != SYSTEMD_SYSTEM) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers."); m->exit_code = MANAGER_REBOOT; - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } @@ -979,11 +979,11 @@ static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata) SELINUX_ACCESS_CHECK(bus, message, "halt"); if (m->running_as != SYSTEMD_SYSTEM) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers."); m->exit_code = MANAGER_POWEROFF; - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_halt(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -996,11 +996,11 @@ static int method_halt(sd_bus *bus, sd_bus_message *message, void *userdata) { SELINUX_ACCESS_CHECK(bus, message, "halt"); if (m->running_as != SYSTEMD_SYSTEM) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers."); m->exit_code = MANAGER_HALT; - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kexec(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1013,11 +1013,11 @@ static int method_kexec(sd_bus *bus, sd_bus_message *message, void *userdata) { SELINUX_ACCESS_CHECK(bus, message, "reboot"); if (m->running_as != SYSTEMD_SYSTEM) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers."); m->exit_code = MANAGER_KEXEC; - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1033,42 +1033,42 @@ static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userda SELINUX_ACCESS_CHECK(bus, message, "reboot"); if (m->running_as != SYSTEMD_SYSTEM) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers."); r = sd_bus_message_read(message, "ss", &root, &init); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (path_equal(root, "/") || !path_is_absolute(root)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid switch root path %s", root); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid switch root path %s", root); /* Safety check */ if (isempty(init)) { if (! path_is_os_tree(root)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Specified switch root path %s does not seem to be an OS tree. /etc/os-release is missing.", root); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Specified switch root path %s does not seem to be an OS tree. /etc/os-release is missing.", root); } else { _cleanup_free_ char *p = NULL; if (!path_is_absolute(init)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid init path %s", init); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid init path %s", init); p = strappend(root, init); if (!p) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); if (access(p, X_OK) < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Specified init binary %s does not exist.", p); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Specified init binary %s does not exist.", p); } rt = strdup(root); if (!rt) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); if (!isempty(init)) { ri = strdup(init); if (!ri) { free(ri); - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); } } @@ -1078,7 +1078,7 @@ static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userda free(m->switch_root_init); m->switch_root_init = ri; - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_set_environment(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1094,15 +1094,15 @@ static int method_set_environment(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read_strv(message, &plus); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!strv_env_is_valid(plus)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments"); r = manager_environment_add(m, NULL, plus); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_unset_environment(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1118,16 +1118,16 @@ static int method_unset_environment(sd_bus *bus, sd_bus_message *message, void * r = sd_bus_message_read_strv(message, &minus); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!strv_env_name_or_assignment_is_valid(minus)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments"); r = manager_environment_add(m, minus, NULL); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_unset_and_set_environment(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1143,22 +1143,22 @@ static int method_unset_and_set_environment(sd_bus *bus, sd_bus_message *message r = sd_bus_message_read_strv(message, &plus); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_read_strv(message, &minus); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!strv_env_is_valid(plus)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments"); if (!strv_env_name_or_assignment_is_valid(minus)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment variable names or assignments"); r = manager_environment_add(m, minus, plus); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1175,23 +1175,23 @@ static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *us SELINUX_ACCESS_CHECK(bus, message, "status"); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); h = hashmap_new(string_hash_func, string_compare_func); if (!h) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } r = sd_bus_message_open_container(reply, 'a', "(ss)"); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } @@ -1199,7 +1199,7 @@ static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_append(reply, "(ss)", item->path, unit_file_state_to_string(item->state)); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } } @@ -1208,7 +1208,7 @@ static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); @@ -1232,15 +1232,15 @@ static int method_get_unit_file_state(sd_bus *bus, sd_bus_message *message, void r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; state = unit_file_get_state(scope, NULL, name); if (state < 0) - return sd_bus_reply_method_errno(bus, message, state, NULL); + return sd_bus_reply_method_errno(message, state, NULL); - return sd_bus_reply_method_return(bus, message, "s", unit_file_state_to_string(state)); + return sd_bus_reply_method_return(message, "s", unit_file_state_to_string(state)); } static int method_get_default_target(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1259,9 +1259,9 @@ static int method_get_default_target(sd_bus *bus, sd_bus_message *message, void r = unit_file_get_default(scope, NULL, &default_target); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, "s", default_target); + return sd_bus_reply_method_return(message, "s", default_target); } static int send_unit_files_changed(sd_bus *bus, const char *destination, void *userdata) { @@ -1292,7 +1292,7 @@ static int reply_unit_file_changes_and_free( if (n_changes > 0) bus_manager_foreach_client(m, send_unit_files_changed, NULL); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) goto fail; @@ -1324,7 +1324,7 @@ static int reply_unit_file_changes_and_free( fail: unit_file_changes_free(changes, n_changes); - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } static int method_enable_unit_files_generic( @@ -1349,17 +1349,17 @@ static int method_enable_unit_files_generic( r = sd_bus_message_read_strv(message, &l); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_read(message, "bb", &runtime, &force); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; r = call(scope, runtime, NULL, l, force, &changes, &n_changes); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return reply_unit_file_changes_and_free(m, bus, message, carries_install_info ? r : -1, changes, n_changes); } @@ -1405,17 +1405,17 @@ static int method_disable_unit_files_generic( r = sd_bus_message_read_strv(message, &l); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_read(message, "b", &runtime); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; r = call(scope, runtime, NULL, l, &changes, &n_changes); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return reply_unit_file_changes_and_free(m, bus, message, -1, changes, n_changes); } @@ -1444,13 +1444,13 @@ static int method_set_default_target(sd_bus *bus, sd_bus_message *message, void r = sd_bus_message_read(message, "sb", &name, &force); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; r = unit_file_set_default(scope, NULL, name, force, &changes, &n_changes); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return reply_unit_file_changes_and_free(m, bus, message, -1, changes, n_changes); } diff --git a/src/core/dbus-snapshot.c b/src/core/dbus-snapshot.c index a4ba588a1d..1e53fefc66 100644 --- a/src/core/dbus-snapshot.c +++ b/src/core/dbus-snapshot.c @@ -36,7 +36,7 @@ int bus_snapshot_method_remove(sd_bus *bus, sd_bus_message *message, void *userd snapshot_remove(s); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable bus_snapshot_vtable[] = { diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 49054781c0..759fc4a869 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -369,11 +369,11 @@ int bus_unit_method_start_generic(sd_bus *bus, sd_bus_message *message, Unit *u, r = sd_bus_message_read(message, "s", &smode); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); mode = job_mode_from_string(smode); if (mode < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s invalid", smode); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s invalid", smode); return bus_unit_queue_job(bus, message, u, job_type, mode, reload_if_possible); } @@ -420,26 +420,26 @@ int bus_unit_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { r = sd_bus_message_read(message, "si", &swho, &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(swho)) who = KILL_ALL; else { who = kill_who_from_string(swho); if (who < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid who argument %s", swho); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid who argument %s", swho); } if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Signal number out of range."); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Signal number out of range."); SELINUX_UNIT_ACCESS_CHECK(u, bus, message, "stop"); r = unit_kill(u, who, signo, &error); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } int bus_unit_method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -453,7 +453,7 @@ int bus_unit_method_reset_failed(sd_bus *bus, sd_bus_message *message, void *use unit_reset_failed(u); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } int bus_unit_method_set_properties(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -467,23 +467,23 @@ int bus_unit_method_set_properties(sd_bus *bus, sd_bus_message *message, void *u r = sd_bus_message_read(message, "b", &runtime); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); SELINUX_UNIT_ACCESS_CHECK(u, bus, message, "start"); r = sd_bus_message_enter_container(message, 'a', "(sv)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = bus_unit_set_properties(u, message, runtime ? UNIT_RUNTIME : UNIT_PERSISTENT, true, &error); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); r = sd_bus_message_exit_container(message); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable bus_unit_vtable[] = { @@ -755,26 +755,26 @@ int bus_unit_queue_job( if (type == JOB_STOP && (u->load_state == UNIT_NOT_FOUND || u->load_state == UNIT_ERROR) && unit_active_state(u) == UNIT_INACTIVE) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", u->id); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", u->id); if ((type == JOB_START && u->refuse_manual_start) || (type == JOB_STOP && u->refuse_manual_stop) || ((type == JOB_RESTART || type == JOB_TRY_RESTART) && (u->refuse_manual_start || u->refuse_manual_stop))) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only.", u->id); + return sd_bus_reply_method_errorf(message, BUS_ERROR_ONLY_BY_DEPENDENCY, "Operation refused, unit %s may be requested by dependency only.", u->id); r = manager_add_job(u->manager, type, u, mode, true, &error, &j); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); r = bus_client_track(&j->subscribed, bus, sd_bus_message_get_sender(message)); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); path = job_dbus_path(j); if (!path) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, "o", path); + return sd_bus_reply_method_return(message, "o", path); } static int bus_unit_set_transient_property( diff --git a/src/core/selinux-access.h b/src/core/selinux-access.h index 0926a5eb09..3404f62166 100644 --- a/src/core/selinux-access.h +++ b/src/core/selinux-access.h @@ -39,7 +39,7 @@ int selinux_access_check(sd_bus *bus, sd_bus_message *message, const char *path, int _r; \ _r = selinux_access_check(_b, _m, NULL, (permission), &_error); \ if (_r < 0) \ - return sd_bus_reply_method_errno(_b, _m, _r, &_error); \ + return sd_bus_reply_method_errno(_m, _r, &_error); \ } while (false) #define SELINUX_UNIT_ACCESS_CHECK(unit, bus, message, permission) \ @@ -51,7 +51,7 @@ int selinux_access_check(sd_bus *bus, sd_bus_message *message, const char *path, int _r; \ _r = selinux_access_check(_b, _m, _u->source_path ?: _u->fragment_path, (permission), &_error); \ if (_r < 0) \ - return sd_bus_reply_method_errno(_b, _m, _r, &_error); \ + return sd_bus_reply_method_errno(_m, _r, &_error); \ } while (false) #else diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 4363b09edb..332c00bee5 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -377,7 +377,7 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata) { r = sd_bus_message_read(m, "sb", &name, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (isempty(name)) name = c->data[PROP_STATIC_HOSTNAME]; @@ -386,14 +386,14 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata) { name = "localhost"; if (!hostname_is_valid(name)) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", name); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", name); if (streq_ptr(name, c->data[PROP_HOSTNAME])) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.hostname1.set-hostname", interactive, &error, method_set_hostname, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -407,14 +407,14 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata) { r = context_write_data_hostname(c); if (r < 0) { log_error("Failed to set host name: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set hostname: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set hostname: %s", strerror(-r)); } log_info("Changed host name to '%s'", strna(c->data[PROP_HOSTNAME])); sd_bus_emit_properties_changed(bus, "/org/freedesktop/hostname1", "org.freedesktop.hostname1", "Hostname", NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *userdata) { @@ -426,17 +426,17 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user r = sd_bus_message_read(m, "sb", &name, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (isempty(name)) name = NULL; if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME])) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.hostname1.set-static-hostname", interactive, &error, method_set_static_hostname, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -447,7 +447,7 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user char *h; if (!hostname_is_valid(name)) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid static hostname '%s'", name); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid static hostname '%s'", name); h = strdup(name); if (!h) @@ -460,14 +460,14 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user r = context_write_data_static_hostname(c); if (r < 0) { log_error("Failed to write static host name: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set static hostname: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set static hostname: %s", strerror(-r)); } log_info("Changed static host name to '%s'", strna(c->data[PROP_STATIC_HOSTNAME])); sd_bus_emit_properties_changed(bus, "/org/freedesktop/hostname1", "org.freedesktop.hostname1", "StaticHostname", NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop, sd_bus_message_handler_t cb) { @@ -482,13 +482,13 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop r = sd_bus_message_read(m, "sb", &name, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (isempty(name)) name = NULL; if (streq_ptr(name, c->data[prop])) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); /* Since the pretty hostname should always be changed at the * same time as the static one, use the same policy action for @@ -498,7 +498,7 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop "org.freedesktop.hostname1.set-static-hostname" : "org.freedesktop.hostname1.set-machine-info", interactive, &error, cb, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -512,12 +512,12 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop * name, so better be safe than sorry */ if (prop == PROP_ICON_NAME && !filename_is_safe(name)) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid icon name '%s'", name); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid icon name '%s'", name); if (prop == PROP_PRETTY_HOSTNAME && (string_has_cc(name) || chars_intersect(name, "\t"))) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid pretty host name '%s'", name); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid pretty host name '%s'", name); if (prop == PROP_CHASSIS && !valid_chassis(name)) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid chassis '%s'", name); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid chassis '%s'", name); h = strdup(name); if (!h) @@ -530,7 +530,7 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop r = context_write_data_other(c); if (r < 0) { log_error("Failed to write machine info: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to write machine info: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to write machine info: %s", strerror(-r)); } log_info("Changed %s to '%s'", @@ -541,7 +541,7 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop prop == PROP_PRETTY_HOSTNAME ? "PrettyHostname" : prop == PROP_CHASSIS ? "Chassis" : "IconName", NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_pretty_hostname(sd_bus *bus, sd_bus_message *m, void *userdata) { diff --git a/src/libsystemd-bus/bus-convenience.c b/src/libsystemd-bus/bus-convenience.c index 9bf2e2cbe5..6446874713 100644 --- a/src/libsystemd-bus/bus-convenience.c +++ b/src/libsystemd-bus/bus-convenience.c @@ -91,24 +91,22 @@ _public_ int sd_bus_call_method( } _public_ int sd_bus_reply_method_return( - sd_bus *bus, sd_bus_message *call, const char *types, ...) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; int r; - assert_return(bus, -EINVAL); assert_return(call, -EINVAL); assert_return(call->sealed, -EPERM); assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); - assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); - assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(call->bus), -ECHILD); if (call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED) return 0; - r = sd_bus_message_new_method_return(bus, call, &m); + r = sd_bus_message_new_method_return(call, &m); if (r < 0) return r; @@ -122,37 +120,34 @@ _public_ int sd_bus_reply_method_return( return r; } - return sd_bus_send(bus, m, NULL); + return sd_bus_send(call->bus, m, NULL); } _public_ int sd_bus_reply_method_error( - sd_bus *bus, sd_bus_message *call, const sd_bus_error *e) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; int r; - assert_return(bus, -EINVAL); assert_return(call, -EINVAL); assert_return(call->sealed, -EPERM); assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); assert_return(sd_bus_error_is_set(e), -EINVAL); - assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); - assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(call->bus), -ECHILD); if (call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED) return 0; - r = sd_bus_message_new_method_error(bus, call, e, &m); + r = sd_bus_message_new_method_error(call, e, &m); if (r < 0) return r; - return sd_bus_send(bus, m, NULL); + return sd_bus_send(call->bus, m, NULL); } _public_ int sd_bus_reply_method_errorf( - sd_bus *bus, sd_bus_message *call, const char *name, const char *format, @@ -162,12 +157,11 @@ _public_ int sd_bus_reply_method_errorf( va_list ap; int r; - assert_return(bus, -EINVAL); assert_return(call, -EINVAL); assert_return(call->sealed, -EPERM); assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); - assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); - assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(call->bus), -ECHILD); if (call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED) return 0; @@ -179,37 +173,34 @@ _public_ int sd_bus_reply_method_errorf( if (r < 0) return r; - return sd_bus_reply_method_error(bus, call, &error); + return sd_bus_reply_method_error(call, &error); } _public_ int sd_bus_reply_method_errno( - sd_bus *bus, sd_bus_message *call, int error, const sd_bus_error *p) { _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL; - assert_return(bus, -EINVAL); assert_return(call, -EINVAL); assert_return(call->sealed, -EPERM); assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); - assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); - assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(call->bus), -ECHILD); if (call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED) return 0; if (sd_bus_error_is_set(p)) - return sd_bus_reply_method_error(bus, call, p); + return sd_bus_reply_method_error(call, p); sd_bus_error_set_errno(&berror, error); - return sd_bus_reply_method_error(bus, call, &berror); + return sd_bus_reply_method_error(call, &berror); } _public_ int sd_bus_reply_method_errnof( - sd_bus *bus, sd_bus_message *call, int error, const char *format, @@ -218,12 +209,11 @@ _public_ int sd_bus_reply_method_errnof( _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL; va_list ap; - assert_return(bus, -EINVAL); assert_return(call, -EINVAL); assert_return(call->sealed, -EPERM); assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); - assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); - assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(call->bus), -ECHILD); if (call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED) return 0; @@ -232,7 +222,7 @@ _public_ int sd_bus_reply_method_errnof( bus_error_set_errnofv(&berror, error, format, ap); va_end(ap); - return sd_bus_reply_method_error(bus, call, &berror); + return sd_bus_reply_method_error(call, &berror); } _public_ int sd_bus_get_property( diff --git a/src/libsystemd-bus/bus-introspect.c b/src/libsystemd-bus/bus-introspect.c index 4c6031729a..1965364cd0 100644 --- a/src/libsystemd-bus/bus-introspect.c +++ b/src/libsystemd-bus/bus-introspect.c @@ -169,7 +169,7 @@ int introspect_finish(struct introspect *i, sd_bus *bus, sd_bus_message *m, sd_b if (ferror(i->f)) return -ENOMEM; - r = sd_bus_message_new_method_return(bus, m, &q); + r = sd_bus_message_new_method_return(m, &q); if (r < 0) return r; diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index bf8de04ab6..da9474dc51 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -485,7 +485,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess if (n_bytes != total) return -EBADMSG; - r = bus_message_from_header(h, sizeof(struct bus_header), fds, n_fds, NULL, seclabel, 0, &m); + r = bus_message_from_header(bus, h, sizeof(struct bus_header), fds, n_fds, NULL, seclabel, 0, &m); if (r < 0) return r; @@ -603,7 +603,6 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess /* We take possession of the kmsg struct now */ m->kdbus = k; - m->bus = sd_bus_ref(bus); m->release_kdbus = true; m->free_fds = true; diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c index 666307cc6e..4aa7dde05c 100644 --- a/src/libsystemd-bus/bus-message.c +++ b/src/libsystemd-bus/bus-message.c @@ -305,6 +305,7 @@ static int message_append_field_uint32(sd_bus_message *m, uint8_t h, uint32_t x) } int bus_message_from_header( + sd_bus *bus, void *buffer, size_t length, int *fds, @@ -368,11 +369,15 @@ int bus_message_from_header( memcpy(m->label, label, label_sz + 1); } + if (bus) + m->bus = sd_bus_ref(bus); + *ret = m; return 0; } int bus_message_from_malloc( + sd_bus *bus, void *buffer, size_t length, int *fds, @@ -384,7 +389,7 @@ int bus_message_from_malloc( sd_bus_message *m; int r; - r = bus_message_from_header(buffer, length, fds, n_fds, ucred, label, 0, &m); + r = bus_message_from_header(bus, buffer, length, fds, n_fds, ucred, label, 0, &m); if (r < 0) return r; @@ -530,7 +535,6 @@ fail: } static int message_new_reply( - sd_bus *bus, sd_bus_message *call, uint8_t type, sd_bus_message **m) { @@ -538,13 +542,13 @@ static int message_new_reply( sd_bus_message *t; int r; - assert_return(!bus || bus->state != BUS_UNSET, -ENOTCONN); assert_return(call, -EINVAL); assert_return(call->sealed, -EPERM); assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); + assert_return(!call->bus || call->bus->state != BUS_UNSET, -ENOTCONN); assert_return(m, -EINVAL); - t = message_new(bus, type); + t = message_new(call->bus, type); if (!t) return -ENOMEM; @@ -572,15 +576,13 @@ fail: } _public_ int sd_bus_message_new_method_return( - sd_bus *bus, sd_bus_message *call, sd_bus_message **m) { - return message_new_reply(bus, call, SD_BUS_MESSAGE_METHOD_RETURN, m); + return message_new_reply(call, SD_BUS_MESSAGE_METHOD_RETURN, m); } _public_ int sd_bus_message_new_method_error( - sd_bus *bus, sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m) { @@ -591,7 +593,7 @@ _public_ int sd_bus_message_new_method_error( assert_return(sd_bus_error_is_set(e), -EINVAL); assert_return(m, -EINVAL); - r = message_new_reply(bus, call, SD_BUS_MESSAGE_METHOD_ERROR, &t); + r = message_new_reply(call, SD_BUS_MESSAGE_METHOD_ERROR, &t); if (r < 0) return r; @@ -614,7 +616,6 @@ fail: } _public_ int sd_bus_message_new_method_errorf( - sd_bus *bus, sd_bus_message *call, sd_bus_message **m, const char *name, @@ -635,11 +636,10 @@ _public_ int sd_bus_message_new_method_errorf( if (r < 0) return r; - return sd_bus_message_new_method_error(bus, call, &error, m); + return sd_bus_message_new_method_error(call, &error, m); } _public_ int sd_bus_message_new_method_errno( - sd_bus *bus, sd_bus_message *call, int error, const sd_bus_error *p, @@ -648,15 +648,14 @@ _public_ int sd_bus_message_new_method_errno( _cleanup_free_ sd_bus_error berror = SD_BUS_ERROR_NULL; if (sd_bus_error_is_set(p)) - return sd_bus_message_new_method_error(bus, call, p, m); + return sd_bus_message_new_method_error(call, p, m); sd_bus_error_set_errno(&berror, error); - return sd_bus_message_new_method_error(bus, call, &berror, m); + return sd_bus_message_new_method_error(call, &berror, m); } _public_ int sd_bus_message_new_method_errnof( - sd_bus *bus, sd_bus_message *call, sd_bus_message **m, int error, @@ -674,7 +673,7 @@ _public_ int sd_bus_message_new_method_errnof( if (r < 0) return r; - return sd_bus_message_new_method_error(bus, call, &berror, m); + return sd_bus_message_new_method_error(call, &berror, m); } int bus_message_new_synthetic_error( diff --git a/src/libsystemd-bus/bus-message.h b/src/libsystemd-bus/bus-message.h index aec6f75857..8c0ba86213 100644 --- a/src/libsystemd-bus/bus-message.h +++ b/src/libsystemd-bus/bus-message.h @@ -194,6 +194,7 @@ int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz); int bus_message_read_strv_extend(sd_bus_message *m, char ***l); int bus_message_from_header( + sd_bus *bus, void *header, size_t length, int *fds, @@ -204,6 +205,7 @@ int bus_message_from_header( sd_bus_message **ret); int bus_message_from_malloc( + sd_bus *bus, void *buffer, size_t length, int *fds, diff --git a/src/libsystemd-bus/bus-objects.c b/src/libsystemd-bus/bus-objects.c index a6e8b2de86..d9be3ddbfc 100644 --- a/src/libsystemd-bus/bus-objects.c +++ b/src/libsystemd-bus/bus-objects.c @@ -289,7 +289,7 @@ static int method_callbacks_run( return -EINVAL; if (!streq(strempty(c->vtable->x.method.signature), signature)) { - r = sd_bus_reply_method_errorf(bus, m, + r = sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid arguments '%s' to call %s:%s, expecting '%s'.", signature, c->interface, c->member, strempty(c->vtable->x.method.signature)); @@ -303,7 +303,7 @@ static int method_callbacks_run( return c->vtable->x.method.handler(bus, m, u); /* If the method callback is NULL, make this a successful NOP */ - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); if (r < 0) return r; @@ -449,7 +449,7 @@ static int property_get_set_callbacks_run( *found_object = true; - r = sd_bus_message_new_method_return(bus, m, &reply); + r = sd_bus_message_new_method_return(m, &reply); if (r < 0) return r; @@ -470,7 +470,7 @@ static int property_get_set_callbacks_run( return r; if (sd_bus_error_is_set(&error)) { - r = sd_bus_reply_method_error(bus, m, &error); + r = sd_bus_reply_method_error(m, &error); if (r < 0) return r; @@ -507,7 +507,7 @@ static int property_get_set_callbacks_run( } if (sd_bus_error_is_set(&error)) { - r = sd_bus_reply_method_error(bus, m, &error); + r = sd_bus_reply_method_error(m, &error); if (r < 0) return r; @@ -598,7 +598,7 @@ static int property_get_all_callbacks_run( assert(m); assert(found_object); - r = sd_bus_message_new_method_return(bus, m, &reply); + r = sd_bus_message_new_method_return(m, &reply); if (r < 0) return r; @@ -637,7 +637,7 @@ static int property_get_all_callbacks_run( return r; if (sd_bus_error_is_set(&error)) { - r = sd_bus_reply_method_error(bus, m, &error); + r = sd_bus_reply_method_error(m, &error); if (r < 0) return r; @@ -649,7 +649,7 @@ static int property_get_all_callbacks_run( if (!found_interface) { r = sd_bus_reply_method_errorf( - bus, m, + m, SD_BUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface '%s'.", iface); if (r < 0) @@ -1004,7 +1004,7 @@ static int process_get_managed_objects( if (bus->nodes_modified) return 0; - r = sd_bus_message_new_method_return(bus, m, &reply); + r = sd_bus_message_new_method_return(m, &reply); if (r < 0) return r; @@ -1048,7 +1048,7 @@ static int process_get_managed_objects( return -ENOMEM; if (sd_bus_error_is_set(&error)) { - r = sd_bus_reply_method_error(bus, m, &error); + r = sd_bus_reply_method_error(m, &error); if (r < 0) return r; @@ -1232,12 +1232,12 @@ int bus_process_object(sd_bus *bus, sd_bus_message *m) { if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Get") || sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Set")) r = sd_bus_reply_method_errorf( - bus, m, + m, SD_BUS_ERROR_UNKNOWN_PROPERTY, "Unknown property or interface."); else r = sd_bus_reply_method_errorf( - bus, m, + m, SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method '%s' or interface '%s'.", m->member, m->interface); diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c index b7e816ea80..60d9ad41c3 100644 --- a/src/libsystemd-bus/bus-socket.c +++ b/src/libsystemd-bus/bus-socket.c @@ -909,7 +909,8 @@ static int bus_socket_make_message(sd_bus *bus, size_t size, sd_bus_message **m) } else b = NULL; - r = bus_message_from_malloc(bus->rbuffer, size, + r = bus_message_from_malloc(bus, + bus->rbuffer, size, bus->fds, bus->n_fds, bus->ucred_valid ? &bus->ucred : NULL, bus->label[0] ? bus->label : NULL, diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c index 0ae52563e7..9374be93ca 100644 --- a/src/libsystemd-bus/sd-bus.c +++ b/src/libsystemd-bus/sd-bus.c @@ -1986,7 +1986,7 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) { return 1; if (streq_ptr(m->member, "Ping")) - r = sd_bus_message_new_method_return(bus, m, &reply); + r = sd_bus_message_new_method_return(m, &reply); else if (streq_ptr(m->member, "GetMachineId")) { sd_id128_t id; char sid[33]; @@ -1995,14 +1995,14 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) { if (r < 0) return r; - r = sd_bus_message_new_method_return(bus, m, &reply); + r = sd_bus_message_new_method_return(m, &reply); if (r < 0) return r; r = sd_bus_message_append(reply, "s", sd_id128_to_string(id, sid)); } else { r = sd_bus_message_new_method_errorf( - bus, m, &reply, + m, &reply, SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method '%s' on interface '%s'.", m->member, m->interface); } @@ -2097,7 +2097,7 @@ static int process_running(sd_bus *bus, sd_bus_message **ret) { if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL) { r = sd_bus_reply_method_errorf( - bus, m, + m, SD_BUS_ERROR_UNKNOWN_OBJECT, "Unknown object '%s'.", m->path); if (r < 0) diff --git a/src/libsystemd-bus/test-bus-chat.c b/src/libsystemd-bus/test-bus-chat.c index 67411f1184..8c344f6edb 100644 --- a/src/libsystemd-bus/test-bus-chat.c +++ b/src/libsystemd-bus/test-bus-chat.c @@ -52,7 +52,7 @@ static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata) { if (sd_bus_message_is_method_call(m, "org.object.test", "Foobar")) { log_info("Invoked Foobar() on %s", sd_bus_message_get_path(m)); - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); return r; @@ -185,14 +185,14 @@ static int server(sd_bus *bus) { ascii_strlower(lowercase); - r = sd_bus_reply_method_return(bus, m, "s", lowercase); + r = sd_bus_reply_method_return(m, "s", lowercase); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); goto fail; } } else if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "ExitClient1")) { - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); goto fail; @@ -201,7 +201,7 @@ static int server(sd_bus *bus) { client1_gone = true; } else if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "ExitClient2")) { - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); goto fail; @@ -212,7 +212,7 @@ static int server(sd_bus *bus) { sleep(1); - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); goto fail; @@ -236,7 +236,7 @@ static int server(sd_bus *bus) { goto fail; } - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); goto fail; @@ -245,7 +245,7 @@ static int server(sd_bus *bus) { } else if (sd_bus_message_is_method_call(m, NULL, NULL)) { r = sd_bus_reply_method_error( - bus, m, + m, &SD_BUS_ERROR_MAKE(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method.")); if (r < 0) { log_error("Failed to send reply: %s", strerror(-r)); diff --git a/src/libsystemd-bus/test-bus-kernel-benchmark.c b/src/libsystemd-bus/test-bus-kernel-benchmark.c index 18b08ed816..6afae7f487 100644 --- a/src/libsystemd-bus/test-bus-kernel-benchmark.c +++ b/src/libsystemd-bus/test-bus-kernel-benchmark.c @@ -52,7 +52,7 @@ static void server(sd_bus *b, size_t *result) { continue; if (sd_bus_message_is_method_call(m, "benchmark.server", "Ping")) - assert_se(sd_bus_reply_method_return(b, m, NULL) >= 0); + assert_se(sd_bus_reply_method_return(m, NULL) >= 0); else if (sd_bus_message_is_method_call(m, "benchmark.server", "Work")) { const void *p; size_t sz; @@ -60,7 +60,7 @@ static void server(sd_bus *b, size_t *result) { /* Make sure the mmap is mapped */ assert_se(sd_bus_message_read_array(m, 'y', &p, &sz) > 0); - assert_se(sd_bus_reply_method_return(b, m, NULL) >= 0); + assert_se(sd_bus_reply_method_return(m, NULL) >= 0); } else if (sd_bus_message_is_method_call(m, "benchmark.server", "Exit")) { uint64_t res; assert_se(sd_bus_message_read(m, "t", &res) > 0); diff --git a/src/libsystemd-bus/test-bus-marshal.c b/src/libsystemd-bus/test-bus-marshal.c index 98737b6811..da072c707f 100644 --- a/src/libsystemd-bus/test-bus-marshal.c +++ b/src/libsystemd-bus/test-bus-marshal.c @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) { m = sd_bus_message_unref(m); - r = bus_message_from_malloc(buffer, sz, NULL, 0, NULL, NULL, &m); + r = bus_message_from_malloc(NULL, buffer, sz, NULL, 0, NULL, NULL, &m); assert_se(r >= 0); bus_message_dump(m, stdout, true); diff --git a/src/libsystemd-bus/test-bus-objects.c b/src/libsystemd-bus/test-bus-objects.c index c9fb846ffd..0e9ef57da1 100644 --- a/src/libsystemd-bus/test-bus-objects.c +++ b/src/libsystemd-bus/test-bus-objects.c @@ -61,7 +61,7 @@ static int something_handler(sd_bus *bus, sd_bus_message *m, void *userdata) { log_info("AlterSomething() called, got %s, returning %s", s, n); - r = sd_bus_reply_method_return(bus, m, "s", n); + r = sd_bus_reply_method_return(m, "s", n); assert_se(r >= 0); return 1; @@ -75,7 +75,7 @@ static int exit_handler(sd_bus *bus, sd_bus_message *m, void *userdata) { log_info("Exit called"); - r = sd_bus_reply_method_return(bus, m, ""); + r = sd_bus_reply_method_return(m, ""); assert_se(r >= 0); return 1; @@ -134,7 +134,7 @@ static int notify_test(sd_bus *bus, sd_bus_message *m, void *userdata) { assert_se(sd_bus_emit_properties_changed(bus, m->path, "org.freedesktop.systemd.ValueTest", "Value", NULL) >= 0); - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); return 1; @@ -145,7 +145,7 @@ static int emit_interfaces_added(sd_bus *bus, sd_bus_message *m, void *userdata) assert_se(sd_bus_emit_interfaces_added(bus, m->path, "org.freedesktop.systemd.test", NULL) >= 0); - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); return 1; @@ -156,7 +156,7 @@ static int emit_interfaces_removed(sd_bus *bus, sd_bus_message *m, void *userdat assert_se(sd_bus_emit_interfaces_removed(bus, m->path, "org.freedesktop.systemd.test", NULL) >= 0); - r = sd_bus_reply_method_return(bus, m, NULL); + r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); return 1; diff --git a/src/libsystemd-bus/test-bus-server.c b/src/libsystemd-bus/test-bus-server.c index a9db1f4101..33a5dd5f6f 100644 --- a/src/libsystemd-bus/test-bus-server.c +++ b/src/libsystemd-bus/test-bus-server.c @@ -88,7 +88,7 @@ static void *server(void *p) { assert_se((sd_bus_can_send(bus, 'h') >= 1) == (c->server_negotiate_unix_fds && c->client_negotiate_unix_fds)); - r = sd_bus_message_new_method_return(bus, m, &reply); + r = sd_bus_message_new_method_return(m, &reply); if (r < 0) { log_error("Failed to allocate return: %s", strerror(-r)); goto fail; @@ -98,7 +98,7 @@ static void *server(void *p) { } else if (sd_bus_message_is_method_call(m, NULL, NULL)) { r = sd_bus_message_new_method_error( - bus, m, + m, &SD_BUS_ERROR_MAKE(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method."), &reply); if (r < 0) { diff --git a/src/locale/localed.c b/src/locale/localed.c index 1248f20c9b..7bf80fbf2b 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -825,11 +825,11 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata) { r = bus_message_read_strv_extend(m, &l); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); r = sd_bus_message_read_basic(m, 'b', &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); /* Check whether a variable changed and if so valid */ STRV_FOREACH(i, l) { @@ -853,7 +853,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata) { } if (!valid) - sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid Locale data."); + sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid Locale data."); } /* Check whether a variable is unset */ @@ -870,7 +870,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata) { "org.freedesktop.locale1.set-locale", interactive, &error, method_set_locale, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -905,7 +905,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata) { r = locale_write_data(c); if (r < 0) { log_error("Failed to set locale: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set locale: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set locale: %s", strerror(-r)); } locale_update_system_manager(c, bus); @@ -918,7 +918,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata) { "Locale", NULL); } - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata) { @@ -930,7 +930,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata r = sd_bus_message_read(m, "ssbb", &keymap, &keymap_toggle, &convert, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (isempty(keymap)) keymap = NULL; @@ -943,13 +943,13 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata if ((keymap && (!filename_is_safe(keymap) || !string_is_safe(keymap))) || (keymap_toggle && (!filename_is_safe(keymap_toggle) || !string_is_safe(keymap_toggle)))) - return sd_bus_reply_method_errnof(bus, m, r, "Received invalid keymap data: %s", -EINVAL); + return sd_bus_reply_method_errnof(m, r, "Received invalid keymap data: %s", -EINVAL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.locale1.set-keyboard", interactive, &error, method_set_vc_keyboard, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -960,7 +960,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata r = vconsole_write_data(c); if (r < 0) { log_error("Failed to set virtual console keymap: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set virtual console keymap: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set virtual console keymap: %s", strerror(-r)); } log_info("Changed virtual console keymap to '%s'", strempty(c->vc_keymap)); @@ -981,7 +981,7 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata } } - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata) { @@ -993,7 +993,7 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat r = sd_bus_message_read(m, "ssssbb", &layout, &model, &variant, &options, &convert, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (isempty(layout)) layout = NULL; @@ -1016,13 +1016,13 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat (model && !string_is_safe(model)) || (variant && !string_is_safe(variant)) || (options && !string_is_safe(options))) - return sd_bus_reply_method_errnof(bus, m, r, "Received invalid keyboard data: %s", -EINVAL); + return sd_bus_reply_method_errnof(m, r, "Received invalid keyboard data: %s", -EINVAL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.locale1.set-keyboard", interactive, &error, method_set_x11_keyboard, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -1035,7 +1035,7 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat r = write_data_x11(c); if (r < 0) { log_error("Failed to set X11 keyboard layout: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set X11 keyboard layout: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set X11 keyboard layout: %s", strerror(-r)); } log_info("Changed X11 keyboard layout to '%s'", strempty(c->x11_layout)); @@ -1052,7 +1052,7 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat } } - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static const sd_bus_vtable locale_vtable[] = { diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 7e6f6109dc..984235c4e5 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -141,17 +141,17 @@ static int method_get_session(sd_bus *bus, sd_bus_message *message, void *userda r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(m->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); p = session_bus_path(session); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_get_session_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -169,25 +169,25 @@ static int method_get_session_by_pid(sd_bus *bus, sd_bus_message *message, void r = sd_bus_message_read(message, "u", &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (pid == 0) { r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = manager_get_session_by_pid(m, pid, &session); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SESSION_FOR_PID, "PID %lu does not belong to any known session", (unsigned long) pid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SESSION_FOR_PID, "PID %lu does not belong to any known session", (unsigned long) pid); p = session_bus_path(session); if (!p) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -203,17 +203,17 @@ static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata) r = sd_bus_message_read(message, "u", &uid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (!user) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); p = user_bus_path(user); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_get_user_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -231,25 +231,25 @@ static int method_get_user_by_pid(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read(message, "u", &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (pid == 0) { r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = manager_get_user_by_pid(m, pid, &user); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!user) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_USER_FOR_PID, "PID %lu does not belong to any known or logged in user", (unsigned long) pid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_USER_FOR_PID, "PID %lu does not belong to any known or logged in user", (unsigned long) pid); p = user_bus_path(user); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_get_seat(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -265,17 +265,17 @@ static int method_get_seat(sd_bus *bus, sd_bus_message *message, void *userdata) r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); seat = hashmap_get(m->seats, name); if (!seat) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name); p = seat_bus_path(seat); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -289,20 +289,20 @@ static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *user assert(message); assert(m); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(susso)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH(session, m->sessions, i) { _cleanup_free_ char *p = NULL; p = session_bus_path(session); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); r = sd_bus_message_append(reply, "(susso)", session->id, @@ -311,12 +311,12 @@ static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *user session->seat ? session->seat->id : "", p); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -332,32 +332,32 @@ static int method_list_users(sd_bus *bus, sd_bus_message *message, void *userdat assert(message); assert(m); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(uso)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH(user, m->users, i) { _cleanup_free_ char *p = NULL; p = user_bus_path(user); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); r = sd_bus_message_append(reply, "(uso)", (uint32_t) user->uid, user->name, p); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -373,29 +373,29 @@ static int method_list_seats(sd_bus *bus, sd_bus_message *message, void *userdat assert(message); assert(m); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(so)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH(seat, m->seats, i) { _cleanup_free_ char *p = NULL; p = seat_bus_path(seat); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); r = sd_bus_message_append(reply, "(so)", seat->id, p); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -407,13 +407,13 @@ static int method_list_inhibitors(sd_bus *bus, sd_bus_message *message, void *us Iterator i; int r; - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(ssssuu)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH(inhibitor, m->inhibitors, i) { @@ -425,12 +425,12 @@ static int method_list_inhibitors(sd_bus *bus, sd_bus_message *message, void *us (uint32_t) inhibitor->uid, (uint32_t) inhibitor->pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -455,17 +455,17 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use r = sd_bus_message_read(message, "uussssussbss", &uid, &leader, &service, &type, &class, &cseat, &vtnr, &tty, &display, &remote, &remote_user, &remote_host); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (leader == 1) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID"); if (isempty(type)) t = _SESSION_TYPE_INVALID; else { t = session_type_from_string(type); if (t < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid session type %s", type); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid session type %s", type); } if (isempty(class)) @@ -473,7 +473,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use else { c = session_class_from_string(class); if (c < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid session class %s", class); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid session class %s", class); } if (isempty(cseat)) @@ -481,7 +481,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use else { seat = hashmap_get(m->seats, cseat); if (!seat) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", seat); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", seat); } if (tty_is_vc(tty)) { @@ -490,41 +490,41 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (!seat) seat = m->seat0; else if (seat != m->seat0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "TTY %s is virtual console but seat %s is not seat0", tty, seat); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "TTY %s is virtual console but seat %s is not seat0", tty, seat); v = vtnr_from_tty(tty); if (v <= 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Cannot determine VT number from virtual console TTY %s", tty); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Cannot determine VT number from virtual console TTY %s", tty); if (vtnr <= 0) vtnr = (uint32_t) v; else if (vtnr != (uint32_t) v) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Specified TTY and VT number do not match"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Specified TTY and VT number do not match"); } else if (tty_is_console(tty)) { if (!seat) seat = m->seat0; else if (seat != m->seat0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Console TTY specified but seat is not seat0"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Console TTY specified but seat is not seat0"); if (vtnr != 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Console TTY specified but VT number is not 0"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Console TTY specified but VT number is not 0"); } if (seat) { if (seat_has_vts(seat)) { if (vtnr > 63) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "VT number out of range"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "VT number out of range"); } else { if (vtnr != 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Seat has no VTs but VT number not 0"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Seat has no VTs but VT number not 0"); } } r = sd_bus_message_enter_container(message, 'a', "(sv)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (t == _SESSION_TYPE_INVALID) { if (!isempty(display)) @@ -547,7 +547,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), (pid_t*) &leader); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } manager_get_session_by_pid(m, leader, &session); @@ -561,14 +561,14 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use fifo_fd = session_create_fifo(session); if (fifo_fd < 0) - return sd_bus_reply_method_errno(bus, message, fifo_fd, NULL); + return sd_bus_reply_method_errno(message, fifo_fd, NULL); path = session_bus_path(session); if (!path) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); return sd_bus_reply_method_return( - bus, message, "soshsub", + message, "soshsub", session->id, path, session->user->runtime_path, @@ -583,7 +583,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use /* Keep our session IDs and the audit session IDs in sync */ if (asprintf(&id, "%lu", (unsigned long) audit_id) < 0) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); /* Wut? There's already a session by this name and we * didn't find it above? Weird, then let's not trust @@ -604,20 +604,20 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use id = NULL; if (asprintf(&id, "c%lu", ++m->session_counter) < 0) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); } while (hashmap_get(m->sessions, id)); } r = manager_add_user_by_uid(m, uid, &user); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } r = manager_add_session(m, id, &session); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } @@ -633,7 +633,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(tty)) { session->tty = strdup(tty); if (!session->tty) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } @@ -641,7 +641,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(display)) { session->display = strdup(display); if (!session->display) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } @@ -649,7 +649,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(remote_user)) { session->remote_user = strdup(remote_user); if (!session->remote_user) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } @@ -657,7 +657,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(remote_host)) { session->remote_host = strdup(remote_host); if (!session->remote_host) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } @@ -665,7 +665,7 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(service)) { session->service = strdup(service); if (!session->service) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } @@ -673,14 +673,14 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use if (seat) { r = seat_attach_session(seat, session); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } } r = session_start(session); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, NULL); + r = sd_bus_reply_method_errno(message, r, NULL); goto fail; } @@ -714,11 +714,11 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(m->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); /* We use the FIFO to detect stray sessions where the process invoking PAM dies abnormally. We need to make sure that @@ -730,7 +730,7 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us session_save(session); user_save(session->user); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -745,17 +745,17 @@ static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *u r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(m->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); r = session_activate(session); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_activate_session_on_seat(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -774,24 +774,24 @@ static int method_activate_session_on_seat(sd_bus *bus, sd_bus_message *message, r = sd_bus_message_read(message, "ss", &session_name, &seat_name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(m->sessions, session_name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", session_name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", session_name); seat = hashmap_get(m->seats, seat_name); if (!seat) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", seat_name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", seat_name); if (session->seat != seat) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_SESSION_NOT_ON_SEAT, "Session %s not on seat %s", session_name, seat_name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_SESSION_NOT_ON_SEAT, "Session %s not on seat %s", session_name, seat_name); r = session_activate(session); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_lock_session(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -806,17 +806,17 @@ static int method_lock_session(sd_bus *bus, sd_bus_message *message, void *userd r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(m->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); r = session_send_lock(session, streq(sd_bus_message_get_member(message), "LockSession")); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_lock_sessions(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -829,9 +829,9 @@ static int method_lock_sessions(sd_bus *bus, sd_bus_message *message, void *user r = session_send_lock_all(m, streq(sd_bus_message_get_member(message), "LockSessions")); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kill_session(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -848,28 +848,28 @@ static int method_kill_session(sd_bus *bus, sd_bus_message *message, void *userd r = sd_bus_message_read(message, "ssi", &name, &swho, &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(swho)) who = KILL_ALL; else { who = kill_who_from_string(swho); if (who < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); } if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); session = hashmap_get(m->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); r = session_kill(session, who, signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -885,20 +885,20 @@ static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata r = sd_bus_message_read(message, "ui", &uid, &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (!user) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); r = user_kill(user, signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -913,17 +913,17 @@ static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void * r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(m->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); r = session_stop(session); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -938,17 +938,17 @@ static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *use r = sd_bus_message_read(message, "u", &uid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); user = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (!user) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_USER, "No user '%lu' known or logged in", (unsigned long) uid); r = user_stop(user); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -963,17 +963,17 @@ static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *use r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); seat = hashmap_get(m->seats, name); if (!seat) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SEAT, "No seat '%s' known", name); r = seat_stop_sessions(seat); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -992,12 +992,12 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us r = sd_bus_message_read(message, "ubb", &uid, &b, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); errno = 0; pw = getpwuid(uid); if (!pw) - return sd_bus_reply_method_errno(bus, message, errno ? errno : ENOENT, NULL); + return sd_bus_reply_method_errno(message, errno ? errno : ENOENT, NULL); r = bus_verify_polkit_async(bus, &m->polkit_registry, @@ -1007,7 +1007,7 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us &error, method_set_user_linger, m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -1015,11 +1015,11 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us r = mkdir_safe_label("/var/lib/systemd/linger", 0755, 0, 0); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); cc = cescape(pw->pw_name); if (!cc) - return sd_bus_reply_method_errno(bus, message, ENOMEM, NULL); + return sd_bus_reply_method_errno(message, ENOMEM, NULL); path = strappenda("/var/lib/systemd/linger/", cc); if (b) { @@ -1027,7 +1027,7 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us r = touch(path); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (manager_add_user_by_uid(m, uid, &u) >= 0) user_start(u); @@ -1037,14 +1037,14 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us r = unlink(path); if (r < 0 && errno != ENOENT) - return sd_bus_reply_method_errno(bus, message, errno, NULL); + return sd_bus_reply_method_errno(message, errno, NULL); u = hashmap_get(m->users, ULONG_TO_PTR((unsigned long) uid)); if (u) user_add_to_gc_queue(u); } - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int trigger_device(Manager *m, struct udev_device *d) { @@ -1190,13 +1190,13 @@ static int method_attach_device(sd_bus *bus, sd_bus_message *message, void *user r = sd_bus_message_read(message, "ssb", &seat, &sysfs, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!path_startswith(sysfs, "/sys")) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Path %s is not in /sys", sysfs); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Path %s is not in /sys", sysfs); if (!seat_name_is_valid(seat)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Seat %s is not valid", seat); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Seat %s is not valid", seat); r = bus_verify_polkit_async(bus, &m->polkit_registry, @@ -1206,15 +1206,15 @@ static int method_attach_device(sd_bus *bus, sd_bus_message *message, void *user &error, method_attach_device, m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ r = attach_device(m, seat, sysfs); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_flush_devices(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1228,7 +1228,7 @@ static int method_flush_devices(sd_bus *bus, sd_bus_message *message, void *user r = sd_bus_message_read(message, "b", &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = bus_verify_polkit_async(bus, &m->polkit_registry, @@ -1238,15 +1238,15 @@ static int method_flush_devices(sd_bus *bus, sd_bus_message *message, void *user &error, method_flush_devices, m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ r = flush_devices(m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int have_multiple_sessions( @@ -1451,28 +1451,28 @@ static int method_do_shutdown_or_sleep( r = sd_bus_message_read(message, "b", &interactive); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); /* Don't allow multiple jobs being executed at the same time */ if (m->action_what) - return sd_bus_reply_method_errorf(m->bus, message, BUS_ERROR_OPERATION_IN_PROGRESS, "There's already a shutdown or sleep operation in progress"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_OPERATION_IN_PROGRESS, "There's already a shutdown or sleep operation in progress"); if (sleep_verb) { r = can_sleep(sleep_verb); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (r == 0) - return sd_bus_reply_method_errorf(m->bus, message, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, "Sleep verb not supported"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, "Sleep verb not supported"); } r = sd_bus_get_owner_uid(m->bus, sd_bus_message_get_sender(message), &uid); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = have_multiple_sessions(m, uid); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); multiple_sessions = r > 0; blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid); @@ -1481,28 +1481,28 @@ static int method_do_shutdown_or_sleep( r = bus_verify_polkit_async(m->bus, &m->polkit_registry, message, action_multiple_sessions, interactive, &error, method, m); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); } if (blocked) { r = bus_verify_polkit_async(m->bus, &m->polkit_registry, message, action_ignore_inhibit, interactive, &error, method, m); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); } if (!multiple_sessions && !blocked) { r = bus_verify_polkit_async(m->bus, &m->polkit_registry, message, action, interactive, &error, method, m); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); } r = bus_manager_shutdown_or_sleep_now_or_later(m, unit_name, w, &error); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); - return sd_bus_reply_method_return(m->bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1601,18 +1601,18 @@ static int method_can_shutdown_or_sleep( if (sleep_verb) { r = can_sleep(sleep_verb); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (r == 0) - return sd_bus_reply_method_return(m->bus, message, "s", "na"); + return sd_bus_reply_method_return(message, "s", "na"); } r = sd_bus_get_owner_uid(m->bus, sd_bus_message_get_sender(message), &uid); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = have_multiple_sessions(m, uid); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); multiple_sessions = r > 0; blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid); @@ -1620,7 +1620,7 @@ static int method_can_shutdown_or_sleep( if (multiple_sessions) { r = bus_verify_polkit(m->bus, message, action_multiple_sessions, false, &challenge, &error); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r > 0) result = "yes"; @@ -1633,7 +1633,7 @@ static int method_can_shutdown_or_sleep( if (blocked) { r = bus_verify_polkit(m->bus, message, action_ignore_inhibit, false, &challenge, &error); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r > 0 && !result) result = "yes"; @@ -1649,7 +1649,7 @@ static int method_can_shutdown_or_sleep( r = bus_verify_polkit(m->bus, message, action, false, &challenge, &error); if (r < 0) - return sd_bus_reply_method_errno(m->bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r > 0) result = "yes"; @@ -1659,7 +1659,7 @@ static int method_can_shutdown_or_sleep( result = "no"; } - return sd_bus_reply_method_return(m->bus, message, "s", result); + return sd_bus_reply_method_return(message, "s", result); } static int method_can_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -1741,26 +1741,26 @@ static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata) r = sd_bus_message_read(message, "ssss", &what, &who, &why, &mode); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); w = inhibit_what_from_string(what); if (w <= 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid what specification %s", what); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid what specification %s", what); mm = inhibit_mode_from_string(mode); if (mm < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid mode specification %s", mode); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid mode specification %s", mode); /* Delay is only supported for shutdown/sleep */ if (mm == INHIBIT_DELAY && (w & ~(INHIBIT_SHUTDOWN|INHIBIT_SLEEP))) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Delay inhibitors only supported for shutdown and sleep"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Delay inhibitors only supported for shutdown and sleep"); /* Don't allow taking delay locks while we are already * executing the operation. We shouldn't create the impression * that the lock was successful if the machine is about to go * down/suspend any moment. */ if (m->action_what & w) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_OPERATION_IN_PROGRESS, "The operation inhibition has been requested for is already running"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_OPERATION_IN_PROGRESS, "The operation inhibition has been requested for is already running"); r = bus_verify_polkit_async(bus, &m->polkit_registry, message, w == INHIBIT_SHUTDOWN ? (mm == INHIBIT_BLOCK ? "org.freedesktop.login1.inhibit-block-shutdown" : "org.freedesktop.login1.inhibit-delay-shutdown") : @@ -1772,30 +1772,30 @@ static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata) "org.freedesktop.login1.inhibit-handle-lid-switch", false, &error, method_inhibit, m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, &error); + return sd_bus_reply_method_errno(message, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ r = sd_bus_get_owner_uid(m->bus, sd_bus_message_get_sender(message), &uid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_get_owner_pid(m->bus, sd_bus_message_get_sender(message), &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); do { free(id); id = NULL; if (asprintf(&id, "%lu", ++m->inhibit_counter) < 0) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); } while (hashmap_get(m->inhibitors, id)); r = manager_add_inhibitor(m, id, &i); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); i->what = w; i->mode = mm; @@ -1805,19 +1805,19 @@ static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata) i->who = strdup(who); if (!i->why || !i->who) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } fifo_fd = inhibitor_create_fifo(i); if (fifo_fd < 0) { - r = sd_bus_reply_method_errno(bus, message, fifo_fd, NULL); + r = sd_bus_reply_method_errno(message, fifo_fd, NULL); goto fail; } inhibitor_start(i); - return sd_bus_reply_method_return(bus, message, "h", fifo_fd); + return sd_bus_reply_method_return(message, "h", fifo_fd); fail: if (i) diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c index 268cd993aa..02dbc625ca 100644 --- a/src/login/logind-seat-dbus.c +++ b/src/login/logind-seat-dbus.c @@ -202,9 +202,9 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata r = seat_stop_sessions(s); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -219,20 +219,20 @@ static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *u r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); session = hashmap_get(s->manager->sessions, name); if (!session) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name); if (session->seat != s) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_SESSION_NOT_ON_SEAT, "Session %s not on seat %s", name, s->id); + return sd_bus_reply_method_errorf(message, BUS_ERROR_SESSION_NOT_ON_SEAT, "Session %s not on seat %s", name, s->id); r = session_activate(session); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable seat_vtable[] = { diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index cebdfe311a..bf4cccbd17 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -189,9 +189,9 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata r = session_stop(s); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_activate(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -204,9 +204,9 @@ static int method_activate(sd_bus *bus, sd_bus_message *message, void *userdata) r = session_activate(s); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_lock(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -219,9 +219,9 @@ static int method_lock(sd_bus *bus, sd_bus_message *message, void *userdata) { r = session_send_lock(s, streq(sd_bus_message_get_member(message), "Lock")); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_set_idle_hint(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -235,18 +235,18 @@ static int method_set_idle_hint(sd_bus *bus, sd_bus_message *message, void *user r = sd_bus_message_read(message, "b", &b); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_get_owner_uid(bus, sd_bus_message_get_sender(message), &uid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (uid != 0 && uid != s->user->uid) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session my set idle hint"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session my set idle hint"); session_set_idle_hint(s, b); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -262,24 +262,24 @@ static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { r = sd_bus_message_read(message, "si", &swho, &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(swho)) who = KILL_ALL; else { who = kill_who_from_string(swho); if (who < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); } if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); r = session_kill(s, who, signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_take_control(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -293,20 +293,20 @@ static int method_take_control(sd_bus *bus, sd_bus_message *message, void *userd r = sd_bus_message_read(message, "b", &force); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_get_owner_uid(bus, sd_bus_message_get_sender(message), &uid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (uid != 0 && (force || uid != s->user->uid)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may take control"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may take control"); r = session_set_controller(s, sd_bus_message_get_sender(message), force); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_release_control(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -317,11 +317,11 @@ static int method_release_control(sd_bus *bus, sd_bus_message *message, void *us assert(s); if (!session_is_controller(s, sd_bus_message_get_sender(message))) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); session_drop_controller(s); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_take_device(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -337,10 +337,10 @@ static int method_take_device(sd_bus *bus, sd_bus_message *message, void *userda r = sd_bus_message_read(message, "uu", &major, &minor); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!session_is_controller(s, sd_bus_message_get_sender(message))) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); dev = makedev(major, minor); sd = hashmap_get(s->devices, &dev); @@ -350,13 +350,13 @@ static int method_take_device(sd_bus *bus, sd_bus_message *message, void *userda * The caller should use dup() if it requires more * than one fd (it would be functionally * equivalent). */ - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_DEVICE_IS_TAKEN, "Device already taken"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_DEVICE_IS_TAKEN, "Device already taken"); r = session_device_new(s, dev, &sd); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - r = sd_bus_reply_method_return(bus, message, "hb", sd->fd, !sd->active); + r = sd_bus_reply_method_return(message, "hb", sd->fd, !sd->active); if (r < 0) session_device_free(sd); @@ -376,18 +376,18 @@ static int method_release_device(sd_bus *bus, sd_bus_message *message, void *use r = sd_bus_message_read(message, "uu", &major, &minor); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!session_is_controller(s, sd_bus_message_get_sender(message))) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); dev = makedev(major, minor); sd = hashmap_get(s->devices, &dev); if (!sd) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken"); session_device_free(sd); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_pause_device_complete(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -403,19 +403,19 @@ static int method_pause_device_complete(sd_bus *bus, sd_bus_message *message, vo r = sd_bus_message_read(message, "uu", &major, &minor); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!session_is_controller(s, sd_bus_message_get_sender(message))) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); dev = makedev(major, minor); sd = hashmap_get(s->devices, &dev); if (!sd) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken"); + return sd_bus_reply_method_errorf(message, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken"); session_device_complete_pause(sd); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable session_vtable[] = { @@ -643,7 +643,7 @@ int session_send_create_reply(Session *s, sd_bus_error *error) { s->create_message = NULL; if (error) - return sd_bus_reply_method_error(s->manager->bus, c, error); + return sd_bus_reply_method_error(c, error); fifo_fd = session_create_fifo(s); if (fifo_fd < 0) @@ -667,7 +667,7 @@ int session_send_create_reply(Session *s, sd_bus_error *error) { (uint32_t) s->vtnr); return sd_bus_reply_method_return( - s->manager->bus, c, + c, "soshsub", s->id, p, diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c index 563c7ef6be..cf106c6013 100644 --- a/src/login/logind-user-dbus.c +++ b/src/login/logind-user-dbus.c @@ -182,9 +182,9 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata r = user_stop(u); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -198,16 +198,16 @@ static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { r = sd_bus_message_read(message, "i", &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); r = user_kill(u, signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable user_vtable[] = { diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 7f3b486035..8e671edba3 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -87,9 +87,9 @@ static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata r = machine_stop(m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -105,24 +105,24 @@ static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata) { r = sd_bus_message_read(message, "si", &swho, &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(swho)) who = KILL_ALL; else { who = kill_who_from_string(swho); if (who < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); } if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); r = machine_kill(m, who, signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable machine_vtable[] = { @@ -262,7 +262,7 @@ int machine_send_create_reply(Machine *m, sd_bus_error *error) { m->create_message = NULL; if (error) - return sd_bus_reply_method_error(m->manager->bus, c, error); + return sd_bus_reply_method_error(c, error); /* Update the machine state file before we notify the client * about the result. */ @@ -272,5 +272,5 @@ int machine_send_create_reply(Machine *m, sd_bus_error *error) { if (!p) return -ENOMEM; - return sd_bus_reply_method_return(m->manager->bus, c, "o", p); + return sd_bus_reply_method_return(c, "o", p); } diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index be0dbe0097..2bf18a2b6e 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -71,17 +71,17 @@ static int method_get_machine(sd_bus *bus, sd_bus_message *message, void *userda r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); machine = hashmap_get(m->machines, name); if (!machine) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); p = machine_bus_path(machine); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_get_machine_by_pid(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -99,25 +99,25 @@ static int method_get_machine_by_pid(sd_bus *bus, sd_bus_message *message, void r = sd_bus_message_read(message, "u", &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (pid == 0) { r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), &pid); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = manager_get_machine_by_pid(m, pid, &machine); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!machine) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_MACHINE_FOR_PID, "PID %lu does not belong to any known machine", (unsigned long) pid); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_MACHINE_FOR_PID, "PID %lu does not belong to any known machine", (unsigned long) pid); p = machine_bus_path(machine); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); - return sd_bus_reply_method_return(bus, message, "o", p); + return sd_bus_reply_method_return(message, "o", p); } static int method_list_machines(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -131,20 +131,20 @@ static int method_list_machines(sd_bus *bus, sd_bus_message *message, void *user assert(message); assert(m); - r = sd_bus_message_new_method_return(bus, message, &reply); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); r = sd_bus_message_open_container(reply, 'a', "(ssso)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); HASHMAP_FOREACH(machine, m->machines, i) { _cleanup_free_ char *p = NULL; p = machine_bus_path(machine); if (!p) - return sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + return sd_bus_reply_method_errno(message, -ENOMEM, NULL); r = sd_bus_message_append(reply, "(ssso)", machine->name, @@ -152,12 +152,12 @@ static int method_list_machines(sd_bus *bus, sd_bus_message *message, void *user machine->service, p); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } r = sd_bus_message_close_container(reply); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); return sd_bus_send(bus, reply, NULL); } @@ -180,56 +180,56 @@ static int method_create_machine(sd_bus *bus, sd_bus_message *message, void *use r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (!valid_machine_name(name)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine name"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine name"); r = sd_bus_message_read_array(message, 'y', &v, &n); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (n == 0) id = SD_ID128_NULL; else if (n == 16) memcpy(&id, v, n); else - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine ID parameter"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine ID parameter"); r = sd_bus_message_read(message, "ssus", &service, &class, &leader, &root_directory); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(class)) c = _MACHINE_CLASS_INVALID; else { c = machine_class_from_string(class); if (c < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter"); } if (leader == 1) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID"); if (!isempty(root_directory) && !path_is_absolute(root_directory)) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Root directory must be empty or an absolute path"); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Root directory must be empty or an absolute path"); r = sd_bus_message_enter_container(message, 'a', "(sv)"); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (leader == 0) { assert_cc(sizeof(uint32_t) == sizeof(pid_t)); r = sd_bus_get_owner_pid(bus, sd_bus_message_get_sender(message), (pid_t*) &leader); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); } if (hashmap_get(manager->machines, name)) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_MACHINE_EXISTS, "Machine '%s' already exists", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_MACHINE_EXISTS, "Machine '%s' already exists", name); r = manager_add_machine(manager, name, &m); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); m->leader = leader; m->class = c; @@ -238,7 +238,7 @@ static int method_create_machine(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(service)) { m->service = strdup(service); if (!m->service) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } @@ -246,14 +246,14 @@ static int method_create_machine(sd_bus *bus, sd_bus_message *message, void *use if (!isempty(root_directory)) { m->root_directory = strdup(root_directory); if (!m->root_directory) { - r = sd_bus_reply_method_errno(bus, message, -ENOMEM, NULL); + r = sd_bus_reply_method_errno(message, -ENOMEM, NULL); goto fail; } } r = machine_start(m, message, &error); if (r < 0) { - r = sd_bus_reply_method_errno(bus, message, r, &error); + r = sd_bus_reply_method_errno(message, r, &error); goto fail; } @@ -279,17 +279,17 @@ static int method_terminate_machine(sd_bus *bus, sd_bus_message *message, void * r = sd_bus_message_read(message, "s", &name); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); machine = hashmap_get(m->machines, name); if (!machine) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); r = machine_stop(machine); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } static int method_kill_machine(sd_bus *bus, sd_bus_message *message, void *userdata) { @@ -307,28 +307,28 @@ static int method_kill_machine(sd_bus *bus, sd_bus_message *message, void *userd r = sd_bus_message_read(message, "ssi", &name, &swho, &signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); if (isempty(swho)) who = KILL_ALL; else { who = kill_who_from_string(swho); if (who < 0) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); } if (signo <= 0 || signo >= _NSIG) - return sd_bus_reply_method_errorf(bus, message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); + return sd_bus_reply_method_errorf(message, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); machine = hashmap_get(m->machines, name); if (!machine) - return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); + return sd_bus_reply_method_errorf(message, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); r = machine_kill(machine, who, signo); if (r < 0) - return sd_bus_reply_method_errno(bus, message, r, NULL); + return sd_bus_reply_method_errno(message, r, NULL); - return sd_bus_reply_method_return(bus, message, NULL); + return sd_bus_reply_method_return(message, NULL); } const sd_bus_vtable manager_vtable[] = { diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index fb7925cd26..6537a77164 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -139,11 +139,11 @@ int sd_bus_remove_object_manager(sd_bus *bus, const char *path); /* Message object */ int sd_bus_message_new_signal(sd_bus *bus, const char *path, const char *interface, const char *member, sd_bus_message **m); int sd_bus_message_new_method_call(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message **m); -int sd_bus_message_new_method_return(sd_bus *bus, sd_bus_message *call, sd_bus_message **m); -int sd_bus_message_new_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m); -int sd_bus_message_new_method_errorf(sd_bus *bus, sd_bus_message *call, sd_bus_message **m, const char *name, const char *format, ...) _sd_printf_(5, 0); -int sd_bus_message_new_method_errno(sd_bus *bus, sd_bus_message *call, int error, const sd_bus_error *e, sd_bus_message **m); -int sd_bus_message_new_method_errnof(sd_bus *bus, sd_bus_message *call, sd_bus_message **m, int error, const char *format, ...) _sd_printf_(5, 0); +int sd_bus_message_new_method_return(sd_bus_message *call, sd_bus_message **m); +int sd_bus_message_new_method_error(sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m); +int sd_bus_message_new_method_errorf(sd_bus_message *call, sd_bus_message **m, const char *name, const char *format, ...) _sd_printf_(4, 0); +int sd_bus_message_new_method_errno(sd_bus_message *call, int error, const sd_bus_error *e, sd_bus_message **m); +int sd_bus_message_new_method_errnof(sd_bus_message *call, sd_bus_message **m, int error, const char *format, ...) _sd_printf_(4, 0); sd_bus_message* sd_bus_message_ref(sd_bus_message *m); sd_bus_message* sd_bus_message_unref(sd_bus_message *m); @@ -227,11 +227,11 @@ int sd_bus_get_property_string(sd_bus *bus, const char *destination, const char int sd_bus_get_property_strv(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, char ***ret); /* free the result! */ int sd_bus_set_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, const char *type, ...); -int sd_bus_reply_method_return(sd_bus *bus, sd_bus_message *call, const char *types, ...); -int sd_bus_reply_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e); -int sd_bus_reply_method_errorf(sd_bus *bus, sd_bus_message *call, const char *name, const char *format, ...) _sd_printf_(4, 0); -int sd_bus_reply_method_errno(sd_bus *bus, sd_bus_message *call, int error, const sd_bus_error *e); -int sd_bus_reply_method_errnof(sd_bus *bus, sd_bus_message *call, int error, const char *format, ...) _sd_printf_(4, 0); +int sd_bus_reply_method_return(sd_bus_message *call, const char *types, ...); +int sd_bus_reply_method_error(sd_bus_message *call, const sd_bus_error *e); +int sd_bus_reply_method_errorf(sd_bus_message *call, const char *name, const char *format, ...) _sd_printf_(3, 0); +int sd_bus_reply_method_errno(sd_bus_message *call, int error, const sd_bus_error *e); +int sd_bus_reply_method_errnof(sd_bus_message *call, int error, const char *format, ...) _sd_printf_(3, 0); int sd_bus_emit_signal(sd_bus *bus, const char *path, const char *interface, const char *member, const char *types, ...); diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 0ae93d852d..735e090e62 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -533,17 +533,17 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata) { r = sd_bus_message_read(m, "sb", &z, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (!valid_timezone(z)) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid time zone '%s'", z); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid time zone '%s'", z); if (streq_ptr(z, c->zone)) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.timedate1.set-timezone", interactive, &error, method_set_timezone, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ @@ -558,7 +558,7 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata) { r = context_write_data_timezone(c); if (r < 0) { log_error("Failed to set timezone: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set timezone: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set timezone: %s", strerror(-r)); } /* 2. Tell the kernel our timezone */ @@ -582,7 +582,7 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata) { sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata) { @@ -598,14 +598,14 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata) r = sd_bus_message_read(m, "bbb", &lrtc, &fix_system, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (lrtc == c->local_rtc) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.timedate1.set-local-rtc", interactive, &error, method_set_local_rtc, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; @@ -615,7 +615,7 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata) r = context_write_data_local_rtc(c); if (r < 0) { log_error("Failed to set RTC to local/UTC: %s", strerror(-r)); - return sd_bus_reply_method_errnof(bus, m, r, "Failed to set RTC to local/UTC: %s", strerror(-r)); + return sd_bus_reply_method_errnof(m, r, "Failed to set RTC to local/UTC: %s", strerror(-r)); } /* 2. Tell the kernel our timezone */ @@ -666,7 +666,7 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata) sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "LocalRTC", NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) { @@ -684,13 +684,13 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) { r = sd_bus_message_read(m, "xbb", &utc, &relative, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if (!relative && utc <= 0) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Invalid absolute time"); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Invalid absolute time"); if (relative && utc == 0) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); if (relative) { usec_t n, x; @@ -700,7 +700,7 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) { if ((utc > 0 && x < n) || (utc < 0 && x > n)) - return sd_bus_reply_method_errorf(bus, m, SD_BUS_ERROR_INVALID_ARGS, "Time value overflow"); + return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Time value overflow"); timespec_store(&ts, x); } else @@ -708,14 +708,14 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) { r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.timedate1.set-time", interactive, &error, method_set_time, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; /* Set system clock */ if (clock_settime(CLOCK_REALTIME, &ts) < 0) { log_error("Failed to set local time: %m"); - return sd_bus_reply_method_errnof(bus, m, errno, "Failed to set local time: %m"); + return sd_bus_reply_method_errnof(m, errno, "Failed to set local time: %m"); } /* Sync down to RTC */ @@ -732,7 +732,7 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) { "MESSAGE=Changed local time to %s", ctime(&ts.tv_sec), NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata) { @@ -743,14 +743,14 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata) { r = sd_bus_message_read(m, "bb", &ntp, &interactive); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, NULL); + return sd_bus_reply_method_errno(m, r, NULL); if ((bool)ntp == c->use_ntp) - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); r = bus_verify_polkit_async(bus, &c->polkit_registry, m, "org.freedesktop.timedate1.set-ntp", interactive, &error, method_set_ntp, c); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); if (r == 0) return 1; @@ -758,17 +758,17 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata) { r = context_enable_ntp(c, bus, &error); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); r = context_start_ntp(c, bus, &error); if (r < 0) - return sd_bus_reply_method_errno(bus, m, r, &error); + return sd_bus_reply_method_errno(m, r, &error); log_info("Set NTP to %s", c->use_ntp ? "enabled" : "disabled"); sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL); - return sd_bus_reply_method_return(bus, m, NULL); + return sd_bus_reply_method_return(m, NULL); } static const sd_bus_vtable timedate_vtable[] = { |