diff options
40 files changed, 456 insertions, 556 deletions
diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index fa1d1f3389..cd6b909426 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -52,11 +52,10 @@ static int property_get_unit( return sd_bus_message_append(reply, "(so)", j->unit->id, p); } -int bus_job_method_cancel(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_job_method_cancel(sd_bus_message *message, void *userdata, sd_bus_error *error) { Job *j = userdata; int r; - assert(bus); assert(message); assert(j); diff --git a/src/core/dbus-job.h b/src/core/dbus-job.h index 6c2fc0789c..fb5f1b513e 100644 --- a/src/core/dbus-job.h +++ b/src/core/dbus-job.h @@ -26,7 +26,7 @@ extern const sd_bus_vtable bus_job_vtable[]; -int bus_job_method_cancel(sd_bus *bus, sd_bus_message *message, void *job, sd_bus_error *error); +int bus_job_method_cancel(sd_bus_message *message, void *job, sd_bus_error *error); void bus_job_send_change_signal(Job *j); void bus_job_send_removed_signal(Job *j); diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 8821cc7820..5fb0da2cb2 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -343,14 +343,13 @@ static int property_set_runtime_watchdog( return watchdog_set_timeout(t); } -static int method_get_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *path = NULL; Manager *m = userdata; const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -392,14 +391,13 @@ static int method_get_unit(sd_bus *bus, sd_bus_message *message, void *userdata, 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, sd_bus_error *error) { +static int method_get_unit_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *path = NULL; Manager *m = userdata; pid_t pid; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -440,14 +438,13 @@ static int method_get_unit_by_pid(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_reply_method_return(message, "o", path); } -static int method_load_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_load_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *path = NULL; Manager *m = userdata; const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -489,12 +486,11 @@ static int method_load_unit(sd_bus *bus, sd_bus_message *message, void *userdata 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, sd_bus_error *error) { +static int method_start_unit_generic(sd_bus_message *message, Manager *m, JobType job_type, bool reload_if_possible, sd_bus_error *error) { const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -506,44 +502,43 @@ static int method_start_unit_generic(sd_bus *bus, sd_bus_message *message, Manag if (r < 0) return r; - return bus_unit_method_start_generic(bus, message, u, job_type, reload_if_possible, error); + return bus_unit_method_start_generic(message, u, job_type, reload_if_possible, error); } -static int method_start_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_START, false, error); +static int method_start_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_START, false, error); } -static int method_stop_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_STOP, false, error); +static int method_stop_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_STOP, false, error); } -static int method_reload_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_RELOAD, false, error); +static int method_reload_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_RELOAD, false, error); } -static int method_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_RESTART, false, error); +static int method_restart_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_RESTART, false, error); } -static int method_try_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_TRY_RESTART, false, error); +static int method_try_restart_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_TRY_RESTART, false, error); } -static int method_reload_or_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_RESTART, true, error); +static int method_reload_or_restart_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_RESTART, true, error); } -static int method_reload_or_try_restart_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_start_unit_generic(bus, message, userdata, JOB_TRY_RESTART, true, error); +static int method_reload_or_try_restart_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_start_unit_generic(message, userdata, JOB_TRY_RESTART, true, error); } -static int method_start_unit_replace(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_start_unit_replace(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *old_name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -555,16 +550,15 @@ static int method_start_unit_replace(sd_bus *bus, sd_bus_message *message, void if (!u || !u->job || u->job->type != JOB_START) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_JOB, "No job queued for unit %s", old_name); - return method_start_unit_generic(bus, message, m, JOB_START, false, error); + return method_start_unit_generic(message, m, JOB_START, false, error); } -static int method_kill_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_kill_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -576,16 +570,15 @@ static int method_kill_unit(sd_bus *bus, sd_bus_message *message, void *userdata if (!u) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); - return bus_unit_method_kill(bus, message, u, error); + return bus_unit_method_kill(message, u, error); } -static int method_reset_failed_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_reset_failed_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -597,16 +590,15 @@ static int method_reset_failed_unit(sd_bus *bus, sd_bus_message *message, void * if (!u) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); - return bus_unit_method_reset_failed(bus, message, u, error); + return bus_unit_method_reset_failed(message, u, error); } -static int method_set_unit_properties(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_unit_properties(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -618,7 +610,7 @@ static int method_set_unit_properties(sd_bus *bus, sd_bus_message *message, void if (!u) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); - return bus_unit_method_set_properties(bus, message, u, error); + return bus_unit_method_set_properties(message, u, error); } static int transient_unit_from_message( @@ -704,7 +696,7 @@ static int transient_aux_units_from_message( return 0; } -static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_start_transient_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *name, *smode; Manager *m = userdata; JobMode mode; @@ -712,7 +704,6 @@ static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, voi Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -757,17 +748,16 @@ static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, voi manager_dispatch_load_queue(m); /* Finally, start it */ - return bus_unit_queue_job(bus, message, u, JOB_START, mode, false, error); + return bus_unit_queue_job(message, u, JOB_START, mode, false, error); } -static int method_get_job(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_job(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *path = NULL; Manager *m = userdata; uint32_t id; Job *j; int r; - assert(bus); assert(message); assert(m); @@ -792,13 +782,12 @@ static int method_get_job(sd_bus *bus, sd_bus_message *message, void *userdata, return sd_bus_reply_method_return(message, "o", path); } -static int method_cancel_job(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_cancel_job(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; uint32_t id; Job *j; int r; - assert(bus); assert(message); assert(m); @@ -810,14 +799,13 @@ static int method_cancel_job(sd_bus *bus, sd_bus_message *message, void *userdat if (!j) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id); - return bus_job_method_cancel(bus, message, j, error); + return bus_job_method_cancel(message, j, error); } -static int method_clear_jobs(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_clear_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -836,11 +824,10 @@ static int method_clear_jobs(sd_bus *bus, sd_bus_message *message, void *userdat return sd_bus_reply_method_return(message, NULL); } -static int method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -859,7 +846,7 @@ static int method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userd return sd_bus_reply_method_return(message, NULL); } -static int list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error, char **states) { +static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_error *error, char **states) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; const char *k; @@ -867,7 +854,6 @@ static int list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userd Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -930,14 +916,14 @@ static int list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userd if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return list_units_filtered(bus, message, userdata, error, NULL); +static int method_list_units(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return list_units_filtered(message, userdata, error, NULL); } -static int method_list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **states = NULL; int r; @@ -945,17 +931,16 @@ static int method_list_units_filtered(sd_bus *bus, sd_bus_message *message, void if (r < 0) return r; - return list_units_filtered(bus, message, userdata, error, states); + return list_units_filtered(message, userdata, error, states); } -static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; Iterator i; Job *j; int r; - assert(bus); assert(message); assert(m); @@ -1000,14 +985,13 @@ static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -static int method_subscribe(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_subscribe(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1017,13 +1001,13 @@ static int method_subscribe(sd_bus *bus, sd_bus_message *message, void *userdata if (r < 0) return r; - if (bus == m->api_bus) { + if (sd_bus_message_get_bus(message) == m->api_bus) { /* Note that direct bus connection subscribe by * default, we only track peers on the API bus here */ if (!m->subscribed) { - r = sd_bus_track_new(bus, &m->subscribed, NULL, NULL); + r = sd_bus_track_new(sd_bus_message_get_bus(message), &m->subscribed, NULL, NULL); if (r < 0) return r; } @@ -1038,11 +1022,10 @@ static int method_subscribe(sd_bus *bus, sd_bus_message *message, void *userdata return sd_bus_reply_method_return(message, NULL); } -static int method_unsubscribe(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_unsubscribe(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1052,7 +1035,7 @@ static int method_unsubscribe(sd_bus *bus, sd_bus_message *message, void *userda if (r < 0) return r; - if (bus == m->api_bus) { + if (sd_bus_message_get_bus(message) == m->api_bus) { r = sd_bus_track_remove_sender(m->subscribed, message); if (r < 0) return r; @@ -1063,14 +1046,13 @@ static int method_unsubscribe(sd_bus *bus, sd_bus_message *message, void *userda return sd_bus_reply_method_return(message, NULL); } -static int method_dump(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_dump(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *dump = NULL; _cleanup_fclose_ FILE *f = NULL; Manager *m = userdata; size_t size; int r; - assert(bus); assert(message); assert(m); @@ -1095,7 +1077,7 @@ static int method_dump(sd_bus *bus, sd_bus_message *message, void *userdata, sd_ return sd_bus_reply_method_return(message, "s", dump); } -static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_create_snapshot(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *path = NULL; Manager *m = userdata; const char *name; @@ -1103,7 +1085,6 @@ static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *us Snapshot *s = NULL; int r; - assert(bus); assert(message); assert(m); @@ -1135,13 +1116,12 @@ static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_reply_method_return(message, "o", path); } -static int method_remove_snapshot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_remove_snapshot(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; Unit *u; int r; - assert(bus); assert(message); assert(m); @@ -1156,14 +1136,13 @@ static int method_remove_snapshot(sd_bus *bus, sd_bus_message *message, void *us if (u->type != UNIT_SNAPSHOT) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not a snapshot", name); - return bus_snapshot_method_remove(bus, message, u, error); + return bus_snapshot_method_remove(message, u, error); } -static int method_reload(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1187,17 +1166,16 @@ static int method_reload(sd_bus *bus, sd_bus_message *message, void *userdata, s if (r < 0) return r; - m->queued_message_bus = sd_bus_ref(bus); + m->queued_message_bus = sd_bus_ref(sd_bus_message_get_bus(message)); m->exit_code = MANAGER_RELOAD; return 1; } -static int method_reexecute(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_reexecute(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1218,11 +1196,10 @@ static int method_reexecute(sd_bus *bus, sd_bus_message *message, void *userdata return 1; } -static int method_exit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1238,11 +1215,10 @@ static int method_exit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_ return sd_bus_reply_method_return(message, NULL); } -static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1258,11 +1234,10 @@ static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, s return sd_bus_reply_method_return(message, NULL); } -static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1278,11 +1253,10 @@ static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, return sd_bus_reply_method_return(message, NULL); } -static int method_halt(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1298,11 +1272,10 @@ static int method_halt(sd_bus *bus, sd_bus_message *message, void *userdata, sd_ return sd_bus_reply_method_return(message, NULL); } -static int method_kexec(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1318,13 +1291,12 @@ static int method_kexec(sd_bus *bus, sd_bus_message *message, void *userdata, sd return sd_bus_reply_method_return(message, NULL); } -static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_error *error) { char *ri = NULL, *rt = NULL; const char *root, *init; Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1383,12 +1355,11 @@ static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userda return sd_bus_reply_method_return(message, NULL); } -static int method_set_environment(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_environment(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **plus = NULL; Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1415,12 +1386,11 @@ static int method_set_environment(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_reply_method_return(message, NULL); } -static int method_unset_environment(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_unset_environment(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **minus = NULL; Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1448,12 +1418,11 @@ static int method_unset_environment(sd_bus *bus, sd_bus_message *message, void * return sd_bus_reply_method_return(message, NULL); } -static int method_unset_and_set_environment(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_unset_and_set_environment(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **minus = NULL, **plus = NULL; Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -1487,7 +1456,7 @@ static int method_unset_and_set_environment(sd_bus *bus, sd_bus_message *message return sd_bus_reply_method_return(message, NULL); } -static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; UnitFileList *item; @@ -1495,7 +1464,6 @@ static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *us Iterator i; int r; - assert(bus); assert(message); assert(m); @@ -1534,21 +1502,20 @@ static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *us if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); fail: unit_file_list_free(h); return r; } -static int method_get_unit_file_state(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_unit_file_state(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; UnitFileState state; UnitFileScope scope; int r; - assert(bus); assert(message); assert(m); @@ -1571,13 +1538,12 @@ static int method_get_unit_file_state(sd_bus *bus, sd_bus_message *message, void 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, sd_bus_error *error) { +static int method_get_default_target(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *default_target = NULL; Manager *m = userdata; UnitFileScope scope; int r; - assert(bus); assert(message); assert(m); @@ -1611,7 +1577,6 @@ static int send_unit_files_changed(sd_bus *bus, void *userdata) { static int reply_unit_file_changes_and_free( Manager *m, - sd_bus *bus, sd_bus_message *message, int carries_install_info, UnitFileChange *changes, @@ -1655,7 +1620,7 @@ static int reply_unit_file_changes_and_free( if (r < 0) goto fail; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(message), reply, NULL); fail: unit_file_changes_free(changes, n_changes); @@ -1663,7 +1628,6 @@ fail: } static int method_enable_unit_files_generic( - sd_bus *bus, sd_bus_message *message, Manager *m, const char *verb, @@ -1677,7 +1641,6 @@ static int method_enable_unit_files_generic( UnitFileScope scope; int runtime, force, r; - assert(bus); assert(message); assert(m); @@ -1705,34 +1668,34 @@ static int method_enable_unit_files_generic( if (r < 0) return r; - return reply_unit_file_changes_and_free(m, bus, message, carries_install_info ? r : -1, changes, n_changes); + return reply_unit_file_changes_and_free(m, message, carries_install_info ? r : -1, changes, n_changes); } -static int method_enable_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_enable_unit_files_generic(bus, message, userdata, "enable", unit_file_enable, true, error); +static int method_enable_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_enable_unit_files_generic(message, userdata, "enable", unit_file_enable, true, error); } -static int method_reenable_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_enable_unit_files_generic(bus, message, userdata, "enable", unit_file_reenable, true, error); +static int method_reenable_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_enable_unit_files_generic(message, userdata, "enable", unit_file_reenable, true, error); } -static int method_link_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_enable_unit_files_generic(bus, message, userdata, "enable", unit_file_link, false, error); +static int method_link_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_enable_unit_files_generic(message, userdata, "enable", unit_file_link, false, error); } static int unit_file_preset_without_mode(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes) { return unit_file_preset(scope, runtime, root_dir, files, UNIT_FILE_PRESET_FULL, force, changes, n_changes); } -static int method_preset_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_enable_unit_files_generic(bus, message, userdata, "enable", unit_file_preset_without_mode, true, error); +static int method_preset_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_enable_unit_files_generic(message, userdata, "enable", unit_file_preset_without_mode, true, error); } -static int method_mask_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_enable_unit_files_generic(bus, message, userdata, "disable", unit_file_mask, false, error); +static int method_mask_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_enable_unit_files_generic(message, userdata, "disable", unit_file_mask, false, error); } -static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_preset_unit_files_with_mode(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; UnitFileChange *changes = NULL; @@ -1743,7 +1706,6 @@ static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message *messa int runtime, force, r; const char *mode; - assert(bus); assert(message); assert(m); @@ -1779,11 +1741,10 @@ static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message *messa if (r < 0) return r; - return reply_unit_file_changes_and_free(m, bus, message, r, changes, n_changes); + return reply_unit_file_changes_and_free(m, message, r, changes, n_changes); } static int method_disable_unit_files_generic( - sd_bus *bus, sd_bus_message *message, Manager *m, const char *verb, @@ -1796,7 +1757,6 @@ static int method_disable_unit_files_generic( UnitFileScope scope; int r, runtime; - assert(bus); assert(message); assert(m); @@ -1824,18 +1784,18 @@ static int method_disable_unit_files_generic( if (r < 0) return r; - return reply_unit_file_changes_and_free(m, bus, message, -1, changes, n_changes); + return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes); } -static int method_disable_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_disable_unit_files_generic(bus, message, userdata, "disable", unit_file_disable, error); +static int method_disable_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_disable_unit_files_generic(message, userdata, "disable", unit_file_disable, error); } -static int method_unmask_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_disable_unit_files_generic(bus, message, userdata, "enable", unit_file_unmask, error); +static int method_unmask_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_disable_unit_files_generic(message, userdata, "enable", unit_file_unmask, error); } -static int method_set_default_target(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_default_target(sd_bus_message *message, void *userdata, sd_bus_error *error) { UnitFileChange *changes = NULL; unsigned n_changes = 0; Manager *m = userdata; @@ -1843,7 +1803,6 @@ static int method_set_default_target(sd_bus *bus, sd_bus_message *message, void const char *name; int force, r; - assert(bus); assert(message); assert(m); @@ -1867,10 +1826,10 @@ static int method_set_default_target(sd_bus *bus, sd_bus_message *message, void if (r < 0) return r; - return reply_unit_file_changes_and_free(m, bus, message, -1, changes, n_changes); + return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes); } -static int method_preset_all_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_preset_all_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { UnitFileChange *changes = NULL; unsigned n_changes = 0; Manager *m = userdata; @@ -1879,7 +1838,6 @@ static int method_preset_all_unit_files(sd_bus *bus, sd_bus_message *message, vo const char *mode; int force, runtime, r; - assert(bus); assert(message); assert(m); @@ -1911,10 +1869,10 @@ static int method_preset_all_unit_files(sd_bus *bus, sd_bus_message *message, vo if (r < 0) return r; - return reply_unit_file_changes_and_free(m, bus, message, -1, changes, n_changes); + return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes); } -static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_add_dependency_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; UnitFileChange *changes = NULL; @@ -1925,7 +1883,6 @@ static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message *message char *type; UnitDependency dep; - assert(bus); assert(message); assert(m); @@ -1957,7 +1914,7 @@ static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message *message if (r < 0) return r; - return reply_unit_file_changes_and_free(m, bus, message, -1, changes, n_changes); + return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes); } const sd_bus_vtable bus_manager_vtable[] = { diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c index 651c163be0..f8fb373bf0 100644 --- a/src/core/dbus-scope.c +++ b/src/core/dbus-scope.c @@ -31,11 +31,10 @@ #include "dbus-kill.h" #include "dbus-scope.h" -static int bus_scope_abandon(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int bus_scope_abandon(sd_bus_message *message, void *userdata, sd_bus_error *error) { Scope *s = userdata; int r; - assert(bus); assert(message); assert(s); diff --git a/src/core/dbus-snapshot.c b/src/core/dbus-snapshot.c index 0be46c288e..cfe44c9c15 100644 --- a/src/core/dbus-snapshot.c +++ b/src/core/dbus-snapshot.c @@ -25,11 +25,10 @@ #include "snapshot.h" #include "dbus-snapshot.h" -int bus_snapshot_method_remove(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_snapshot_method_remove(sd_bus_message *message, void *userdata, sd_bus_error *error) { Snapshot *s = userdata; int r; - assert(bus); assert(message); assert(s); diff --git a/src/core/dbus-snapshot.h b/src/core/dbus-snapshot.h index d7551cbcdc..9288f44e15 100644 --- a/src/core/dbus-snapshot.h +++ b/src/core/dbus-snapshot.h @@ -25,4 +25,4 @@ extern const sd_bus_vtable bus_snapshot_vtable[]; -int bus_snapshot_method_remove(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_snapshot_method_remove(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index af7dc26241..2699e81492 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -391,7 +391,6 @@ static int property_get_load_error( } int bus_unit_method_start_generic( - sd_bus *bus, sd_bus_message *message, Unit *u, JobType job_type, @@ -402,7 +401,6 @@ int bus_unit_method_start_generic( JobMode mode; int r; - assert(bus); assert(message); assert(u); assert(job_type >= 0 && job_type < _JOB_TYPE_MAX); @@ -425,45 +423,44 @@ int bus_unit_method_start_generic( if (r == 0) return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ - return bus_unit_queue_job(bus, message, u, job_type, mode, reload_if_possible, error); + return bus_unit_queue_job(message, u, job_type, mode, reload_if_possible, error); } -static int method_start(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_START, false, error); +static int method_start(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_START, false, error); } -static int method_stop(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_STOP, false, error); +static int method_stop(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_STOP, false, error); } -static int method_reload(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_RELOAD, false, error); +static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_RELOAD, false, error); } -static int method_restart(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_RESTART, false, error); +static int method_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_RESTART, false, error); } -static int method_try_restart(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_TRY_RESTART, false, error); +static int method_try_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_TRY_RESTART, false, error); } -static int method_reload_or_restart(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_RESTART, true, error); +static int method_reload_or_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_RESTART, true, error); } -static int method_reload_or_try_restart(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return bus_unit_method_start_generic(bus, message, userdata, JOB_TRY_RESTART, true, error); +static int method_reload_or_try_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_unit_method_start_generic(message, userdata, JOB_TRY_RESTART, true, error); } -int bus_unit_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) { Unit *u = userdata; const char *swho; int32_t signo; KillWho who; int r; - assert(bus); assert(message); assert(u); @@ -499,11 +496,10 @@ int bus_unit_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, s return sd_bus_reply_method_return(message, NULL); } -int bus_unit_method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_unit_method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error) { Unit *u = userdata; int r; - assert(bus); assert(message); assert(u); @@ -522,11 +518,10 @@ int bus_unit_method_reset_failed(sd_bus *bus, sd_bus_message *message, void *use return sd_bus_reply_method_return(message, NULL); } -int bus_unit_method_set_properties(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_unit_method_set_properties(sd_bus_message *message, void *userdata, sd_bus_error *error) { Unit *u = userdata; int runtime, r; - assert(bus); assert(message); assert(u); @@ -831,7 +826,6 @@ void bus_unit_send_removed_signal(Unit *u) { } int bus_unit_queue_job( - sd_bus *bus, sd_bus_message *message, Unit *u, JobType type, @@ -843,7 +837,6 @@ int bus_unit_queue_job( Job *j; int r; - assert(bus); assert(message); assert(u); assert(type >= 0 && type < _JOB_TYPE_MAX); @@ -877,9 +870,9 @@ int bus_unit_queue_job( if (r < 0) return r; - if (bus == u->manager->api_bus) { + if (sd_bus_message_get_bus(message) == u->manager->api_bus) { if (!j->clients) { - r = sd_bus_track_new(bus, &j->clients, NULL, NULL); + r = sd_bus_track_new(sd_bus_message_get_bus(message), &j->clients, NULL, NULL); if (r < 0) return r; } diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h index 57a5e19744..b622e0ae8d 100644 --- a/src/core/dbus-unit.h +++ b/src/core/dbus-unit.h @@ -30,10 +30,10 @@ extern const sd_bus_vtable bus_unit_cgroup_vtable[]; void bus_unit_send_change_signal(Unit *u); void bus_unit_send_removed_signal(Unit *u); -int bus_unit_method_start_generic(sd_bus *bus, sd_bus_message *message, Unit *u, JobType job_type, bool reload_if_possible, sd_bus_error *error); -int bus_unit_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_unit_method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_unit_method_start_generic(sd_bus_message *message, Unit *u, JobType job_type, bool reload_if_possible, sd_bus_error *error); +int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_unit_method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_unit_queue_job(sd_bus *bus, sd_bus_message *message, Unit *u, JobType type, JobMode mode, bool reload_if_possible, sd_bus_error *error); +int bus_unit_queue_job(sd_bus_message *message, Unit *u, JobType type, JobMode mode, bool reload_if_possible, sd_bus_error *error); int bus_unit_set_properties(Unit *u, sd_bus_message *message, UnitSetPropertiesMode mode, bool commit, sd_bus_error *error); -int bus_unit_method_set_properties(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_unit_method_set_properties(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/core/dbus.c b/src/core/dbus.c index 43b2ccd64e..8d72502a1a 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -71,12 +71,11 @@ int bus_send_queued_message(Manager *m) { return 0; } -static int signal_agent_released(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int signal_agent_released(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *cgroup; int r; - assert(bus); assert(message); assert(m); @@ -104,12 +103,13 @@ exit: return 0; } -static int signal_disconnected(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int signal_disconnected(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; + sd_bus *bus; - assert(bus); assert(message); assert(m); + assert_se(bus = sd_bus_message_get_bus(message)); if (bus == m->api_bus) destroy_bus(m, &m->api_bus); @@ -123,12 +123,11 @@ static int signal_disconnected(sd_bus *bus, sd_bus_message *message, void *userd return 0; } -static int signal_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int signal_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *name, *old_owner, *new_owner; Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -146,17 +145,18 @@ static int signal_name_owner_changed(sd_bus *bus, sd_bus_message *message, void return 0; } -static int signal_activation_request(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { +static int signal_activation_request(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; const char *name; + sd_bus *bus; Unit *u; int r; - assert(bus); assert(message); assert(m); + assert_se(bus = sd_bus_message_get_bus(message)); r = sd_bus_message_read(message, "s", &name); if (r < 0) { @@ -212,14 +212,13 @@ failed: } #ifdef HAVE_SELINUX -static int mac_selinux_filter(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int mac_selinux_filter(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *verb, *path; Unit *u = NULL; Job *j; int r; - assert(bus); assert(message); /* Our own method calls are all protected individually with diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 77b776fea6..ddf7b8f1bd 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -403,13 +403,16 @@ static int property_get_chassis( return sd_bus_message_append(reply, "s", name); } -static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *name; int interactive; char *h; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "sb", &name, &interactive); if (r < 0) return r; @@ -454,17 +457,20 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, s 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); + (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/hostname1", "org.freedesktop.hostname1", "Hostname", NULL); return sd_bus_reply_method_return(m, NULL); } -static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *name; int interactive; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "sb", &name, &interactive); if (r < 0) return r; @@ -519,18 +525,17 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user 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); + (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/hostname1", "org.freedesktop.hostname1", "StaticHostname", 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, sd_bus_error *error) { +static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_message_handler_t cb, sd_bus_error *error) { int interactive; const char *name; int r; assert(c); - assert(bus); assert(m); r = sd_bus_message_read(m, "sb", &name, &interactive); @@ -600,33 +605,36 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop prop == PROP_LOCATION ? "location" : prop == PROP_CHASSIS ? "chassis" : "icon name", strna(c->data[prop])); - sd_bus_emit_properties_changed(bus, "/org/freedesktop/hostname1", "org.freedesktop.hostname1", - prop == PROP_PRETTY_HOSTNAME ? "PrettyHostname" : - prop == PROP_DEPLOYMENT ? "Deployment" : - prop == PROP_LOCATION ? "Location" : - prop == PROP_CHASSIS ? "Chassis" : "IconName" , NULL); + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), + "/org/freedesktop/hostname1", + "org.freedesktop.hostname1", + prop == PROP_PRETTY_HOSTNAME ? "PrettyHostname" : + prop == PROP_DEPLOYMENT ? "Deployment" : + prop == PROP_LOCATION ? "Location" : + prop == PROP_CHASSIS ? "Chassis" : "IconName" , NULL); return sd_bus_reply_method_return(m, NULL); } -static int method_set_pretty_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { - return set_machine_info(userdata, bus, m, PROP_PRETTY_HOSTNAME, method_set_pretty_hostname, error); +static int method_set_pretty_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) { + return set_machine_info(userdata, m, PROP_PRETTY_HOSTNAME, method_set_pretty_hostname, error); } -static int method_set_icon_name(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { - return set_machine_info(userdata, bus, m, PROP_ICON_NAME, method_set_icon_name, error); +static int method_set_icon_name(sd_bus_message *m, void *userdata, sd_bus_error *error) { + return set_machine_info(userdata, m, PROP_ICON_NAME, method_set_icon_name, error); } -static int method_set_chassis(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { - return set_machine_info(userdata, bus, m, PROP_CHASSIS, method_set_chassis, error); +static int method_set_chassis(sd_bus_message *m, void *userdata, sd_bus_error *error) { + return set_machine_info(userdata, m, PROP_CHASSIS, method_set_chassis, error); } -static int method_set_deployment(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { - return set_machine_info(userdata, bus, m, PROP_DEPLOYMENT, method_set_deployment, error); +static int method_set_deployment(sd_bus_message *m, void *userdata, sd_bus_error *error) { + return set_machine_info(userdata, m, PROP_DEPLOYMENT, method_set_deployment, error); } -static int method_set_location(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { - return set_machine_info(userdata, bus, m, PROP_LOCATION, method_set_location, error); +static int method_set_location(sd_bus_message *m, void *userdata, sd_bus_error *error) { + return set_machine_info(userdata, m, PROP_LOCATION, method_set_location, error); } static const sd_bus_vtable hostname_vtable[] = { diff --git a/src/import/importd.c b/src/import/importd.c index d4da4b29a2..4f3701f5c5 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -719,7 +719,7 @@ static Transfer *manager_find(Manager *m, TransferType type, const char *dkr_ind return NULL; } -static int method_import_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_import_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_error *error) { _cleanup_(transfer_unrefp) Transfer *t = NULL; int fd, force, read_only, r; const char *local, *object; @@ -727,6 +727,9 @@ static int method_import_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *user TransferType type; uint32_t id; + assert(msg); + assert(m); + r = bus_verify_polkit_async( msg, CAP_SYS_ADMIN, @@ -780,7 +783,7 @@ static int method_import_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *user return sd_bus_reply_method_return(msg, "uo", id, object); } -static int method_export_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_export_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_error *error) { _cleanup_(transfer_unrefp) Transfer *t = NULL; int fd, r; const char *local, *object, *format; @@ -788,6 +791,9 @@ static int method_export_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *user TransferType type; uint32_t id; + assert(msg); + assert(m); + r = bus_verify_polkit_async( msg, CAP_SYS_ADMIN, @@ -841,7 +847,7 @@ static int method_export_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *user return sd_bus_reply_method_return(msg, "uo", id, object); } -static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_pull_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_error *error) { _cleanup_(transfer_unrefp) Transfer *t = NULL; const char *remote, *local, *verify, *object; Manager *m = userdata; @@ -850,7 +856,6 @@ static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userda int force, r; uint32_t id; - assert(bus); assert(msg); assert(m); @@ -924,7 +929,7 @@ static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userda return sd_bus_reply_method_return(msg, "uo", id, object); } -static int method_pull_dkr(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_pull_dkr(sd_bus_message *msg, void *userdata, sd_bus_error *error) { _cleanup_(transfer_unrefp) Transfer *t = NULL; const char *index_url, *remote, *tag, *local, *verify, *object; Manager *m = userdata; @@ -932,7 +937,6 @@ static int method_pull_dkr(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_ int force, r; uint32_t id; - assert(bus); assert(msg); assert(m); @@ -1023,14 +1027,13 @@ static int method_pull_dkr(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_ return sd_bus_reply_method_return(msg, "uo", id, object); } -static int method_list_transfers(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; Transfer *t; Iterator i; int r; - assert(bus); assert(msg); assert(m); @@ -1061,14 +1064,13 @@ static int method_list_transfers(sd_bus *bus, sd_bus_message *msg, void *userdat if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(msg), reply, NULL); } -static int method_cancel(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_cancel(sd_bus_message *msg, void *userdata, sd_bus_error *error) { Transfer *t = userdata; int r; - assert(bus); assert(msg); assert(t); @@ -1092,13 +1094,12 @@ static int method_cancel(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bu return sd_bus_reply_method_return(msg, NULL); } -static int method_cancel_transfer(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { +static int method_cancel_transfer(sd_bus_message *msg, void *userdata, sd_bus_error *error) { Manager *m = userdata; Transfer *t; uint32_t id; int r; - assert(bus); assert(msg); assert(m); diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c index a9e944c94b..7c5264fad4 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -328,7 +328,7 @@ int bus_match_run( bus->current_handler = node->leaf.callback->callback; bus->current_userdata = slot->userdata; } - r = node->leaf.callback->callback(bus, m, slot->userdata, &error_buffer); + r = node->leaf.callback->callback(m, slot->userdata, &error_buffer); if (bus) { bus->current_userdata = NULL; bus->current_handler = NULL; diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index fc6c223283..e4bbd880e5 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -277,7 +277,7 @@ static int node_callbacks_run( bus->current_slot = sd_bus_slot_ref(slot); bus->current_handler = c->callback; bus->current_userdata = slot->userdata; - r = c->callback(bus, m, slot->userdata, &error_buffer); + r = c->callback(m, slot->userdata, &error_buffer); bus->current_userdata = NULL; bus->current_handler = NULL; bus->current_slot = sd_bus_slot_unref(slot); @@ -395,7 +395,7 @@ static int method_callbacks_run( bus->current_slot = sd_bus_slot_ref(slot); bus->current_handler = c->vtable->x.method.handler; bus->current_userdata = u; - r = c->vtable->x.method.handler(bus, m, u, &error); + r = c->vtable->x.method.handler(m, u, &error); bus->current_userdata = NULL; bus->current_handler = NULL; bus->current_slot = sd_bus_slot_unref(slot); diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c index 6582baa8e0..ec9340f8e1 100644 --- a/src/libsystemd/sd-bus/bus-track.c +++ b/src/libsystemd/sd-bus/bus-track.c @@ -142,12 +142,11 @@ _public_ sd_bus_track* sd_bus_track_unref(sd_bus_track *track) { return NULL; } -static int on_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int on_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) { sd_bus_track *track = userdata; const char *name, *old, *new; int r; - assert(bus); assert(message); assert(track); diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 31bd45c687..f0695bfde0 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -39,14 +39,13 @@ #include "bus-util.h" #include "bus-internal.h" -static int name_owner_change_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { sd_event *e = userdata; - assert(bus); assert(m); assert(e); - sd_bus_close(bus); + sd_bus_close(sd_bus_message_get_bus(m)); sd_event_exit(e, 0); return 1; @@ -322,12 +321,11 @@ static void async_polkit_query_free(AsyncPolkitQuery *q) { free(q); } -static int async_polkit_callback(sd_bus *bus, sd_bus_message *reply, void *userdata, sd_bus_error *error) { +static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) { _cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL; AsyncPolkitQuery *q = userdata; int r; - assert(bus); assert(reply); assert(q); @@ -340,7 +338,7 @@ static int async_polkit_callback(sd_bus *bus, sd_bus_message *reply, void *userd goto finish; } - r = q->callback(bus, q->request, q->userdata, &error_buffer); + r = q->callback(q->request, q->userdata, &error_buffer); r = bus_maybe_reply_error(q->request, r, &error_buffer); finish: @@ -1606,24 +1604,22 @@ typedef struct BusWaitForJobs { sd_bus_slot *slot_disconnected; } BusWaitForJobs; -static int match_disconnected(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { - assert(bus); +static int match_disconnected(sd_bus_message *m, void *userdata, sd_bus_error *error) { assert(m); log_error("Warning! D-Bus connection terminated."); - sd_bus_close(bus); + sd_bus_close(sd_bus_message_get_bus(m)); return 0; } -static int match_job_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int match_job_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) { const char *path, *unit, *result; BusWaitForJobs *d = userdata; uint32_t id; char *found; int r; - assert(bus); assert(m); assert(d); diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 2cb1aafa2b..41fbe7d4af 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -367,13 +367,15 @@ _public_ int sd_bus_get_allow_interactive_authorization(sd_bus *bus) { return bus->allow_interactive_authorization; } -static int hello_callback(sd_bus *bus, sd_bus_message *reply, void *userdata, sd_bus_error *error) { +static int hello_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) { const char *s; + sd_bus *bus; int r; + assert(reply); + bus = reply->bus; assert(bus); assert(bus->state == BUS_HELLO || bus->state == BUS_CLOSING); - assert(reply); r = sd_bus_message_get_errno(reply); if (r > 0) @@ -2193,7 +2195,7 @@ static int process_timeout(sd_bus *bus) { bus->current_slot = sd_bus_slot_ref(slot); bus->current_handler = c->callback; bus->current_userdata = slot->userdata; - r = c->callback(bus, m, slot->userdata, &error_buffer); + r = c->callback(m, slot->userdata, &error_buffer); bus->current_userdata = NULL; bus->current_handler = NULL; bus->current_slot = NULL; @@ -2296,7 +2298,7 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) { bus->current_slot = sd_bus_slot_ref(slot); bus->current_handler = c->callback; bus->current_userdata = slot->userdata; - r = c->callback(bus, m, slot->userdata, &error_buffer); + r = c->callback(m, slot->userdata, &error_buffer); bus->current_userdata = NULL; bus->current_handler = NULL; bus->current_slot = NULL; @@ -2343,7 +2345,7 @@ static int process_filter(sd_bus *bus, sd_bus_message *m) { bus->current_slot = sd_bus_slot_ref(slot); bus->current_handler = l->callback; bus->current_userdata = slot->userdata; - r = l->callback(bus, m, slot->userdata, &error_buffer); + r = l->callback(m, slot->userdata, &error_buffer); bus->current_userdata = NULL; bus->current_handler = NULL; bus->current_slot = sd_bus_slot_unref(slot); @@ -2624,7 +2626,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) { bus->current_slot = sd_bus_slot_ref(slot); bus->current_handler = c->callback; bus->current_userdata = slot->userdata; - r = c->callback(bus, m, slot->userdata, &error_buffer); + r = c->callback(m, slot->userdata, &error_buffer); bus->current_userdata = NULL; bus->current_handler = NULL; bus->current_slot = NULL; diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index ab2ec27889..99261fa4c9 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -35,16 +35,14 @@ #include "bus-internal.h" #include "bus-util.h" -static int match_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +static int match_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { log_info("Match triggered! interface=%s member=%s", strna(sd_bus_message_get_interface(m)), strna(sd_bus_message_get_member(m))); return 0; } -static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +static int object_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int r; - assert_se(bus); - if (sd_bus_message_is_method_error(m, NULL)) return 0; @@ -358,7 +356,7 @@ finish: return INT_TO_PTR(r); } -static int quit_callback(sd_bus *b, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +static int quit_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { bool *x = userdata; log_error("Quit callback: %s", strerror(sd_bus_message_get_errno(m))); diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c index 051969f9c7..40c67046da 100644 --- a/src/libsystemd/sd-bus/test-bus-match.c +++ b/src/libsystemd/sd-bus/test-bus-match.c @@ -29,7 +29,7 @@ static bool mask[32]; -static int filter(sd_bus *b, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +static int filter(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { log_info("Ran %u", PTR_TO_UINT(userdata)); assert_se(PTR_TO_UINT(userdata) < ELEMENTSOF(mask)); mask[PTR_TO_UINT(userdata)] = true; diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c index 895eda4eaa..52952603e4 100644 --- a/src/libsystemd/sd-bus/test-bus-objects.c +++ b/src/libsystemd/sd-bus/test-bus-objects.c @@ -41,7 +41,7 @@ struct context { uint32_t automatic_integer_property; }; -static int something_handler(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int something_handler(sd_bus_message *m, void *userdata, sd_bus_error *error) { struct context *c = userdata; const char *s; char *n = NULL; @@ -67,7 +67,7 @@ static int something_handler(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return 1; } -static int exit_handler(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int exit_handler(sd_bus_message *m, void *userdata, sd_bus_error *error) { struct context *c = userdata; int r; @@ -129,10 +129,10 @@ static int value_handler(sd_bus *bus, const char *path, const char *interface, c return 1; } -static int notify_test(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int notify_test(sd_bus_message *m, void *userdata, sd_bus_error *error) { int r; - assert_se(sd_bus_emit_properties_changed(bus, m->path, "org.freedesktop.systemd.ValueTest", "Value", NULL) >= 0); + assert_se(sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), m->path, "org.freedesktop.systemd.ValueTest", "Value", NULL) >= 0); r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); @@ -140,10 +140,10 @@ static int notify_test(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_er return 1; } -static int notify_test2(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int notify_test2(sd_bus_message *m, void *userdata, sd_bus_error *error) { int r; - assert_se(sd_bus_emit_properties_changed_strv(bus, m->path, "org.freedesktop.systemd.ValueTest", NULL) >= 0); + assert_se(sd_bus_emit_properties_changed_strv(sd_bus_message_get_bus(m), m->path, "org.freedesktop.systemd.ValueTest", NULL) >= 0); r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); @@ -151,10 +151,10 @@ static int notify_test2(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_e return 1; } -static int emit_interfaces_added(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int emit_interfaces_added(sd_bus_message *m, void *userdata, sd_bus_error *error) { int r; - assert_se(sd_bus_emit_interfaces_added(bus, m->path, "org.freedesktop.systemd.test", NULL) >= 0); + assert_se(sd_bus_emit_interfaces_added(sd_bus_message_get_bus(m), m->path, "org.freedesktop.systemd.test", NULL) >= 0); r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); @@ -162,10 +162,10 @@ static int emit_interfaces_added(sd_bus *bus, sd_bus_message *m, void *userdata, return 1; } -static int emit_interfaces_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int emit_interfaces_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) { int r; - assert_se(sd_bus_emit_interfaces_removed(bus, m->path, "org.freedesktop.systemd.test", NULL) >= 0); + assert_se(sd_bus_emit_interfaces_removed(sd_bus_message_get_bus(m), m->path, "org.freedesktop.systemd.test", NULL) >= 0); r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); @@ -173,10 +173,10 @@ static int emit_interfaces_removed(sd_bus *bus, sd_bus_message *m, void *userdat return 1; } -static int emit_object_added(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int emit_object_added(sd_bus_message *m, void *userdata, sd_bus_error *error) { int r; - assert_se(sd_bus_emit_object_added(bus, m->path) >= 0); + assert_se(sd_bus_emit_object_added(sd_bus_message_get_bus(m), m->path) >= 0); r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); @@ -184,10 +184,10 @@ static int emit_object_added(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return 1; } -static int emit_object_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int emit_object_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) { int r; - assert_se(sd_bus_emit_object_removed(bus, m->path) >= 0); + assert_se(sd_bus_emit_object_removed(sd_bus_message_get_bus(m), m->path) >= 0); r = sd_bus_reply_method_return(m, NULL); assert_se(r >= 0); diff --git a/src/locale/localed.c b/src/locale/localed.c index fd0eb2db55..0e59350e98 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -869,7 +869,7 @@ static int property_get_locale( return sd_bus_message_append_strv(reply, l); } -static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; _cleanup_strv_free_ char **l = NULL; char **i; @@ -880,6 +880,9 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ int p; int r; + assert(m); + assert(c); + r = bus_message_read_strv_extend(m, &l); if (r < 0) return r; @@ -989,7 +992,7 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return sd_bus_error_set_errnof(error, r, "Failed to set locale: %s", strerror(-r)); } - locale_update_system_manager(c, bus); + locale_update_system_manager(c, sd_bus_message_get_bus(m)); if (settings) { _cleanup_free_ char *line; @@ -999,7 +1002,8 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ } else log_info("Changed locale to unset."); - sd_bus_emit_properties_changed(bus, + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), "/org/freedesktop/locale1", "org.freedesktop.locale1", "Locale", NULL); @@ -1010,12 +1014,15 @@ static int method_set_locale(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return sd_bus_reply_method_return(m, NULL); } -static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *keymap, *keymap_toggle; int convert, interactive; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "ssbb", &keymap, &keymap_toggle, &convert, &interactive); if (r < 0) return r; @@ -1059,17 +1066,18 @@ static int method_set_vc_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata log_info("Changed virtual console keymap to '%s' toggle '%s'", strempty(c->vc_keymap), strempty(c->vc_keymap_toggle)); - r = vconsole_reload(bus); + r = vconsole_reload(sd_bus_message_get_bus(m)); if (r < 0) log_error_errno(r, "Failed to request keymap reload: %m"); - sd_bus_emit_properties_changed(bus, + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), "/org/freedesktop/locale1", "org.freedesktop.locale1", "VConsoleKeymap", "VConsoleKeymapToggle", NULL); if (convert) { - r = vconsole_convert_to_x11(c, bus); + r = vconsole_convert_to_x11(c, sd_bus_message_get_bus(m)); if (r < 0) log_error_errno(r, "Failed to convert keymap data: %m"); } @@ -1126,12 +1134,15 @@ static int verify_xkb_rmlvo(const char *model, const char *layout, const char *v } #endif -static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *layout, *model, *variant, *options; int convert, interactive; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "ssssbb", &layout, &model, &variant, &options, &convert, &interactive); if (r < 0) return r; @@ -1197,13 +1208,14 @@ static int method_set_x11_keyboard(sd_bus *bus, sd_bus_message *m, void *userdat strempty(c->x11_variant), strempty(c->x11_options)); - sd_bus_emit_properties_changed(bus, + (void) sd_bus_emit_properties_changed( + sd_bus_message_get_bus(m), "/org/freedesktop/locale1", "org.freedesktop.locale1", "X11Layout", "X11Model", "X11Variant", "X11Options", NULL); if (convert) { - r = x11_convert_to_vconsole(c, bus); + r = x11_convert_to_vconsole(c, sd_bus_message_get_bus(m)); if (r < 0) log_error_errno(r, "Failed to convert keymap data: %m"); } diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 880fbf73ca..7603b0ec72 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -243,14 +243,13 @@ static int property_get_scheduled_shutdown( static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_handle_action, handle_action, HandleAction); -static int method_get_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; const char *name; Session *session; int r; - assert(bus); assert(message); assert(m); @@ -269,14 +268,13 @@ static int method_get_session(sd_bus *bus, sd_bus_message *message, void *userda 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, sd_bus_error *error) { +static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Session *session = NULL; Manager *m = userdata; pid_t pid; int r; - assert(bus); assert(message); assert(m); @@ -306,14 +304,13 @@ static int method_get_session_by_pid(sd_bus *bus, sd_bus_message *message, void return sd_bus_reply_method_return(message, "o", p); } -static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_user(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; uint32_t uid; User *user; int r; - assert(bus); assert(message); assert(m); @@ -332,14 +329,13 @@ static int method_get_user(sd_bus *bus, sd_bus_message *message, void *userdata, 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, sd_bus_error *error) { +static int method_get_user_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; User *user = NULL; pid_t pid; int r; - assert(bus); assert(message); assert(m); @@ -368,14 +364,13 @@ static int method_get_user_by_pid(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_reply_method_return(message, "o", p); } -static int method_get_seat(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; const char *name; Seat *seat; int r; - assert(bus); assert(message); assert(m); @@ -394,14 +389,13 @@ static int method_get_seat(sd_bus *bus, sd_bus_message *message, void *userdata, return sd_bus_reply_method_return(message, "o", p); } -static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; Session *session; Iterator i; int r; - assert(bus); assert(message); assert(m); @@ -434,17 +428,16 @@ static int method_list_sessions(sd_bus *bus, sd_bus_message *message, void *user if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -static int method_list_users(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; User *user; Iterator i; int r; - assert(bus); assert(message); assert(m); @@ -475,17 +468,16 @@ static int method_list_users(sd_bus *bus, sd_bus_message *message, void *userdat if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -static int method_list_seats(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; Seat *seat; Iterator i; int r; - assert(bus); assert(message); assert(m); @@ -513,16 +505,19 @@ static int method_list_seats(sd_bus *bus, sd_bus_message *message, void *userdat if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -static int method_list_inhibitors(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; Inhibitor *inhibitor; Iterator i; int r; + assert(message); + assert(m); + r = sd_bus_message_new_method_return(message, &reply); if (r < 0) return r; @@ -548,10 +543,10 @@ static int method_list_inhibitors(sd_bus *bus, sd_bus_message *message, void *us if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -static int method_create_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_create_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *service, *type, *class, *cseat, *tty, *display, *remote_user, *remote_host, *desktop; uint32_t uid, leader, audit_id = 0; _cleanup_free_ char *id = NULL; @@ -565,7 +560,6 @@ static int method_create_session(sd_bus *bus, sd_bus_message *message, void *use SessionClass c; int r; - assert(bus); assert(message); assert(m); @@ -841,13 +835,12 @@ fail: return r; } -static int method_release_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_release_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Session *session; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -866,13 +859,12 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_reply_method_return(message, NULL); } -static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_activate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Session *session; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -884,17 +876,16 @@ static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *u if (r < 0) return r; - return bus_session_method_activate(bus, message, session, error); + return bus_session_method_activate(message, session, error); } -static int method_activate_session_on_seat(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_activate_session_on_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *session_name, *seat_name; Manager *m = userdata; Session *session; Seat *seat; int r; - assert(bus); assert(message); assert(m); @@ -923,13 +914,12 @@ static int method_activate_session_on_seat(sd_bus *bus, sd_bus_message *message, return sd_bus_reply_method_return(message, NULL); } -static int method_lock_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_lock_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Session *session; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -941,14 +931,13 @@ static int method_lock_session(sd_bus *bus, sd_bus_message *message, void *userd if (r < 0) return r; - return bus_session_method_lock(bus, message, session, error); + return bus_session_method_lock(message, session, error); } -static int method_lock_sessions(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_lock_sessions(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -972,13 +961,12 @@ static int method_lock_sessions(sd_bus *bus, sd_bus_message *message, void *user return sd_bus_reply_method_return(message, NULL); } -static int method_kill_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_kill_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *name; Manager *m = userdata; Session *session; int r; - assert(bus); assert(message); assert(m); @@ -990,16 +978,15 @@ static int method_kill_session(sd_bus *bus, sd_bus_message *message, void *userd if (r < 0) return r; - return bus_session_method_kill(bus, message, session, error); + return bus_session_method_kill(message, session, error); } -static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_kill_user(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; uint32_t uid; User *user; int r; - assert(bus); assert(message); assert(m); @@ -1011,16 +998,15 @@ static int method_kill_user(sd_bus *bus, sd_bus_message *message, void *userdata if (r < 0) return r; - return bus_user_method_kill(bus, message, user, error); + return bus_user_method_kill(message, user, error); } -static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_terminate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; Session *session; int r; - assert(bus); assert(message); assert(m); @@ -1032,16 +1018,15 @@ static int method_terminate_session(sd_bus *bus, sd_bus_message *message, void * if (r < 0) return r; - return bus_session_method_terminate(bus, message, session, error); + return bus_session_method_terminate(message, session, error); } -static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_terminate_user(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; uint32_t uid; User *user; int r; - assert(bus); assert(message); assert(m); @@ -1053,16 +1038,15 @@ static int method_terminate_user(sd_bus *bus, sd_bus_message *message, void *use if (r < 0) return r; - return bus_user_method_terminate(bus, message, user, error); + return bus_user_method_terminate(message, user, error); } -static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_terminate_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; const char *name; Seat *seat; int r; - assert(bus); assert(message); assert(m); @@ -1074,10 +1058,10 @@ static int method_terminate_seat(sd_bus *bus, sd_bus_message *message, void *use if (r < 0) return r; - return bus_seat_method_terminate(bus, message, seat, error); + return bus_seat_method_terminate(message, seat, error); } -static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *cc = NULL; Manager *m = userdata; int b, r; @@ -1086,7 +1070,6 @@ static int method_set_user_linger(sd_bus *bus, sd_bus_message *message, void *us uint32_t uid; int interactive; - assert(bus); assert(message); assert(m); @@ -1266,12 +1249,11 @@ static int flush_devices(Manager *m) { return trigger_device(m, NULL); } -static int method_attach_device(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_attach_device(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *sysfs, *seat; Manager *m = userdata; int interactive, r; - assert(bus); assert(message); assert(m); @@ -1305,11 +1287,10 @@ static int method_attach_device(sd_bus *bus, sd_bus_message *message, void *user return sd_bus_reply_method_return(message, NULL); } -static int method_flush_devices(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_flush_devices(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; int interactive, r; - assert(bus); assert(message); assert(m); @@ -1728,7 +1709,7 @@ static int method_do_shutdown_or_sleep( return sd_bus_reply_method_return(message, NULL); } -static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_do_shutdown_or_sleep( @@ -1742,7 +1723,7 @@ static int method_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, error); } -static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_do_shutdown_or_sleep( @@ -1756,7 +1737,7 @@ static int method_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, s error); } -static int method_suspend(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_suspend(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_do_shutdown_or_sleep( @@ -1864,7 +1845,7 @@ static int manager_scheduled_shutdown_handler( return 0; } -static int method_schedule_shutdown(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; const char *action_multiple_sessions = NULL; @@ -1967,7 +1948,7 @@ static int method_schedule_shutdown(sd_bus *bus, sd_bus_message *message, void * return sd_bus_reply_method_return(message, NULL); } -static int method_cancel_scheduled_shutdown(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; bool cancelled; @@ -2002,7 +1983,7 @@ static int method_cancel_scheduled_shutdown(sd_bus *bus, sd_bus_message *message return sd_bus_reply_method_return(message, "b", cancelled); } -static int method_hibernate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_hibernate(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_do_shutdown_or_sleep( @@ -2016,7 +1997,7 @@ static int method_hibernate(sd_bus *bus, sd_bus_message *message, void *userdata error); } -static int method_hybrid_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_do_shutdown_or_sleep( @@ -2122,7 +2103,7 @@ static int method_can_shutdown_or_sleep( return sd_bus_reply_method_return(message, "s", result); } -static int method_can_poweroff(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_can_poweroff(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_can_shutdown_or_sleep( @@ -2135,7 +2116,7 @@ static int method_can_poweroff(sd_bus *bus, sd_bus_message *message, void *userd error); } -static int method_can_reboot(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_can_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_can_shutdown_or_sleep( @@ -2148,7 +2129,7 @@ static int method_can_reboot(sd_bus *bus, sd_bus_message *message, void *userdat error); } -static int method_can_suspend(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_can_suspend(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_can_shutdown_or_sleep( @@ -2161,7 +2142,7 @@ static int method_can_suspend(sd_bus *bus, sd_bus_message *message, void *userda error); } -static int method_can_hibernate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_can_hibernate(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_can_shutdown_or_sleep( @@ -2174,7 +2155,7 @@ static int method_can_hibernate(sd_bus *bus, sd_bus_message *message, void *user error); } -static int method_can_hybrid_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_can_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; return method_can_shutdown_or_sleep( @@ -2209,7 +2190,6 @@ static int property_get_reboot_to_firmware_setup( } static int method_set_reboot_to_firmware_setup( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -2217,7 +2197,6 @@ static int method_set_reboot_to_firmware_setup( int b, r; Manager *m = userdata; - assert(bus); assert(message); assert(m); @@ -2245,7 +2224,6 @@ static int method_set_reboot_to_firmware_setup( } static int method_can_reboot_to_firmware_setup( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -2255,7 +2233,6 @@ static int method_can_reboot_to_firmware_setup( const char *result; Manager *m = userdata; - assert(bus); assert(message); assert(m); @@ -2284,7 +2261,7 @@ static int method_can_reboot_to_firmware_setup( return sd_bus_reply_method_return(message, "s", result); } -static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; const char *who, *why, *what, *mode; _cleanup_free_ char *id = NULL; @@ -2297,7 +2274,6 @@ static int method_inhibit(sd_bus *bus, sd_bus_message *message, void *userdata, uid_t uid; int r; - assert(bus); assert(message); assert(m); @@ -2500,7 +2476,7 @@ static int session_jobs_reply(Session *s, const char *unit, const char *result) return r; } -int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *path, *result, *unit; Manager *m = userdata; Session *session; @@ -2508,7 +2484,6 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b User *user; int r; - assert(bus); assert(message); assert(m); @@ -2569,14 +2544,13 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b return 0; } -int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *path, *unit; Manager *m = userdata; Session *session; User *user; int r; - assert(bus); assert(message); assert(m); @@ -2597,7 +2571,7 @@ int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_ return 0; } -int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *unit = NULL; Manager *m = userdata; const char *path; @@ -2605,7 +2579,6 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat User *user; int r; - assert(bus); assert(message); assert(m); @@ -2630,13 +2603,14 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat return 0; } -int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Session *session; Iterator i; int b, r; - assert(bus); + assert(message); + assert(m); r = sd_bus_message_read(message, "b", &b); if (r < 0) { @@ -2656,16 +2630,17 @@ int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus return 0; } -int match_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *name, *old, *new; Manager *m = userdata; Session *session; Iterator i; int r; - - char *key; + assert(message); + assert(m); + r = sd_bus_message_read(message, "sss", &name, &old, &new); if (r < 0) { bus_log_parse_error(r); diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c index f50ee8d759..ce67ffde37 100644 --- a/src/login/logind-seat-dbus.c +++ b/src/login/logind-seat-dbus.c @@ -193,11 +193,10 @@ static int property_get_idle_since_hint( return sd_bus_message_append(reply, "t", u); } -int bus_seat_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_seat_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) { Seat *s = userdata; int r; - assert(bus); assert(message); assert(s); @@ -221,13 +220,12 @@ int bus_seat_method_terminate(sd_bus *bus, sd_bus_message *message, void *userda return sd_bus_reply_method_return(message, NULL); } -static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_activate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) { Seat *s = userdata; const char *name; Session *session; int r; - assert(bus); assert(message); assert(s); @@ -249,12 +247,11 @@ static int method_activate_session(sd_bus *bus, sd_bus_message *message, void *u return sd_bus_reply_method_return(message, NULL); } -static int method_switch_to(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_switch_to(sd_bus_message *message, void *userdata, sd_bus_error *error) { Seat *s = userdata; unsigned int to; int r; - assert(bus); assert(message); assert(s); @@ -272,11 +269,10 @@ static int method_switch_to(sd_bus *bus, sd_bus_message *message, void *userdata return sd_bus_reply_method_return(message, NULL); } -static int method_switch_to_next(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_switch_to_next(sd_bus_message *message, void *userdata, sd_bus_error *error) { Seat *s = userdata; int r; - assert(bus); assert(message); assert(s); @@ -287,11 +283,10 @@ static int method_switch_to_next(sd_bus *bus, sd_bus_message *message, void *use return sd_bus_reply_method_return(message, NULL); } -static int method_switch_to_previous(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_switch_to_previous(sd_bus_message *message, void *userdata, sd_bus_error *error) { Seat *s = userdata; int r; - assert(bus); assert(message); assert(s); diff --git a/src/login/logind-seat.h b/src/login/logind-seat.h index 2a0f574be6..248dbeb9d7 100644 --- a/src/login/logind-seat.h +++ b/src/login/logind-seat.h @@ -94,4 +94,4 @@ char *seat_bus_path(Seat *s); int seat_send_signal(Seat *s, bool new_seat); int seat_send_changed(Seat *s, const char *properties, ...) _sentinel_; -int bus_seat_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_seat_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index b119c8321b..debaa31a29 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -180,11 +180,10 @@ static int property_get_idle_since_hint( return sd_bus_message_append(reply, "t", u); } -int bus_session_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_session_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; int r; - assert(bus); assert(message); assert(s); @@ -208,11 +207,10 @@ int bus_session_method_terminate(sd_bus *bus, sd_bus_message *message, void *use return sd_bus_reply_method_return(message, NULL); } -int bus_session_method_activate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_session_method_activate(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; int r; - assert(bus); assert(message); assert(s); @@ -223,11 +221,10 @@ int bus_session_method_activate(sd_bus *bus, sd_bus_message *message, void *user return sd_bus_reply_method_return(message, NULL); } -int bus_session_method_lock(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_session_method_lock(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; int r; - assert(bus); assert(message); assert(s); @@ -251,13 +248,12 @@ int bus_session_method_lock(sd_bus *bus, sd_bus_message *message, void *userdata return sd_bus_reply_method_return(message, NULL); } -static int method_set_idle_hint(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_idle_hint(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; Session *s = userdata; uid_t uid; int r, b; - assert(bus); assert(message); assert(s); @@ -281,14 +277,13 @@ static int method_set_idle_hint(sd_bus *bus, sd_bus_message *message, void *user return sd_bus_reply_method_return(message, NULL); } -int bus_session_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_session_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; const char *swho; int32_t signo; KillWho who; int r; - assert(bus); assert(message); assert(s); @@ -327,13 +322,12 @@ int bus_session_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata return sd_bus_reply_method_return(message, NULL); } -static int method_take_control(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_take_control(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL; Session *s = userdata; int r, force; uid_t uid; - assert(bus); assert(message); assert(s); @@ -359,10 +353,9 @@ static int method_take_control(sd_bus *bus, sd_bus_message *message, void *userd return sd_bus_reply_method_return(message, NULL); } -static int method_release_control(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_release_control(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; - assert(bus); assert(message); assert(s); @@ -374,14 +367,13 @@ static int method_release_control(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_reply_method_return(message, NULL); } -static int method_take_device(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; uint32_t major, minor; SessionDevice *sd; dev_t dev; int r; - assert(bus); assert(message); assert(s); @@ -413,14 +405,13 @@ static int method_take_device(sd_bus *bus, sd_bus_message *message, void *userda return r; } -static int method_release_device(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_release_device(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; uint32_t major, minor; SessionDevice *sd; dev_t dev; int r; - assert(bus); assert(message); assert(s); @@ -440,14 +431,13 @@ static int method_release_device(sd_bus *bus, sd_bus_message *message, void *use return sd_bus_reply_method_return(message, NULL); } -static int method_pause_device_complete(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_pause_device_complete(sd_bus_message *message, void *userdata, sd_bus_error *error) { Session *s = userdata; uint32_t major, minor; SessionDevice *sd; dev_t dev; int r; - assert(bus); assert(message); assert(s); diff --git a/src/login/logind-session.h b/src/login/logind-session.h index 9305dca83f..7a329b94ad 100644 --- a/src/login/logind-session.h +++ b/src/login/logind-session.h @@ -176,7 +176,7 @@ bool session_is_controller(Session *s, const char *sender); int session_set_controller(Session *s, const char *sender, bool force); void session_drop_controller(Session *s); -int bus_session_method_activate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_session_method_lock(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_session_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_session_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_session_method_activate(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_session_method_lock(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_session_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_session_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c index 03c33708fc..8a710cef13 100644 --- a/src/login/logind-user-dbus.c +++ b/src/login/logind-user-dbus.c @@ -172,11 +172,10 @@ static int property_get_linger( return sd_bus_message_append(reply, "b", r > 0); } -int bus_user_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) { User *u = userdata; int r; - assert(bus); assert(message); assert(u); @@ -200,12 +199,11 @@ int bus_user_method_terminate(sd_bus *bus, sd_bus_message *message, void *userda return sd_bus_reply_method_return(message, NULL); } -int bus_user_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) { User *u = userdata; int32_t signo; int r; - assert(bus); assert(message); assert(u); diff --git a/src/login/logind-user.h b/src/login/logind-user.h index be5b56883c..722247806b 100644 --- a/src/login/logind-user.h +++ b/src/login/logind-user.h @@ -91,5 +91,5 @@ int user_send_changed(User *u, const char *properties, ...) _sentinel_; const char* user_state_to_string(UserState s) _const_; UserState user_state_from_string(const char *s) _pure_; -int bus_user_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_user_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/login/logind.h b/src/login/logind.h index 56c05b850c..cd226f55fc 100644 --- a/src/login/logind.h +++ b/src/login/logind.h @@ -162,11 +162,11 @@ bool manager_is_docked_or_multiple_displays(Manager *m); extern const sd_bus_vtable manager_vtable[]; -int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_name_owner_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error); int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, const char *unit_name, InhibitWhat w, sd_bus_error *error); diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c index 12c879aff0..95d7bca4bf 100644 --- a/src/machine/image-dbus.c +++ b/src/machine/image-dbus.c @@ -28,7 +28,6 @@ static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, image_type, ImageType); int bus_image_method_remove( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -37,7 +36,6 @@ int bus_image_method_remove( Manager *m = image->userdata; int r; - assert(bus); assert(message); assert(image); @@ -62,7 +60,6 @@ int bus_image_method_remove( } int bus_image_method_rename( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -72,7 +69,6 @@ int bus_image_method_rename( const char *new_name; int r; - assert(bus); assert(message); assert(image); @@ -104,7 +100,6 @@ int bus_image_method_rename( } int bus_image_method_clone( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -114,7 +109,6 @@ int bus_image_method_clone( const char *new_name; int r, read_only; - assert(bus); assert(message); assert(image); @@ -146,7 +140,6 @@ int bus_image_method_clone( } int bus_image_method_mark_read_only( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -155,7 +148,6 @@ int bus_image_method_mark_read_only( Manager *m = image->userdata; int r, read_only; - assert(bus); assert(message); r = sd_bus_message_read(message, "b", &read_only); @@ -183,7 +175,6 @@ int bus_image_method_mark_read_only( } int bus_image_method_set_limit( - sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { @@ -193,7 +184,6 @@ int bus_image_method_set_limit( uint64_t limit; int r; - assert(bus); assert(message); r = sd_bus_message_read(message, "t", &limit); diff --git a/src/machine/image-dbus.h b/src/machine/image-dbus.h index b9def6bc1b..d56d905c8e 100644 --- a/src/machine/image-dbus.h +++ b/src/machine/image-dbus.h @@ -30,8 +30,8 @@ char *image_bus_path(const char *name); int image_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error); int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error); -int bus_image_method_remove(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_image_method_rename(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_image_method_clone(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_image_method_mark_read_only(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_image_method_set_limit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_image_method_remove(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_image_method_rename(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_image_method_clone(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_image_method_mark_read_only(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_image_method_set_limit(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index 2d710a9a9b..4e73467b06 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -121,11 +121,10 @@ static int property_get_netif( static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_class, machine_class, MachineClass); -int bus_machine_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) { Machine *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -149,14 +148,13 @@ int bus_machine_method_terminate(sd_bus *bus, sd_bus_message *message, void *use return sd_bus_reply_method_return(message, NULL); } -int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) { Machine *m = userdata; const char *swho; int32_t signo; KillWho who; int r; - assert(bus); assert(message); assert(m); @@ -195,7 +193,7 @@ int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata return sd_bus_reply_method_return(message, NULL); } -int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; _cleanup_close_pair_ int pair[2] = { -1, -1 }; _cleanup_free_ char *us = NULL, *them = NULL; @@ -206,7 +204,6 @@ int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void pid_t child; int r; - assert(bus); assert(message); assert(m); @@ -338,10 +335,10 @@ int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -int bus_machine_method_get_os_release(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; _cleanup_close_ int mntns_fd = -1, root_fd = -1; _cleanup_close_pair_ int pair[2] = { -1, -1 }; @@ -353,7 +350,6 @@ int bus_machine_method_get_os_release(sd_bus *bus, sd_bus_message *message, void pid_t child; int r; - assert(bus); assert(message); assert(m); @@ -430,17 +426,16 @@ int bus_machine_method_get_os_release(sd_bus *bus, sd_bus_message *message, void if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -int bus_machine_method_open_pty(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; _cleanup_free_ char *pty_name = NULL; _cleanup_close_ int master = -1; Machine *m = userdata; int r; - assert(bus); assert(message); assert(m); @@ -463,10 +458,10 @@ int bus_machine_method_open_pty(sd_bus *bus, sd_bus_message *message, void *user if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -int bus_machine_method_open_login(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; _cleanup_free_ char *pty_name = NULL, *getty = NULL; _cleanup_bus_unref_ sd_bus *container_bus = NULL; @@ -476,6 +471,9 @@ int bus_machine_method_open_login(sd_bus *bus, sd_bus_message *message, void *us char *address; int r; + assert(message); + assert(m); + if (m->class != MACHINE_CONTAINER) return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Opening logins is only supported on container machines."); @@ -553,10 +551,10 @@ int bus_machine_method_open_login(sd_bus *bus, sd_bus_message *message, void *us if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL); } -int bus_machine_method_bind_mount(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 }; char mount_slave[] = "/tmp/propagate.XXXXXX", *mount_tmp, *mount_outside, *p; bool mount_slave_created = false, mount_slave_mounted = false, @@ -569,6 +567,9 @@ int bus_machine_method_bind_mount(sd_bus *bus, sd_bus_message *message, void *us siginfo_t si; int r; + assert(message); + assert(m); + if (m->class != MACHINE_CONTAINER) return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Bind mounting is only supported on container machines."); @@ -814,7 +815,7 @@ fail: return 0; } -int bus_machine_method_copy(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *src, *dest, *host_path, *container_path, *host_basename, *host_dirname, *container_basename, *container_dirname; _cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 }; _cleanup_close_ int hostfd = -1; @@ -825,6 +826,9 @@ int bus_machine_method_copy(sd_bus *bus, sd_bus_message *message, void *userdata char *t; int r; + assert(message); + assert(m); + if (m->n_operations >= MACHINE_OPERATIONS_MAX) return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing copies."); diff --git a/src/machine/machine-dbus.h b/src/machine/machine-dbus.h index 4eb24f9a1f..d309131860 100644 --- a/src/machine/machine-dbus.h +++ b/src/machine/machine-dbus.h @@ -29,14 +29,14 @@ char *machine_bus_path(Machine *s); int machine_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error); int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error); -int bus_machine_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_get_os_release(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_open_pty(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_open_login(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_bind_mount(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int bus_machine_method_copy(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_error *error); int machine_send_signal(Machine *m, bool new_machine); int machine_send_create_reply(Machine *m, sd_bus_error *error); diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 26cd5b8002..ed7221800f 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -1115,11 +1115,10 @@ static int bind_mount(int argc, char *argv[], void *userdata) { return 0; } -static int on_machine_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +static int on_machine_removed(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { PTYForward ** forward = (PTYForward**) userdata; int r; - assert(bus); assert(m); assert(forward); @@ -1136,7 +1135,7 @@ static int on_machine_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd } /* On error, or when the forwarder is not initialized yet, quit immediately */ - sd_event_exit(sd_bus_get_event(bus), EXIT_FAILURE); + sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), EXIT_FAILURE); return 0; } @@ -1496,12 +1495,11 @@ static int enable_machine(int argc, char *argv[], void *userdata) { return 0; } -static int match_log_message(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int match_log_message(sd_bus_message *m, void *userdata, sd_bus_error *error) { const char **our_path = userdata, *line; unsigned priority; int r; - assert(bus); assert(m); assert(our_path); @@ -1521,12 +1519,11 @@ static int match_log_message(sd_bus *bus, sd_bus_message *m, void *userdata, sd_ return 0; } -static int match_transfer_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int match_transfer_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) { const char **our_path = userdata, *path, *result; uint32_t id; int r; - assert(bus); assert(m); assert(our_path); @@ -1539,7 +1536,7 @@ static int match_transfer_removed(sd_bus *bus, sd_bus_message *m, void *userdata if (!streq_ptr(*our_path, path)) return 0; - sd_event_exit(sd_bus_get_event(bus), !streq_ptr(result, "done")); + sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), !streq_ptr(result, "done")); return 0; } diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 76109700a3..5036a63985 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -125,14 +125,13 @@ static int property_get_pool_limit( return sd_bus_message_append(reply, "t", size); } -static int method_get_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -151,13 +150,12 @@ static int method_get_machine(sd_bus *bus, sd_bus_message *message, void *userda return sd_bus_reply_method_return(message, "o", p); } -static int method_get_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_image(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -178,14 +176,13 @@ static int method_get_image(sd_bus *bus, sd_bus_message *message, void *userdata 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, sd_bus_error *error) { +static int method_get_machine_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *p = NULL; Manager *m = userdata; Machine *machine = NULL; pid_t pid; int r; - assert(bus); assert(message); assert(m); @@ -220,14 +217,13 @@ static int method_get_machine_by_pid(sd_bus *bus, sd_bus_message *message, void return sd_bus_reply_method_return(message, "o", p); } -static int method_list_machines(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_machines(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; Manager *m = userdata; Machine *machine; Iterator i; int r; - assert(bus); assert(message); assert(m); @@ -259,7 +255,7 @@ static int method_list_machines(sd_bus *bus, sd_bus_message *message, void *user if (r < 0) return sd_bus_error_set_errno(error, r); - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(message), reply, NULL); } static int method_create_or_register_machine(Manager *manager, sd_bus_message *message, bool read_network, Machine **_m, sd_bus_error *error) { @@ -387,11 +383,14 @@ fail: return r; } -static int method_create_machine_internal(sd_bus *bus, sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) { +static int method_create_machine_internal(sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) { Manager *manager = userdata; Machine *m = NULL; int r; + assert(message); + assert(manager); + r = method_create_or_register_machine(manager, message, read_network, &m, error); if (r < 0) return r; @@ -412,20 +411,23 @@ fail: return r; } -static int method_create_machine_with_network(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_create_machine_internal(bus, message, true, userdata, error); +static int method_create_machine_with_network(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_create_machine_internal(message, true, userdata, error); } -static int method_create_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_create_machine_internal(bus, message, false, userdata, error); +static int method_create_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_create_machine_internal(message, false, userdata, error); } -static int method_register_machine_internal(sd_bus *bus, sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) { +static int method_register_machine_internal(sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) { Manager *manager = userdata; _cleanup_free_ char *p = NULL; Machine *m = NULL; int r; + assert(message); + assert(manager); + r = method_create_or_register_machine(manager, message, read_network, &m, error); if (r < 0) return r; @@ -453,21 +455,20 @@ fail: return r; } -static int method_register_machine_with_network(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_register_machine_internal(bus, message, true, userdata, error); +static int method_register_machine_with_network(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_register_machine_internal(message, true, userdata, error); } -static int method_register_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - return method_register_machine_internal(bus, message, false, userdata, error); +static int method_register_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return method_register_machine_internal(message, false, userdata, error); } -static int method_terminate_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_terminate_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -479,16 +480,15 @@ static int method_terminate_machine(sd_bus *bus, sd_bus_message *message, void * if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_terminate(bus, message, machine, error); + return bus_machine_method_terminate(message, machine, error); } -static int method_kill_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_kill_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -500,16 +500,15 @@ static int method_kill_machine(sd_bus *bus, sd_bus_message *message, void *userd if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_kill(bus, message, machine, error); + return bus_machine_method_kill(message, machine, error); } -static int method_get_machine_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_machine_addresses(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -521,16 +520,15 @@ static int method_get_machine_addresses(sd_bus *bus, sd_bus_message *message, vo if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_get_addresses(bus, message, machine, error); + return bus_machine_method_get_addresses(message, machine, error); } -static int method_get_machine_os_release(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_get_machine_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -542,10 +540,10 @@ static int method_get_machine_os_release(sd_bus *bus, sd_bus_message *message, v if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_get_os_release(bus, message, machine, error); + return bus_machine_method_get_os_release(message, machine, error); } -static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; _cleanup_(image_hashmap_freep) Hashmap *images = NULL; Manager *m = userdata; @@ -553,7 +551,6 @@ static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userda Iterator i; int r; - assert(bus); assert(message); assert(m); @@ -596,16 +593,15 @@ static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userda if (r < 0) return r; - return sd_bus_send(bus, reply, NULL); + return sd_bus_send(sd_bus_message_get_bus(message), reply, NULL); } -static int method_open_machine_pty(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_open_machine_pty(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -617,16 +613,15 @@ static int method_open_machine_pty(sd_bus *bus, sd_bus_message *message, void *u if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_open_pty(bus, message, machine, error); + return bus_machine_method_open_pty(message, machine, error); } -static int method_open_machine_login(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_open_machine_login(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -638,16 +633,15 @@ static int method_open_machine_login(sd_bus *bus, sd_bus_message *message, void if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_open_login(bus, message, machine, error); + return bus_machine_method_open_login(message, machine, error); } -static int method_bind_mount_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_bind_mount_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -659,16 +653,15 @@ static int method_bind_mount_machine(sd_bus *bus, sd_bus_message *message, void if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_bind_mount(bus, message, machine, error); + return bus_machine_method_bind_mount(message, machine, error); } -static int method_copy_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_copy_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; const char *name; int r; - assert(bus); assert(message); assert(m); @@ -680,15 +673,14 @@ static int method_copy_machine(sd_bus *bus, sd_bus_message *message, void *userd if (!machine) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - return bus_machine_method_copy(bus, message, machine, error); + return bus_machine_method_copy(message, machine, error); } -static int method_remove_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_remove_image(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image* i = NULL; const char *name; int r; - assert(bus); assert(message); r = sd_bus_message_read(message, "s", &name); @@ -705,15 +697,14 @@ static int method_remove_image(sd_bus *bus, sd_bus_message *message, void *userd return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name); i->userdata = userdata; - return bus_image_method_remove(bus, message, i, error); + return bus_image_method_remove(message, i, error); } -static int method_rename_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_rename_image(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image* i = NULL; const char *old_name; int r; - assert(bus); assert(message); r = sd_bus_message_read(message, "s", &old_name); @@ -730,15 +721,16 @@ static int method_rename_image(sd_bus *bus, sd_bus_message *message, void *userd return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", old_name); i->userdata = userdata; - return bus_image_method_rename(bus, message, i, error); + return bus_image_method_rename(message, i, error); } -static int method_clone_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_clone_image(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image *i = NULL; const char *old_name; int r; - assert(bus); + assert(message); + r = sd_bus_message_read(message, "s", &old_name); if (r < 0) return r; @@ -753,15 +745,16 @@ static int method_clone_image(sd_bus *bus, sd_bus_message *message, void *userda return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", old_name); i->userdata = userdata; - return bus_image_method_clone(bus, message, i, error); + return bus_image_method_clone(message, i, error); } -static int method_mark_image_read_only(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_mark_image_read_only(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image *i = NULL; const char *name; int r; - assert(bus); + assert(message); + r = sd_bus_message_read(message, "s", &name); if (r < 0) return r; @@ -776,15 +769,16 @@ static int method_mark_image_read_only(sd_bus *bus, sd_bus_message *message, voi return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name); i->userdata = userdata; - return bus_image_method_mark_read_only(bus, message, i, error); + return bus_image_method_mark_read_only(message, i, error); } -static int method_set_pool_limit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; uint64_t limit; int r; - assert(bus); + assert(message); + r = sd_bus_message_read(message, "t", &limit); if (r < 0) return r; @@ -822,12 +816,13 @@ static int method_set_pool_limit(sd_bus *bus, sd_bus_message *message, void *use return sd_bus_reply_method_return(message, NULL); } -static int method_set_image_limit(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int method_set_image_limit(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image *i = NULL; const char *name; int r; - assert(bus); + assert(message); + r = sd_bus_message_read(message, "s", &name); if (r < 0) return r; @@ -842,7 +837,7 @@ static int method_set_image_limit(sd_bus *bus, sd_bus_message *message, void *us return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name); i->userdata = userdata; - return bus_image_method_set_limit(bus, message, i, error); + return bus_image_method_set_limit(message, i, error); } const sd_bus_vtable manager_vtable[] = { @@ -879,14 +874,13 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_VTABLE_END }; -int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *path, *result, *unit; Manager *m = userdata; Machine *machine; uint32_t id; int r; - assert(bus); assert(message); assert(m); @@ -922,14 +916,13 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b return 0; } -int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_free_ char *unit = NULL; const char *path, *interface; Manager *m = userdata; Machine *machine; int r; - assert(bus); assert(message); assert(m); @@ -983,13 +976,12 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat return 0; } -int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) { const char *path, *unit; Manager *m = userdata; Machine *machine; int r; - assert(bus); assert(message); assert(m); @@ -1009,13 +1001,14 @@ int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_ return 0; } -int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; Machine *machine; Iterator i; int b, r; - assert(bus); + assert(message); + assert(m); r = sd_bus_message_read(message, "b", &b); if (r < 0) { diff --git a/src/machine/machined.h b/src/machine/machined.h index 0f3df17d7f..61dbefb5f1 100644 --- a/src/machine/machined.h +++ b/src/machine/machined.h @@ -65,10 +65,10 @@ int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine); extern const sd_bus_vtable manager_vtable[]; -int match_reloading(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_unit_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error); +int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error); int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, sd_bus_message *more_properties, sd_bus_error *error, char **job); int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index ab115a053b..0f9a1cd6d1 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -734,11 +734,11 @@ static int link_set_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { return 0; } -static int set_hostname_handler(sd_bus *bus, sd_bus_message *m, void *userdata, - sd_bus_error *ret_error) { +static int set_hostname_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { _cleanup_link_unref_ Link *link = userdata; int r; + assert(m); assert(link); if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 0e204ebae6..db737ad484 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -105,12 +105,11 @@ static int manager_reset_all(Manager *m) { return 0; } -static int match_prepare_for_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { +static int match_prepare_for_sleep(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { Manager *m = userdata; int b, r; - assert(bus); - assert(bus); + assert(message); r = sd_bus_message_read(message, "b", &b); if (r < 0) { diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index fba2afcc8d..0ea585e197 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -275,7 +275,7 @@ static int check_ifindex_flags(int ifindex, uint64_t *flags, sd_bus_error *error return 0; } -static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int bus_method_resolve_hostname(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(dns_question_unrefp) DnsQuestion *question = NULL; Manager *m = userdata; const char *hostname; @@ -284,7 +284,6 @@ static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, voi DnsQuery *q; int r; - assert(bus); assert(message); assert(m); @@ -340,7 +339,7 @@ static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, voi q->request_hostname = hostname; q->complete = bus_method_resolve_hostname_complete; - r = dns_query_bus_track(q, bus, message); + r = dns_query_bus_track(q, sd_bus_message_get_bus(message), message); if (r < 0) return r; @@ -428,7 +427,7 @@ finish: dns_query_free(q); } -static int bus_method_resolve_address(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int bus_method_resolve_address(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL; _cleanup_(dns_question_unrefp) DnsQuestion *question = NULL; _cleanup_free_ char *reverse = NULL; @@ -440,7 +439,6 @@ static int bus_method_resolve_address(sd_bus *bus, sd_bus_message *message, void size_t sz; int r; - assert(bus); assert(message); assert(m); @@ -493,7 +491,7 @@ static int bus_method_resolve_address(sd_bus *bus, sd_bus_message *message, void memcpy(&q->request_address, d, sz); q->complete = bus_method_resolve_address_complete; - r = dns_query_bus_track(q, bus, message); + r = dns_query_bus_track(q, sd_bus_message_get_bus(message), message); if (r < 0) return r; @@ -600,7 +598,7 @@ finish: dns_query_free(q); } -static int bus_method_resolve_record(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL; _cleanup_(dns_question_unrefp) DnsQuestion *question = NULL; Manager *m = userdata; @@ -610,7 +608,6 @@ static int bus_method_resolve_record(sd_bus *bus, sd_bus_message *message, void uint64_t flags; DnsQuery *q; - assert(bus); assert(message); assert(m); @@ -646,7 +643,7 @@ static int bus_method_resolve_record(sd_bus *bus, sd_bus_message *message, void q->request_hostname = name; q->complete = bus_method_resolve_record_complete; - r = dns_query_bus_track(q, bus, message); + r = dns_query_bus_track(q, sd_bus_message_get_bus(message), message); if (r < 0) return r; @@ -683,12 +680,12 @@ static int on_bus_retry(sd_event_source *s, usec_t usec, void *userdata) { return 0; } -static int match_prepare_for_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { +static int match_prepare_for_sleep(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { Manager *m = userdata; int b, r; - assert(bus); - assert(bus); + assert(message); + assert(m); r = sd_bus_message_read(message, "b", &b); if (r < 0) { diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index d3588d5b65..19f01a6284 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -100,11 +100,11 @@ enum { /* Callbacks */ -typedef int (*sd_bus_message_handler_t)(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error); +typedef int (*sd_bus_message_handler_t)(sd_bus_message *m, void *userdata, sd_bus_error *ret_error); typedef int (*sd_bus_property_get_t) (sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *ret_error); typedef int (*sd_bus_property_set_t) (sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *ret_error); typedef int (*sd_bus_object_find_t) (sd_bus *bus, const char *path, const char *interface, void *userdata, void **ret_found, sd_bus_error *ret_error); -typedef int (*sd_bus_node_enumerator_t) (sd_bus *bus, const char *path, void *userdata, char ***ret_nodes, sd_bus_error *ret_error); +typedef int (*sd_bus_node_enumerator_t) (sd_bus *bus, const char *prefix, void *userdata, char ***ret_nodes, sd_bus_error *ret_error); typedef int (*sd_bus_track_handler_t) (sd_bus_track *track, void *userdata); #include "sd-bus-protocol.h" diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index d48fc822e2..187522e596 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -357,14 +357,13 @@ static int property_get_ntp_sync( return sd_bus_message_append(reply, "b", ntp_synced()); } -static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *error) { Context *c = userdata; const char *z; int interactive; char *t; int r; - assert(bus); assert(m); assert(c); @@ -424,18 +423,17 @@ static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata, s LOG_MESSAGE("Changed time zone to '%s'.", c->zone), NULL); - sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL); + (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "Timezone", NULL); return sd_bus_reply_method_return(m, NULL); } -static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error *error) { int lrtc, fix_system, interactive; Context *c = userdata; struct timespec ts; int r; - assert(bus); assert(m); assert(c); @@ -514,12 +512,12 @@ static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata, log_info("RTC configured to %s time.", c->local_rtc ? "local" : "UTC"); - sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "LocalRTC", NULL); + (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "LocalRTC", NULL); return sd_bus_reply_method_return(m, NULL); } -static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *error) { int relative, interactive; Context *c = userdata; int64_t utc; @@ -528,7 +526,6 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu struct tm* tm; int r; - assert(bus); assert(m); assert(c); @@ -605,11 +602,14 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu return sd_bus_reply_method_return(m, NULL); } -static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) { +static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error) { int enabled, interactive; Context *c = userdata; int r; + assert(m); + assert(c); + r = sd_bus_message_read(m, "bb", &enabled, &interactive); if (r < 0) return r; @@ -630,18 +630,18 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus if (r == 0) return 1; - r = context_enable_ntp(bus, error, enabled); + r = context_enable_ntp(sd_bus_message_get_bus(m), error, enabled); if (r < 0) return r; - r = context_start_ntp(bus, error, enabled); + r = context_start_ntp(sd_bus_message_get_bus(m), error, enabled); if (r < 0) return r; c->use_ntp = enabled; log_info("Set NTP to %s", enabled ? "enabled" : "disabled"); - sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL); + (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL); return sd_bus_reply_method_return(m, NULL); } |