1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-12 13:18:14 +03:00

homed: Use new SD_BUS_METHOD_WITH_ARGS macro

Migrate homed to use the new macros to declare a D-Bus method.
Replaced `SD_BUS_METHOD_WITH_NAMES` with `SD_BUS_METHOD_WITH_ARGS`
This commit is contained in:
Nishal Kulkarni 2021-12-17 18:31:55 +05:30 committed by Yu Watanabe
parent c0a2e0cc24
commit 9a8141662e
2 changed files with 172 additions and 231 deletions

View File

@ -796,76 +796,61 @@ const sd_bus_vtable home_vtable[] = {
property_get_user_record, 0, property_get_user_record, 0,
SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION|SD_BUS_VTABLE_SENSITIVE), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD_WITH_NAMES("Activate", SD_BUS_METHOD_WITH_ARGS("Activate",
"s", SD_BUS_ARGS("s", secret),
SD_BUS_PARAM(secret), SD_BUS_NO_RESULT,
NULL,, bus_home_method_activate,
bus_home_method_activate, SD_BUS_VTABLE_SENSITIVE),
SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD("Deactivate", NULL, NULL, bus_home_method_deactivate, 0), SD_BUS_METHOD("Deactivate", NULL, NULL, bus_home_method_deactivate, 0),
SD_BUS_METHOD("Unregister", NULL, NULL, bus_home_method_unregister, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Unregister", NULL, NULL, bus_home_method_unregister, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD_WITH_NAMES("Realize", SD_BUS_METHOD_WITH_ARGS("Realize",
"s", SD_BUS_ARGS("s", secret),
SD_BUS_PARAM(secret), SD_BUS_NO_RESULT,
NULL,, bus_home_method_realize,
bus_home_method_realize, SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD("Remove", NULL, NULL, bus_home_method_remove, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Remove", NULL, NULL, bus_home_method_remove, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD_WITH_NAMES("Fixate", SD_BUS_METHOD_WITH_ARGS("Fixate",
"s", SD_BUS_ARGS("s", secret),
SD_BUS_PARAM(secret), SD_BUS_NO_RESULT,
NULL,, bus_home_method_fixate,
bus_home_method_fixate, SD_BUS_VTABLE_SENSITIVE),
SD_BUS_VTABLE_SENSITIVE), SD_BUS_METHOD_WITH_ARGS("Authenticate",
SD_BUS_METHOD_WITH_NAMES("Authenticate", SD_BUS_ARGS("s", secret),
"s", SD_BUS_NO_RESULT,
SD_BUS_PARAM(secret), bus_home_method_authenticate,
NULL,, SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
bus_home_method_authenticate, SD_BUS_METHOD_WITH_ARGS("Update",
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE), SD_BUS_ARGS("s", user_record),
SD_BUS_METHOD_WITH_NAMES("Update", SD_BUS_NO_RESULT,
"s", bus_home_method_update,
SD_BUS_PARAM(user_record), SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
NULL,, SD_BUS_METHOD_WITH_ARGS("Resize",
bus_home_method_update, SD_BUS_ARGS("t", size, "s", secret),
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE), SD_BUS_NO_RESULT,
SD_BUS_METHOD_WITH_NAMES("Resize", bus_home_method_resize,
"ts", SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_PARAM(size) SD_BUS_METHOD_WITH_ARGS("ChangePassword",
SD_BUS_PARAM(secret), SD_BUS_ARGS("s", new_secret, "s", old_secret),
NULL,, SD_BUS_NO_RESULT,
bus_home_method_resize, bus_home_method_change_password,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE), SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD_WITH_NAMES("ChangePassword",
"ss",
SD_BUS_PARAM(new_secret)
SD_BUS_PARAM(old_secret),
NULL,,
bus_home_method_change_password,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD("Lock", NULL, NULL, bus_home_method_lock, 0), SD_BUS_METHOD("Lock", NULL, NULL, bus_home_method_lock, 0),
SD_BUS_METHOD_WITH_NAMES("Unlock", SD_BUS_METHOD_WITH_ARGS("Unlock",
"s", SD_BUS_ARGS("s", secret),
SD_BUS_PARAM(secret), SD_BUS_NO_RESULT,
NULL,, bus_home_method_unlock,
bus_home_method_unlock, SD_BUS_VTABLE_SENSITIVE),
SD_BUS_VTABLE_SENSITIVE), SD_BUS_METHOD_WITH_ARGS("Acquire",
SD_BUS_METHOD_WITH_NAMES("Acquire", SD_BUS_ARGS("s", secret, "b", please_suspend),
"sb", SD_BUS_RESULT("h", send_fd),
SD_BUS_PARAM(secret) bus_home_method_acquire,
SD_BUS_PARAM(please_suspend), SD_BUS_VTABLE_SENSITIVE),
"h", SD_BUS_METHOD_WITH_ARGS("Ref",
SD_BUS_PARAM(send_fd), SD_BUS_ARGS("b", please_suspend),
bus_home_method_acquire, SD_BUS_RESULT("h", send_fd),
SD_BUS_VTABLE_SENSITIVE), bus_home_method_ref,
SD_BUS_METHOD_WITH_NAMES("Ref", 0),
"b",
SD_BUS_PARAM(please_suspend),
"h",
SD_BUS_PARAM(send_fd),
bus_home_method_ref,
0),
SD_BUS_METHOD("Release", NULL, NULL, bus_home_method_release, 0), SD_BUS_METHOD("Release", NULL, NULL, bus_home_method_release, 0),
SD_BUS_VTABLE_END SD_BUS_VTABLE_END
}; };

View File

@ -661,174 +661,138 @@ static const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("AutoLogin", "a(sso)", property_get_auto_login, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("AutoLogin", "a(sso)", property_get_auto_login, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_METHOD_WITH_NAMES("GetHomeByName", SD_BUS_METHOD_WITH_ARGS("GetHomeByName",
"s", SD_BUS_ARGS("s", user_name),
SD_BUS_PARAM(user_name), SD_BUS_RESULT("u", uid,
"usussso", "s", home_state,
SD_BUS_PARAM(uid) "u", gid,
SD_BUS_PARAM(home_state) "s", real_name,
SD_BUS_PARAM(gid) "s", home_directory,
SD_BUS_PARAM(real_name) "s", shell,
SD_BUS_PARAM(home_directory) "o", bus_path),
SD_BUS_PARAM(shell) method_get_home_by_name,
SD_BUS_PARAM(bus_path), SD_BUS_VTABLE_UNPRIVILEGED),
method_get_home_by_name, SD_BUS_METHOD_WITH_ARGS("GetHomeByUID",
SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_ARGS("u", uid),
SD_BUS_METHOD_WITH_NAMES("GetHomeByUID", SD_BUS_RESULT("s", user_name,
"u", "s", home_state,
SD_BUS_PARAM(uid), "u", gid,
"ssussso", "s", real_name,
SD_BUS_PARAM(user_name) "s", home_directory,
SD_BUS_PARAM(home_state) "s", shell,
SD_BUS_PARAM(gid) "o", bus_path),
SD_BUS_PARAM(real_name) method_get_home_by_uid,
SD_BUS_PARAM(home_directory) SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_PARAM(shell) SD_BUS_METHOD_WITH_ARGS("GetUserRecordByName",
SD_BUS_PARAM(bus_path), SD_BUS_ARGS("s", user_name),
method_get_home_by_uid, SD_BUS_RESULT("s", user_record, "b", incomplete, "o", bus_path),
SD_BUS_VTABLE_UNPRIVILEGED), method_get_user_record_by_name,
SD_BUS_METHOD_WITH_NAMES("GetUserRecordByName", SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
"s", SD_BUS_METHOD_WITH_ARGS("GetUserRecordByUID",
SD_BUS_PARAM(user_name), SD_BUS_ARGS("u", uid),
"sbo", SD_BUS_RESULT("s", user_record, "b", incomplete, "o", bus_path),
SD_BUS_PARAM(user_record) method_get_user_record_by_uid,
SD_BUS_PARAM(incomplete) SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_PARAM(bus_path), SD_BUS_METHOD_WITH_ARGS("ListHomes",
method_get_user_record_by_name, SD_BUS_NO_ARGS,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE), SD_BUS_RESULT("a(susussso)", home_areas),
SD_BUS_METHOD_WITH_NAMES("GetUserRecordByUID", method_list_homes,
"u", SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_PARAM(uid),
"sbo",
SD_BUS_PARAM(user_record)
SD_BUS_PARAM(incomplete)
SD_BUS_PARAM(bus_path),
method_get_user_record_by_uid,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD_WITH_NAMES("ListHomes",
NULL,,
"a(susussso)",
SD_BUS_PARAM(home_areas),
method_list_homes,
SD_BUS_VTABLE_UNPRIVILEGED),
/* The following methods directly execute an operation on a home area, without ref-counting, queueing /* The following methods directly execute an operation on a home area, without ref-counting, queueing
* or anything, and are accessible through homectl. */ * or anything, and are accessible through homectl. */
SD_BUS_METHOD_WITH_NAMES("ActivateHome", SD_BUS_METHOD_WITH_ARGS("ActivateHome",
"ss", SD_BUS_ARGS("s", user_name, "s", secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(secret), method_activate_home,
NULL,, SD_BUS_VTABLE_SENSITIVE),
method_activate_home, SD_BUS_METHOD_WITH_ARGS("DeactivateHome",
SD_BUS_VTABLE_SENSITIVE), SD_BUS_ARGS("s", user_name),
SD_BUS_METHOD_WITH_NAMES("DeactivateHome", SD_BUS_NO_RESULT,
"s", method_deactivate_home,
SD_BUS_PARAM(user_name), 0),
NULL,,
method_deactivate_home,
0),
/* Add the JSON record to homed, but don't create actual $HOME */ /* Add the JSON record to homed, but don't create actual $HOME */
SD_BUS_METHOD_WITH_NAMES("RegisterHome", SD_BUS_METHOD_WITH_ARGS("RegisterHome",
"s", SD_BUS_ARGS("s", user_record),
SD_BUS_PARAM(user_record), SD_BUS_NO_RESULT,
NULL,, method_register_home,
method_register_home, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_UNPRIVILEGED),
/* Remove the JSON record from homed, but don't remove actual $HOME */ /* Remove the JSON record from homed, but don't remove actual $HOME */
SD_BUS_METHOD_WITH_NAMES("UnregisterHome", SD_BUS_METHOD_WITH_ARGS("UnregisterHome",
"s", SD_BUS_ARGS("s", user_name),
SD_BUS_PARAM(user_name), SD_BUS_NO_RESULT,
NULL,, method_unregister_home,
method_unregister_home, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_UNPRIVILEGED),
/* Add JSON record, and create $HOME for it */ /* Add JSON record, and create $HOME for it */
SD_BUS_METHOD_WITH_NAMES("CreateHome", SD_BUS_METHOD_WITH_ARGS("CreateHome",
"s", SD_BUS_ARGS("s", user_record),
SD_BUS_PARAM(user_record), SD_BUS_NO_RESULT,
NULL,, method_create_home,
method_create_home, SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
/* Create $HOME for already registered JSON entry */ /* Create $HOME for already registered JSON entry */
SD_BUS_METHOD_WITH_NAMES("RealizeHome", SD_BUS_METHOD_WITH_ARGS("RealizeHome",
"ss", SD_BUS_ARGS("s", user_name, "s", secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(secret), method_realize_home,
NULL,, SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
method_realize_home,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
/* Remove the JSON record and remove $HOME */ /* Remove the JSON record and remove $HOME */
SD_BUS_METHOD_WITH_NAMES("RemoveHome", SD_BUS_METHOD_WITH_ARGS("RemoveHome",
"s", SD_BUS_ARGS("s", user_name),
SD_BUS_PARAM(user_name), SD_BUS_NO_RESULT,
NULL,, method_remove_home,
method_remove_home, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_UNPRIVILEGED),
/* Investigate $HOME and propagate contained JSON record into our database */ /* Investigate $HOME and propagate contained JSON record into our database */
SD_BUS_METHOD_WITH_NAMES("FixateHome", SD_BUS_METHOD_WITH_ARGS("FixateHome",
"ss", SD_BUS_ARGS("s", user_name, "s", secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(secret), method_fixate_home,
NULL,, SD_BUS_VTABLE_SENSITIVE),
method_fixate_home,
SD_BUS_VTABLE_SENSITIVE),
/* Just check credentials */ /* Just check credentials */
SD_BUS_METHOD_WITH_NAMES("AuthenticateHome", SD_BUS_METHOD_WITH_ARGS("AuthenticateHome",
"ss", SD_BUS_ARGS("s", user_name, "s", secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(secret), method_authenticate_home,
NULL,, SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
method_authenticate_home,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
/* Update the JSON record of existing user */ /* Update the JSON record of existing user */
SD_BUS_METHOD_WITH_NAMES("UpdateHome", SD_BUS_METHOD_WITH_ARGS("UpdateHome",
"s", SD_BUS_ARGS("s", user_record),
SD_BUS_PARAM(user_record), SD_BUS_NO_RESULT,
NULL,, method_update_home,
method_update_home, SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD_WITH_NAMES("ResizeHome", SD_BUS_METHOD_WITH_ARGS("ResizeHome",
"sts", SD_BUS_ARGS("s", user_name, "t", size, "s", secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(size) method_resize_home,
SD_BUS_PARAM(secret), SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
NULL,,
method_resize_home,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
SD_BUS_METHOD_WITH_NAMES("ChangePasswordHome", SD_BUS_METHOD_WITH_ARGS("ChangePasswordHome",
"sss", SD_BUS_ARGS("s", user_name, "s", new_secret, "s", old_secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(new_secret) method_change_password_home,
SD_BUS_PARAM(old_secret), SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
NULL,,
method_change_password_home,
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
/* Prepare active home for system suspend: flush out passwords, suspend access */ /* Prepare active home for system suspend: flush out passwords, suspend access */
SD_BUS_METHOD_WITH_NAMES("LockHome", SD_BUS_METHOD_WITH_ARGS("LockHome",
"s", SD_BUS_ARGS("s", user_name),
SD_BUS_PARAM(user_name), SD_BUS_NO_RESULT,
NULL,, method_lock_home,
method_lock_home, 0),
0),
/* Make $HOME usable after system resume again */ /* Make $HOME usable after system resume again */
SD_BUS_METHOD_WITH_NAMES("UnlockHome", SD_BUS_METHOD_WITH_ARGS("UnlockHome",
"ss", SD_BUS_ARGS("s", user_name, "s", secret),
SD_BUS_PARAM(user_name) SD_BUS_NO_RESULT,
SD_BUS_PARAM(secret), method_unlock_home,
NULL,, SD_BUS_VTABLE_SENSITIVE),
method_unlock_home,
SD_BUS_VTABLE_SENSITIVE),
/* The following methods implement ref-counted activation, and are what the PAM module and "homectl /* The following methods implement ref-counted activation, and are what the PAM module and "homectl
* with" use. In contrast to the methods above which fail if an operation is already being executed * with" use. In contrast to the methods above which fail if an operation is already being executed
@ -837,29 +801,21 @@ static const sd_bus_vtable manager_vtable[] = {
* the state of the home area, so that the end result is always the same (i.e. the home directory is * the state of the home area, so that the end result is always the same (i.e. the home directory is
* accessible), and we always validate the specified passwords. RefHome() will not authenticate, and * accessible), and we always validate the specified passwords. RefHome() will not authenticate, and
* thus only works if the home area is already active. */ * thus only works if the home area is already active. */
SD_BUS_METHOD_WITH_NAMES("AcquireHome", SD_BUS_METHOD_WITH_ARGS("AcquireHome",
"ssb", SD_BUS_ARGS("s", user_name, "s", secret, "b", please_suspend),
SD_BUS_PARAM(user_name) SD_BUS_RESULT("h", send_fd),
SD_BUS_PARAM(secret) method_acquire_home,
SD_BUS_PARAM(please_suspend), SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE),
"h", SD_BUS_METHOD_WITH_ARGS("RefHome",
SD_BUS_PARAM(send_fd), SD_BUS_ARGS("s", user_name, "b", please_suspend),
method_acquire_home, SD_BUS_RESULT("h", send_fd),
SD_BUS_VTABLE_UNPRIVILEGED|SD_BUS_VTABLE_SENSITIVE), method_ref_home,
SD_BUS_METHOD_WITH_NAMES("RefHome", 0),
"sb", SD_BUS_METHOD_WITH_ARGS("ReleaseHome",
SD_BUS_PARAM(user_name) SD_BUS_ARGS("s", user_name),
SD_BUS_PARAM(please_suspend), SD_BUS_NO_RESULT,
"h", method_release_home,
SD_BUS_PARAM(send_fd), 0),
method_ref_home,
0),
SD_BUS_METHOD_WITH_NAMES("ReleaseHome",
"s",
SD_BUS_PARAM(user_name),
NULL,,
method_release_home,
0),
/* An operation that acts on all homes that allow it */ /* An operation that acts on all homes that allow it */
SD_BUS_METHOD("LockAllHomes", NULL, NULL, method_lock_all_homes, 0), SD_BUS_METHOD("LockAllHomes", NULL, NULL, method_lock_all_homes, 0),