1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

Merge pull request #33714 from poettering/make-varlink-public

varlink: make API public as "sd-varlink.h"
This commit is contained in:
Daan De Meyer 2024-07-17 12:58:50 +02:00 committed by GitHub
commit d9b1ec27f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
124 changed files with 3776 additions and 3481 deletions

8
TODO
View File

@ -139,8 +139,6 @@ Features:
chattr bit. This is useful as protection against early uses of /var/ or /tmp/
before their contents is mounted.
* use c23 in headers to force enum size in public headers
* go through all uses of table_new() in our codebase, and make sure we support
all three of:
1. --no-legend properly
@ -295,12 +293,6 @@ Features:
the bg via vmspawn/nspawn if not done so yet and then requests a shell inside
it for the invoking user.
* make varlink.h a public API, i.e. give all symbols an sd_ prefix, and rename
header file to sd-varlink.h. This of course also means we have to make json.h
public the same way. Convert the function param checks from assert() to
assert_ret(). Only export the stuff we are sure about, and keep some symbols
internally where things are not clear whether we want other projects to use.
* importd/…: define per-user dirs for container/VM images too.
* add a new specifier to unit files that figures out the DDI the unit file is

View File

@ -2069,7 +2069,8 @@ libsystemd_includes = [basic_includes, include_directories(
'src/libsystemd/sd-json',
'src/libsystemd/sd-netlink',
'src/libsystemd/sd-network',
'src/libsystemd/sd-resolve')]
'src/libsystemd/sd-resolve',
'src/libsystemd/sd-varlink')]
includes = [libsystemd_includes, include_directories('src/shared')]

View File

@ -38,7 +38,7 @@ int verb_reboot_to_firmware(int argc, char *argv[], void *userdata) {
}
}
int vl_method_set_reboot_to_firmware(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_set_reboot_to_firmware(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "state", SD_JSON_VARIANT_BOOLEAN, sd_json_dispatch_stdbool, 0, 0 },
{}
@ -46,30 +46,30 @@ int vl_method_set_reboot_to_firmware(Varlink *link, sd_json_variant *parameters,
bool b;
int r;
r = varlink_dispatch(link, parameters, dispatch_table, &b);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &b);
if (r != 0)
return r;
r = efi_set_reboot_to_firmware(b);
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
return varlink_error(link, "io.systemd.BootControl.RebootToFirmwareNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.BootControl.RebootToFirmwareNotSupported", NULL);
if (r < 0)
return r;
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
int vl_method_get_reboot_to_firmware(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_get_reboot_to_firmware(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
int r;
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
r = efi_get_reboot_to_firmware();
if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
return varlink_error(link, "io.systemd.BootControl.RebootToFirmwareNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.BootControl.RebootToFirmwareNotSupported", NULL);
if (r < 0)
return r;
return varlink_replybo(link, SD_JSON_BUILD_PAIR_BOOLEAN("state", r));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_BOOLEAN("state", r));
}

View File

@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "varlink.h"
#include "sd-varlink.h"
int verb_reboot_to_firmware(int argc, char *argv[], void *userdata);
int vl_method_set_reboot_to_firmware(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_get_reboot_to_firmware(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_set_reboot_to_firmware(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
int vl_method_get_reboot_to_firmware(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -835,7 +835,7 @@ int verb_unlink(int argc, char *argv[], void *userdata) {
return verb_list(argc, argv, userdata);
}
int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_list_boot_entries(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
_cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
dev_t esp_devid = 0, xbootldr_devid = 0;
int r;
@ -843,10 +843,10 @@ int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, Varl
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
if (!FLAGS_SET(flags, VARLINK_METHOD_MORE))
return varlink_error(link, VARLINK_ERROR_EXPECTED_MORE, NULL);
if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE))
return sd_varlink_error(link, SD_VARLINK_ERROR_EXPECTED_MORE, NULL);
r = acquire_esp(/* unprivileged_mode= */ false,
/* graceful= */ false,
@ -876,7 +876,7 @@ int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, Varl
_cleanup_(sd_json_variant_unrefp) sd_json_variant *previous = NULL;
for (size_t i = 0; i < config.n_entries; i++) {
if (previous) {
r = varlink_notifybo(link, SD_JSON_BUILD_PAIR_VARIANT("entry", previous));
r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR_VARIANT("entry", previous));
if (r < 0)
return r;
@ -889,7 +889,7 @@ int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, Varl
}
if (!previous)
return varlink_error(link, "io.systemd.BootControl.NoSuchBootEntry", NULL);
return sd_varlink_error(link, "io.systemd.BootControl.NoSuchBootEntry", NULL);
return varlink_replybo(link, SD_JSON_BUILD_PAIR_VARIANT("entry", previous));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_VARIANT("entry", previous));
}

View File

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "varlink.h"
#include "sd-varlink.h"
int verb_status(int argc, char *argv[], void *userdata);
int verb_list(int argc, char *argv[], void *userdata);
int verb_unlink(int argc, char *argv[], void *userdata);
int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_list_boot_entries(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -2,6 +2,8 @@
#include <getopt.h>
#include "sd-varlink.h"
#include "blockdev-util.h"
#include "bootctl.h"
#include "bootctl-install.h"
@ -22,7 +24,6 @@
#include "parse-argument.h"
#include "pretty-print.h"
#include "utf8.h"
#include "varlink.h"
#include "varlink-io.systemd.BootControl.h"
#include "verbs.h"
#include "virt.h"
@ -432,7 +433,7 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_dry_run && argv[optind] && !STR_IN_SET(argv[optind], "unlink", "cleanup"))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--dry is only supported with --unlink or --cleanup");
r = varlink_invocation(VARLINK_ALLOW_ACCEPT);
r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT);
if (r < 0)
return log_error_errno(r, "Failed to check if invoked in Varlink mode: %m");
if (r > 0) {
@ -485,19 +486,19 @@ static int run(int argc, char *argv[]) {
return r;
if (arg_varlink) {
_cleanup_(varlink_server_unrefp) VarlinkServer *varlink_server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *varlink_server = NULL;
/* Invocation as Varlink service */
r = varlink_server_new(&varlink_server, VARLINK_SERVER_ROOT_ONLY);
r = sd_varlink_server_new(&varlink_server, SD_VARLINK_SERVER_ROOT_ONLY);
if (r < 0)
return log_error_errno(r, "Failed to allocate Varlink server: %m");
r = varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_BootControl);
r = sd_varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_BootControl);
if (r < 0)
return log_error_errno(r, "Failed to add Varlink interface: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
varlink_server,
"io.systemd.BootControl.ListBootEntries", vl_method_list_boot_entries,
"io.systemd.BootControl.SetRebootToFirmware", vl_method_set_reboot_to_firmware,
@ -505,7 +506,7 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to bind Varlink methods: %m");
r = varlink_server_loop_auto(varlink_server);
r = sd_varlink_server_loop_auto(varlink_server);
if (r < 0)
return log_error_errno(r, "Failed to run Varlink event loop: %m");

View File

@ -1,11 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink.h"
#include "core-varlink.h"
#include "json-util.h"
#include "mkdir-label.h"
#include "strv.h"
#include "user-util.h"
#include "varlink.h"
#include "varlink-io.systemd.UserDatabase.h"
#include "varlink-io.systemd.ManagedOOM.h"
@ -147,11 +148,11 @@ int manager_varlink_send_managed_oom_update(Unit *u) {
if (MANAGER_IS_SYSTEM(u->manager))
/* in system mode, oomd is our client, thus send out notifications as replies to the
* initiating method call from them. */
r = varlink_notify(u->manager->managed_oom_varlink, v);
r = sd_varlink_notify(u->manager->managed_oom_varlink, v);
else
/* in user mode, we are oomd's client, thus send out notifications as method calls that do
* not expect a reply. */
r = varlink_send(u->manager->managed_oom_varlink, "io.systemd.oom.ReportManagedOOMCGroups", v);
r = sd_varlink_send(u->manager->managed_oom_varlink, "io.systemd.oom.ReportManagedOOMCGroups", v);
return r;
}
@ -211,9 +212,9 @@ static int build_managed_oom_cgroups_json(Manager *m, sd_json_variant **ret) {
}
static int vl_method_subscribe_managed_oom_cgroups(
Varlink *link,
sd_varlink *link,
sd_json_variant *parameters,
VarlinkMethodFlags flags,
sd_varlink_method_flags_t flags,
void *userdata) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
@ -224,37 +225,37 @@ static int vl_method_subscribe_managed_oom_cgroups(
assert(link);
r = varlink_get_peer_pid(link, &pid);
r = sd_varlink_get_peer_pid(link, &pid);
if (r < 0)
return r;
u = manager_get_unit_by_pid(m, pid);
if (!u)
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
/* This is meant to be a deterrent and not actual security. The alternative is to check for the systemd-oom
* user that this unit runs as, but NSS lookups are blocking and not allowed from PID 1. */
if (!streq(u->id, "systemd-oomd.service"))
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
/* We only take one subscriber for this method so return an error if there's already an existing one.
* This shouldn't happen since systemd-oomd is the only client of this method. */
if (FLAGS_SET(flags, VARLINK_METHOD_MORE) && m->managed_oom_varlink)
return varlink_error(link, "io.systemd.ManagedOOM.SubscriptionTaken", NULL);
if (FLAGS_SET(flags, SD_VARLINK_METHOD_MORE) && m->managed_oom_varlink)
return sd_varlink_error(link, "io.systemd.ManagedOOM.SubscriptionTaken", NULL);
r = build_managed_oom_cgroups_json(m, &v);
if (r < 0)
return r;
if (!FLAGS_SET(flags, VARLINK_METHOD_MORE))
return varlink_reply(link, v);
if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE))
return sd_varlink_reply(link, v);
assert(!m->managed_oom_varlink);
m->managed_oom_varlink = varlink_ref(link);
return varlink_notify(m->managed_oom_varlink, v);
m->managed_oom_varlink = sd_varlink_ref(link);
return sd_varlink_notify(m->managed_oom_varlink, v);
}
static int manager_varlink_send_managed_oom_initial(Manager *m) {
@ -272,10 +273,10 @@ static int manager_varlink_send_managed_oom_initial(Manager *m) {
if (r < 0)
return r;
return varlink_send(m->managed_oom_varlink, "io.systemd.oom.ReportManagedOOMCGroups", v);
return sd_varlink_send(m->managed_oom_varlink, "io.systemd.oom.ReportManagedOOMCGroups", v);
}
static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "uid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, uid), 0 },
@ -296,12 +297,12 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.DynamicUser"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (uid_is_valid(p.uid))
r = dynamic_user_lookup_uid(m, p.uid, &found_name);
@ -321,7 +322,7 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
continue;
if (v) {
r = varlink_notify(link, v);
r = sd_varlink_notify(link, v);
if (r < 0)
return r;
@ -334,12 +335,12 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
}
if (!v)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
if (r == -ESRCH)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (r < 0)
return r;
@ -347,13 +348,13 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
un = found_name ?: p.user_name;
if (!user_match_lookup_parameters(&p, un, uid))
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
r = build_user_json(un, uid, &v);
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int build_group_json(const char *group_name, gid_t gid, sd_json_variant **ret) {
@ -381,7 +382,7 @@ static bool group_match_lookup_parameters(LookupParameters *p, const char *name,
return true;
}
static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "gid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, gid), 0 },
@ -402,12 +403,12 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.DynamicUser"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (gid_is_valid(p.gid))
r = dynamic_user_lookup_uid(m, (uid_t) p.gid, &found_name);
@ -429,7 +430,7 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
continue;
if (v) {
r = varlink_notify(link, v);
r = sd_varlink_notify(link, v);
if (r < 0)
return r;
@ -442,12 +443,12 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
}
if (!v)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
if (r == -ESRCH)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (r < 0)
return r;
@ -455,16 +456,16 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
gn = found_name ?: p.group_name;
if (!group_match_lookup_parameters(&p, gn, gid))
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
r = build_group_json(gn, gid, &v);
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "userName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParameters, user_name), SD_JSON_STRICT },
@ -478,48 +479,48 @@ static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters,
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.DynamicUser"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
/* We don't support auxiliary groups with dynamic users. */
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
}
static void vl_disconnect(VarlinkServer *s, Varlink *link, void *userdata) {
static void vl_disconnect(sd_varlink_server *s, sd_varlink *link, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(link);
if (link == m->managed_oom_varlink)
m->managed_oom_varlink = varlink_unref(link);
m->managed_oom_varlink = sd_varlink_unref(link);
}
static int manager_setup_varlink_server(Manager *m, VarlinkServer **ret) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
static int manager_setup_varlink_server(Manager *m, sd_varlink_server **ret) {
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
assert(ret);
r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_debug_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(s, m);
sd_varlink_server_set_userdata(s, m);
r = varlink_server_add_interface_many(
r = sd_varlink_server_add_interface_many(
s,
&vl_interface_io_systemd_UserDatabase,
&vl_interface_io_systemd_ManagedOOM);
if (r < 0)
return log_debug_errno(r, "Failed to add interfaces to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
s,
"io.systemd.UserDatabase.GetUserRecord", vl_method_get_user_record,
"io.systemd.UserDatabase.GetGroupRecord", vl_method_get_group_record,
@ -528,7 +529,7 @@ static int manager_setup_varlink_server(Manager *m, VarlinkServer **ret) {
if (r < 0)
return log_debug_errno(r, "Failed to register varlink methods: %m");
r = varlink_server_bind_disconnect(s, vl_disconnect);
r = sd_varlink_server_bind_disconnect(s, vl_disconnect);
if (r < 0)
return log_debug_errno(r, "Failed to register varlink disconnect handler: %m");
@ -537,7 +538,7 @@ static int manager_setup_varlink_server(Manager *m, VarlinkServer **ret) {
}
static int manager_varlink_init_system(Manager *m) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
@ -566,13 +567,13 @@ static int manager_varlink_init_system(Manager *m) {
"Failed to check if varlink socket '%s' exists: %m", address);
}
r = varlink_server_listen_address(s, address, 0666);
r = sd_varlink_server_listen_address(s, address, 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket '%s': %m", address);
}
}
r = varlink_server_attach_event(s, m->event, EVENT_PRIORITY_IPC);
r = sd_varlink_server_attach_event(s, m->event, EVENT_PRIORITY_IPC);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
@ -580,18 +581,18 @@ static int manager_varlink_init_system(Manager *m) {
return 1;
}
static int vl_reply(Varlink *link, sd_json_variant *parameters, const char *error_id, VarlinkReplyFlags flags, void *userdata) {
static int vl_reply(sd_varlink *link, sd_json_variant *parameters, const char *error_id, sd_varlink_reply_flags_t flags, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
int r;
if (error_id)
log_debug("varlink systemd-oomd client error: %s", error_id);
if (FLAGS_SET(flags, VARLINK_REPLY_ERROR) && FLAGS_SET(flags, VARLINK_REPLY_LOCAL)) {
/* Varlink connection was closed, likely because of systemd-oomd restart. Let's try to
if (FLAGS_SET(flags, SD_VARLINK_REPLY_ERROR) && FLAGS_SET(flags, SD_VARLINK_REPLY_LOCAL)) {
/* sd_varlink connection was closed, likely because of systemd-oomd restart. Let's try to
* reconnect and send the initial ManagedOOM update again. */
m->managed_oom_varlink = varlink_unref(link);
m->managed_oom_varlink = sd_varlink_unref(link);
log_debug("Reconnecting to %s", VARLINK_ADDR_PATH_MANAGED_OOM_USER);
@ -604,7 +605,7 @@ static int vl_reply(Varlink *link, sd_json_variant *parameters, const char *erro
}
static int manager_varlink_init_user(Manager *m) {
_cleanup_(varlink_close_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_close_unrefp) sd_varlink *link = NULL;
int r;
assert(m);
@ -615,7 +616,7 @@ static int manager_varlink_init_user(Manager *m) {
if (MANAGER_IS_TEST_RUN(m))
return 0;
r = varlink_connect_address(&link, VARLINK_ADDR_PATH_MANAGED_OOM_USER);
r = sd_varlink_connect_address(&link, VARLINK_ADDR_PATH_MANAGED_OOM_USER);
if (r < 0) {
if (r == -ENOENT || ERRNO_IS_DISCONNECT(r)) {
log_debug("systemd-oomd varlink unix socket not found, skipping user manager varlink setup");
@ -624,13 +625,13 @@ static int manager_varlink_init_user(Manager *m) {
return log_error_errno(r, "Failed to connect to %s: %m", VARLINK_ADDR_PATH_MANAGED_OOM_USER);
}
varlink_set_userdata(link, m);
sd_varlink_set_userdata(link, m);
r = varlink_bind_reply(link, vl_reply);
r = sd_varlink_bind_reply(link, vl_reply);
if (r < 0)
return r;
r = varlink_attach_event(link, m->event, EVENT_PRIORITY_IPC);
r = sd_varlink_attach_event(link, m->event, EVENT_PRIORITY_IPC);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
@ -653,8 +654,8 @@ void manager_varlink_done(Manager *m) {
* the manager, and only then disconnect it in two steps so that we don't end up accidentally
* unreffing it twice. After all, closing the connection might cause the disconnect handler we
* installed (vl_disconnect() above) to be called, where we will unref it too. */
varlink_close_unref(TAKE_PTR(m->managed_oom_varlink));
sd_varlink_close_unref(TAKE_PTR(m->managed_oom_varlink));
m->varlink_server = varlink_server_unref(m->varlink_server);
m->managed_oom_varlink = varlink_close_unref(m->managed_oom_varlink);
m->varlink_server = sd_varlink_server_unref(m->varlink_server);
m->managed_oom_varlink = sd_varlink_close_unref(m->managed_oom_varlink);
}

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink.h"
#include "clean-ipc.h"
#include "core-varlink.h"
#include "dbus.h"
@ -15,7 +17,7 @@
#include "syslog-util.h"
#include "unit-serialize.h"
#include "user-util.h"
#include "varlink-internal.h"
#include "varlink-serialize.h"
int manager_open_serialization(Manager *m, FILE **ret_f) {
assert(ret_f);

View File

@ -7,6 +7,7 @@
#include "sd-bus.h"
#include "sd-device.h"
#include "sd-event.h"
#include "sd-varlink.h"
#include "common-signal.h"
#include "cgroup-util.h"
@ -16,7 +17,6 @@
#include "list.h"
#include "prioq.h"
#include "ratelimit.h"
#include "varlink.h"
struct libmnt_monitor;
typedef struct Unit Unit;
@ -486,12 +486,12 @@ struct Manager {
unsigned sigchldgen;
unsigned notifygen;
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
/* When we're a system manager, this object manages the subscription from systemd-oomd to PID1 that's
* used to report changes in ManagedOOM settings (systemd server - oomd client). When
* we're a user manager, this object manages the client connection from the user manager to
* systemd-oomd to report changes in ManagedOOM settings (systemd client - oomd server). */
Varlink *managed_oom_varlink;
sd_varlink *managed_oom_varlink;
/* Reference to RestrictFileSystems= BPF program */
struct restrict_fs_bpf *restrict_fs;

View File

@ -4,6 +4,7 @@
#include <unistd.h>
#include "sd-json.h"
#include "sd-varlink.h"
#include "build.h"
#include "bus-polkit.h"
@ -29,7 +30,6 @@
#include "tpm2-pcr.h"
#include "tpm2-util.h"
#include "user-util.h"
#include "varlink.h"
#include "varlink-io.systemd.Credentials.h"
#include "verbs.h"
@ -1056,7 +1056,7 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_tpm2_public_key_pcr_mask == UINT32_MAX)
arg_tpm2_public_key_pcr_mask = UINT32_C(1) << TPM2_PCR_KERNEL_BOOT;
r = varlink_invocation(VARLINK_ALLOW_ACCEPT);
r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT);
if (r < 0)
return log_error_errno(r, "Failed to check if invoked in Varlink mode: %m");
arg_varlink = r;
@ -1126,7 +1126,7 @@ static void method_encrypt_parameters_done(MethodEncryptParameters *p) {
}
static int settle_scope(
Varlink *link,
sd_varlink *link,
CredentialScope *scope,
uid_t *uid,
CredentialFlags *flags,
@ -1140,7 +1140,7 @@ static int settle_scope(
assert(uid);
assert(flags);
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -1163,13 +1163,13 @@ static int settle_scope(
} else {
assert(*scope == CREDENTIAL_SYSTEM);
if (uid_is_valid(*uid))
return varlink_error_invalid_parameter_name(link, "uid");
return sd_varlink_error_invalid_parameter_name(link, "uid");
}
return 0;
}
static int vl_method_encrypt(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_encrypt(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(MethodEncryptParameters, name), 0 },
@ -1197,28 +1197,28 @@ static int vl_method_encrypt(Varlink *link, sd_json_variant *parameters, Varlink
assert(link);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.name && !credential_name_valid(p.name))
return varlink_error_invalid_parameter_name(link, "name");
return sd_varlink_error_invalid_parameter_name(link, "name");
/* Specifying both or neither the text string and the binary data is not allowed */
if (!!p.text == !!p.data.iov_base)
return varlink_error_invalid_parameter_name(link, "data");
return sd_varlink_error_invalid_parameter_name(link, "data");
if (p.timestamp == UINT64_MAX) {
p.timestamp = now(CLOCK_REALTIME);
timestamp_fresh = true;
} else
timestamp_fresh = timestamp_is_fresh(p.timestamp);
if (p.not_after != UINT64_MAX && p.not_after < p.timestamp)
return varlink_error_invalid_parameter_name(link, "notAfter");
return sd_varlink_error_invalid_parameter_name(link, "notAfter");
r = settle_scope(link, &p.scope, &p.uid, &cflags, /* any_scope_after_polkit= */ NULL);
if (r < 0)
return r;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -1251,7 +1251,7 @@ static int vl_method_encrypt(Varlink *link, sd_json_variant *parameters, Varlink
cflags,
&output);
if (r == -ESRCH)
return varlink_error(link, "io.systemd.Credentials.NoSuchUser", NULL);
return sd_varlink_error(link, "io.systemd.Credentials.NoSuchUser", NULL);
if (r < 0)
return r;
@ -1264,7 +1264,7 @@ static int vl_method_encrypt(Varlink *link, sd_json_variant *parameters, Varlink
/* Let's also mark the (theoretically encrypted) reply as sensitive, in case the NULL encryption scheme was used. */
sd_json_variant_sensitive(reply);
return varlink_reply(link, reply);
return sd_varlink_reply(link, reply);
}
typedef struct MethodDecryptParameters {
@ -1281,7 +1281,7 @@ static void method_decrypt_parameters_done(MethodDecryptParameters *p) {
iovec_done_erase(&p->blob);
}
static int vl_method_decrypt(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_decrypt(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(MethodDecryptParameters, name), 0 },
@ -1306,12 +1306,12 @@ static int vl_method_decrypt(Varlink *link, sd_json_variant *parameters, Varlink
assert(link);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.name && !credential_name_valid(p.name))
return varlink_error_invalid_parameter_name(link, "name");
return sd_varlink_error_invalid_parameter_name(link, "name");
if (p.timestamp == UINT64_MAX) {
p.timestamp = now(CLOCK_REALTIME);
timestamp_fresh = true;
@ -1322,7 +1322,7 @@ static int vl_method_decrypt(Varlink *link, sd_json_variant *parameters, Varlink
if (r < 0)
return r;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -1363,15 +1363,15 @@ static int vl_method_decrypt(Varlink *link, sd_json_variant *parameters, Varlink
}
if (r == -EBADMSG)
return varlink_error(link, "io.systemd.Credentials.BadFormat", NULL);
return sd_varlink_error(link, "io.systemd.Credentials.BadFormat", NULL);
if (r == -EREMOTE)
return varlink_error(link, "io.systemd.Credentials.NameMismatch", NULL);
return sd_varlink_error(link, "io.systemd.Credentials.NameMismatch", NULL);
if (r == -ESTALE)
return varlink_error(link, "io.systemd.Credentials.TimeMismatch", NULL);
return sd_varlink_error(link, "io.systemd.Credentials.TimeMismatch", NULL);
if (r == -ESRCH)
return varlink_error(link, "io.systemd.Credentials.NoSuchUser", NULL);
return sd_varlink_error(link, "io.systemd.Credentials.NoSuchUser", NULL);
if (r == -EMEDIUMTYPE)
return varlink_error(link, "io.systemd.Credentials.BadScope", NULL);
return sd_varlink_error(link, "io.systemd.Credentials.BadScope", NULL);
if (r < 0)
return r;
@ -1383,7 +1383,7 @@ static int vl_method_decrypt(Varlink *link, sd_json_variant *parameters, Varlink
sd_json_variant_sensitive(reply);
return varlink_reply(link, reply);
return sd_varlink_reply(link, reply);
}
static int run(int argc, char *argv[]) {
@ -1396,29 +1396,29 @@ static int run(int argc, char *argv[]) {
return r;
if (arg_varlink) {
_cleanup_(varlink_server_unrefp) VarlinkServer *varlink_server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *varlink_server = NULL;
_cleanup_(hashmap_freep) Hashmap *polkit_registry = NULL;
/* Invocation as Varlink service */
r = varlink_server_new(&varlink_server, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA|VARLINK_SERVER_INPUT_SENSITIVE);
r = sd_varlink_server_new(&varlink_server, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA|SD_VARLINK_SERVER_INPUT_SENSITIVE);
if (r < 0)
return log_error_errno(r, "Failed to allocate Varlink server: %m");
r = varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_Credentials);
r = sd_varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_Credentials);
if (r < 0)
return log_error_errno(r, "Failed to add Varlink interface: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
varlink_server,
"io.systemd.Credentials.Encrypt", vl_method_encrypt,
"io.systemd.Credentials.Decrypt", vl_method_decrypt);
if (r < 0)
return log_error_errno(r, "Failed to bind Varlink methods: %m");
varlink_server_set_userdata(varlink_server, &polkit_registry);
sd_varlink_server_set_userdata(varlink_server, &polkit_registry);
r = varlink_server_loop_auto(varlink_server);
r = sd_varlink_server_loop_auto(varlink_server);
if (r < 0)
return log_error_errno(r, "Failed to run Varlink event loop: %m");

View File

@ -2,16 +2,18 @@
#include <unistd.h>
#include "sd-varlink-idl.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fuzz.h"
#include "io-util.h"
#include "log.h"
#include "string-util.h"
#include "varlink-idl.h"
#include "varlink-idl-util.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(varlink_interface_freep) VarlinkInterface *vi = NULL;
_cleanup_(varlink_interface_freep) sd_varlink_interface *vi = NULL;
_cleanup_free_ char *str = NULL, *dump = NULL;
int r;
@ -28,7 +30,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;
}
assert_se(varlink_idl_format(vi, &dump) >= 0);
assert_se(sd_varlink_idl_format(vi, &dump) >= 0);
(void) varlink_idl_consistent(vi, LOG_DEBUG);
return 0;

View File

@ -2,22 +2,23 @@
#include <unistd.h>
#include "sd-varlink.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fuzz.h"
#include "hexdecoct.h"
#include "iovec-util.h"
#include "varlink.h"
#include "log.h"
static FILE *null = NULL;
static int method_something(Varlink *v, sd_json_variant *p, VarlinkMethodFlags flags, void *userdata) {
static int method_something(sd_varlink *v, sd_json_variant *p, sd_varlink_method_flags_t flags, void *userdata) {
sd_json_variant_dump(p, SD_JSON_FORMAT_NEWLINE|SD_JSON_FORMAT_PRETTY, null, NULL);
return 0;
}
static int reply_callback(Varlink *v, sd_json_variant *p, const char *error_id, VarlinkReplyFlags flags, void *userdata) {
static int reply_callback(sd_varlink *v, sd_json_variant *p, const char *error_id, sd_varlink_reply_flags_t flags, void *userdata) {
sd_json_variant_dump(p, SD_JSON_FORMAT_NEWLINE|SD_JSON_FORMAT_PRETTY, null, NULL);
return 0;
}
@ -88,8 +89,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_close_pair_ int server_pair[2] = EBADF_PAIR, client_pair[2] = EBADF_PAIR;
_cleanup_(sd_event_source_unrefp) sd_event_source *idle_event_source = NULL,
*server_event_source = NULL, *client_event_source = NULL;
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(varlink_flush_close_unrefp) Varlink *c = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *c = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
fuzz_setup_logging();
@ -100,22 +101,22 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
/* Test one: write the data as method call to a server */
assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, server_pair) >= 0);
assert_se(varlink_server_new(&s, 0) >= 0);
assert_se(varlink_server_set_description(s, "myserver") >= 0);
assert_se(varlink_server_attach_event(s, e, 0) >= 0);
assert_se(varlink_server_add_connection(s, server_pair[0], NULL) >= 0);
assert_se(sd_varlink_server_new(&s, 0) >= 0);
assert_se(sd_varlink_server_set_description(s, "myserver") >= 0);
assert_se(sd_varlink_server_attach_event(s, e, 0) >= 0);
assert_se(sd_varlink_server_add_connection(s, server_pair[0], NULL) >= 0);
TAKE_FD(server_pair[0]);
assert_se(varlink_server_bind_method(s, "io.test.DoSomething", method_something) >= 0);
assert_se(sd_varlink_server_bind_method(s, "io.test.DoSomething", method_something) >= 0);
assert_se(sd_event_add_io(e, &server_event_source, server_pair[1], EPOLLIN|EPOLLOUT, io_callback, &server_iov) >= 0);
/* Test two: write the data as method response to a client */
assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, client_pair) >= 0);
assert_se(varlink_connect_fd(&c, client_pair[0]) >= 0);
assert_se(sd_varlink_connect_fd(&c, client_pair[0]) >= 0);
TAKE_FD(client_pair[0]);
assert_se(varlink_set_description(c, "myclient") >= 0);
assert_se(varlink_attach_event(c, e, 0) >= 0);
assert_se(varlink_bind_reply(c, reply_callback) >= 0);
assert_se(varlink_invoke(c, "io.test.DoSomething", NULL) >= 0);
assert_se(sd_varlink_set_description(c, "myclient") >= 0);
assert_se(sd_varlink_attach_event(c, e, 0) >= 0);
assert_se(sd_varlink_bind_reply(c, reply_callback) >= 0);
assert_se(sd_varlink_invoke(c, "io.test.DoSomething", NULL) >= 0);
assert_se(sd_event_add_io(e, &client_event_source, client_pair[1], EPOLLIN|EPOLLOUT, io_callback, &client_iov) >= 0);
assert_se(sd_event_add_defer(e, &idle_event_source, idle_callback, NULL) >= 0);

View File

@ -293,7 +293,7 @@ Manager* manager_free(Manager *m) {
hashmap_free(m->public_keys);
varlink_server_unref(m->varlink_server);
sd_varlink_server_unref(m->varlink_server);
free(m->userdb_service);
free(m->default_file_system_type);
@ -1008,17 +1008,17 @@ static int manager_bind_varlink(Manager *m) {
assert(m);
assert(!m->varlink_server);
r = varlink_server_new(&m->varlink_server, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA|VARLINK_SERVER_INPUT_SENSITIVE);
r = sd_varlink_server_new(&m->varlink_server, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA|SD_VARLINK_SERVER_INPUT_SENSITIVE);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(m->varlink_server, m);
sd_varlink_server_set_userdata(m->varlink_server, m);
r = varlink_server_add_interface(m->varlink_server, &vl_interface_io_systemd_UserDatabase);
r = sd_varlink_server_add_interface(m->varlink_server, &vl_interface_io_systemd_UserDatabase);
if (r < 0)
return log_error_errno(r, "Failed to add UserDatabase interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
m->varlink_server,
"io.systemd.UserDatabase.GetUserRecord", vl_method_get_user_record,
"io.systemd.UserDatabase.GetGroupRecord", vl_method_get_group_record,
@ -1039,11 +1039,11 @@ static int manager_bind_varlink(Manager *m) {
} else
socket_path = "/run/systemd/userdb/io.systemd.Home";
r = varlink_server_listen_address(m->varlink_server, socket_path, 0666);
r = sd_varlink_server_listen_address(m->varlink_server, socket_path, 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(m->varlink_server, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(m->varlink_server, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");

View File

@ -6,12 +6,12 @@
#include "sd-bus.h"
#include "sd-device.h"
#include "sd-event.h"
#include "sd-varlink.h"
typedef struct Manager Manager;
#include "hashmap.h"
#include "homed-home.h"
#include "varlink.h"
/* The LUKS free disk space rebalancing logic goes through this state machine */
typedef enum RebalanceState {
@ -55,7 +55,7 @@ struct Manager {
Home *gc_focus;
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
char *userdb_service;
EVP_PKEY *private_key; /* actually a pair of private and public key */

View File

@ -18,14 +18,14 @@ typedef struct LookupParameters {
const char *service;
} LookupParameters;
static bool client_is_trusted(Varlink *link, Home *h) {
static bool client_is_trusted(sd_varlink *link, Home *h) {
uid_t peer_uid;
int r;
assert(link);
assert(h);
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0) {
log_debug_errno(r, "Unable to query peer UID, ignoring: %m");
return false;
@ -70,7 +70,7 @@ static bool home_user_match_lookup_parameters(LookupParameters *p, Home *h) {
return true;
}
int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "uid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, uid), 0 },
@ -90,12 +90,12 @@ int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, Varlin
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, m->userdb_service))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (uid_is_valid(p.uid))
h = hashmap_get(m->homes_by_uid, UID_TO_PTR(p.uid));
@ -114,7 +114,7 @@ int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, Varlin
if (v) {
/* An entry set from the previous iteration? Then send it now */
r = varlink_notify(link, v);
r = sd_varlink_notify(link, v);
if (r < 0)
return r;
@ -129,16 +129,16 @@ int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, Varlin
}
if (!v)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
if (!h)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (!home_user_match_lookup_parameters(&p, h))
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
trusted = client_is_trusted(link, h);
@ -146,7 +146,7 @@ int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, Varlin
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int build_group_json(Home *h, sd_json_variant **ret) {
@ -183,7 +183,7 @@ static bool home_group_match_lookup_parameters(LookupParameters *p, Home *h) {
return true;
}
int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "gid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, gid), 0 },
@ -202,12 +202,12 @@ int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, Varli
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, m->userdb_service))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (gid_is_valid(p.gid))
h = hashmap_get(m->homes_by_uid, UID_TO_PTR((uid_t) p.gid));
@ -221,7 +221,7 @@ int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, Varli
continue;
if (v) {
r = varlink_notify(link, v);
r = sd_varlink_notify(link, v);
if (r < 0)
return r;
@ -234,25 +234,25 @@ int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, Varli
}
if (!v)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
if (!h)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (!home_group_match_lookup_parameters(&p, h))
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
r = build_group_json(h, &v);
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "userName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParameters, user_name), SD_JSON_STRICT },
@ -268,25 +268,25 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, m->userdb_service))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (p.user_name) {
const char *last = NULL;
h = hashmap_get(m->homes_by_name, p.user_name);
if (!h)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (p.group_name) {
if (!strv_contains(h->record->member_of, p.group_name))
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
@ -294,7 +294,7 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
STRV_FOREACH(i, h->record->member_of) {
if (last) {
r = varlink_notifybo(
r = sd_varlink_notifybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last)));
@ -306,7 +306,7 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
}
if (last)
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last)));
@ -320,7 +320,7 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
continue;
if (last) {
r = varlink_notifybo(
r = sd_varlink_notifybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
@ -332,7 +332,7 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
}
if (last)
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
@ -345,7 +345,7 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
if (last_user_name) {
assert(last_group_name);
r = varlink_notifybo(
r = sd_varlink_notifybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name)));
@ -360,12 +360,12 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
if (last_user_name) {
assert(last_group_name);
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name)));
}
}
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
}

View File

@ -3,6 +3,6 @@
#include "homed-manager.h"
int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -80,7 +80,7 @@ typedef struct Context {
sd_event *event;
sd_bus *bus;
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
Hashmap *polkit_registry;
} Context;
@ -102,7 +102,7 @@ static void context_destroy(Context *c) {
hashmap_free(c->polkit_registry);
sd_event_unref(c->event);
sd_bus_flush_close_unref(c->bus);
varlink_server_unref(c->varlink_server);
sd_varlink_server_unref(c->varlink_server);
}
static void context_read_etc_hostname(Context *c) {
@ -1601,7 +1601,7 @@ static int connect_bus(Context *c) {
return 0;
}
static int vl_method_describe(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_describe(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
VARLINK_DISPATCH_POLKIT_FIELD,
{}
@ -1614,7 +1614,7 @@ static int vl_method_describe(Varlink *link, sd_json_variant *parameters, Varlin
assert(link);
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, /* userdata= */ NULL);
r = sd_varlink_dispatch(link, parameters, dispatch_table, /* userdata= */ NULL);
if (r != 0)
return r;
@ -1638,7 +1638,7 @@ static int vl_method_describe(Varlink *link, sd_json_variant *parameters, Varlin
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int connect_varlink(Context *c) {
@ -1648,31 +1648,31 @@ static int connect_varlink(Context *c) {
assert(c->event);
assert(!c->varlink_server);
r = varlink_server_new(&c->varlink_server, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&c->varlink_server, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate Varlink server: %m");
varlink_server_set_userdata(c->varlink_server, c);
sd_varlink_server_set_userdata(c->varlink_server, c);
r = varlink_server_add_interface(c->varlink_server, &vl_interface_io_systemd_Hostname);
r = sd_varlink_server_add_interface(c->varlink_server, &vl_interface_io_systemd_Hostname);
if (r < 0)
return log_error_errno(r, "Failed to add Hostname interface to varlink server: %m");
return log_error_errno(r, "Failed to add Hostname interface to Varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
c->varlink_server,
"io.systemd.Hostname.Describe", vl_method_describe);
if (r < 0)
return log_error_errno(r, "Failed to bind Varlink method calls: %m");
r = varlink_server_attach_event(c->varlink_server, c->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(c->varlink_server, c->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach Varlink server to event loop: %m");
r = varlink_server_listen_auto(c->varlink_server);
r = sd_varlink_server_listen_auto(c->varlink_server);
if (r < 0)
return log_error_errno(r, "Failed to bind to passed Varlink sockets: %m");
if (r == 0) {
r = varlink_server_listen_address(c->varlink_server, "/run/systemd/io.systemd.Hostname", 0666);
r = sd_varlink_server_listen_address(c->varlink_server, "/run/systemd/io.systemd.Hostname", 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to Varlink socket: %m");
}
@ -1683,7 +1683,7 @@ static int connect_varlink(Context *c) {
static bool context_check_idle(void *userdata) {
Context *c = ASSERT_PTR(userdata);
return varlink_server_current_connections(c->varlink_server) == 0 &&
return sd_varlink_server_current_connections(c->varlink_server) == 0 &&
hashmap_isempty(c->polkit_registry);
}

View File

@ -4,6 +4,7 @@
#include <sys/wait.h>
#include "sd-bus.h"
#include "sd-varlink.h"
#include "alloc-util.h"
#include "build-path.h"
@ -40,8 +41,8 @@
#include "strv.h"
#include "syslog-util.h"
#include "user-util.h"
#include "varlink.h"
#include "varlink-io.systemd.Import.h"
#include "varlink-util.h"
#include "web-util.h"
typedef struct Transfer Transfer;
@ -97,7 +98,7 @@ struct Transfer {
struct Manager {
sd_event *event;
sd_bus *bus;
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
uint32_t current_transfer_id;
Hashmap *transfers;
@ -126,7 +127,7 @@ static const char* const transfer_type_table[_TRANSFER_TYPE_MAX] = {
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(transfer_type, TransferType);
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(varlink_hash_ops, void, trivial_hash_func, trivial_compare_func, Varlink, varlink_unref);
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(varlink_hash_ops, void, trivial_hash_func, trivial_compare_func, sd_varlink, sd_varlink_unref);
static Transfer *transfer_unref(Transfer *t) {
if (!t)
@ -622,7 +623,7 @@ static Manager *manager_unref(Manager *m) {
hashmap_free(m->polkit_registry);
m->bus = sd_bus_flush_close_unref(m->bus);
m->varlink_server = varlink_server_unref(m->varlink_server);
m->varlink_server = sd_varlink_server_unref(m->varlink_server);
sd_event_unref(m->event);
@ -1786,7 +1787,7 @@ static int make_transfer_json(Transfer *t, sd_json_variant **ret) {
return 0;
}
static int vl_method_list_transfers(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_list_transfers(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
struct p {
ImageClass class;
@ -1805,12 +1806,12 @@ static int vl_method_list_transfers(Varlink *link, sd_json_variant *parameters,
assert(link);
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!FLAGS_SET(flags, VARLINK_METHOD_MORE))
return varlink_error(link, VARLINK_ERROR_EXPECTED_MORE, NULL);
if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE))
return sd_varlink_error(link, SD_VARLINK_ERROR_EXPECTED_MORE, NULL);
Transfer *previous = NULL, *t;
HASHMAP_FOREACH(t, m->transfers) {
@ -1825,7 +1826,7 @@ static int vl_method_list_transfers(Varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
r = varlink_notify(link, v);
r = sd_varlink_notify(link, v);
if (r < 0)
return r;
}
@ -1840,16 +1841,16 @@ static int vl_method_list_transfers(Varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
return varlink_error(link, "io.systemd.Import.NoTransfers", NULL);
return sd_varlink_error(link, "io.systemd.Import.NoTransfers", NULL);
}
static JSON_DISPATCH_ENUM_DEFINE(json_dispatch_import_verify, ImportVerify, import_verify_from_string);
static JSON_DISPATCH_ENUM_DEFINE(json_dispatch_import_type, ImportType, import_type_from_string);
static int vl_method_pull(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_pull(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
struct p {
const char *remote, *local;
@ -1883,15 +1884,15 @@ static int vl_method_pull(Varlink *link, sd_json_variant *parameters, VarlinkMet
assert(link);
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!http_url_is_valid(p.remote) && !file_url_is_valid(p.remote))
return varlink_error_invalid_parameter_name(link, "remote");
return sd_varlink_error_invalid_parameter_name(link, "remote");
if (p.local && !image_name_is_valid(p.local))
return varlink_error_invalid_parameter_name(link, "local");
return sd_varlink_error_invalid_parameter_name(link, "local");
uint64_t transfer_flags = (p.force * IMPORT_FORCE) | (p.read_only * IMPORT_READ_ONLY) | (p.keep_download * IMPORT_PULL_KEEP_DOWNLOAD);
@ -1902,7 +1903,7 @@ static int vl_method_pull(Varlink *link, sd_json_variant *parameters, VarlinkMet
assert(tt >= 0);
if (manager_find(m, tt, p.remote))
return varlink_errorbo(link, "io.systemd.Import.AlreadyInProgress", SD_JSON_BUILD_PAIR_STRING("remote", p.remote));
return sd_varlink_errorbo(link, "io.systemd.Import.AlreadyInProgress", SD_JSON_BUILD_PAIR_STRING("remote", p.remote));
r = varlink_verify_polkit_async(
link,
@ -1944,17 +1945,17 @@ static int vl_method_pull(Varlink *link, sd_json_variant *parameters, VarlinkMet
return r;
/* If more was not set, just return the download id, and be done with it */
if (!FLAGS_SET(flags, VARLINK_METHOD_MORE))
return varlink_replybo(link, SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id)));
if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE))
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id)));
/* Otherwise add this connection to the set of subscriptions, return the id, but keep the thing running */
r = set_ensure_put(&t->varlink_subscribed, &varlink_hash_ops, link);
if (r < 0)
return r;
varlink_ref(link);
sd_varlink_ref(link);
r = varlink_notifybo(link, SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id)));
r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id)));
if (r < 0)
return r;
@ -1969,32 +1970,32 @@ static int manager_connect_varlink(Manager *m) {
assert(m->event);
assert(!m->varlink_server);
r = varlink_server_new(&m->varlink_server, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&m->varlink_server, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate Varlink server: %m");
varlink_server_set_userdata(m->varlink_server, m);
sd_varlink_server_set_userdata(m->varlink_server, m);
r = varlink_server_add_interface(m->varlink_server, &vl_interface_io_systemd_Import);
r = sd_varlink_server_add_interface(m->varlink_server, &vl_interface_io_systemd_Import);
if (r < 0)
return log_error_errno(r, "Failed to add Import interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
m->varlink_server,
"io.systemd.Import.ListTransfers", vl_method_list_transfers,
"io.systemd.Import.Pull", vl_method_pull);
if (r < 0)
return log_error_errno(r, "Failed to bind Varlink method calls: %m");
r = varlink_server_attach_event(m->varlink_server, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(m->varlink_server, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach Varlink server to event loop: %m");
r = varlink_server_listen_auto(m->varlink_server);
r = sd_varlink_server_listen_auto(m->varlink_server);
if (r < 0)
return log_error_errno(r, "Failed to bind to passed Varlink sockets: %m");
if (r == 0) {
r = varlink_server_listen_address(m->varlink_server, "/run/systemd/io.systemd.Import", 0666);
r = sd_varlink_server_listen_address(m->varlink_server, "/run/systemd/io.systemd.Import", 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to Varlink socket: %m");
}
@ -2007,7 +2008,7 @@ static bool manager_check_idle(void *userdata) {
return hashmap_isempty(m->transfers) &&
hashmap_isempty(m->polkit_registry) &&
varlink_server_current_connections(m->varlink_server) == 0;
sd_varlink_server_current_connections(m->varlink_server) == 0;
}
static void manager_parse_env(Manager *m) {

View File

@ -1,15 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink.h"
#include "errno-util.h"
#include "journal-internal.h"
#include "journal-vacuum.h"
#include "journalctl.h"
#include "journalctl-util.h"
#include "journalctl-varlink.h"
#include "varlink.h"
#include "varlink-util.h"
static int varlink_connect_journal(Varlink **ret) {
_cleanup_(varlink_flush_close_unrefp) Varlink *vl = NULL;
static int varlink_connect_journal(sd_varlink **ret) {
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
const char *address;
int r;
@ -19,19 +21,19 @@ static int varlink_connect_journal(Varlink **ret) {
strjoina("/run/systemd/journal.", arg_namespace, "/io.systemd.journal") :
"/run/systemd/journal/io.systemd.journal";
r = varlink_connect_address(&vl, address);
r = sd_varlink_connect_address(&vl, address);
if (r < 0)
return r;
(void) varlink_set_description(vl, "journal");
(void) varlink_set_relative_timeout(vl, USEC_INFINITY);
(void) sd_varlink_set_description(vl, "journal");
(void) sd_varlink_set_relative_timeout(vl, USEC_INFINITY);
*ret = TAKE_PTR(vl);
return 0;
}
int action_flush_to_var(void) {
_cleanup_(varlink_flush_close_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *link = NULL;
int r;
assert(arg_action == ACTION_FLUSH);
@ -54,7 +56,7 @@ int action_flush_to_var(void) {
}
int action_relinquish_var(void) {
_cleanup_(varlink_flush_close_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *link = NULL;
int r;
assert(arg_action == ACTION_RELINQUISH_VAR);
@ -72,7 +74,7 @@ int action_relinquish_var(void) {
}
int action_rotate(void) {
_cleanup_(varlink_flush_close_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *link = NULL;
int r;
assert(IN_SET(arg_action, ACTION_ROTATE, ACTION_ROTATE_AND_VACUUM));
@ -121,7 +123,7 @@ int action_rotate_and_vacuum(void) {
}
int action_sync(void) {
_cleanup_(varlink_flush_close_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *link = NULL;
int r;
assert(arg_action == ACTION_SYNC);

View File

@ -2187,11 +2187,11 @@ static int server_connect_notify(Server *s) {
}
static int synchronize_second_half(sd_event_source *event_source, void *userdata) {
Varlink *link = ASSERT_PTR(userdata);
sd_varlink *link = ASSERT_PTR(userdata);
Server *s;
int r;
assert_se(s = varlink_get_userdata(link));
assert_se(s = sd_varlink_get_userdata(link));
/* This is the "second half" of the Synchronize() varlink method. This function is called as deferred
* event source at a low priority to ensure the synchronization completes after all queued log
@ -2205,14 +2205,14 @@ static int synchronize_second_half(sd_event_source *event_source, void *userdata
if (r < 0)
return log_error_errno(r, "Failed to mark event source as non-floating: %m");
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static void synchronize_destroy(void *userdata) {
varlink_unref(userdata);
sd_varlink_unref(userdata);
}
static int vl_method_synchronize(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_synchronize(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
_cleanup_(sd_event_source_unrefp) sd_event_source *event_source = NULL;
Server *s = ASSERT_PTR(userdata);
int r;
@ -2220,7 +2220,7 @@ static int vl_method_synchronize(Varlink *link, sd_json_variant *parameters, Var
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
log_info("Received client request to sync journal.");
@ -2236,7 +2236,7 @@ static int vl_method_synchronize(Varlink *link, sd_json_variant *parameters, Var
if (r < 0)
return log_error_errno(r, "Failed to set event source destroy callback: %m");
varlink_ref(link); /* The varlink object is now left to the destroy callback to unref */
sd_varlink_ref(link); /* The varlink object is now left to the destroy callback to unref */
r = sd_event_source_set_priority(event_source, SD_EVENT_PRIORITY_NORMAL+15);
if (r < 0)
@ -2253,53 +2253,53 @@ static int vl_method_synchronize(Varlink *link, sd_json_variant *parameters, Var
return 0;
}
static int vl_method_rotate(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_rotate(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Server *s = ASSERT_PTR(userdata);
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
log_info("Received client request to rotate journal, rotating.");
server_full_rotate(s);
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static int vl_method_flush_to_var(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_flush_to_var(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Server *s = ASSERT_PTR(userdata);
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
if (s->namespace)
return varlink_error(link, "io.systemd.Journal.NotSupportedByNamespaces", NULL);
return sd_varlink_error(link, "io.systemd.Journal.NotSupportedByNamespaces", NULL);
log_info("Received client request to flush runtime journal.");
server_full_flush(s);
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static int vl_method_relinquish_var(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_relinquish_var(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Server *s = ASSERT_PTR(userdata);
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
if (s->namespace)
return varlink_error(link, "io.systemd.Journal.NotSupportedByNamespaces", NULL);
return sd_varlink_error(link, "io.systemd.Journal.NotSupportedByNamespaces", NULL);
log_info("Received client request to relinquish %s access.", s->system_storage.path);
server_relinquish_var(s);
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static int vl_connect(VarlinkServer *server, Varlink *link, void *userdata) {
static int vl_connect(sd_varlink_server *server, sd_varlink *link, void *userdata) {
Server *s = ASSERT_PTR(userdata);
assert(server);
@ -2310,7 +2310,7 @@ static int vl_connect(VarlinkServer *server, Varlink *link, void *userdata) {
return 0;
}
static void vl_disconnect(VarlinkServer *server, Varlink *link, void *userdata) {
static void vl_disconnect(sd_varlink_server *server, sd_varlink *link, void *userdata) {
Server *s = ASSERT_PTR(userdata);
assert(server);
@ -2324,17 +2324,17 @@ static int server_open_varlink(Server *s, const char *socket, int fd) {
assert(s);
r = varlink_server_new(&s->varlink_server, VARLINK_SERVER_ROOT_ONLY|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&s->varlink_server, SD_VARLINK_SERVER_ROOT_ONLY|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return r;
varlink_server_set_userdata(s->varlink_server, s);
sd_varlink_server_set_userdata(s->varlink_server, s);
r = varlink_server_add_interface(s->varlink_server, &vl_interface_io_systemd_Journal);
r = sd_varlink_server_add_interface(s->varlink_server, &vl_interface_io_systemd_Journal);
if (r < 0)
return log_error_errno(r, "Failed to add Journal interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
s->varlink_server,
"io.systemd.Journal.Synchronize", vl_method_synchronize,
"io.systemd.Journal.Rotate", vl_method_rotate,
@ -2343,22 +2343,22 @@ static int server_open_varlink(Server *s, const char *socket, int fd) {
if (r < 0)
return r;
r = varlink_server_bind_connect(s->varlink_server, vl_connect);
r = sd_varlink_server_bind_connect(s->varlink_server, vl_connect);
if (r < 0)
return r;
r = varlink_server_bind_disconnect(s->varlink_server, vl_disconnect);
r = sd_varlink_server_bind_disconnect(s->varlink_server, vl_disconnect);
if (r < 0)
return r;
if (fd < 0)
r = varlink_server_listen_address(s->varlink_server, socket, 0600);
r = sd_varlink_server_listen_address(s->varlink_server, socket, 0600);
else
r = varlink_server_listen_fd(s->varlink_server, fd);
r = sd_varlink_server_listen_fd(s->varlink_server, fd);
if (r < 0)
return r;
r = varlink_server_attach_event(s->varlink_server, s->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(s->varlink_server, s->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return r;
@ -2423,7 +2423,7 @@ static bool server_is_idle(Server *s) {
return false;
/* We aren't idle if we have a varlink client */
if (varlink_server_current_connections(s->varlink_server) > 0)
if (sd_varlink_server_current_connections(s->varlink_server) > 0)
return false;
/* If we have stdout streams we aren't idle */
@ -2898,7 +2898,7 @@ Server* server_free(Server *s) {
ordered_hashmap_free_with_destructor(s->user_journals, journal_file_offline_close);
varlink_server_unref(s->varlink_server);
sd_varlink_server_unref(s->varlink_server);
sd_event_source_unref(s->syslog_event_source);
sd_event_source_unref(s->native_event_source);

View File

@ -5,7 +5,7 @@
#include <sys/types.h>
#include "sd-event.h"
#include "socket-util.h"
#include "sd-varlink.h"
typedef struct Server Server;
@ -18,8 +18,8 @@ typedef struct Server Server;
#include "list.h"
#include "prioq.h"
#include "ratelimit.h"
#include "socket-util.h"
#include "time-util.h"
#include "varlink.h"
typedef enum Storage {
STORAGE_AUTO,
@ -185,7 +185,7 @@ struct Server {
ClientContext *my_context; /* the context of journald itself */
ClientContext *pid1_context; /* the context of PID 1 */
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
};
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + STRLEN("_MACHINE_ID="))

View File

@ -948,4 +948,100 @@ global:
sd_json_variant_unref;
sd_json_variant_unref_many;
sd_json_variant_unsigned;
sd_varlink_attach_event;
sd_varlink_bind_reply;
sd_varlink_call;
sd_varlink_call_full;
sd_varlink_callb;
sd_varlink_callb_ap;
sd_varlink_callb_full;
sd_varlink_close;
sd_varlink_close_unref;
sd_varlink_collect;
sd_varlink_collect_full;
sd_varlink_collectb;
sd_varlink_connect_address;
sd_varlink_connect_exec;
sd_varlink_connect_fd;
sd_varlink_connect_fd_pair;
sd_varlink_connect_url;
sd_varlink_detach_event;
sd_varlink_dispatch;
sd_varlink_dispatch_again;
sd_varlink_error;
sd_varlink_error_errno;
sd_varlink_error_invalid_parameter;
sd_varlink_error_invalid_parameter_name;
sd_varlink_error_to_errno;
sd_varlink_errorb;
sd_varlink_flush;
sd_varlink_flush_close_unref;
sd_varlink_get_current_parameters;
sd_varlink_get_event;
sd_varlink_get_events;
sd_varlink_get_fd;
sd_varlink_get_peer_gid;
sd_varlink_get_peer_pid;
sd_varlink_get_peer_pidfd;
sd_varlink_get_peer_uid;
sd_varlink_get_server;
sd_varlink_get_timeout;
sd_varlink_get_userdata;
sd_varlink_idl_dump;
sd_varlink_idl_format;
sd_varlink_idl_format_full;
sd_varlink_invocation;
sd_varlink_invoke;
sd_varlink_invokeb;
sd_varlink_is_idle;
sd_varlink_notify;
sd_varlink_notifyb;
sd_varlink_observe;
sd_varlink_observeb;
sd_varlink_peek_dup_fd;
sd_varlink_peek_fd;
sd_varlink_process;
sd_varlink_push_dup_fd;
sd_varlink_push_fd;
sd_varlink_ref;
sd_varlink_reply;
sd_varlink_replyb;
sd_varlink_send;
sd_varlink_sendb;
sd_varlink_server_add_connection;
sd_varlink_server_add_connection_pair;
sd_varlink_server_add_connection_stdio;
sd_varlink_server_add_interface;
sd_varlink_server_add_interface_many_internal;
sd_varlink_server_attach_event;
sd_varlink_server_bind_connect;
sd_varlink_server_bind_disconnect;
sd_varlink_server_bind_method;
sd_varlink_server_bind_method_many_internal;
sd_varlink_server_connections_max;
sd_varlink_server_connections_per_uid_max;
sd_varlink_server_current_connections;
sd_varlink_server_detach_event;
sd_varlink_server_get_event;
sd_varlink_server_get_userdata;
sd_varlink_server_listen_address;
sd_varlink_server_listen_auto;
sd_varlink_server_listen_fd;
sd_varlink_server_loop_auto;
sd_varlink_server_new;
sd_varlink_server_set_connections_max;
sd_varlink_server_set_connections_per_uid_max;
sd_varlink_server_set_description;
sd_varlink_server_set_exit_on_idle;
sd_varlink_server_set_userdata;
sd_varlink_server_shutdown;
sd_varlink_set_allow_fd_passing_input;
sd_varlink_set_allow_fd_passing_output;
sd_varlink_set_description;
sd_varlink_set_input_sensitive;
sd_varlink_set_relative_timeout;
sd_varlink_set_userdata;
sd_varlink_take_fd;
sd_varlink_unref;
sd_varlink_wait;
} LIBSYSTEMD_256;

View File

@ -73,6 +73,16 @@ sd_json_sources = files(
############################################################
sd_varlink_sources = files(
'sd-varlink/sd-varlink.c',
'sd-varlink/sd-varlink-idl.c',
'sd-varlink/varlink-io.systemd.c',
'sd-varlink/varlink-org.varlink.service.c',
'sd-varlink/varlink-util.c',
)
############################################################
libsystemd_sources = files(
'sd-bus/bus-common-errors.c',
'sd-bus/bus-container.c',
@ -116,7 +126,7 @@ libsystemd_sources = files(
'sd-network/sd-network.c',
'sd-path/sd-path.c',
'sd-resolve/sd-resolve.c',
) + sd_journal_sources + id128_sources + sd_daemon_sources + sd_event_sources + sd_login_sources + sd_json_sources
) + sd_journal_sources + id128_sources + sd_daemon_sources + sd_event_sources + sd_login_sources + sd_json_sources + sd_varlink_sources
libsystemd_c_args = ['-fvisibility=default']

View File

@ -664,7 +664,7 @@ _public_ int sd_json_variant_new_array_strv(sd_json_variant **ret, char **l) {
size_t n;
int r;
assert(ret);
assert_return(ret, -EINVAL);
n = strv_length(l);
if (n == 0) {
@ -1477,7 +1477,8 @@ _public_ int sd_json_variant_equal(sd_json_variant *a, sd_json_variant *b) {
}
_public_ void sd_json_variant_sensitive(sd_json_variant *v) {
assert(v);
if (!v)
return;
/* Marks a variant as "sensitive", so that it is erased from memory when it is destroyed. This is a
* one-way operation: as soon as it is marked this way it remains marked this way until it's
@ -1932,7 +1933,7 @@ _public_ int sd_json_variant_filter(sd_json_variant **v, char **to_remove) {
size_t n = 0, k = 0;
int r;
assert(v);
assert_return(v, -EINVAL);
if (sd_json_variant_is_blank_object(*v))
return 0;
@ -1985,8 +1986,8 @@ _public_ int sd_json_variant_set_field(sd_json_variant **v, const char *field, s
size_t k = 0;
int r;
assert(v);
assert(field);
assert_return(v, -EINVAL);
assert_return(field, -EINVAL);
if (sd_json_variant_is_blank_object(*v)) {
array = new(sd_json_variant*, 2);
@ -2199,8 +2200,8 @@ _public_ int sd_json_variant_append_array(sd_json_variant **v, sd_json_variant *
bool blank;
int r;
assert(v);
assert(element);
assert_return(v, -EINVAL);
assert_return(element, -EINVAL);
if (!*v || sd_json_variant_is_null(*v))
blank = true;
@ -2286,7 +2287,7 @@ _public_ sd_json_variant *sd_json_variant_find(sd_json_variant *haystack, sd_jso
}
_public_ int sd_json_variant_append_array_nodup(sd_json_variant **v, sd_json_variant *element) {
assert(v);
assert_return(v, -EINVAL);
if (sd_json_variant_find(*v, element))
return 0;
@ -2299,7 +2300,7 @@ _public_ int sd_json_variant_strv(sd_json_variant *v, char ***ret) {
bool sensitive;
int r;
assert(ret);
assert_return(ret, -EINVAL);
if (!v || sd_json_variant_is_null(v)) {
l = new0(char*, 1);
@ -4830,7 +4831,7 @@ _public_ int sd_json_dispatch(
_public_ int sd_json_dispatch_stdbool(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
bool *b = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
if (!sd_json_variant_is_boolean(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a boolean.", strna(name));
@ -4842,7 +4843,7 @@ _public_ int sd_json_dispatch_stdbool(const char *name, sd_json_variant *variant
_public_ int sd_json_dispatch_intbool(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
int *b = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
if (!sd_json_variant_is_boolean(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a boolean.", strna(name));
@ -4854,7 +4855,7 @@ _public_ int sd_json_dispatch_intbool(const char *name, sd_json_variant *variant
_public_ int sd_json_dispatch_tristate(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
int *b = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
if (sd_json_variant_is_null(variant)) {
*b = -1;
@ -4871,7 +4872,7 @@ _public_ int sd_json_dispatch_tristate(const char *name, sd_json_variant *varian
_public_ int sd_json_dispatch_int64(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
int64_t *i = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
/* Also accept numbers formatted as string, to increase compatibility with less capable JSON
* implementations that cannot do 64bit integers. */
@ -4888,7 +4889,7 @@ _public_ int sd_json_dispatch_int64(const char *name, sd_json_variant *variant,
_public_ int sd_json_dispatch_uint64(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
uint64_t *u = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
/* Since 64bit values (in particular unsigned ones) in JSON are problematic, let's also accept them
* formatted as strings. If this is not desired make sure to set the .type field in
@ -4910,7 +4911,7 @@ _public_ int sd_json_dispatch_uint32(const char *name, sd_json_variant *variant,
uint64_t u64;
int r;
assert(variant);
assert_return(variant, -EINVAL);
r = sd_json_dispatch_uint64(name, variant, flags, &u64);
if (r < 0)
@ -4931,7 +4932,7 @@ _public_ int sd_json_dispatch_int32(const char *name, sd_json_variant *variant,
int64_t i64;
int r;
assert(variant);
assert_return(variant, -EINVAL);
r = sd_json_dispatch_int64(name, variant, flags, &i64);
if (r < 0)
@ -4952,7 +4953,7 @@ _public_ int sd_json_dispatch_int16(const char *name, sd_json_variant *variant,
int64_t i64;
int r;
assert(variant);
assert_return(variant, -EINVAL);
r = sd_json_dispatch_int64(name, variant, flags, &i64);
if (r < 0)
@ -4970,7 +4971,7 @@ _public_ int sd_json_dispatch_uint16(const char *name, sd_json_variant *variant,
uint64_t u64;
int r;
assert(variant);
assert_return(variant, -EINVAL);
r = sd_json_dispatch_uint64(name, variant, flags, &u64);
if (r < 0)
@ -4988,7 +4989,7 @@ _public_ int sd_json_dispatch_int8(const char *name, sd_json_variant *variant, s
int64_t i64;
int r;
assert(variant);
assert_return(variant, -EINVAL);
r = sd_json_dispatch_int64(name, variant, flags, &i64);
if (r < 0)
@ -5006,7 +5007,7 @@ _public_ int sd_json_dispatch_uint8(const char *name, sd_json_variant *variant,
uint64_t u64;
int r;
assert(variant);
assert_return(variant, -EINVAL);
r = sd_json_dispatch_uint64(name, variant, flags, &u64);
if (r < 0)
@ -5022,6 +5023,8 @@ _public_ int sd_json_dispatch_uint8(const char *name, sd_json_variant *variant,
_public_ int sd_json_dispatch_double(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
double *d = ASSERT_PTR(userdata);
assert_return(variant, -EINVAL);
/* Note, this will take care of parsing NaN, -Infinity, Infinity for us */
if (sd_json_variant_is_string(variant) && safe_atod(sd_json_variant_string(variant), d) >= 0)
return 0;
@ -5037,7 +5040,7 @@ _public_ int sd_json_dispatch_string(const char *name, sd_json_variant *variant,
char **s = ASSERT_PTR(userdata);
int r;
assert(variant);
assert_return(variant, -EINVAL);
if (sd_json_variant_is_null(variant)) {
*s = mfree(*s);
@ -5060,7 +5063,7 @@ _public_ int sd_json_dispatch_string(const char *name, sd_json_variant *variant,
_public_ int sd_json_dispatch_const_string(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
const char **s = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
if (sd_json_variant_is_null(variant)) {
*s = NULL;
@ -5083,7 +5086,7 @@ _public_ int sd_json_dispatch_strv(const char *name, sd_json_variant *variant, s
sd_json_variant *e;
int r;
assert(variant);
assert_return(variant, -EINVAL);
if (sd_json_variant_is_null(variant)) {
*s = strv_free(*s);
@ -5124,7 +5127,8 @@ _public_ int sd_json_dispatch_strv(const char *name, sd_json_variant *variant, s
_public_ int sd_json_dispatch_variant(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
sd_json_variant **p = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
/* Takes a reference */
JSON_VARIANT_REPLACE(*p, sd_json_variant_ref(variant));
@ -5133,7 +5137,8 @@ _public_ int sd_json_dispatch_variant(const char *name, sd_json_variant *variant
_public_ int sd_json_dispatch_variant_noref(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
sd_json_variant **p = ASSERT_PTR(userdata);
assert(variant);
assert_return(variant, -EINVAL);
/* Doesn't take a reference */
*p = variant;
@ -5144,6 +5149,8 @@ _public_ int sd_json_dispatch_uid_gid(const char *name, sd_json_variant *variant
uid_t *uid = userdata;
uint64_t k;
assert_return(variant, -EINVAL);
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
@ -5171,6 +5178,8 @@ _public_ int sd_json_dispatch_id128(const char *name, sd_json_variant *variant,
sd_id128_t *uuid = userdata;
int r;
assert_return(variant, -EINVAL);
if (sd_json_variant_is_null(variant)) {
*uuid = SD_ID128_NULL;
return 0;
@ -5205,7 +5214,7 @@ _public_ int sd_json_variant_sort(sd_json_variant **v) {
size_t m;
int r;
assert(v);
assert_return(v, -EINVAL);
if (sd_json_variant_is_sorted(*v))
return 0;
@ -5245,7 +5254,7 @@ _public_ int sd_json_variant_normalize(sd_json_variant **v) {
size_t i, m;
int r;
assert(v);
assert_return(v, -EINVAL);
if (sd_json_variant_is_normalized(*v))
return 0;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-varlink-idl.h"
#include "macro.h"
int varlink_idl_parse(const char *text, unsigned *ret_line, unsigned *ret_column, sd_varlink_interface **ret);
sd_varlink_interface* varlink_interface_free(sd_varlink_interface *interface);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_varlink_interface*, varlink_interface_free);
bool varlink_idl_field_name_is_valid(const char *name);
bool varlink_idl_symbol_name_is_valid(const char *name);
bool varlink_idl_interface_name_is_valid(const char *name);
int varlink_idl_qualified_symbol_name_is_valid(const char *name);
int varlink_idl_consistent(const sd_varlink_interface *interface, int level);
const sd_varlink_symbol* varlink_idl_find_symbol(const sd_varlink_interface *interface, sd_varlink_symbol_type_t type, const char *name);
const sd_varlink_field* varlink_idl_find_field(const sd_varlink_symbol *symbol, const char *name);
int varlink_idl_validate_method_call(const sd_varlink_symbol *method, sd_json_variant *v, const char **bad_field);
int varlink_idl_validate_method_reply(const sd_varlink_symbol *method, sd_json_variant *v, const char **bad_field);
int varlink_idl_validate_error(const sd_varlink_symbol *error, sd_json_variant *v, const char **bad_field);

View File

@ -0,0 +1,249 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <sys/socket.h>
#include "sd-event.h"
#include "sd-varlink.h"
#include "hashmap.h"
#include "list.h"
typedef enum VarlinkState {
/* Client side states */
VARLINK_IDLE_CLIENT,
VARLINK_AWAITING_REPLY,
VARLINK_AWAITING_REPLY_MORE,
VARLINK_CALLING,
VARLINK_CALLED,
VARLINK_COLLECTING,
VARLINK_COLLECTING_REPLY,
VARLINK_PROCESSING_REPLY,
/* Server side states */
VARLINK_IDLE_SERVER,
VARLINK_PROCESSING_METHOD,
VARLINK_PROCESSING_METHOD_MORE,
VARLINK_PROCESSING_METHOD_ONEWAY,
VARLINK_PROCESSED_METHOD,
VARLINK_PENDING_METHOD,
VARLINK_PENDING_METHOD_MORE,
/* Common states (only during shutdown) */
VARLINK_PENDING_DISCONNECT,
VARLINK_PENDING_TIMEOUT,
VARLINK_PROCESSING_DISCONNECT,
VARLINK_PROCESSING_TIMEOUT,
VARLINK_PROCESSING_FAILURE,
VARLINK_DISCONNECTED,
_VARLINK_STATE_MAX,
_VARLINK_STATE_INVALID = -EINVAL,
} VarlinkState;
/* Tests whether we are not yet disconnected. Note that this is true during all states where the connection
* is still good for something, and false only when it's dead for good. This means: when we are
* asynchronously connecting to a peer and the connect() is still pending, then this will return 'true', as
* the connection is still good, and we are likely to be able to properly operate on it soon. */
#define VARLINK_STATE_IS_ALIVE(state) \
IN_SET(state, \
VARLINK_IDLE_CLIENT, \
VARLINK_AWAITING_REPLY, \
VARLINK_AWAITING_REPLY_MORE, \
VARLINK_CALLING, \
VARLINK_CALLED, \
VARLINK_COLLECTING, \
VARLINK_COLLECTING_REPLY, \
VARLINK_PROCESSING_REPLY, \
VARLINK_IDLE_SERVER, \
VARLINK_PROCESSING_METHOD, \
VARLINK_PROCESSING_METHOD_MORE, \
VARLINK_PROCESSING_METHOD_ONEWAY, \
VARLINK_PROCESSED_METHOD, \
VARLINK_PENDING_METHOD, \
VARLINK_PENDING_METHOD_MORE)
typedef struct VarlinkJsonQueueItem VarlinkJsonQueueItem;
/* A queued message we shall write into the socket, along with the file descriptors to send at the same
* time. This queue item binds them together so that message/fd boundaries are maintained throughout the
* whole pipeline. */
struct VarlinkJsonQueueItem {
LIST_FIELDS(VarlinkJsonQueueItem, queue);
sd_json_variant *data;
size_t n_fds;
int fds[];
};
struct sd_varlink {
unsigned n_ref;
sd_varlink_server *server;
VarlinkState state;
bool connecting; /* This boolean indicates whether the socket fd we are operating on is currently
* processing an asynchronous connect(). In that state we watch the socket for
* EPOLLOUT, but we refrain from calling read() or write() on the socket as that
* will trigger ENOTCONN. Note that this boolean is kept separate from the
* VarlinkState above on purpose: while the connect() is still not complete we
* already want to allow queuing of messages and similar. Thus it's nice to keep
* these two state concepts separate: the VarlinkState encodes what our own view of
* the connection is, i.e. whether we think it's a server, a client, and has
* something queued already, while 'connecting' tells us a detail about the
* transport used below, that should have no effect on how we otherwise accept and
* process operations from the user.
*
* Or to say this differently: VARLINK_STATE_IS_ALIVE(state) tells you whether the
* connection is good to use, even if it might not be fully connected
* yet. connecting=true then informs you that actually we are still connecting, and
* the connection is actually not established yet and thus any requests you enqueue
* now will still work fine but will be queued only, not sent yet, but that
* shouldn't stop you from using the connection, since eventually whatever you queue
* *will* be sent.
*
* Or to say this even differently: 'state' is a high-level ("application layer"
* high, if you so will) state, while 'conecting' is a low-level ("transport layer"
* low, if you so will) state, and while they are not entirely unrelated and
* sometimes propagate effects to each other they are only asynchronously connected
* at most. */
unsigned n_pending;
int input_fd;
int output_fd;
char *input_buffer; /* valid data starts at input_buffer_index, ends at input_buffer_index+input_buffer_size */
size_t input_buffer_index;
size_t input_buffer_size;
size_t input_buffer_unscanned;
void *input_control_buffer;
size_t input_control_buffer_size;
char *output_buffer; /* valid data starts at output_buffer_index, ends at output_buffer_index+output_buffer_size */
size_t output_buffer_index;
size_t output_buffer_size;
int *input_fds; /* file descriptors associated with the data in input_buffer (for fd passing) */
size_t n_input_fds;
int *output_fds; /* file descriptors associated with the data in output_buffer (for fd passing) */
size_t n_output_fds;
/* Further messages to output not yet formatted into text, and thus not included in output_buffer
* yet. We keep them separate from output_buffer, to not violate fd message boundaries: we want that
* each fd that is sent is associated with its fds, and that fds cannot be accidentally associated
* with preceding or following messages. */
LIST_HEAD(VarlinkJsonQueueItem, output_queue);
VarlinkJsonQueueItem *output_queue_tail;
/* The fds to associate with the next message that is about to be enqueued. The user first pushes the
* fds it intends to send via varlink_push_fd() into this queue, and then once the message data is
* submitted we'll combine the fds and the message data into one. */
int *pushed_fds;
size_t n_pushed_fds;
sd_varlink_reply_t reply_callback;
sd_json_variant *current;
sd_json_variant *current_collected;
sd_varlink_reply_flags_t current_reply_flags;
sd_varlink_symbol *current_method;
int peer_pidfd;
struct ucred ucred;
bool ucred_acquired:1;
bool write_disconnected:1;
bool read_disconnected:1;
bool prefer_read:1;
bool prefer_write:1;
bool got_pollhup:1;
bool allow_fd_passing_input:1;
bool allow_fd_passing_output:1;
bool output_buffer_sensitive:1; /* whether to erase the output buffer after writing it to the socket */
bool input_sensitive:1; /* Whether incoming messages might be sensitive */
int af; /* address family if socket; AF_UNSPEC if not socket; negative if not known */
usec_t timestamp;
usec_t timeout;
void *userdata;
char *description;
sd_event *event;
sd_event_source *input_event_source;
sd_event_source *output_event_source;
sd_event_source *time_event_source;
sd_event_source *quit_event_source;
sd_event_source *defer_event_source;
pid_t exec_pid;
};
typedef struct VarlinkServerSocket VarlinkServerSocket;
struct VarlinkServerSocket {
sd_varlink_server *server;
int fd;
char *address;
sd_event_source *event_source;
LIST_FIELDS(VarlinkServerSocket, sockets);
};
struct sd_varlink_server {
unsigned n_ref;
sd_varlink_server_flags_t flags;
LIST_HEAD(VarlinkServerSocket, sockets);
Hashmap *methods; /* Fully qualified symbol name of a method → VarlinkMethod */
Hashmap *interfaces; /* Fully qualified interface name → VarlinkInterface* */
Hashmap *symbols; /* Fully qualified symbol name of method/error → VarlinkSymbol* */
sd_varlink_connect_t connect_callback;
sd_varlink_disconnect_t disconnect_callback;
sd_event *event;
int64_t event_priority;
unsigned n_connections;
Hashmap *by_uid; /* UID_TO_PTR(uid) → UINT_TO_PTR(n_connections) */
void *userdata;
char *description;
unsigned connections_max;
unsigned connections_per_uid_max;
bool exit_on_idle;
};
#define varlink_log_errno(v, error, fmt, ...) \
log_debug_errno(error, "%s: " fmt, varlink_description(v), ##__VA_ARGS__)
#define varlink_log(v, fmt, ...) \
log_debug("%s: " fmt, varlink_description(v), ##__VA_ARGS__)
#define varlink_server_log_errno(s, error, fmt, ...) \
log_debug_errno(error, "%s: " fmt, varlink_server_description(s), ##__VA_ARGS__)
#define varlink_server_log(s, fmt, ...) \
log_debug("%s: " fmt, varlink_server_description(s), ##__VA_ARGS__)
static inline const char* varlink_description(sd_varlink *v) {
return (v ? v->description : NULL) ?: "varlink";
}
static inline const char* varlink_server_description(sd_varlink_server *s) {
return (s ? s->description : NULL) ?: "varlink";
}
VarlinkServerSocket* varlink_server_socket_free(VarlinkServerSocket *ss);
DEFINE_TRIVIAL_CLEANUP_FUNC(VarlinkServerSocket *, varlink_server_socket_free);
int varlink_server_add_socket_event_source(sd_varlink_server *s, VarlinkServerSocket *ss, int64_t priority);

View File

@ -3,16 +3,16 @@
#include "varlink-io.systemd.h"
/* These are local errors that never cross the wire, and are our own invention */
static VARLINK_DEFINE_ERROR(Disconnected);
static VARLINK_DEFINE_ERROR(TimedOut);
static VARLINK_DEFINE_ERROR(Protocol);
static SD_VARLINK_DEFINE_ERROR(Disconnected);
static SD_VARLINK_DEFINE_ERROR(TimedOut);
static SD_VARLINK_DEFINE_ERROR(Protocol);
/* This one we invented, and use for generically propagating system errors (errno) to clients */
static VARLINK_DEFINE_ERROR(
static SD_VARLINK_DEFINE_ERROR(
System,
VARLINK_DEFINE_FIELD(errno, VARLINK_INT, 0));
SD_VARLINK_DEFINE_FIELD(errno, SD_VARLINK_INT, 0));
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd,
"io.systemd",
&vl_error_Disconnected,

View File

@ -0,0 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-varlink-idl.h"
extern const sd_varlink_interface vl_interface_io_systemd;

View File

@ -0,0 +1,49 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "varlink-org.varlink.service.h"
static SD_VARLINK_DEFINE_METHOD(
GetInfo,
SD_VARLINK_DEFINE_OUTPUT(vendor, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(product, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(version, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(url, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(interfaces, SD_VARLINK_STRING, SD_VARLINK_ARRAY));
static SD_VARLINK_DEFINE_METHOD(
GetInterfaceDescription,
SD_VARLINK_DEFINE_INPUT(interface, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(description, SD_VARLINK_STRING, 0));
static SD_VARLINK_DEFINE_ERROR(
InterfaceNotFound,
SD_VARLINK_DEFINE_FIELD(interface, SD_VARLINK_STRING, 0));
static SD_VARLINK_DEFINE_ERROR(
MethodNotFound,
SD_VARLINK_DEFINE_FIELD(method, SD_VARLINK_STRING, 0));
static SD_VARLINK_DEFINE_ERROR(
MethodNotImplemented,
SD_VARLINK_DEFINE_FIELD(method, SD_VARLINK_STRING, 0));
static SD_VARLINK_DEFINE_ERROR(
InvalidParameter,
SD_VARLINK_DEFINE_FIELD(parameter, SD_VARLINK_STRING, 0));
static SD_VARLINK_DEFINE_ERROR(PermissionDenied);
static SD_VARLINK_DEFINE_ERROR(ExpectedMore);
/* As per https://varlink.org/Service */
SD_VARLINK_DEFINE_INTERFACE(
org_varlink_service,
"org.varlink.service",
&vl_method_GetInfo,
&vl_method_GetInterfaceDescription,
&vl_error_InterfaceNotFound,
&vl_error_MethodNotFound,
&vl_error_MethodNotImplemented,
&vl_error_InvalidParameter,
&vl_error_PermissionDenied,
&vl_error_ExpectedMore);

View File

@ -0,0 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-varlink-idl.h"
extern const sd_varlink_interface vl_interface_org_varlink_service;

View File

@ -0,0 +1,136 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "errno-util.h"
#include "varlink-internal.h"
#include "varlink-util.h"
int varlink_get_peer_pidref(sd_varlink *v, PidRef *ret) {
int r;
assert_return(v, -EINVAL);
assert_return(ret, -EINVAL);
/* Returns r > 0 if we acquired the pidref via SO_PEERPIDFD (i.e. if we can use it for
* authentication). Returns == 0 if we didn't, and the pidref should not be used for
* authentication. */
int pidfd = sd_varlink_get_peer_pidfd(v);
if (pidfd < 0) {
if (!ERRNO_IS_NEG_NOT_SUPPORTED(pidfd))
return pidfd;
pid_t pid;
r = sd_varlink_get_peer_pid(v, &pid);
if (r < 0)
return r;
r = pidref_set_pid(ret, pid);
if (r < 0)
return r;
return 0; /* didn't get pidfd securely */
}
r = pidref_set_pidfd(ret, pidfd);
if (r < 0)
return r;
return 1; /* got pidfd securely */
}
int varlink_call_and_log(
sd_varlink *v,
const char *method,
sd_json_variant *parameters,
sd_json_variant **ret_parameters) {
sd_json_variant *reply = NULL;
const char *error_id = NULL;
int r;
assert_return(v, -EINVAL);
assert_return(method, -EINVAL);
r = sd_varlink_call(v, method, parameters, &reply, &error_id);
if (r < 0)
return log_error_errno(r, "Failed to issue %s() varlink call: %m", method);
if (error_id)
return log_error_errno(sd_varlink_error_to_errno(error_id, reply),
"Failed to issue %s() varlink call: %s", method, error_id);
if (ret_parameters)
*ret_parameters = TAKE_PTR(reply);
return 0;
}
int varlink_callb_and_log(
sd_varlink *v,
const char *method,
sd_json_variant **ret_parameters,
...) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *parameters = NULL;
va_list ap;
int r;
assert_return(v, -EINVAL);
assert_return(method, -EINVAL);
va_start(ap, ret_parameters);
r = sd_json_buildv(&parameters, ap);
va_end(ap);
if (r < 0)
return log_error_errno(r, "Failed to build JSON message: %m");
return varlink_call_and_log(v, method, parameters, ret_parameters);
}
int varlink_many_notifyb(Set *s, ...) {
int r;
/* Equivalent to varlink_notifyb(), but does this for each entry of the supplied set of Varlink connections */
if (set_isempty(s))
return 0;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *parameters = NULL;
va_list ap;
va_start(ap, s);
r = sd_json_buildv(&parameters, ap);
va_end(ap);
if (r < 0)
return r;
int ret = 1;
sd_varlink *link;
SET_FOREACH(link, s)
RET_GATHER(ret, sd_varlink_notify(link, parameters));
return ret;
}
int varlink_many_reply(Set *s, sd_json_variant *parameters) {
if (set_isempty(s))
return 0;
int r = 1;
sd_varlink *link;
SET_FOREACH(link, s)
RET_GATHER(r, sd_varlink_reply(link, parameters));
return r;
}
int varlink_many_error(Set *s, const char *error_id, sd_json_variant *parameters) {
if (set_isempty(s))
return 0;
int r = 1;
sd_varlink *link;
SET_FOREACH(link, s)
RET_GATHER(r, sd_varlink_error(link, error_id, parameters));
return r;
}

View File

@ -0,0 +1,20 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-varlink.h"
#include "pidref.h"
#include "set.h"
int varlink_get_peer_pidref(sd_varlink *v, PidRef *ret);
int varlink_call_and_log(sd_varlink *v, const char *method, sd_json_variant *parameters, sd_json_variant **ret_parameters);
int varlink_callb_and_log(sd_varlink *v, const char *method, sd_json_variant **ret_parameters, ...);
#define varlink_callbo_and_log(v, method, ret_parameters, ...) \
varlink_callb_and_log((v), (method), (ret_parameters), SD_JSON_BUILD_OBJECT(__VA_ARGS__))
int varlink_many_notifyb(Set *s, ...);
#define varlink_many_notifybo(s, ...) \
varlink_many_notifyb((s), SD_JSON_BUILD_OBJECT(__VA_ARGS__))
int varlink_many_reply(Set *s, sd_json_variant *parameters);
int varlink_many_error(Set *s, const char *error_id, sd_json_variant *parameters);

View File

@ -4,6 +4,7 @@
#include "sd-id128.h"
#include "sd-json.h"
#include "sd-varlink.h"
#include "bus-polkit.h"
#include "hostname-util.h"
@ -15,7 +16,7 @@
#include "process-util.h"
#include "socket-util.h"
#include "string-util.h"
#include "varlink.h"
#include "varlink-util.h"
static JSON_DISPATCH_ENUM_DEFINE(dispatch_machine_class, MachineClass, machine_class_from_string);
@ -121,7 +122,7 @@ static int machine_cid(const char *name, sd_json_variant *variant, sd_json_dispa
return 0;
}
int vl_method_register(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int vl_method_register(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Manager *manager = ASSERT_PTR(userdata);
_cleanup_(machine_freep) Machine *machine = NULL;
int r;
@ -146,7 +147,7 @@ int vl_method_register(Varlink *link, sd_json_variant *parameters, VarlinkMethod
if (r < 0)
return r;
r = varlink_dispatch(link, parameters, dispatch_table, machine);
r = sd_varlink_dispatch(link, parameters, dispatch_table, machine);
if (r != 0)
return r;
@ -168,7 +169,7 @@ int vl_method_register(Varlink *link, sd_json_variant *parameters, VarlinkMethod
r = machine_link(manager, machine);
if (r == -EEXIST)
return varlink_error(link, "io.systemd.Machine.MachineExists", NULL);
return sd_varlink_error(link, "io.systemd.Machine.MachineExists", NULL);
if (r < 0)
return r;
@ -185,5 +186,5 @@ int vl_method_register(Varlink *link, sd_json_variant *parameters, VarlinkMethod
/* the manager will free this machine */
TAKE_PTR(machine);
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink.h"
#include "sd-varlink.h"
int vl_method_register(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int vl_method_register(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink.h"
#include "format-util.h"
#include "hostname-util.h"
#include "json-util.h"
@ -8,7 +10,6 @@
#include "mkdir.h"
#include "socket-util.h"
#include "user-util.h"
#include "varlink.h"
#include "varlink-io.systemd.Machine.h"
#include "varlink-io.systemd.UserDatabase.h"
@ -142,7 +143,7 @@ static int user_lookup_name(Manager *m, const char *name, uid_t *ret_uid, char *
return 0;
}
static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "uid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, uid), 0 },
@ -163,21 +164,21 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.Machine"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (uid_is_valid(p.uid))
r = user_lookup_uid(m, p.uid, &found_name, &found_real_name);
else if (p.user_name)
r = user_lookup_name(m, p.user_name, &found_uid, &found_real_name);
else
return varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
if (r == -ESRCH)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (r < 0)
return r;
@ -185,13 +186,13 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
un = found_name ?: p.user_name;
if (!user_match_lookup_parameters(&p, un, uid))
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
r = build_user_json(un, uid, found_real_name, &v);
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int build_group_json(const char *group_name, gid_t gid, const char *description, sd_json_variant **ret) {
@ -308,7 +309,7 @@ static int group_lookup_name(Manager *m, const char *name, gid_t *ret_gid, char
return 0;
}
static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "gid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, gid), 0 },
@ -329,21 +330,21 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.Machine"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (gid_is_valid(p.gid))
r = group_lookup_gid(m, p.gid, &found_name, &found_description);
else if (p.group_name)
r = group_lookup_name(m, p.group_name, (uid_t*) &found_gid, &found_description);
else
return varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
if (r == -ESRCH)
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
if (r < 0)
return r;
@ -351,16 +352,16 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
gn = found_name ?: p.group_name;
if (!group_match_lookup_parameters(&p, gn, gid))
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
r = build_group_json(gn, gid, found_description, &v);
if (r < 0)
return r;
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "userName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParameters, user_name), SD_JSON_STRICT },
@ -374,18 +375,18 @@ static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters,
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.Machine"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
/* We don't support auxiliary groups for machines. */
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
}
static int list_machine_one(Varlink *link, Machine *m, bool more) {
static int list_machine_one(sd_varlink *link, Machine *m, bool more) {
int r;
assert(link);
@ -409,12 +410,12 @@ static int list_machine_one(Varlink *link, Machine *m, bool more) {
return r;
if (more)
return varlink_notify(link, v);
return sd_varlink_notify(link, v);
return varlink_reply(link, v);
return sd_varlink_reply(link, v);
}
static int vl_method_list(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_list(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
const char *mn = NULL;
@ -427,23 +428,23 @@ static int vl_method_list(Varlink *link, sd_json_variant *parameters, VarlinkMet
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, 0);
r = sd_varlink_dispatch(link, parameters, dispatch_table, 0);
if (r != 0)
return r;
if (mn) {
if (!hostname_is_valid(mn, /* flags= */ VALID_HOSTNAME_DOT_HOST))
return varlink_error_invalid_parameter_name(link, "name");
return sd_varlink_error_invalid_parameter_name(link, "name");
Machine *machine = hashmap_get(m->machines, mn);
if (!machine)
return varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
return sd_varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
return list_machine_one(link, machine, /* more= */ false);
}
if (!FLAGS_SET(flags, VARLINK_METHOD_MORE))
return varlink_error(link, VARLINK_ERROR_EXPECTED_MORE, NULL);
if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE))
return sd_varlink_error(link, SD_VARLINK_ERROR_EXPECTED_MORE, NULL);
Machine *previous = NULL, *i;
HASHMAP_FOREACH(i, m->machines) {
@ -459,11 +460,11 @@ static int vl_method_list(Varlink *link, sd_json_variant *parameters, VarlinkMet
if (previous)
return list_machine_one(link, previous, /* more= */ false);
return varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
return sd_varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
}
static int manager_varlink_init_userdb(Manager *m) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
@ -471,17 +472,17 @@ static int manager_varlink_init_userdb(Manager *m) {
if (m->varlink_userdb_server)
return 0;
r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(s, m);
sd_varlink_server_set_userdata(s, m);
r = varlink_server_add_interface(s, &vl_interface_io_systemd_UserDatabase);
r = sd_varlink_server_add_interface(s, &vl_interface_io_systemd_UserDatabase);
if (r < 0)
return log_error_errno(r, "Failed to add UserDatabase interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
s,
"io.systemd.UserDatabase.GetUserRecord", vl_method_get_user_record,
"io.systemd.UserDatabase.GetGroupRecord", vl_method_get_group_record,
@ -491,11 +492,11 @@ static int manager_varlink_init_userdb(Manager *m) {
(void) mkdir_p("/run/systemd/userdb", 0755);
r = varlink_server_listen_address(s, "/run/systemd/userdb/io.systemd.Machine", 0666);
r = sd_varlink_server_listen_address(s, "/run/systemd/userdb/io.systemd.Machine", 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
@ -504,7 +505,7 @@ static int manager_varlink_init_userdb(Manager *m) {
}
static int manager_varlink_init_machine(Manager *m) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
@ -512,17 +513,17 @@ static int manager_varlink_init_machine(Manager *m) {
if (m->varlink_machine_server)
return 0;
r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(s, m);
sd_varlink_server_set_userdata(s, m);
r = varlink_server_add_interface(s, &vl_interface_io_systemd_Machine);
r = sd_varlink_server_add_interface(s, &vl_interface_io_systemd_Machine);
if (r < 0)
return log_error_errno(r, "Failed to add UserDatabase interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
s,
"io.systemd.Machine.Register", vl_method_register,
"io.systemd.Machine.List", vl_method_list);
@ -531,11 +532,11 @@ static int manager_varlink_init_machine(Manager *m) {
(void) mkdir_p("/run/systemd/machine", 0755);
r = varlink_server_listen_address(s, "/run/systemd/machine/io.systemd.Machine", 0666);
r = sd_varlink_server_listen_address(s, "/run/systemd/machine/io.systemd.Machine", 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
@ -560,6 +561,6 @@ int manager_varlink_init(Manager *m) {
void manager_varlink_done(Manager *m) {
assert(m);
m->varlink_userdb_server = varlink_server_unref(m->varlink_userdb_server);
m->varlink_machine_server = varlink_server_unref(m->varlink_machine_server);
m->varlink_userdb_server = sd_varlink_server_unref(m->varlink_userdb_server);
m->varlink_machine_server = sd_varlink_server_unref(m->varlink_machine_server);
}

View File

@ -298,10 +298,10 @@ static bool check_idle(void *userdata) {
if (m->operations)
return false;
if (varlink_server_current_connections(m->varlink_userdb_server) > 0)
if (sd_varlink_server_current_connections(m->varlink_userdb_server) > 0)
return false;
if (varlink_server_current_connections(m->varlink_machine_server) > 0)
if (sd_varlink_server_current_connections(m->varlink_machine_server) > 0)
return false;
if (!hashmap_isempty(m->polkit_registry))

View File

@ -5,6 +5,7 @@
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-varlink.h"
typedef struct Manager Manager;
@ -14,7 +15,6 @@ typedef struct Manager Manager;
#include "machine-dbus.h"
#include "machine.h"
#include "operation.h"
#include "varlink.h"
struct Manager {
sd_event *event;
@ -38,8 +38,8 @@ struct Manager {
LIST_HEAD(Operation, operations);
unsigned n_operations;
VarlinkServer *varlink_userdb_server;
VarlinkServer *varlink_machine_server;
sd_varlink_server *varlink_userdb_server;
sd_varlink_server *varlink_machine_server;
};
int manager_add_machine(Manager *m, const char *name, Machine **_machine);

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-daemon.h"
#include "sd-varlink.h"
#include "argv-util.h"
#include "bus-polkit.h"
@ -21,7 +22,6 @@
#include "process-util.h"
#include "stat-util.h"
#include "user-util.h"
#include "varlink.h"
#include "varlink-io.systemd.MountFileSystem.h"
#define ITERATIONS_MAX 64U
@ -213,7 +213,7 @@ static int determine_image_policy(
return image_policy_intersect(default_policy, client_policy, ret);
}
static int validate_userns(Varlink *link, int *userns_fd) {
static int validate_userns(sd_varlink *link, int *userns_fd) {
int r;
assert(link);
@ -230,7 +230,7 @@ static int validate_userns(Varlink *link, int *userns_fd) {
if (r < 0)
return r;
if (r == 0)
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
/* Our own host user namespace? Then close the fd, and handle it as if none was specified. */
r = is_our_namespace(*userns_fd, NAMESPACE_USER);
@ -245,9 +245,9 @@ static int validate_userns(Varlink *link, int *userns_fd) {
}
static int vl_method_mount_image(
Varlink *link,
sd_varlink *link,
sd_json_variant *parameters,
VarlinkMethodFlags flags,
sd_varlink_method_flags_t flags,
void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
@ -284,22 +284,22 @@ static int vl_method_mount_image(
sd_json_variant_sensitive(parameters); /* might contain passwords */
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return log_debug_errno(r, "Failed to get client UID: %m");
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.image_fd_idx != UINT_MAX) {
image_fd = varlink_peek_dup_fd(link, p.image_fd_idx);
image_fd = sd_varlink_peek_dup_fd(link, p.image_fd_idx);
if (image_fd < 0)
return log_debug_errno(image_fd, "Failed to peek image fd from client: %m");
}
if (p.userns_fd_idx != UINT_MAX) {
userns_fd = varlink_peek_dup_fd(link, p.userns_fd_idx);
userns_fd = sd_varlink_peek_dup_fd(link, p.userns_fd_idx);
if (userns_fd < 0)
return log_debug_errno(userns_fd, "Failed to peek user namespace fd from client: %m");
}
@ -415,11 +415,11 @@ static int vl_method_mount_image(
dissect_flags,
&di);
if (r == -ENOPKG)
return varlink_error(link, "io.systemd.MountFileSystem.IncompatibleImage", NULL);
return sd_varlink_error(link, "io.systemd.MountFileSystem.IncompatibleImage", NULL);
if (r == -ENOTUNIQ)
return varlink_error(link, "io.systemd.MountFileSystem.MultipleRootPartitionsFound", NULL);
return sd_varlink_error(link, "io.systemd.MountFileSystem.MultipleRootPartitionsFound", NULL);
if (r == -ENXIO)
return varlink_error(link, "io.systemd.MountFileSystem.RootPartitionNotFound", NULL);
return sd_varlink_error(link, "io.systemd.MountFileSystem.RootPartitionNotFound", NULL);
if (r == -ERFKILL) {
/* The image policy refused this, let's retry after trying to get PolicyKit */
@ -443,7 +443,7 @@ static int vl_method_mount_image(
}
}
return varlink_error(link, "io.systemd.MountFileSystem.DeniedByImagePolicy", NULL);
return sd_varlink_error(link, "io.systemd.MountFileSystem.DeniedByImagePolicy", NULL);
}
if (r < 0)
return r;
@ -466,13 +466,13 @@ static int vl_method_mount_image(
dissect_flags);
if (r == -ENOKEY) /* new dm-verity userspace returns ENOKEY if the dm-verity signature key is not in
* key chain. That's great. */
return varlink_error(link, "io.systemd.MountFileSystem.KeyNotFound", NULL);
return sd_varlink_error(link, "io.systemd.MountFileSystem.KeyNotFound", NULL);
if (r == -EBUSY) /* DM kernel subsystem is shit with returning useful errors hence we keep retrying
* under the assumption that some errors are transitional. Which the errors might
* not actually be. After all retries failed we return EBUSY. Let's turn that into a
* generic Verity error. It's not very helpful, could mean anything, but at least it
* gives client a clear idea that this has to do with Verity. */
return varlink_error(link, "io.systemd.MountFileSystem.VerityFailure", NULL);
return sd_varlink_error(link, "io.systemd.MountFileSystem.VerityFailure", NULL);
if (r < 0)
return r;
@ -502,7 +502,7 @@ static int vl_method_mount_image(
return r;
}
fd_idx = varlink_push_fd(link, pp->fsmount_fd);
fd_idx = sd_varlink_push_fd(link, pp->fsmount_fd);
if (fd_idx < 0)
return fd_idx;
@ -527,7 +527,7 @@ static int vl_method_mount_image(
loop_device_relinquish(loop);
r = varlink_replybo(
r = sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("partitions", SD_JSON_BUILD_VARIANT(aj)),
SD_JSON_BUILD_PAIR("imagePolicy", SD_JSON_BUILD_STRING(ps)),
@ -540,9 +540,9 @@ static int vl_method_mount_image(
return r;
}
static int process_connection(VarlinkServer *server, int _fd) {
static int process_connection(sd_varlink_server *server, int _fd) {
_cleanup_close_ int fd = TAKE_FD(_fd); /* always take possession */
_cleanup_(varlink_close_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_close_unrefp) sd_varlink *vl = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
int r;
@ -550,22 +550,22 @@ static int process_connection(VarlinkServer *server, int _fd) {
if (r < 0)
return r;
r = varlink_server_attach_event(server, event, 0);
r = sd_varlink_server_attach_event(server, event, 0);
if (r < 0)
return log_error_errno(r, "Failed to attach Varlink server to event loop: %m");
r = varlink_server_add_connection(server, fd, &vl);
r = sd_varlink_server_add_connection(server, fd, &vl);
if (r < 0)
return log_error_errno(r, "Failed to add connection: %m");
TAKE_FD(fd);
vl = varlink_ref(vl);
vl = sd_varlink_ref(vl);
r = varlink_set_allow_fd_passing_input(vl, true);
r = sd_varlink_set_allow_fd_passing_input(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable fd passing for read: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable fd passing for write: %m");
@ -573,7 +573,7 @@ static int process_connection(VarlinkServer *server, int _fd) {
if (r < 0)
return log_error_errno(r, "Failed to run event loop: %m");
r = varlink_server_detach_event(server);
r = sd_varlink_server_detach_event(server);
if (r < 0)
return log_error_errno(r, "Failed to detach Varlink server from event loop: %m");
@ -582,7 +582,7 @@ static int process_connection(VarlinkServer *server, int _fd) {
static int run(int argc, char *argv[]) {
usec_t start_time, listen_idle_usec, last_busy_usec = USEC_INFINITY;
_cleanup_(varlink_server_unrefp) VarlinkServer *server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *server = NULL;
_cleanup_(hashmap_freep) Hashmap *polkit_registry = NULL;
_cleanup_(pidref_done) PidRef parent = PIDREF_NULL;
unsigned n_iterations = 0;
@ -604,23 +604,23 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to turn off non-blocking mode for listening socket: %m");
r = varlink_server_new(&server, VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&server, SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate server: %m");
r = varlink_server_add_interface(server, &vl_interface_io_systemd_MountFileSystem);
r = sd_varlink_server_add_interface(server, &vl_interface_io_systemd_MountFileSystem);
if (r < 0)
return log_error_errno(r, "Failed to add MountFileSystem interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
server,
"io.systemd.MountFileSystem.MountImage", vl_method_mount_image);
if (r < 0)
return log_error_errno(r, "Failed to bind methods: %m");
varlink_server_set_userdata(server, &polkit_registry);
sd_varlink_server_set_userdata(server, &polkit_registry);
r = varlink_server_set_exit_on_idle(server, true);
r = sd_varlink_server_set_exit_on_idle(server, true);
if (r < 0)
return log_error_errno(r, "Failed to enable exit-on-idle mode: %m");

View File

@ -19,6 +19,7 @@
#include "sd-json.h"
#include "sd-netlink.h"
#include "sd-network.h"
#include "sd-varlink.h"
#include "alloc-util.h"
#include "bond-util.h"
@ -73,7 +74,7 @@
#include "terminal-util.h"
#include "udev-util.h"
#include "unit-def.h"
#include "varlink.h"
#include "varlink-util.h"
#include "verbs.h"
#include "wifi-util.h"
@ -96,19 +97,19 @@ sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
STATIC_DESTRUCTOR_REGISTER(arg_drop_in, freep);
static int varlink_connect_networkd(Varlink **ret_varlink) {
_cleanup_(varlink_flush_close_unrefp) Varlink *vl = NULL;
static int varlink_connect_networkd(sd_varlink **ret_varlink) {
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
sd_json_variant *reply;
uint64_t id;
int r;
r = varlink_connect_address(&vl, "/run/systemd/netif/io.systemd.Network");
r = sd_varlink_connect_address(&vl, "/run/systemd/netif/io.systemd.Network");
if (r < 0)
return log_error_errno(r, "Failed to connect to network service /run/systemd/netif/io.systemd.Network: %m");
(void) varlink_set_description(vl, "varlink-network");
(void) sd_varlink_set_description(vl, "varlink-network");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to allow passing file descriptor through varlink: %m");
@ -1362,7 +1363,7 @@ static const sd_json_dispatch_field lldp_neighbor_dispatch_table[] = {
{},
};
static int dump_lldp_neighbors(Varlink *vl, Table *table, int ifindex) {
static int dump_lldp_neighbors(sd_varlink *vl, Table *table, int ifindex) {
_cleanup_strv_free_ char **buf = NULL;
sd_json_variant *reply;
int r;
@ -1685,7 +1686,7 @@ static int link_status_one(
sd_bus *bus,
sd_netlink *rtnl,
sd_hwdb *hwdb,
Varlink *vl,
sd_varlink *vl,
const LinkInfo *info) {
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL,
@ -2428,7 +2429,7 @@ static int link_status(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
_cleanup_(varlink_flush_close_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
_cleanup_(link_info_array_freep) LinkInfo *links = NULL;
int r, c;
@ -2590,7 +2591,7 @@ static int dump_lldp_neighbors_json(sd_json_variant *reply, char * const *patter
}
static int link_lldp_status(int argc, char *argv[], void *userdata) {
_cleanup_(varlink_flush_close_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
sd_json_variant *reply;
uint64_t all = 0;
@ -2931,7 +2932,7 @@ static int verb_reconfigure(int argc, char *argv[], void *userdata) {
}
static int verb_persistent_storage(int argc, char *argv[], void *userdata) {
_cleanup_(varlink_flush_close_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *vl = NULL;
bool ready;
int r;
@ -2951,7 +2952,7 @@ static int verb_persistent_storage(int argc, char *argv[], void *userdata) {
if (fd < 0)
return log_error_errno(errno, "Failed to open /var/lib/systemd/network/: %m");
r = varlink_push_fd(vl, fd);
r = sd_varlink_push_fd(vl, fd);
if (r < 0)
return log_error_errno(r, "Failed to push file descriptor of /var/lib/systemd/network/ into varlink: %m");

View File

@ -2,6 +2,8 @@
#include <unistd.h>
#include "sd-varlink.h"
#include "bus-polkit.h"
#include "fd-util.h"
#include "json-util.h"
@ -9,18 +11,17 @@
#include "networkd-dhcp-server.h"
#include "networkd-manager-varlink.h"
#include "stat-util.h"
#include "varlink.h"
#include "varlink-io.systemd.Network.h"
static int vl_method_get_states(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_states(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR_STRING("AddressState", link_address_state_to_string(m->address_state)),
SD_JSON_BUILD_PAIR_STRING("IPv4AddressState", link_address_state_to_string(m->ipv4_address_state)),
@ -30,7 +31,7 @@ static int vl_method_get_states(Varlink *link, sd_json_variant *parameters, Varl
SD_JSON_BUILD_PAIR_STRING("OperationalState", link_operstate_to_string(m->operational_state)));
}
static int vl_method_get_namespace_id(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_namespace_id(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
uint64_t inode = 0;
uint32_t nsid = UINT32_MAX;
int r;
@ -38,7 +39,7 @@ static int vl_method_get_namespace_id(Varlink *link, sd_json_variant *parameters
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
/* Network namespaces have two identifiers: the inode number (which all namespace types have), and
* the "nsid" (aka the "cookie"), which only network namespaces know as a concept, and which is not
@ -55,7 +56,7 @@ static int vl_method_get_namespace_id(Varlink *link, sd_json_variant *parameters
if (r < 0)
log_full_errno(r == -ENODATA ? LOG_DEBUG : LOG_WARNING, r, "Failed to query network nsid, ignoring: %m");
return varlink_replybo(link,
return sd_varlink_replybo(link,
SD_JSON_BUILD_PAIR_UNSIGNED("NamespaceId", inode),
SD_JSON_BUILD_PAIR_CONDITION(nsid == UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_NULL),
SD_JSON_BUILD_PAIR_CONDITION(nsid != UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_UNSIGNED(nsid)));
@ -66,7 +67,7 @@ typedef struct InterfaceInfo {
const char *ifname;
} InterfaceInfo;
static int dispatch_interface(Varlink *vlink, sd_json_variant *parameters, Manager *manager, Link **ret) {
static int dispatch_interface(sd_varlink *vlink, sd_json_variant *parameters, Manager *manager, Link **ret) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "InterfaceIndex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(InterfaceInfo, ifindex), 0 },
{ "InterfaceName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(InterfaceInfo, ifname), 0 },
@ -80,23 +81,23 @@ static int dispatch_interface(Varlink *vlink, sd_json_variant *parameters, Manag
assert(vlink);
assert(manager);
r = varlink_dispatch(vlink, parameters, dispatch_table, &info);
r = sd_varlink_dispatch(vlink, parameters, dispatch_table, &info);
if (r != 0)
return r;
if (info.ifindex < 0)
return varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
if (info.ifindex > 0 && link_get_by_index(manager, info.ifindex, &link) < 0)
return varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceIndex"));
if (info.ifname) {
Link *link_by_name;
if (link_get_by_name(manager, info.ifname, &link_by_name) < 0)
return varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
if (link && link_by_name != link)
/* If both arguments are specified, then these must be consistent. */
return varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
return sd_varlink_error_invalid_parameter(vlink, JSON_VARIANT_STRING_CONST("InterfaceName"));
link = link_by_name;
}
@ -119,7 +120,7 @@ static int link_append_lldp_neighbors(Link *link, sd_json_variant *v, sd_json_va
SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(v), "Neighbors", SD_JSON_BUILD_VARIANT(v)));
}
static int vl_method_get_lldp_neighbors(Varlink *vlink, sd_json_variant *parameters, VarlinkMethodFlags flags, Manager *manager) {
static int vl_method_get_lldp_neighbors(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, Manager *manager) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *array = NULL;
Link *link = NULL;
int r;
@ -162,13 +163,13 @@ static int vl_method_get_lldp_neighbors(Varlink *vlink, sd_json_variant *paramet
return r;
}
return varlink_replybo(
return sd_varlink_replybo(
vlink,
SD_JSON_BUILD_PAIR_CONDITION(sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_EMPTY_ARRAY),
SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_VARIANT(array)));
}
static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_set_persistent_storage(sd_varlink *vlink, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "Ready", SD_JSON_VARIANT_BOOLEAN, sd_json_dispatch_stdbool, 0, 0 },
{}
@ -180,7 +181,7 @@ static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *par
assert(vlink);
r = varlink_dispatch(vlink, parameters, dispatch_table, &ready);
r = sd_varlink_dispatch(vlink, parameters, dispatch_table, &ready);
if (r != 0)
return r;
@ -188,7 +189,7 @@ static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *par
struct stat st, st_prev;
int fd;
fd = varlink_peek_fd(vlink, 0);
fd = sd_varlink_peek_fd(vlink, 0);
if (fd < 0)
return log_warning_errno(fd, "Failed to peek file descriptor of the persistent storage: %m");
@ -203,7 +204,7 @@ static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *par
return log_warning_errno(r, "Failed to check if the persistent storage is writable: %m");
if (r > 0) {
log_warning("The persistent storage is on read-only filesystem.");
return varlink_error(vlink, "io.systemd.Network.StorageReadOnly", NULL);
return sd_varlink_error(vlink, "io.systemd.Network.StorageReadOnly", NULL);
}
if (fstat(fd, &st) < 0)
@ -216,11 +217,11 @@ static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *par
if (manager->persistent_storage_fd >= 0 &&
fstat(manager->persistent_storage_fd, &st_prev) >= 0 &&
stat_inode_same(&st, &st_prev))
return varlink_reply(vlink, NULL);
return sd_varlink_reply(vlink, NULL);
} else {
if (manager->persistent_storage_fd < 0)
return varlink_reply(vlink, NULL);
return sd_varlink_reply(vlink, NULL);
}
r = varlink_verify_polkit_async(
@ -235,7 +236,7 @@ static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *par
if (ready) {
_cleanup_close_ int fd = -EBADF;
fd = varlink_take_fd(vlink, 0);
fd = sd_varlink_take_fd(vlink, 0);
if (fd < 0)
return log_warning_errno(fd, "Failed to take file descriptor of the persistent storage: %m");
@ -245,15 +246,15 @@ static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *par
manager_toggle_dhcp4_server_state(manager, ready);
return varlink_reply(vlink, NULL);
return sd_varlink_reply(vlink, NULL);
}
static int on_connect(VarlinkServer *s, Varlink *vlink, void *userdata) {
static int on_connect(sd_varlink_server *s, sd_varlink *vlink, void *userdata) {
int r;
assert(vlink);
r = varlink_set_allow_fd_passing_input(vlink, true);
r = sd_varlink_set_allow_fd_passing_input(vlink, true);
if (r < 0)
return log_warning_errno(r, "Failed to allow receiving file descriptor through varlink: %m");
@ -261,7 +262,7 @@ static int on_connect(VarlinkServer *s, Varlink *vlink, void *userdata) {
}
int manager_connect_varlink(Manager *m) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
@ -269,19 +270,19 @@ int manager_connect_varlink(Manager *m) {
if (m->varlink_server)
return 0;
r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(s, m);
sd_varlink_server_set_userdata(s, m);
(void) varlink_server_set_description(s, "varlink-api-network");
(void) sd_varlink_server_set_description(s, "varlink-api-network");
r = varlink_server_add_interface(s, &vl_interface_io_systemd_Network);
r = sd_varlink_server_add_interface(s, &vl_interface_io_systemd_Network);
if (r < 0)
return log_error_errno(r, "Failed to add Network interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
s,
"io.systemd.Network.GetStates", vl_method_get_states,
"io.systemd.Network.GetNamespaceId", vl_method_get_namespace_id,
@ -290,15 +291,15 @@ int manager_connect_varlink(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to register varlink methods: %m");
r = varlink_server_listen_address(s, "/run/systemd/netif/io.systemd.Network", 0666);
r = sd_varlink_server_listen_address(s, "/run/systemd/netif/io.systemd.Network", 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
r = varlink_server_bind_connect(s, on_connect);
r = sd_varlink_server_bind_connect(s, on_connect);
if (r < 0)
return log_error_errno(r, "Failed to set on-connect callback for varlink: %m");
@ -309,6 +310,6 @@ int manager_connect_varlink(Manager *m) {
void manager_varlink_done(Manager *m) {
assert(m);
m->varlink_server = varlink_server_unref(m->varlink_server);
m->varlink_server = sd_varlink_server_unref(m->varlink_server);
(void) unlink("/run/systemd/netif/io.systemd.Network");
}

View File

@ -7,6 +7,7 @@
#include "sd-id128.h"
#include "sd-netlink.h"
#include "sd-resolve.h"
#include "sd-varlink.h"
#include "dhcp-duid-internal.h"
#include "firewall-util.h"
@ -17,7 +18,6 @@
#include "ordered-set.h"
#include "set.h"
#include "time-util.h"
#include "varlink.h"
struct Manager {
sd_netlink *rtnl;
@ -26,7 +26,7 @@ struct Manager {
sd_event *event;
sd_resolve *resolve;
sd_bus *bus;
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
sd_device_monitor *device_monitor;
Hashmap *polkit_registry;
int ethtool_fd;

View File

@ -9,6 +9,7 @@
#include "sd-daemon.h"
#include "sd-netlink.h"
#include "sd-varlink.h"
#include "env-util.h"
#include "fd-util.h"
@ -42,7 +43,6 @@
#include "userns-restrict.h"
#include "varlink-io.systemd.NamespaceResource.h"
#include "varlink-io.systemd.UserDatabase.h"
#include "varlink.h"
#define ITERATIONS_MAX 64U
#define RUNTIME_MAX_USEC (5 * USEC_PER_MINUTE)
@ -95,7 +95,7 @@ static int build_user_json(UserNamespaceInfo *userns_info, uid_t offset, sd_json
SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition))));
}
static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "uid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, uid), 0 },
@ -114,12 +114,12 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.NamespaceResource"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (p.user_name) {
_cleanup_free_ char *n = NULL;
@ -153,7 +153,7 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
goto not_found;
if (uid_is_valid(p.uid) && p.uid != userns_info->start + offset)
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
} else if (uid_is_valid(p.uid)) {
uid_t start, uidmask;
@ -180,16 +180,16 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
if (offset >= userns_info->size) /* Outside of range? */
goto not_found;
} else
return varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
r = build_user_json(userns_info, offset, &v);
if (r < 0)
return r;
return varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)));
not_found:
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
}
static int build_group_json(UserNamespaceInfo *userns_info, gid_t offset, sd_json_variant **ret) {
@ -222,7 +222,7 @@ static int build_group_json(UserNamespaceInfo *userns_info, gid_t offset, sd_jso
SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition))));
}
static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "gid", SD_JSON_VARIANT_UNSIGNED, sd_json_dispatch_uid_gid, offsetof(LookupParameters, gid), 0 },
@ -241,12 +241,12 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.NamespaceResource"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
if (p.group_name) {
_cleanup_free_ char *n = NULL;
@ -280,7 +280,7 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
goto not_found;
if (gid_is_valid(p.gid) && p.uid != userns_info->start + offset)
return varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.ConflictingRecordFound", NULL);
} else if (gid_is_valid(p.gid)) {
gid_t start, gidmask;
@ -307,19 +307,19 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
if (offset >= userns_info->size) /* Outside of range? */
goto not_found;
} else
return varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.EnumerationNotSupported", NULL);
r = build_group_json(userns_info, offset, &v);
if (r < 0)
return r;
return varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)));
not_found:
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
}
static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "userName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParameters, user_name), 0 },
{ "groupName", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParameters, group_name), 0 },
@ -332,15 +332,15 @@ static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters,
assert(parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!streq_ptr(p.service, "io.systemd.NamespaceResource"))
return varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.BadService", NULL);
/* We don't support auxiliary groups for namespace allocations */
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
}
static int uid_is_available(
@ -587,7 +587,7 @@ static int write_userns(int usernsfd, const UserNamespaceInfo *userns_info) {
return 0;
}
static int test_userns_api_support(Varlink *link) {
static int test_userns_api_support(sd_varlink *link) {
int r;
assert(link);
@ -601,12 +601,12 @@ static int test_userns_api_support(Varlink *link) {
if (r < 0)
return log_error_errno(r, "Failed to parse $NSRESOURCE_API: %m");
if (r == 0)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceInterfaceNotSupported", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceInterfaceNotSupported", NULL);
return 0;
}
static int validate_name(Varlink *link, const char *name, char **ret) {
static int validate_name(sd_varlink *link, const char *name, char **ret) {
_cleanup_free_ char *un = NULL;
int r;
@ -615,13 +615,13 @@ static int validate_name(Varlink *link, const char *name, char **ret) {
assert(ret);
uid_t peer_uid;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
if (peer_uid == 0) {
if (!userns_name_is_valid(name))
return varlink_error_invalid_parameter_name(link, "name");
return sd_varlink_error_invalid_parameter_name(link, "name");
un = strdup(name);
if (!un)
@ -634,26 +634,26 @@ static int validate_name(Varlink *link, const char *name, char **ret) {
return -ENOMEM;
if (!userns_name_is_valid(un))
return varlink_error_invalid_parameter_name(link, "name");
return sd_varlink_error_invalid_parameter_name(link, "name");
}
*ret = TAKE_PTR(un);
return 0;
}
static int validate_target_and_size(Varlink *link, unsigned target, unsigned size) {
static int validate_target_and_size(sd_varlink *link, unsigned target, unsigned size) {
assert(link);
if (!IN_SET(size, 1U, 0x10000))
return varlink_error_invalid_parameter_name(link, "size");
return sd_varlink_error_invalid_parameter_name(link, "size");
if (!uid_is_valid(target) || target > UINT32_MAX - size)
return varlink_error_invalid_parameter_name(link, "target");
return sd_varlink_error_invalid_parameter_name(link, "target");
return 0;
}
static int validate_userns(Varlink *link, int userns_fd) {
static int validate_userns(sd_varlink *link, int userns_fd) {
int r;
assert(link);
@ -668,17 +668,17 @@ static int validate_userns(Varlink *link, int userns_fd) {
if (r < 0)
return log_debug_errno(r, "Failed to check if user namespace fd is actually a user namespace: %m");
if (r == 0)
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
/* And refuse the thing if it is our own */
r = is_our_namespace(userns_fd, NAMESPACE_USER);
if (r < 0)
return log_debug_errno(r, "Failed to check if user namespace fd refers to our own user namespace: %m");
if (r > 0)
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
uid_t peer_uid;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return log_debug_errno(r, "Failed to acquire peer UID: %m");
@ -689,13 +689,13 @@ static int validate_userns(Varlink *link, int userns_fd) {
return log_debug_errno(errno, "Failed to get owner UID of user namespace: %m");
if (owner_uid != peer_uid)
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
}
return 0;
}
static int validate_userns_is_empty(Varlink *link, int userns_fd) {
static int validate_userns_is_empty(sd_varlink *link, int userns_fd) {
int r;
assert(link);
@ -707,7 +707,7 @@ static int validate_userns_is_empty(Varlink *link, int userns_fd) {
return log_debug_errno(r, "Failed to read userns UID range: %m");
if (!uid_range_is_empty(range))
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
range = uid_range_free(range);
r = uid_range_load_userns_by_fd(userns_fd, GID_RANGE_USERNS_OUTSIDE, &range);
@ -715,7 +715,7 @@ static int validate_userns_is_empty(Varlink *link, int userns_fd) {
return log_debug_errno(r, "Failed to read userns GID range: %m");
if (!uid_range_is_empty(range))
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return 0;
}
@ -727,7 +727,7 @@ typedef struct AllocateParameters {
unsigned userns_fd_idx;
} AllocateParameters;
static int vl_method_allocate_user_range(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_allocate_user_range(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(AllocateParameters, name), SD_JSON_MANDATORY },
@ -755,7 +755,7 @@ static int vl_method_allocate_user_range(Varlink *link, sd_json_variant *paramet
if (r != 0)
return r;
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
@ -767,7 +767,7 @@ static int vl_method_allocate_user_range(Varlink *link, sd_json_variant *paramet
if (r != 0)
return r;
userns_fd = varlink_take_fd(link, p.userns_fd_idx);
userns_fd = sd_varlink_take_fd(link, p.userns_fd_idx);
if (userns_fd < 0)
return log_debug_errno(userns_fd, "Failed to take user namespace fd from Varlink connection: %m");
@ -782,7 +782,7 @@ static int vl_method_allocate_user_range(Varlink *link, sd_json_variant *paramet
if (fstat(userns_fd, &userns_st) < 0)
return log_debug_errno(errno, "Failed to fstat() user namespace fd: %m");
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -811,13 +811,13 @@ static int vl_method_allocate_user_range(Varlink *link, sd_json_variant *paramet
r = allocate_now(registry_dir_fd, userns_info, &lock_fd);
if (r == -EHOSTDOWN) /* The needed UID range is not delegated to us */
return varlink_error(link, "io.systemd.NamespaceResource.DynamicRangeUnavailable", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.DynamicRangeUnavailable", NULL);
if (r == -EBUSY) /* All used up */
return varlink_error(link, "io.systemd.NamespaceResource.NoDynamicRange", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.NoDynamicRange", NULL);
if (r == -EDEADLK)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceExists", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceExists", NULL);
if (r == -EEXIST)
return varlink_error(link, "io.systemd.NamespaceResource.NameExists", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.NameExists", NULL);
if (r < 0)
return r;
@ -854,7 +854,7 @@ static int vl_method_allocate_user_range(Varlink *link, sd_json_variant *paramet
/* Note, we'll not return UID values from the host, since the child might not run in the same
* user namespace as us. If they want to know the ranges they should read them off the userns fd, so
* that they are translated into their PoV */
return varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
return sd_varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
fail:
/* Note: we don't have to clean-up the BPF maps in the error path: the bpf map type used will
@ -863,7 +863,7 @@ fail:
return r;
}
static int validate_userns_is_safe(Varlink *link, int userns_fd) {
static int validate_userns_is_safe(sd_varlink *link, int userns_fd) {
int r;
assert(link);
@ -875,7 +875,7 @@ static int validate_userns_is_safe(Varlink *link, int userns_fd) {
if (r < 0)
return log_debug_errno(r, "Failed to read userns UID range: %m");
if (uid_range_is_empty(outside_range))
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
/* Read the outside GID range and check it is the same as the UID range */
_cleanup_(uid_range_freep) UIDRange *outside_range_gid = NULL;
@ -883,7 +883,7 @@ static int validate_userns_is_safe(Varlink *link, int userns_fd) {
if (r < 0)
return log_debug_errno(r, "Failed to read userns GID range: %m");
if (!uid_range_equal(outside_range, outside_range_gid))
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
/* Read the inside UID range, and verify it matches the size of the outside UID range */
_cleanup_(uid_range_freep) UIDRange *inside_range = NULL;
@ -899,26 +899,26 @@ static int validate_userns_is_safe(Varlink *link, int userns_fd) {
if (r < 0)
return log_debug_errno(r, "Failed to read userns contents: %m");
if (!uid_range_equal(inside_range, inside_range_gid))
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
uid_t peer_uid;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
uid_t peer_gid;
r = varlink_get_peer_gid(link, &peer_gid);
r = sd_varlink_get_peer_gid(link, &peer_gid);
if (r < 0)
return r;
/* Insist that the first UID/GID in the range matches the client's UID/GID */
if (outside_range->entries[0].start != peer_uid ||
outside_range_gid->entries[0].start != peer_gid)
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
/* If there are more than one UID in the range, then also insist that the first UID maps to root inside the userns */
if (uid_range_size(outside_range) > 1 && inside_range->entries[0].start != 0)
return varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "userNamespaceFileDescriptor");
return 0;
}
@ -928,7 +928,7 @@ typedef struct RegisterParameters {
unsigned userns_fd_idx;
} RegisterParameters;
static int vl_method_register_user_namespace(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_register_user_namespace(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(RegisterParameters, name), SD_JSON_MANDATORY },
@ -953,7 +953,7 @@ static int vl_method_register_user_namespace(Varlink *link, sd_json_variant *par
if (r != 0)
return r;
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
@ -961,7 +961,7 @@ static int vl_method_register_user_namespace(Varlink *link, sd_json_variant *par
if (r != 0)
return r;
userns_fd = varlink_take_fd(link, p.userns_fd_idx);
userns_fd = sd_varlink_take_fd(link, p.userns_fd_idx);
if (userns_fd < 0)
return userns_fd;
@ -976,7 +976,7 @@ static int vl_method_register_user_namespace(Varlink *link, sd_json_variant *par
if (fstat(userns_fd, &userns_st) < 0)
return log_debug_errno(errno, "Failed to fstat() user namespace fd: %m");
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -999,13 +999,13 @@ static int vl_method_register_user_namespace(Varlink *link, sd_json_variant *par
if (r < 0)
return r;
if (r > 0)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceExists", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceExists", NULL);
r = name_is_available(registry_dir_fd, userns_name);
if (r < 0)
return r;
if (r == 0)
return varlink_error(link, "io.systemd.NamespaceResource.NameExists", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.NameExists", NULL);
_cleanup_(userns_info_freep) UserNamespaceInfo *userns_info = userns_info_new();
if (!userns_info)
@ -1042,7 +1042,7 @@ static int vl_method_register_user_namespace(Varlink *link, sd_json_variant *par
if (r < 0)
goto fail;
return varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
return sd_varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
fail:
userns_registry_remove(registry_dir_fd, userns_info);
@ -1054,7 +1054,7 @@ typedef struct AddMountParameters {
unsigned mount_fd_idx;
} AddMountParameters;
static int vl_method_add_mount_to_user_namespace(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_add_mount_to_user_namespace(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field parameter_dispatch_table[] = {
{ "userNamespaceFileDescriptor", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint, offsetof(AddMountParameters, userns_fd_idx), SD_JSON_MANDATORY },
@ -1080,17 +1080,17 @@ static int vl_method_add_mount_to_user_namespace(Varlink *link, sd_json_variant
return r;
/* Allowlisting arbitrary mounts is a privileged operation */
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
if (peer_uid != 0)
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
r = varlink_dispatch(link, parameters, parameter_dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, parameter_dispatch_table, &p);
if (r != 0)
return r;
userns_fd = varlink_take_fd(link, p.userns_fd_idx);
userns_fd = sd_varlink_take_fd(link, p.userns_fd_idx);
if (userns_fd < 0)
return userns_fd;
@ -1101,7 +1101,7 @@ static int vl_method_add_mount_to_user_namespace(Varlink *link, sd_json_variant
if (fstat(userns_fd, &userns_st) < 0)
return -errno;
mount_fd = varlink_take_fd(link, p.mount_fd_idx);
mount_fd = sd_varlink_take_fd(link, p.mount_fd_idx);
if (mount_fd < 0)
return mount_fd;
@ -1132,7 +1132,7 @@ static int vl_method_add_mount_to_user_namespace(Varlink *link, sd_json_variant
userns_st.st_ino,
&userns_info);
if (r == -ENOENT)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceNotRegistered", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceNotRegistered", NULL);
if (r < 0)
return r;
@ -1169,10 +1169,10 @@ static int vl_method_add_mount_to_user_namespace(Varlink *link, sd_json_variant
log_debug("Granting access to mount %i to user namespace " INO_FMT " ('%s')",
mnt_id, userns_st.st_ino, userns_info->name);
return varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
return sd_varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
}
static int validate_cgroup(Varlink *link, int fd, uint64_t *ret_cgroup_id) {
static int validate_cgroup(sd_varlink *link, int fd, uint64_t *ret_cgroup_id) {
int r;
assert(link);
@ -1191,7 +1191,7 @@ static int validate_cgroup(Varlink *link, int fd, uint64_t *ret_cgroup_id) {
if (r < 0)
return log_debug_errno(r, "Failed to check if cgroup fd actually refers to cgroupfs: %m");
if (r == 0)
return varlink_error_invalid_parameter_name(link, "controlGroupFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "controlGroupFileDescriptor");
r = cg_fd_get_cgroupid(fd, ret_cgroup_id);
if (r < 0)
@ -1205,7 +1205,7 @@ typedef struct AddCGroupParameters {
unsigned cgroup_fd_idx;
} AddCGroupParameters;
static int vl_method_add_cgroup_to_user_namespace(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_add_cgroup_to_user_namespace(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field parameter_dispatch_table[] = {
{ "userNamespaceFileDescriptor", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint, offsetof(AddCGroupParameters, userns_fd_idx), SD_JSON_MANDATORY },
{ "controlGroupFileDescriptor", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint, offsetof(AddCGroupParameters, cgroup_fd_idx), SD_JSON_MANDATORY },
@ -1229,11 +1229,11 @@ static int vl_method_add_cgroup_to_user_namespace(Varlink *link, sd_json_variant
if (r != 0)
return r;
r = varlink_dispatch(link, parameters, parameter_dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, parameter_dispatch_table, &p);
if (r != 0)
return r;
userns_fd = varlink_take_fd(link, p.userns_fd_idx);
userns_fd = sd_varlink_take_fd(link, p.userns_fd_idx);
if (userns_fd < 0)
return log_debug_errno(userns_fd, "Failed to take user namespace fd from Varlink connection: %m");
@ -1244,7 +1244,7 @@ static int vl_method_add_cgroup_to_user_namespace(Varlink *link, sd_json_variant
if (fstat(userns_fd, &userns_st) < 0)
return log_debug_errno(errno, "Failed to fstat() user namespace fd: %m");
cgroup_fd = varlink_take_fd(link, p.cgroup_fd_idx);
cgroup_fd = sd_varlink_take_fd(link, p.cgroup_fd_idx);
if (cgroup_fd < 0)
return log_debug_errno(cgroup_fd, "Failed to take cgroup fd from Varlink connection: %m");
@ -1270,29 +1270,29 @@ static int vl_method_add_cgroup_to_user_namespace(Varlink *link, sd_json_variant
userns_st.st_ino,
&userns_info);
if (r == -ENOENT)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceNotRegistered", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceNotRegistered", NULL);
if (r < 0)
return r;
/* The user namespace must have a user assigned */
if (userns_info->size == 0)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceWithoutUserRange", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceWithoutUserRange", NULL);
if (userns_info_has_cgroup(userns_info, cgroup_id))
return varlink_error(link, "io.systemd.NamespaceResource.ControlGroupAlreadyAdded", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.ControlGroupAlreadyAdded", NULL);
if (userns_info->n_cgroups > USER_NAMESPACE_CGROUPS_DELEGATE_MAX)
return varlink_error(link, "io.systemd.NamespaceResource.TooManyControlGroups", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.TooManyControlGroups", NULL);
/* Registering a cgroup for this client is only allowed for the root or the owner of a userns */
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return log_debug_errno(r, "Failed to get connection peer: %m");
if (peer_uid != 0) {
if (peer_uid != userns_info->owner)
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
/* The cgroup must be owned by the owner of the userns */
if (cgroup_st.st_uid != userns_info->owner)
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
}
r = userns_info_add_cgroup(userns_info, cgroup_id);
@ -1317,7 +1317,7 @@ static int vl_method_add_cgroup_to_user_namespace(Varlink *link, sd_json_variant
log_debug("Granting ownership to cgroup %" PRIu64 " to userns " INO_FMT " ('%s' @ UID " UID_FMT ")",
cgroup_id, userns_st.st_ino, userns_info->name, userns_info->start);
return varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
return sd_varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
}
static uint64_t hash_ifname_id(UserNamespaceInfo *userns_info, const char *ifname) {
@ -1441,7 +1441,7 @@ static int create_veth(
return 0;
}
static int validate_netns(Varlink *link, int userns_fd, int netns_fd) {
static int validate_netns(sd_varlink *link, int userns_fd, int netns_fd) {
int r;
assert(link);
@ -1457,14 +1457,14 @@ static int validate_netns(Varlink *link, int userns_fd, int netns_fd) {
if (r < 0)
return r;
if (r == 0)
return varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
/* And refuse the thing if it is our own */
r = is_our_namespace(netns_fd, NAMESPACE_NET);
if (r < 0)
return r;
if (r > 0)
return varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
/* Check if the netns actually belongs to the userns */
_cleanup_close_ int owner_userns_fd = -EBADF;
@ -1476,10 +1476,10 @@ static int validate_netns(Varlink *link, int userns_fd, int netns_fd) {
if (r < 0)
return r;
if (r == 0)
return varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
uid_t peer_uid;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -1491,7 +1491,7 @@ static int validate_netns(Varlink *link, int userns_fd, int netns_fd) {
return -errno;
if (owner_uid != peer_uid)
return varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
return sd_varlink_error_invalid_parameter_name(link, "networkNamespaceFileDescriptor");
}
return 0;
@ -1504,7 +1504,7 @@ typedef struct AddNetworkParameters {
const char *mode;
} AddNetworkParameters;
static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_add_netif_to_user_namespace(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field parameter_dispatch_table[] = {
{ "userNamespaceFileDescriptor", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint, offsetof(AddNetworkParameters, userns_fd_idx), SD_JSON_MANDATORY },
{ "networkNamespaceFileDescriptor", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint, offsetof(AddNetworkParameters, netns_fd_idx), SD_JSON_MANDATORY },
@ -1529,11 +1529,11 @@ static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant
if (r != 0)
return r;
r = varlink_dispatch(link, parameters, parameter_dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, parameter_dispatch_table, &p);
if (r != 0)
return r;
userns_fd = varlink_take_fd(link, p.userns_fd_idx);
userns_fd = sd_varlink_take_fd(link, p.userns_fd_idx);
if (userns_fd < 0)
return userns_fd;
@ -1544,7 +1544,7 @@ static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant
if (fstat(userns_fd, &userns_st) < 0)
return -errno;
netns_fd = varlink_take_fd(link, p.netns_fd_idx);
netns_fd = sd_varlink_take_fd(link, p.netns_fd_idx);
if (netns_fd < 0)
return netns_fd;
@ -1553,10 +1553,10 @@ static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant
return r;
if (!streq_ptr(p.mode, "veth"))
return varlink_error_invalid_parameter_name(link, "mode");
return sd_varlink_error_invalid_parameter_name(link, "mode");
if (p.ifname && !ifname_valid(p.ifname))
return varlink_error_invalid_parameter_name(link, "interfaceName");
return sd_varlink_error_invalid_parameter_name(link, "interfaceName");
registry_dir_fd = userns_registry_open_fd();
if (registry_dir_fd < 0)
@ -1572,16 +1572,16 @@ static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant
userns_st.st_ino,
&userns_info);
if (r == -ENOENT)
return varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceNotRegistered", NULL);
return sd_varlink_error(link, "io.systemd.NamespaceResource.UserNamespaceNotRegistered", NULL);
if (r < 0)
return r;
/* Registering a network interface for this client is only allowed for the root or the owner of a userns */
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
if (peer_uid != 0 && peer_uid != userns_info->owner)
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
_cleanup_free_ char *ifname_host = NULL, *altifname_host = NULL;
const char *ifname_namespace = p.ifname ?: "host0";
@ -1614,34 +1614,37 @@ static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant
log_debug("Adding veth tunnel %s from host to userns " INO_FMT " ('%s' @ UID " UID_FMT ", interface %s).",
ifname_host, userns_st.st_ino, userns_info->name, userns_info->start, ifname_namespace);
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("hostInterfaceName", SD_JSON_BUILD_STRING(ifname_host)),
SD_JSON_BUILD_PAIR("namespaceInterfaceName", SD_JSON_BUILD_STRING(ifname_namespace)));
}
static int process_connection(VarlinkServer *server, int _fd) {
static int process_connection(sd_varlink_server *server, int _fd) {
_cleanup_close_ int fd = TAKE_FD(_fd); /* always take possession */
_cleanup_(varlink_close_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_close_unrefp) sd_varlink *vl = NULL;
int r;
r = varlink_server_add_connection(server, fd, &vl);
assert(server);
assert(fd >= 0);
r = sd_varlink_server_add_connection(server, fd, &vl);
if (r < 0)
return log_error_errno(r, "Failed to add connection: %m");
TAKE_FD(fd);
vl = varlink_ref(vl);
vl = sd_varlink_ref(vl);
r = varlink_set_allow_fd_passing_input(vl, true);
r = sd_varlink_set_allow_fd_passing_input(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable fd passing for read: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable fd passing for write: %m");
for (;;) {
r = varlink_process(vl);
r = sd_varlink_process(vl);
if (r == -ENOTCONN) {
log_debug("Connection terminated.");
break;
@ -1651,7 +1654,7 @@ static int process_connection(VarlinkServer *server, int _fd) {
if (r > 0)
continue;
r = varlink_wait(vl, CONNECTION_IDLE_USEC);
r = sd_varlink_wait(vl, CONNECTION_IDLE_USEC);
if (r < 0)
return log_error_errno(r, "Failed to wait for connection events: %m");
if (r == 0)
@ -1664,7 +1667,7 @@ static int process_connection(VarlinkServer *server, int _fd) {
static int run(int argc, char *argv[]) {
_cleanup_(userns_restrict_bpf_freep) struct userns_restrict_bpf *bpf = NULL;
usec_t start_time, listen_idle_usec, last_busy_usec = USEC_INFINITY;
_cleanup_(varlink_server_unrefp) VarlinkServer *server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *server = NULL;
_cleanup_(pidref_done) PidRef parent = PIDREF_NULL;
unsigned n_iterations = 0;
int m, listen_fd, r;
@ -1685,18 +1688,18 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to turn off non-blocking mode for listening socket: %m");
r = varlink_server_new(&server, VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&server, SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate server: %m");
r = varlink_server_add_interface_many(
r = sd_varlink_server_add_interface_many(
server,
&vl_interface_io_systemd_NamespaceResource,
&vl_interface_io_systemd_UserDatabase);
if (r < 0)
return log_error_errno(r, "Failed to add UserDatabase and NamespaceResource interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
server,
"io.systemd.NamespaceResource.AllocateUserRange", vl_method_allocate_user_range,
"io.systemd.NamespaceResource.RegisterUserNamespace", vl_method_register_user_namespace,
@ -1709,7 +1712,7 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to bind methods: %m");
varlink_server_set_userdata(server, &bpf);
sd_varlink_server_set_userdata(server, &bpf);
r = getenv_bool("NSRESOURCE_FIXED_WORKER");
if (r < 0)

View File

@ -8,6 +8,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "sd-varlink.h"
#include "env-util.h"
#include "errno-util.h"
#include "glyph-util.h"
@ -19,7 +21,6 @@
#include "signal-util.h"
#include "string-util.h"
#include "strv.h"
#include "varlink.h"
static sd_json_dispatch_flags_t json_dispatch_flags = SD_JSON_ALLOW_EXTENSIONS;
@ -47,12 +48,12 @@ static bool error_shall_fallback(const char *error_id) {
* fallback module can be loaded. (These are mostly all Varlink-internal errors, as apparently we
* then were unable to even do IPC with systemd-resolved.) */
return STR_IN_SET(error_id,
VARLINK_ERROR_DISCONNECTED,
VARLINK_ERROR_TIMEOUT,
VARLINK_ERROR_PROTOCOL,
VARLINK_ERROR_INTERFACE_NOT_FOUND,
VARLINK_ERROR_METHOD_NOT_FOUND,
VARLINK_ERROR_METHOD_NOT_IMPLEMENTED);
SD_VARLINK_ERROR_DISCONNECTED,
SD_VARLINK_ERROR_TIMEOUT,
SD_VARLINK_ERROR_PROTOCOL,
SD_VARLINK_ERROR_INTERFACE_NOT_FOUND,
SD_VARLINK_ERROR_METHOD_NOT_FOUND,
SD_VARLINK_ERROR_METHOD_NOT_IMPLEMENTED);
}
static bool error_shall_try_again(const char *error_id) {
@ -65,15 +66,15 @@ static bool error_shall_try_again(const char *error_id) {
"io.systemd.Resolve.NetworkDown");
}
static int connect_to_resolved(Varlink **ret) {
_cleanup_(varlink_unrefp) Varlink *link = NULL;
static int connect_to_resolved(sd_varlink **ret) {
_cleanup_(sd_varlink_unrefp) sd_varlink *link = NULL;
int r;
r = varlink_connect_address(&link, "/run/systemd/resolve/io.systemd.Resolve");
r = sd_varlink_connect_address(&link, "/run/systemd/resolve/io.systemd.Resolve");
if (r < 0)
return r;
r = varlink_set_relative_timeout(link, SD_RESOLVED_QUERY_TIMEOUT_USEC);
r = sd_varlink_set_relative_timeout(link, SD_RESOLVED_QUERY_TIMEOUT_USEC);
if (r < 0)
return r;
@ -232,7 +233,7 @@ enum nss_status _nss_resolve_gethostbyname4_r(
int *errnop, int *h_errnop,
int32_t *ttlp) {
_cleanup_(varlink_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *link = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *cparams = NULL;
_cleanup_(resolve_hostname_reply_destroy) ResolveHostnameReply p = {};
sd_json_variant *rparams, *entry;
@ -264,7 +265,7 @@ enum nss_status _nss_resolve_gethostbyname4_r(
* configuration can distinguish such executed but negative replies from complete failure to
* talk to resolved). */
const char *error_id;
r = varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id);
r = sd_varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id);
if (r < 0)
goto fail;
if (!isempty(error_id)) {
@ -392,7 +393,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
int32_t *ttlp,
char **canonp) {
_cleanup_(varlink_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *link = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *cparams = NULL;
_cleanup_(resolve_hostname_reply_destroy) ResolveHostnameReply p = {};
sd_json_variant *rparams, *entry;
@ -428,7 +429,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
goto fail;
const char *error_id;
r = varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id);
r = sd_varlink_call(link, "io.systemd.Resolve.ResolveHostname", cparams, &rparams, &error_id);
if (r < 0)
goto fail;
if (!isempty(error_id)) {
@ -608,7 +609,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
int *errnop, int *h_errnop,
int32_t *ttlp) {
_cleanup_(varlink_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *link = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *cparams = NULL;
_cleanup_(resolve_address_reply_destroy) ResolveAddressReply p = {};
sd_json_variant *rparams, *entry;
@ -648,7 +649,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
goto fail;
const char* error_id;
r = varlink_call(link, "io.systemd.Resolve.ResolveAddress", cparams, &rparams, &error_id);
r = sd_varlink_call(link, "io.systemd.Resolve.ResolveAddress", cparams, &rparams, &error_id);
if (r < 0)
goto fail;
if (!isempty(error_id)) {

View File

@ -127,15 +127,15 @@ static int process_managed_oom_message(Manager *m, uid_t uid, sd_json_variant *p
}
static int process_managed_oom_request(
Varlink *link,
sd_varlink *link,
sd_json_variant *parameters,
VarlinkMethodFlags flags,
sd_varlink_method_flags_t flags,
void *userdata) {
Manager *m = ASSERT_PTR(userdata);
uid_t uid;
int r;
r = varlink_get_peer_uid(link, &uid);
r = sd_varlink_get_peer_uid(link, &uid);
if (r < 0)
return log_error_errno(r, "Failed to get varlink peer uid: %m");
@ -143,10 +143,10 @@ static int process_managed_oom_request(
}
static int process_managed_oom_reply(
Varlink *link,
sd_varlink *link,
sd_json_variant *parameters,
const char *error_id,
VarlinkReplyFlags flags,
sd_varlink_reply_flags_t flags,
void *userdata) {
Manager *m = ASSERT_PTR(userdata);
uid_t uid;
@ -158,7 +158,7 @@ static int process_managed_oom_reply(
goto finish;
}
r = varlink_get_peer_uid(link, &uid);
r = sd_varlink_get_peer_uid(link, &uid);
if (r < 0) {
log_error_errno(r, "Failed to get varlink peer uid: %m");
goto finish;
@ -167,8 +167,8 @@ static int process_managed_oom_reply(
r = process_managed_oom_message(m, uid, parameters);
finish:
if (!FLAGS_SET(flags, VARLINK_REPLY_CONTINUES))
m->varlink_client = varlink_close_unref(link);
if (!FLAGS_SET(flags, SD_VARLINK_REPLY_CONTINUES))
m->varlink_client = sd_varlink_close_unref(link);
return r;
}
@ -308,29 +308,29 @@ static int update_monitored_cgroup_contexts_candidates(Hashmap *monitored_cgroup
}
static int acquire_managed_oom_connect(Manager *m) {
_cleanup_(varlink_close_unrefp) Varlink *link = NULL;
_cleanup_(sd_varlink_close_unrefp) sd_varlink *link = NULL;
int r;
assert(m);
assert(m->event);
r = varlink_connect_address(&link, VARLINK_ADDR_PATH_MANAGED_OOM_SYSTEM);
r = sd_varlink_connect_address(&link, VARLINK_ADDR_PATH_MANAGED_OOM_SYSTEM);
if (r < 0)
return log_error_errno(r, "Failed to connect to " VARLINK_ADDR_PATH_MANAGED_OOM_SYSTEM ": %m");
(void) varlink_set_userdata(link, m);
(void) varlink_set_description(link, "oomd");
(void) varlink_set_relative_timeout(link, USEC_INFINITY);
(void) sd_varlink_set_userdata(link, m);
(void) sd_varlink_set_description(link, "oomd");
(void) sd_varlink_set_relative_timeout(link, USEC_INFINITY);
r = varlink_attach_event(link, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_attach_event(link, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
r = varlink_bind_reply(link, process_managed_oom_reply);
r = sd_varlink_bind_reply(link, process_managed_oom_reply);
if (r < 0)
return log_error_errno(r, "Failed to bind reply callback: %m");
r = varlink_observe(link, "io.systemd.ManagedOOM.SubscribeManagedOOMCGroups", NULL);
r = sd_varlink_observe(link, "io.systemd.ManagedOOM.SubscribeManagedOOMCGroups", NULL);
if (r < 0)
return log_error_errno(r, "Failed to observe varlink call: %m");
@ -625,8 +625,8 @@ static int monitor_memory_pressure_contexts(Manager *m) {
Manager* manager_free(Manager *m) {
assert(m);
varlink_server_unref(m->varlink_server);
varlink_close_unref(m->varlink_client);
sd_varlink_server_unref(m->varlink_server);
sd_varlink_close_unref(m->varlink_client);
sd_event_source_unref(m->swap_context_event_source);
sd_event_source_unref(m->mem_pressure_context_event_source);
sd_event_unref(m->event);
@ -711,34 +711,34 @@ static int manager_connect_bus(Manager *m) {
}
static int manager_varlink_init(Manager *m, int fd) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
assert(!m->varlink_server);
r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID|VARLINK_SERVER_INHERIT_USERDATA);
r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(s, m);
sd_varlink_server_set_userdata(s, m);
r = varlink_server_add_interface(s, &vl_interface_io_systemd_oom);
r = sd_varlink_server_add_interface(s, &vl_interface_io_systemd_oom);
if (r < 0)
return log_error_errno(r, "Failed to add oom interface to varlink server: %m");
r = varlink_server_bind_method(s, "io.systemd.oom.ReportManagedOOMCGroups", process_managed_oom_request);
r = sd_varlink_server_bind_method(s, "io.systemd.oom.ReportManagedOOMCGroups", process_managed_oom_request);
if (r < 0)
return log_error_errno(r, "Failed to register varlink method: %m");
if (fd < 0)
r = varlink_server_listen_address(s, VARLINK_ADDR_PATH_MANAGED_OOM_USER, 0666);
r = sd_varlink_server_listen_address(s, VARLINK_ADDR_PATH_MANAGED_OOM_USER, 0666);
else
r = varlink_server_listen_fd(s, fd);
r = sd_varlink_server_listen_fd(s, fd);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");

View File

@ -3,10 +3,10 @@
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-varlink.h"
#include "conf-parser.h"
#include "oomd-util.h"
#include "varlink.h"
/* Polling interval for monitoring stats */
#define SWAP_INTERVAL_USEC 150000 /* 0.15 seconds */
@ -55,10 +55,10 @@ struct Manager {
/* This varlink object is used to manage the subscription from systemd-oomd to PID1 which it uses to
* listen for changes in ManagedOOM settings (oomd client - systemd server). */
Varlink *varlink_client;
sd_varlink *varlink_client;
/* This varlink server object is used to manage systemd-oomd's varlink server which is used by user
* managers to report changes in ManagedOOM settings (oomd server - systemd client). */
VarlinkServer *varlink_server;
sd_varlink_server *varlink_server;
};
Manager* manager_free(Manager *m);

View File

@ -4,6 +4,7 @@
#include "sd-json.h"
#include "sd-messages.h"
#include "sd-varlink.h"
#include "build.h"
#include "efi-loader.h"
@ -18,7 +19,6 @@
#include "strv.h"
#include "tpm2-pcr.h"
#include "tpm2-util.h"
#include "varlink.h"
#include "varlink-io.systemd.PCRExtend.h"
static bool arg_graceful = false;
@ -167,7 +167,7 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_file_system && arg_machine_id)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--file-system= and --machine-id may not be combined.");
r = varlink_invocation(VARLINK_ALLOW_ACCEPT);
r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT);
if (r < 0)
return log_error_errno(r, "Failed to check if invoked in Varlink mode: %m");
if (r > 0)
@ -258,7 +258,7 @@ static void method_extend_parameters_done(MethodExtendParameters *p) {
iovec_done(&p->data);
}
static int vl_method_extend(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_extend(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "pcr", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint, offsetof(MethodExtendParameters, pcr), SD_JSON_MANDATORY },
@ -273,27 +273,27 @@ static int vl_method_extend(Varlink *link, sd_json_variant *parameters, VarlinkM
assert(link);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (!TPM2_PCR_INDEX_VALID(p.pcr))
return varlink_error_invalid_parameter_name(link, "pcr");
return sd_varlink_error_invalid_parameter_name(link, "pcr");
if (p.text) {
/* Specifying both the text string and the binary data is not allowed */
if (p.data.iov_base)
return varlink_error_invalid_parameter_name(link, "data");
return sd_varlink_error_invalid_parameter_name(link, "data");
r = extend_now(p.pcr, p.text, strlen(p.text), _TPM2_USERSPACE_EVENT_TYPE_INVALID);
} else if (p.data.iov_base)
r = extend_now(p.pcr, p.data.iov_base, p.data.iov_len, _TPM2_USERSPACE_EVENT_TYPE_INVALID);
else
return varlink_error_invalid_parameter_name(link, "text");
return sd_varlink_error_invalid_parameter_name(link, "text");
if (r < 0)
return r;
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static int run(int argc, char *argv[]) {
@ -308,23 +308,23 @@ static int run(int argc, char *argv[]) {
return r;
if (arg_varlink) {
_cleanup_(varlink_server_unrefp) VarlinkServer *varlink_server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *varlink_server = NULL;
/* Invocation as Varlink service */
r = varlink_server_new(&varlink_server, VARLINK_SERVER_ROOT_ONLY);
r = sd_varlink_server_new(&varlink_server, SD_VARLINK_SERVER_ROOT_ONLY);
if (r < 0)
return log_error_errno(r, "Failed to allocate Varlink server: %m");
r = varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_PCRExtend);
r = sd_varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_PCRExtend);
if (r < 0)
return log_error_errno(r, "Failed to add Varlink interface: %m");
r = varlink_server_bind_method(varlink_server, "io.systemd.PCRExtend.Extend", vl_method_extend);
r = sd_varlink_server_bind_method(varlink_server, "io.systemd.PCRExtend.Extend", vl_method_extend);
if (r < 0)
return log_error_errno(r, "Failed to bind Varlink method: %m");
r = varlink_server_loop_auto(varlink_server);
r = sd_varlink_server_loop_auto(varlink_server);
if (r < 0)
return log_error_errno(r, "Failed to run Varlink event loop: %m");

View File

@ -7,6 +7,7 @@
#include "sd-device.h"
#include "sd-json.h"
#include "sd-varlink.h"
#include "ask-password-api.h"
#include "blockdev-util.h"
@ -51,7 +52,6 @@
#include "unaligned.h"
#include "unit-name.h"
#include "utf8.h"
#include "varlink.h"
#include "varlink-io.systemd.PCRLock.h"
#include "verbs.h"
@ -5163,7 +5163,7 @@ static int parse_argv(int argc, char *argv[]) {
return log_oom();
}
r = varlink_invocation(VARLINK_ALLOW_ACCEPT);
r = sd_varlink_invocation(SD_VARLINK_ALLOW_ACCEPT);
if (r < 0)
return log_error_errno(r, "Failed to check if invoked in Varlink mode: %m");
if (r > 0) {
@ -5213,7 +5213,7 @@ static int pcrlock_main(int argc, char *argv[]) {
return dispatch_verb(argc, argv, verbs, NULL);
}
static int vl_method_read_event_log(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_read_event_log(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
_cleanup_(event_log_freep) EventLog *el = NULL;
uint64_t recnum = 0;
int r;
@ -5221,7 +5221,7 @@ static int vl_method_read_event_log(Varlink *link, sd_json_variant *parameters,
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
el = event_log_new();
if (!el)
@ -5236,7 +5236,7 @@ static int vl_method_read_event_log(Varlink *link, sd_json_variant *parameters,
FOREACH_ARRAY(rr, el->records, el->n_records) {
if (rec_cel) {
r = varlink_notifybo(link, SD_JSON_BUILD_PAIR_VARIANT("record", rec_cel));
r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR_VARIANT("record", rec_cel));
if (r < 0)
return r;
@ -5248,14 +5248,14 @@ static int vl_method_read_event_log(Varlink *link, sd_json_variant *parameters,
return r;
}
return varlink_replybo(link, SD_JSON_BUILD_PAIR_CONDITION(!!rec_cel, "record", SD_JSON_BUILD_VARIANT(rec_cel)));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_CONDITION(!!rec_cel, "record", SD_JSON_BUILD_VARIANT(rec_cel)));
}
typedef struct MethodMakePolicyParameters {
bool force;
} MethodMakePolicyParameters;
static int vl_method_make_policy(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_make_policy(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "force", SD_JSON_VARIANT_BOOLEAN, sd_json_dispatch_stdbool, offsetof(MethodMakePolicyParameters, force), 0 },
{}
@ -5265,7 +5265,7 @@ static int vl_method_make_policy(Varlink *link, sd_json_variant *parameters, Var
assert(link);
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
@ -5273,24 +5273,24 @@ static int vl_method_make_policy(Varlink *link, sd_json_variant *parameters, Var
if (r < 0)
return r;
if (r == 0)
return varlink_error(link, "io.systemd.PCRLock.NoChange", NULL);
return sd_varlink_error(link, "io.systemd.PCRLock.NoChange", NULL);
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static int vl_method_remove_policy(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_remove_policy(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
int r;
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
r = remove_policy();
if (r < 0)
return r;
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
static int run(int argc, char *argv[]) {
@ -5303,19 +5303,19 @@ static int run(int argc, char *argv[]) {
return r;
if (arg_varlink) {
_cleanup_(varlink_server_unrefp) VarlinkServer *varlink_server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *varlink_server = NULL;
/* Invocation as Varlink service */
r = varlink_server_new(&varlink_server, VARLINK_SERVER_ROOT_ONLY);
r = sd_varlink_server_new(&varlink_server, SD_VARLINK_SERVER_ROOT_ONLY);
if (r < 0)
return log_error_errno(r, "Failed to allocate Varlink server: %m");
r = varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_PCRLock);
r = sd_varlink_server_add_interface(varlink_server, &vl_interface_io_systemd_PCRLock);
if (r < 0)
return log_error_errno(r, "Failed to add Varlink interface: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
varlink_server,
"io.systemd.PCRLock.ReadEventLog", vl_method_read_event_log,
"io.systemd.PCRLock.MakePolicy", vl_method_make_policy,
@ -5323,7 +5323,7 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to bind Varlink methods: %m");
r = varlink_server_loop_auto(varlink_server);
r = sd_varlink_server_loop_auto(varlink_server);
if (r < 0)
return log_error_errno(r, "Failed to run Varlink event loop: %m");

View File

@ -7,6 +7,7 @@
#include "sd-bus.h"
#include "sd-json.h"
#include "sd-netlink.h"
#include "sd-varlink.h"
#include "af-list.h"
#include "alloc-util.h"
@ -46,7 +47,7 @@
#include "strv.h"
#include "terminal-util.h"
#include "utf8.h"
#include "varlink.h"
#include "varlink-util.h"
#include "verb-log-control.h"
#include "verbs.h"
@ -1107,10 +1108,10 @@ static int verb_tlsa(int argc, char **argv, void *userdata) {
static int show_statistics(int argc, char **argv, void *userdata) {
_cleanup_(table_unrefp) Table *table = NULL;
sd_json_variant *reply = NULL;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
r = varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
r = sd_varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
if (r < 0)
return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m");
@ -1265,10 +1266,10 @@ static int show_statistics(int argc, char **argv, void *userdata) {
static int reset_statistics(int argc, char **argv, void *userdata) {
sd_json_variant *reply = NULL;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
r = varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
r = sd_varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
if (r < 0)
return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m");
@ -2799,10 +2800,10 @@ static void monitor_query_dump(sd_json_variant *v) {
}
static int monitor_reply(
Varlink *link,
sd_varlink *link,
sd_json_variant *parameters,
const char *error_id,
VarlinkReplyFlags flags,
sd_varlink_reply_flags_t flags,
void *userdata) {
assert(link);
@ -2810,13 +2811,13 @@ static int monitor_reply(
if (error_id) {
bool disconnect;
disconnect = streq(error_id, VARLINK_ERROR_DISCONNECTED);
disconnect = streq(error_id, SD_VARLINK_ERROR_DISCONNECTED);
if (disconnect)
log_info("Disconnected.");
else
log_error("Varlink error: %s", error_id);
(void) sd_event_exit(ASSERT_PTR(varlink_get_event(link)), disconnect ? EXIT_SUCCESS : EXIT_FAILURE);
(void) sd_event_exit(ASSERT_PTR(sd_varlink_get_event(link)), disconnect ? EXIT_SUCCESS : EXIT_FAILURE);
return 0;
}
@ -2841,7 +2842,7 @@ static int monitor_reply(
static int verb_monitor(int argc, char *argv[], void *userdata) {
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r, c;
r = sd_event_default(&event);
@ -2852,23 +2853,23 @@ static int verb_monitor(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to enable exit on SIGINT/SIGTERM: %m");
r = varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
r = sd_varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
if (r < 0)
return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m");
r = varlink_set_relative_timeout(vl, USEC_INFINITY); /* We want the monitor to run basically forever */
r = sd_varlink_set_relative_timeout(vl, USEC_INFINITY); /* We want the monitor to run basically forever */
if (r < 0)
return log_error_errno(r, "Failed to set varlink time-out: %m");
r = varlink_attach_event(vl, event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_attach_event(vl, event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
r = varlink_bind_reply(vl, monitor_reply);
r = sd_varlink_bind_reply(vl, monitor_reply);
if (r < 0)
return log_error_errno(r, "Failed to bind reply callback to varlink connection: %m");
r = varlink_observe(vl, "io.systemd.Resolve.Monitor.SubscribeQueryResults", NULL);
r = sd_varlink_observe(vl, "io.systemd.Resolve.Monitor.SubscribeQueryResults", NULL);
if (r < 0)
return log_error_errno(r, "Failed to issue SubscribeQueryResults() varlink call: %m");
@ -2999,10 +3000,10 @@ static int dump_cache_scope(sd_json_variant *scope) {
static int verb_show_cache(int argc, char *argv[], void *userdata) {
sd_json_variant *reply = NULL, *d = NULL;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
r = varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
r = sd_varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
if (r < 0)
return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m");
@ -3173,10 +3174,10 @@ static int dump_server_state(sd_json_variant *server) {
static int verb_show_server_state(int argc, char *argv[], void *userdata) {
sd_json_variant *reply = NULL, *d = NULL;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
r = varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
r = sd_varlink_connect_address(&vl, "/run/systemd/resolve/io.systemd.Resolve.Monitor");
if (r < 0)
return log_error_errno(r, "Failed to connect to query monitoring service /run/systemd/resolve/io.systemd.Resolve.Monitor: %m");

View File

@ -432,8 +432,8 @@ DnsQuery *dns_query_free(DnsQuery *q) {
sd_bus_track_unref(q->bus_track);
if (q->varlink_request) {
varlink_set_userdata(q->varlink_request, NULL);
varlink_unref(q->varlink_request);
sd_varlink_set_userdata(q->varlink_request, NULL);
sd_varlink_unref(q->varlink_request);
}
if (q->request_packet)

View File

@ -2,9 +2,9 @@
#pragma once
#include "sd-bus.h"
#include "sd-varlink.h"
#include "set.h"
#include "varlink.h"
typedef struct DnsQueryCandidate DnsQueryCandidate;
typedef struct DnsQuery DnsQuery;
@ -97,7 +97,7 @@ struct DnsQuery {
/* Bus + Varlink client information */
sd_bus_message *bus_request;
Varlink *varlink_request;
sd_varlink *varlink_request;
int request_family;
union in_addr_union request_address;
unsigned block_all_complete;

View File

@ -43,6 +43,7 @@
#include "string-table.h"
#include "string-util.h"
#include "utf8.h"
#include "varlink-util.h"
#define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)

View File

@ -6,13 +6,13 @@
#include "sd-event.h"
#include "sd-netlink.h"
#include "sd-network.h"
#include "sd-varlink.h"
#include "common-signal.h"
#include "hashmap.h"
#include "list.h"
#include "ordered-set.h"
#include "resolve-util.h"
#include "varlink.h"
typedef struct Manager Manager;
@ -153,8 +153,8 @@ struct Manager {
Hashmap *polkit_registry;
VarlinkServer *varlink_server;
VarlinkServer *varlink_monitor_server;
sd_varlink_server *varlink_server;
sd_varlink_server *varlink_monitor_server;
Set *varlink_subscription;

View File

@ -42,25 +42,25 @@ static int reply_query_state(DnsQuery *q) {
switch (q->state) {
case DNS_TRANSACTION_NO_SERVERS:
return varlink_error(q->varlink_request, "io.systemd.Resolve.NoNameServers", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoNameServers", NULL);
case DNS_TRANSACTION_TIMEOUT:
return varlink_error(q->varlink_request, "io.systemd.Resolve.QueryTimedOut", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.QueryTimedOut", NULL);
case DNS_TRANSACTION_ATTEMPTS_MAX_REACHED:
return varlink_error(q->varlink_request, "io.systemd.Resolve.MaxAttemptsReached", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.MaxAttemptsReached", NULL);
case DNS_TRANSACTION_INVALID_REPLY:
return varlink_error(q->varlink_request, "io.systemd.Resolve.InvalidReply", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.InvalidReply", NULL);
case DNS_TRANSACTION_ERRNO:
return varlink_error_errno(q->varlink_request, q->answer_errno);
return sd_varlink_error_errno(q->varlink_request, q->answer_errno);
case DNS_TRANSACTION_ABORTED:
return varlink_error(q->varlink_request, "io.systemd.Resolve.QueryAborted", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.QueryAborted", NULL);
case DNS_TRANSACTION_DNSSEC_FAILED:
return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed",
return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed",
SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))),
SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0,
"extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
@ -68,28 +68,28 @@ static int reply_query_state(DnsQuery *q) {
"extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)));
case DNS_TRANSACTION_NO_TRUST_ANCHOR:
return varlink_error(q->varlink_request, "io.systemd.Resolve.NoTrustAnchor", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoTrustAnchor", NULL);
case DNS_TRANSACTION_RR_TYPE_UNSUPPORTED:
return varlink_error(q->varlink_request, "io.systemd.Resolve.ResourceRecordTypeUnsupported", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.ResourceRecordTypeUnsupported", NULL);
case DNS_TRANSACTION_NETWORK_DOWN:
return varlink_error(q->varlink_request, "io.systemd.Resolve.NetworkDown", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NetworkDown", NULL);
case DNS_TRANSACTION_NO_SOURCE:
return varlink_error(q->varlink_request, "io.systemd.Resolve.NoSource", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSource", NULL);
case DNS_TRANSACTION_STUB_LOOP:
return varlink_error(q->varlink_request, "io.systemd.Resolve.StubLoop", NULL);
return sd_varlink_error(q->varlink_request, "io.systemd.Resolve.StubLoop", NULL);
case DNS_TRANSACTION_NOT_FOUND:
/* We return this as NXDOMAIN. This is only generated when a host doesn't implement LLMNR/TCP, and we
* thus quickly know that we cannot resolve an in-addr.arpa or ip6.arpa address. */
return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError",
return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError",
SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN)));
case DNS_TRANSACTION_RCODE_FAILURE:
return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError",
return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError",
SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)),
SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0,
"extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
@ -105,13 +105,13 @@ static int reply_query_state(DnsQuery *q) {
}
}
static void vl_on_disconnect(VarlinkServer *s, Varlink *link, void *userdata) {
static void vl_on_disconnect(sd_varlink_server *s, sd_varlink *link, void *userdata) {
DnsQuery *q;
assert(s);
assert(link);
q = varlink_get_userdata(link);
q = sd_varlink_get_userdata(link);
if (!q)
return;
@ -122,15 +122,15 @@ static void vl_on_disconnect(VarlinkServer *s, Varlink *link, void *userdata) {
dns_query_complete(q, DNS_TRANSACTION_ABORTED);
}
static void vl_on_notification_disconnect(VarlinkServer *s, Varlink *link, void *userdata) {
static void vl_on_notification_disconnect(sd_varlink_server *s, sd_varlink *link, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(link);
Varlink *removed_link = set_remove(m->varlink_subscription, link);
sd_varlink *removed_link = set_remove(m->varlink_subscription, link);
if (removed_link) {
varlink_unref(removed_link);
sd_varlink_unref(removed_link);
log_debug("%u monitor clients remain active", set_size(m->varlink_subscription));
}
}
@ -247,7 +247,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) {
r = dns_query_process_cname_many(q);
if (r == -ELOOP) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
goto finish;
}
if (r < 0)
@ -265,7 +265,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) {
goto finish;
if (sd_json_variant_is_blank_object(array)) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
goto finish;
}
@ -274,7 +274,7 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) {
if (r < 0)
goto finish;
r = varlink_replybo(
r = sd_varlink_replybo(
q->varlink_request,
SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_VARIANT(array)),
SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)),
@ -282,11 +282,11 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) {
finish:
if (r < 0) {
log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send hostname reply: %m");
r = varlink_error_errno(q->varlink_request, r);
r = sd_varlink_error_errno(q->varlink_request, r);
}
}
static int parse_as_address(Varlink *link, LookupParameters *p) {
static int parse_as_address(sd_varlink *link, LookupParameters *p) {
_cleanup_free_ char *canonical = NULL;
int r, ff, parsed_ifindex, ifindex;
union in_addr_union parsed;
@ -302,7 +302,7 @@ static int parse_as_address(Varlink *link, LookupParameters *p) {
/* Make sure the data we parsed matches what is requested */
if ((p->family != AF_UNSPEC && ff != p->family) ||
(p->ifindex > 0 && parsed_ifindex > 0 && parsed_ifindex != p->ifindex))
return varlink_error(link, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
return sd_varlink_error(link, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
ifindex = parsed_ifindex > 0 ? parsed_ifindex : p->ifindex;
@ -311,7 +311,7 @@ static int parse_as_address(Varlink *link, LookupParameters *p) {
if (r < 0)
return r;
return varlink_replybo(
return sd_varlink_replybo(
link,
SD_JSON_BUILD_PAIR("addresses",
SD_JSON_BUILD_ARRAY(
@ -324,7 +324,7 @@ static int parse_as_address(Varlink *link, LookupParameters *p) {
SD_RESOLVED_SYNTHETIC)));
}
static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_resolve_hostname(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "ifindex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, ifindex), 0 },
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(LookupParameters, name), SD_JSON_MANDATORY },
@ -343,30 +343,30 @@ static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters
assert(link);
m = varlink_server_get_userdata(varlink_get_server(link));
m = sd_varlink_server_get_userdata(sd_varlink_get_server(link));
assert(m);
if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY))
if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY))
return -EINVAL;
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.ifindex < 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
r = dns_name_is_valid(p.name);
if (r < 0)
return r;
if (r == 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name"));
if (!IN_SET(p.family, AF_UNSPEC, AF_INET, AF_INET6))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
if (!validate_and_mangle_flags(p.name, &p.flags, SD_RESOLVED_NO_SEARCH))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
r = parse_as_address(link, &p);
if (r != 0)
@ -384,8 +384,8 @@ static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters
if (r < 0)
return r;
q->varlink_request = varlink_ref(link);
varlink_set_userdata(link, q);
q->varlink_request = sd_varlink_ref(link);
sd_varlink_set_userdata(link, q);
q->request_family = p.family;
q->complete = vl_method_resolve_hostname_complete;
@ -449,7 +449,7 @@ static void vl_method_resolve_address_complete(DnsQuery *query) {
r = dns_query_process_cname_many(q);
if (r == -ELOOP) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
goto finish;
}
if (r < 0)
@ -484,22 +484,22 @@ static void vl_method_resolve_address_complete(DnsQuery *query) {
}
if (sd_json_variant_is_blank_object(array)) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
goto finish;
}
r = varlink_replybo(
r = sd_varlink_replybo(
q->varlink_request,
SD_JSON_BUILD_PAIR("names", SD_JSON_BUILD_VARIANT(array)),
SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))));
finish:
if (r < 0) {
log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send address reply: %m");
r = varlink_error_errno(q->varlink_request, r);
r = sd_varlink_error_errno(q->varlink_request, r);
}
}
static int vl_method_resolve_address(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_resolve_address(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "ifindex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, ifindex), 0 },
{ "family", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, family), SD_JSON_MANDATORY },
@ -518,27 +518,27 @@ static int vl_method_resolve_address(Varlink *link, sd_json_variant *parameters,
assert(link);
m = varlink_server_get_userdata(varlink_get_server(link));
m = sd_varlink_server_get_userdata(sd_varlink_get_server(link));
assert(m);
if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY))
if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY))
return -EINVAL;
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.ifindex < 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
if (!IN_SET(p.family, AF_INET, AF_INET6))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
if (FAMILY_ADDRESS_SIZE(p.family) != p.address_size)
return varlink_error(link, "io.systemd.Resolve.BadAddressSize", NULL);
return sd_varlink_error(link, "io.systemd.Resolve.BadAddressSize", NULL);
if (!validate_and_mangle_flags(NULL, &p.flags, 0))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
r = dns_question_new_reverse(&question, p.family, &p.address);
if (r < 0)
@ -548,8 +548,8 @@ static int vl_method_resolve_address(Varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
q->varlink_request = varlink_ref(link);
varlink_set_userdata(link, q);
q->varlink_request = sd_varlink_ref(link);
sd_varlink_set_userdata(link, q);
q->request_family = p.family;
q->request_address = p.address;
@ -710,7 +710,7 @@ static int append_srv(
return 1; /* added */
}
static Varlink *get_vl_link_aux_query(DnsQuery *aux) {
static sd_varlink *get_vl_link_aux_query(DnsQuery *aux) {
assert(aux);
/* Find the main query */
@ -768,7 +768,7 @@ static void resolve_service_all_complete(DnsQuery *query) {
assert(bad->auxiliary_result != 0);
if (bad->auxiliary_result == -ELOOP) {
r = varlink_error(query->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
r = sd_varlink_error(query->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
goto finish;
}
@ -804,7 +804,7 @@ static void resolve_service_all_complete(DnsQuery *query) {
}
if (sd_json_variant_is_blank_object(srv)) {
r = varlink_error(query->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
r = sd_varlink_error(query->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
goto finish;
}
@ -828,7 +828,7 @@ static void resolve_service_all_complete(DnsQuery *query) {
if (r < 0)
goto finish;
r = varlink_replybo(
r = sd_varlink_replybo(
query->varlink_request,
SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)),
SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_object(txt), "txt", SD_JSON_BUILD_VARIANT(txt)),
@ -841,7 +841,7 @@ static void resolve_service_all_complete(DnsQuery *query) {
finish:
if (r < 0) {
log_error_errno(r, "Failed to resolve service: %m");
r = varlink_error_errno(q->varlink_request, r);
r = sd_varlink_error_errno(q->varlink_request, r);
}
}
@ -926,7 +926,7 @@ static void vl_method_resolve_service_complete(DnsQuery *query) {
r = dns_query_process_cname_many(q);
if (r == -ELOOP) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
goto finish;
}
if (r < 0)
@ -970,12 +970,12 @@ static void vl_method_resolve_service_complete(DnsQuery *query) {
/* If there's exactly one SRV RR and it uses the root domain as hostname, then the service is
* explicitly not offered on the domain. Report this as a recognizable error. See RFC 2782,
* Section "Usage Rules". */
r = varlink_error(q->varlink_request, "io.systemd.Resolve.ServiceNotProvided", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.ServiceNotProvided", NULL);
goto finish;
}
if (found <= 0) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
goto finish;
}
@ -986,11 +986,11 @@ static void vl_method_resolve_service_complete(DnsQuery *query) {
finish:
if (r < 0) {
log_error_errno(r, "Failed to send address reply: %m");
r = varlink_error_errno(q->varlink_request, r);
r = sd_varlink_error_errno(q->varlink_request, r);
}
}
static int vl_method_resolve_service(Varlink* link, sd_json_variant* parameters, VarlinkMethodFlags flags, void* userdata) {
static int vl_method_resolve_service(sd_varlink* link, sd_json_variant* parameters, sd_varlink_method_flags_t flags, void* userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParametersResolveService, name), 0 },
{ "type", SD_JSON_VARIANT_STRING, sd_json_dispatch_const_string, offsetof(LookupParametersResolveService, type), 0 },
@ -1012,43 +1012,43 @@ static int vl_method_resolve_service(Varlink* link, sd_json_variant* parameters,
assert(link);
m = varlink_server_get_userdata(varlink_get_server(link));
m = sd_varlink_server_get_userdata(sd_varlink_get_server(link));
assert(m);
if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY))
if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY))
return -EINVAL;
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.ifindex < 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
if (!IN_SET(p.family, AF_INET, AF_INET6, AF_UNSPEC))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("family"));
if (isempty(p.name))
p.name = NULL;
else if (!dns_service_name_is_valid(p.name))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name"));
if (isempty(p.type))
p.type = NULL;
else if (!dns_srv_type_is_valid(p.type))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type"));
r = dns_name_is_valid(p.domain);
if (r < 0)
return r;
if (r == 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("domain"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("domain"));
if (p.name && !p.type) /* Service name cannot be specified without service type. */
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("type"));
if (!validate_and_mangle_flags(p.name, &p.flags, SD_RESOLVED_NO_TXT|SD_RESOLVED_NO_ADDRESS))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
r = dns_question_new_service(&question_utf8, p.name, p.type, p.domain, !(p.flags & SD_RESOLVED_NO_TXT), false);
if (r < 0)
@ -1062,11 +1062,11 @@ static int vl_method_resolve_service(Varlink* link, sd_json_variant* parameters,
if (r < 0)
return r;
q->varlink_request = varlink_ref(link);
q->varlink_request = sd_varlink_ref(link);
q->request_family = p.family;
q->complete = vl_method_resolve_service_complete;
varlink_set_userdata(link, q);
sd_varlink_set_userdata(link, q);
r = dns_query_go(q);
if (r < 0)
@ -1091,7 +1091,7 @@ static void vl_method_resolve_record_complete(DnsQuery *query) {
r = dns_query_process_cname_many(q);
if (r == -ELOOP) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.CNAMELoop", NULL);
goto finish;
}
if (r < 0)
@ -1136,22 +1136,22 @@ static void vl_method_resolve_record_complete(DnsQuery *query) {
}
if (added <= 0) {
r = varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
r = sd_varlink_error(q->varlink_request, "io.systemd.Resolve.NoSuchResourceRecord", NULL);
goto finish;
}
r = varlink_replybo(
r = sd_varlink_replybo(
q->varlink_request,
SD_JSON_BUILD_PAIR("rrs", SD_JSON_BUILD_VARIANT(array)),
SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))));
finish:
if (r < 0) {
log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send record reply: %m");
varlink_error_errno(q->varlink_request, r);
sd_varlink_error_errno(q->varlink_request, r);
}
}
static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_resolve_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "ifindex", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int, offsetof(LookupParameters, ifindex), 0 },
{ "name", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(LookupParameters, name), SD_JSON_MANDATORY },
@ -1171,33 +1171,33 @@ static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters,
assert(link);
m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link)));
m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link)));
if (FLAGS_SET(flags, VARLINK_METHOD_ONEWAY))
if (FLAGS_SET(flags, SD_VARLINK_METHOD_ONEWAY))
return -EINVAL;
r = varlink_dispatch(link, parameters, dispatch_table, &p);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &p);
if (r != 0)
return r;
if (p.ifindex < 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("ifindex"));
r = dns_name_is_valid(p.name);
if (r < 0)
return r;
if (r == 0)
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("name"));
if (!dns_type_is_valid_query(p.type))
return varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeInvalidForQuery", NULL);
return sd_varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeInvalidForQuery", NULL);
if (dns_type_is_zone_transfer(p.type))
return varlink_error(link, "io.systemd.Resolve.ZoneTransfersNotPermitted", NULL);
return sd_varlink_error(link, "io.systemd.Resolve.ZoneTransfersNotPermitted", NULL);
if (dns_type_is_obsolete(p.type))
return varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeObsolete", NULL);
return sd_varlink_error(link, "io.systemd.Resolve.ResourceRecordTypeObsolete", NULL);
if (!validate_and_mangle_flags(p.name, &p.flags, SD_RESOLVED_NO_SEARCH))
return varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
return sd_varlink_error_invalid_parameter(link, JSON_VARIANT_STRING_CONST("flags"));
_cleanup_(dns_question_unrefp) DnsQuestion *question = dns_question_new(1);
if (!question)
@ -1216,8 +1216,8 @@ static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
q->varlink_request = varlink_ref(link);
varlink_set_userdata(link, q);
q->varlink_request = sd_varlink_ref(link);
sd_varlink_set_userdata(link, q);
q->complete = vl_method_resolve_record_complete;
r = dns_query_go(q);
@ -1228,38 +1228,38 @@ static int vl_method_resolve_record(Varlink *link, sd_json_variant *parameters,
return 1;
}
static int vl_method_subscribe_query_results(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_subscribe_query_results(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Manager *m;
int r;
assert(link);
m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link)));
m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link)));
/* if the client didn't set the more flag, it is using us incorrectly */
if (!FLAGS_SET(flags, VARLINK_METHOD_MORE))
return varlink_error(link, VARLINK_ERROR_EXPECTED_MORE, NULL);
if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE))
return sd_varlink_error(link, SD_VARLINK_ERROR_EXPECTED_MORE, NULL);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
/* Send a ready message to the connecting client, to indicate that we are now listinening, and all
* queries issued after the point the client sees this will also be reported to the client. */
r = varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true)));
r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true)));
if (r < 0)
return log_error_errno(r, "Failed to report monitor to be established: %m");
r = set_ensure_put(&m->varlink_subscription, NULL, link);
if (r < 0)
return log_error_errno(r, "Failed to add subscription to set: %m");
varlink_ref(link);
sd_varlink_ref(link);
log_debug("%u clients now attached for varlink notifications", set_size(m->varlink_subscription));
return 1;
}
static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_dump_cache(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *list = NULL;
Manager *m;
int r;
@ -1267,9 +1267,9 @@ static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, Varl
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link)));
m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link)));
LIST_FOREACH(scopes, s, m->dns_scopes) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *j = NULL;
@ -1289,7 +1289,7 @@ static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, Varl
return r;
}
return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)));
}
static int dns_server_dump_state_to_json_list(DnsServer *server, sd_json_variant **list) {
@ -1306,7 +1306,7 @@ static int dns_server_dump_state_to_json_list(DnsServer *server, sd_json_variant
return sd_json_variant_append_array(list, j);
}
static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_dump_server_state(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *list = NULL;
Manager *m;
int r;
@ -1315,9 +1315,9 @@ static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameter
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link)));
m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link)));
LIST_FOREACH(servers, server, m->dns_servers) {
r = dns_server_dump_state_to_json_list(server, &list);
@ -1344,10 +1344,10 @@ static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameter
return r;
}
return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)));
return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)));
}
static int vl_method_dump_statistics(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_dump_statistics(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *j = NULL;
Manager *m;
int r;
@ -1355,34 +1355,34 @@ static int vl_method_dump_statistics(Varlink *link, sd_json_variant *parameters,
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link)));
m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link)));
r = dns_manager_dump_statistics_json(m, &j);
if (r < 0)
return r;
return varlink_replyb(link, SD_JSON_BUILD_VARIANT(j));
return sd_varlink_replyb(link, SD_JSON_BUILD_VARIANT(j));
}
static int vl_method_reset_statistics(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
static int vl_method_reset_statistics(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Manager *m;
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
m = ASSERT_PTR(varlink_server_get_userdata(varlink_get_server(link)));
m = ASSERT_PTR(sd_varlink_server_get_userdata(sd_varlink_get_server(link)));
dns_manager_reset_statistics(m);
return varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
return sd_varlink_replyb(link, SD_JSON_BUILD_EMPTY_OBJECT);
}
static int varlink_monitor_server_init(Manager *m) {
_cleanup_(varlink_server_unrefp) VarlinkServer *server = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *server = NULL;
int r;
assert(m);
@ -1390,17 +1390,17 @@ static int varlink_monitor_server_init(Manager *m) {
if (m->varlink_monitor_server)
return 0;
r = varlink_server_new(&server, VARLINK_SERVER_ROOT_ONLY);
r = sd_varlink_server_new(&server, SD_VARLINK_SERVER_ROOT_ONLY);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(server, m);
sd_varlink_server_set_userdata(server, m);
r = varlink_server_add_interface(server, &vl_interface_io_systemd_Resolve_Monitor);
r = sd_varlink_server_add_interface(server, &vl_interface_io_systemd_Resolve_Monitor);
if (r < 0)
return log_error_errno(r, "Failed to add Resolve.Monitor interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
server,
"io.systemd.Resolve.Monitor.SubscribeQueryResults", vl_method_subscribe_query_results,
"io.systemd.Resolve.Monitor.DumpCache", vl_method_dump_cache,
@ -1410,15 +1410,15 @@ static int varlink_monitor_server_init(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to register varlink methods: %m");
r = varlink_server_bind_disconnect(server, vl_on_notification_disconnect);
r = sd_varlink_server_bind_disconnect(server, vl_on_notification_disconnect);
if (r < 0)
return log_error_errno(r, "Failed to register varlink disconnect handler: %m");
r = varlink_server_listen_address(server, "/run/systemd/resolve/io.systemd.Resolve.Monitor", 0600);
r = sd_varlink_server_listen_address(server, "/run/systemd/resolve/io.systemd.Resolve.Monitor", 0600);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(server, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(server, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
@ -1428,7 +1428,7 @@ static int varlink_monitor_server_init(Manager *m) {
}
static int varlink_main_server_init(Manager *m) {
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
_cleanup_(sd_varlink_server_unrefp) sd_varlink_server *s = NULL;
int r;
assert(m);
@ -1436,17 +1436,17 @@ static int varlink_main_server_init(Manager *m) {
if (m->varlink_server)
return 0;
r = varlink_server_new(&s, VARLINK_SERVER_ACCOUNT_UID);
r = sd_varlink_server_new(&s, SD_VARLINK_SERVER_ACCOUNT_UID);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
varlink_server_set_userdata(s, m);
sd_varlink_server_set_userdata(s, m);
r = varlink_server_add_interface(s, &vl_interface_io_systemd_Resolve);
r = sd_varlink_server_add_interface(s, &vl_interface_io_systemd_Resolve);
if (r < 0)
return log_error_errno(r, "Failed to add Resolve interface to varlink server: %m");
r = varlink_server_bind_method_many(
r = sd_varlink_server_bind_method_many(
s,
"io.systemd.Resolve.ResolveHostname", vl_method_resolve_hostname,
"io.systemd.Resolve.ResolveAddress", vl_method_resolve_address,
@ -1455,15 +1455,15 @@ static int varlink_main_server_init(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to register varlink methods: %m");
r = varlink_server_bind_disconnect(s, vl_on_disconnect);
r = sd_varlink_server_bind_disconnect(s, vl_on_disconnect);
if (r < 0)
return log_error_errno(r, "Failed to register varlink disconnect handler: %m");
r = varlink_server_listen_address(s, "/run/systemd/resolve/io.systemd.Resolve", 0666);
r = sd_varlink_server_listen_address(s, "/run/systemd/resolve/io.systemd.Resolve", 0666);
if (r < 0)
return log_error_errno(r, "Failed to bind to varlink socket: %m");
r = varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(s, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_error_errno(r, "Failed to attach varlink connection to event loop: %m");
@ -1488,6 +1488,6 @@ int manager_varlink_init(Manager *m) {
void manager_varlink_done(Manager *m) {
assert(m);
m->varlink_server = varlink_server_unref(m->varlink_server);
m->varlink_monitor_server = varlink_server_unref(m->varlink_monitor_server);
m->varlink_server = sd_varlink_server_unref(m->varlink_server);
m->varlink_monitor_server = sd_varlink_server_unref(m->varlink_monitor_server);
}

View File

@ -7,6 +7,7 @@
#include "process-util.h"
#include "strv.h"
#include "user-util.h"
#include "varlink-util.h"
static int bus_message_check_good_user(sd_bus_message *m, uid_t good_user) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
@ -190,7 +191,7 @@ typedef struct AsyncPolkitQuery {
sd_bus *bus;
sd_bus_message *request; /* the original bus method call that triggered the polkit auth, NULL in case of varlink */
sd_bus_slot *slot;
Varlink *link; /* the original varlink method call that triggered the polkit auth, NULL in case of bus */
sd_varlink *link; /* the original varlink method call that triggered the polkit auth, NULL in case of bus */
Hashmap *registry;
sd_event_source *defer_event_source;
@ -218,7 +219,7 @@ static AsyncPolkitQuery *async_polkit_query_free(AsyncPolkitQuery *q) {
sd_bus_message_unref(q->request);
sd_bus_unref(q->bus);
varlink_unref(q->link);
sd_varlink_unref(q->link);
async_polkit_query_action_free(q->action);
@ -374,7 +375,7 @@ static int async_polkit_process_reply(sd_bus_message *reply, AsyncPolkitQuery *q
}
if (q->link) {
r = varlink_dispatch_again(q->link);
r = sd_varlink_dispatch_again(q->link);
if (r < 0)
return r;
}
@ -394,7 +395,7 @@ static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_e
if (q->request)
(void) sd_bus_reply_method_errno(q->request, r, NULL);
if (q->link)
(void) varlink_error_errno(q->link, r);
(void) sd_varlink_error_errno(q->link, r);
async_polkit_query_unref(q);
}
return r;
@ -625,7 +626,7 @@ int bus_verify_polkit_async_full(
#endif
}
static int varlink_check_good_user(Varlink *link, uid_t good_user) {
static int varlink_check_good_user(sd_varlink *link, uid_t good_user) {
int r;
assert(link);
@ -634,20 +635,20 @@ static int varlink_check_good_user(Varlink *link, uid_t good_user) {
return false;
uid_t peer_uid;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
return good_user == peer_uid;
}
static int varlink_check_peer_privilege(Varlink *link) {
static int varlink_check_peer_privilege(sd_varlink *link) {
int r;
assert(link);
uid_t peer_uid;
r = varlink_get_peer_uid(link, &peer_uid);
r = sd_varlink_get_peer_uid(link, &peer_uid);
if (r < 0)
return r;
@ -659,7 +660,7 @@ static int varlink_check_peer_privilege(Varlink *link) {
#if ENABLE_POLKIT
static int bus_message_new_polkit_auth_call_for_varlink(
sd_bus *bus,
Varlink *link,
sd_varlink *link,
const char *action,
const char **details,
bool interactive,
@ -681,7 +682,7 @@ static int bus_message_new_polkit_auth_call_for_varlink(
return log_debug_errno(SYNTHETIC_ERRNO(EPERM), "Failed to get peer pidfd, cannot securely authenticate.");
uid_t uid;
r = varlink_get_peer_uid(link, &uid);
r = sd_varlink_get_peer_uid(link, &uid);
if (r < 0)
return r;
@ -717,7 +718,7 @@ static int bus_message_new_polkit_auth_call_for_varlink(
return 0;
}
static bool varlink_allow_interactive_authentication(Varlink *link) {
static bool varlink_allow_interactive_authentication(sd_varlink *link) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
int r;
@ -726,7 +727,7 @@ static bool varlink_allow_interactive_authentication(Varlink *link) {
/* We look for the allowInteractiveAuthentication field in the message currently being dispatched,
* always under the same name. */
r = varlink_get_current_parameters(link, &v);
r = sd_varlink_get_current_parameters(link, &v);
if (r < 0) {
log_debug_errno(r, "Unable to query current parameters: %m");
return false;
@ -746,7 +747,7 @@ static bool varlink_allow_interactive_authentication(Varlink *link) {
#endif
int varlink_verify_polkit_async_full(
Varlink *link,
sd_varlink *link,
sd_bus *bus,
const char *action,
const char **details,
@ -789,9 +790,9 @@ int varlink_verify_polkit_async_full(
if (!FLAGS_SET(flags, POLKIT_DONT_REPLY)) {
/* Reply with a nice error */
if (sd_bus_error_has_name(&error, SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED))
(void) varlink_error(link, VARLINK_ERROR_INTERACTIVE_AUTHENTICATION_REQUIRED, NULL);
(void) sd_varlink_error(link, SD_VARLINK_ERROR_INTERACTIVE_AUTHENTICATION_REQUIRED, NULL);
else if (ERRNO_IS_NEG_PRIVILEGE(r))
(void) varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, NULL);
(void) sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, NULL);
}
return r;
@ -806,7 +807,7 @@ int varlink_verify_polkit_async_full(
if (r < 0)
return r;
r = sd_bus_attach_event(mybus, varlink_get_event(link), 0);
r = sd_bus_attach_event(mybus, sd_varlink_get_event(link), 0);
if (r < 0)
return r;
@ -829,7 +830,7 @@ int varlink_verify_polkit_async_full(
*q = (AsyncPolkitQuery) {
.n_ref = 1,
.link = varlink_ref(link),
.link = sd_varlink_ref(link),
.bus = sd_bus_ref(bus),
};
}
@ -866,7 +867,7 @@ int varlink_verify_polkit_async_full(
#endif
}
bool varlink_has_polkit_action(Varlink *link, const char *action, const char **details, Hashmap **registry) {
bool varlink_has_polkit_action(sd_varlink *link, const char *action, const char **details, Hashmap **registry) {
assert(link);
assert(action);
assert(registry);

View File

@ -2,10 +2,10 @@
#pragma once
#include "sd-bus.h"
#include "sd-varlink.h"
#include "hashmap.h"
#include "user-util.h"
#include "varlink.h"
typedef enum PolkitFLags {
POLKIT_ALLOW_INTERACTIVE = 1 << 0, /* Allow interactive auth (typically not required, because can be derived from bus message/link automatically) */
@ -21,8 +21,8 @@ static inline int bus_verify_polkit_async(sd_bus_message *call, const char *acti
return bus_verify_polkit_async_full(call, action, details, UID_INVALID, 0, registry, error);
}
int varlink_verify_polkit_async_full(Varlink *link, sd_bus *bus, const char *action, const char **details, uid_t good_user, PolkitFlags flags, Hashmap **registry);
static inline int varlink_verify_polkit_async(Varlink *link, sd_bus *bus, const char *action, const char **details, Hashmap **registry) {
int varlink_verify_polkit_async_full(sd_varlink *link, sd_bus *bus, const char *action, const char **details, uid_t good_user, PolkitFlags flags, Hashmap **registry);
static inline int varlink_verify_polkit_async(sd_varlink *link, sd_bus *bus, const char *action, const char **details, Hashmap **registry) {
return varlink_verify_polkit_async_full(link, bus, action, details, UID_INVALID, 0, registry);
}
@ -34,4 +34,4 @@ static inline int varlink_verify_polkit_async(Varlink *link, sd_bus *bus, const
.type = SD_JSON_VARIANT_BOOLEAN, \
}
bool varlink_has_polkit_action(Varlink *link, const char *action, const char **details, Hashmap **registry);
bool varlink_has_polkit_action(sd_varlink *link, const char *action, const char **details, Hashmap **registry);

View File

@ -8,6 +8,7 @@
#include "sd-id128.h"
#include "sd-json.h"
#include "sd-varlink.h"
#include "blockdev-util.h"
#include "capability-util.h"
@ -36,7 +37,6 @@
#include "tmpfile-util.h"
#include "tpm2-util.h"
#include "user-util.h"
#include "varlink.h"
#define PUBLIC_KEY_MAX (UINT32_C(1024) * UINT32_C(1024))
@ -1526,18 +1526,18 @@ int decrypt_credential_and_warn(const char *validate_name, usec_t validate_times
#endif
int ipc_encrypt_credential(const char *name, usec_t timestamp, usec_t not_after, uid_t uid, const struct iovec *input, CredentialFlags flags, struct iovec *ret) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
assert(input && iovec_is_valid(input));
assert(ret);
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.Credentials");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.Credentials");
if (r < 0)
return log_error_errno(r, "Failed to connect to io.systemd.Credentials: %m");
/* Mark anything we get from the service as sensitive, given that it might use a NULL cypher, at least in theory */
r = varlink_set_input_sensitive(vl);
r = sd_varlink_set_input_sensitive(vl);
if (r < 0)
return log_error_errno(r, "Failed to enable sensitive Varlink input: %m");
@ -1551,7 +1551,7 @@ int ipc_encrypt_credential(const char *name, usec_t timestamp, usec_t not_after,
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL;
const char *error_id = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.Credentials.Encrypt",
&reply,
@ -1568,7 +1568,7 @@ int ipc_encrypt_credential(const char *name, usec_t timestamp, usec_t not_after,
if (streq(error_id, "io.systemd.Credentials.NoSuchUser"))
return log_error_errno(SYNTHETIC_ERRNO(ESRCH), "No such user.");
return log_error_errno(varlink_error_to_errno(error_id, reply), "Failed to encrypt: %s", error_id);
return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to encrypt: %s", error_id);
}
r = sd_json_dispatch(
@ -1586,17 +1586,17 @@ int ipc_encrypt_credential(const char *name, usec_t timestamp, usec_t not_after,
}
int ipc_decrypt_credential(const char *validate_name, usec_t validate_timestamp, uid_t uid, const struct iovec *input, CredentialFlags flags, struct iovec *ret) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
assert(input && iovec_is_valid(input));
assert(ret);
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.Credentials");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.Credentials");
if (r < 0)
return log_error_errno(r, "Failed to connect to io.systemd.Credentials: %m");
r = varlink_set_input_sensitive(vl);
r = sd_varlink_set_input_sensitive(vl);
if (r < 0)
return log_error_errno(r, "Failed to enable sensitive Varlink input: %m");
@ -1611,7 +1611,7 @@ int ipc_decrypt_credential(const char *validate_name, usec_t validate_timestamp,
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL;
const char *error_id = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.Credentials.Decrypt",
&reply,
@ -1635,7 +1635,7 @@ int ipc_decrypt_credential(const char *validate_name, usec_t validate_timestamp,
if (streq(error_id, "io.systemd.Credentials.BadScope"))
return log_error_errno(SYNTHETIC_ERRNO(EMEDIUMTYPE), "Scope mismtach.");
return log_error_errno(varlink_error_to_errno(error_id, reply), "Failed to decrypt: %s", error_id);
return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to decrypt: %s", error_id);
}
r = sd_json_dispatch(

View File

@ -21,6 +21,7 @@
#include "sd-device.h"
#include "sd-id128.h"
#include "sd-json.h"
#include "sd-varlink.h"
#include "architecture.h"
#include "ask-password-api.h"
@ -77,7 +78,6 @@
#include "tmpfile-util.h"
#include "udev-util.h"
#include "user-util.h"
#include "varlink.h"
#include "xattr-util.h"
/* how many times to wait for the device nodes to appear */
@ -4269,7 +4269,7 @@ int mountfsd_mount_image(
_cleanup_(dissected_image_unrefp) DissectedImage *di = NULL;
_cleanup_close_ int image_fd = -EBADF;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
_cleanup_free_ char *ps = NULL;
unsigned max_fd = UINT_MAX;
const char *error_id;
@ -4278,15 +4278,15 @@ int mountfsd_mount_image(
assert(path);
assert(ret);
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.MountFileSystem");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.MountFileSystem");
if (r < 0)
return log_error_errno(r, "Failed to connect to mountfsd: %m");
r = varlink_set_allow_fd_passing_input(vl, true);
r = sd_varlink_set_allow_fd_passing_input(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable varlink fd passing for read: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable varlink fd passing for write: %m");
@ -4294,12 +4294,12 @@ int mountfsd_mount_image(
if (image_fd < 0)
return log_error_errno(errno, "Failed to open '%s': %m", path);
r = varlink_push_dup_fd(vl, image_fd);
r = sd_varlink_push_dup_fd(vl, image_fd);
if (r < 0)
return log_error_errno(r, "Failed to push image fd into varlink connection: %m");
if (userns_fd >= 0) {
r = varlink_push_dup_fd(vl, userns_fd);
r = sd_varlink_push_dup_fd(vl, userns_fd);
if (r < 0)
return log_error_errno(r, "Failed to push image fd into varlink connection: %m");
}
@ -4311,7 +4311,7 @@ int mountfsd_mount_image(
}
sd_json_variant *reply = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.MountFileSystem.MountImage",
&reply,
@ -4325,7 +4325,7 @@ int mountfsd_mount_image(
if (r < 0)
return log_error_errno(r, "Failed to call MountImage() varlink call: %m");
if (!isempty(error_id))
return log_error_errno(varlink_error_to_errno(error_id, reply), "Failed to call MountImage() varlink call: %s", error_id);
return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to call MountImage() varlink call: %s", error_id);
r = sd_json_dispatch(reply, dispatch_table, SD_JSON_ALLOW_EXTENSIONS, &p);
if (r < 0)
@ -4368,7 +4368,7 @@ int mountfsd_mount_image(
if (max_fd == UINT_MAX || pp.fsmount_fd_idx > max_fd)
max_fd = pp.fsmount_fd_idx;
fsmount_fd = varlink_take_fd(vl, pp.fsmount_fd_idx);
fsmount_fd = sd_varlink_take_fd(vl, pp.fsmount_fd_idx);
if (fsmount_fd < 0)
return fsmount_fd;
}

View File

@ -175,9 +175,6 @@ shared_sources = files(
'user-record.c',
'userdb-dropin.c',
'userdb.c',
'varlink.c',
'varlink-idl.c',
'varlink-io.systemd.c',
'varlink-io.systemd.BootControl.c',
'varlink-io.systemd.Credentials.c',
'varlink-io.systemd.Hostname.c',
@ -196,7 +193,7 @@ shared_sources = files(
'varlink-io.systemd.oom.c',
'varlink-io.systemd.service.c',
'varlink-io.systemd.sysext.c',
'varlink-org.varlink.service.c',
'varlink-serialize.c',
'verb-log-control.c',
'verbs.c',
'vlan-util.c',

View File

@ -2,6 +2,8 @@
#include <sys/prctl.h>
#include "sd-varlink.h"
#include "fd-util.h"
#include "format-util.h"
#include "json-util.h"
@ -9,7 +11,6 @@
#include "namespace-util.h"
#include "nsresource.h"
#include "process-util.h"
#include "varlink.h"
static int make_pid_name(char **ret) {
char comm[TASK_COMM_LEN];
@ -40,7 +41,7 @@ static int make_pid_name(char **ret) {
}
int nsresource_allocate_userns(const char *name, uint64_t size) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
_cleanup_close_ int userns_fd = -EBADF;
_cleanup_free_ char *_name = NULL;
const char *error_id;
@ -59,11 +60,11 @@ int nsresource_allocate_userns(const char *name, uint64_t size) {
if (size <= 0 || size > UINT64_C(0x100000000)) /* Note: the server actually only allows allocating 1 or 64K right now */
return -EINVAL;
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
if (r < 0)
return log_debug_errno(r, "Failed to connect to namespace resource manager: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_debug_errno(r, "Failed to enable varlink fd passing for write: %m");
@ -71,12 +72,12 @@ int nsresource_allocate_userns(const char *name, uint64_t size) {
if (userns_fd < 0)
return log_debug_errno(userns_fd, "Failed to acquire empty user namespace: %m");
userns_fd_idx = varlink_push_dup_fd(vl, userns_fd);
userns_fd_idx = sd_varlink_push_dup_fd(vl, userns_fd);
if (userns_fd_idx < 0)
return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
sd_json_variant *reply = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.NamespaceResource.AllocateUserRange",
&reply,
@ -87,13 +88,13 @@ int nsresource_allocate_userns(const char *name, uint64_t size) {
if (r < 0)
return log_debug_errno(r, "Failed to call AllocateUserRange() varlink call: %m");
if (error_id)
return log_debug_errno(varlink_error_to_errno(error_id, reply), "Failed to allocate user namespace with %" PRIu64 " users: %s", size, error_id);
return log_debug_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to allocate user namespace with %" PRIu64 " users: %s", size, error_id);
return TAKE_FD(userns_fd);
}
int nsresource_register_userns(const char *name, int userns_fd) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
_cleanup_close_ int _userns_fd = -EBADF;
_cleanup_free_ char *_name = NULL;
const char *error_id;
@ -117,20 +118,20 @@ int nsresource_register_userns(const char *name, int userns_fd) {
userns_fd = _userns_fd;
}
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
if (r < 0)
return log_debug_errno(r, "Failed to connect to namespace resource manager: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_debug_errno(r, "Failed to enable varlink fd passing for write: %m");
userns_fd_idx = varlink_push_dup_fd(vl, userns_fd);
userns_fd_idx = sd_varlink_push_dup_fd(vl, userns_fd);
if (userns_fd_idx < 0)
return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
sd_json_variant *reply = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.NamespaceResource.RegisterUserNamespace",
&reply,
@ -140,13 +141,13 @@ int nsresource_register_userns(const char *name, int userns_fd) {
if (r < 0)
return log_debug_errno(r, "Failed to call RegisterUserNamespace() varlink call: %m");
if (error_id)
return log_debug_errno(varlink_error_to_errno(error_id, reply), "Failed to register user namespace: %s", error_id);
return log_debug_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to register user namespace: %s", error_id);
return 0;
}
int nsresource_add_mount(int userns_fd, int mount_fd) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
_cleanup_close_ int _userns_fd = -EBADF;
int r, userns_fd_idx, mount_fd_idx;
const char *error_id;
@ -161,24 +162,24 @@ int nsresource_add_mount(int userns_fd, int mount_fd) {
userns_fd = _userns_fd;
}
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
if (r < 0)
return log_error_errno(r, "Failed to connect to namespace resource manager: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_error_errno(r, "Failed to enable varlink fd passing for write: %m");
userns_fd_idx = varlink_push_dup_fd(vl, userns_fd);
userns_fd_idx = sd_varlink_push_dup_fd(vl, userns_fd);
if (userns_fd_idx < 0)
return log_error_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
mount_fd_idx = varlink_push_dup_fd(vl, mount_fd);
mount_fd_idx = sd_varlink_push_dup_fd(vl, mount_fd);
if (mount_fd_idx < 0)
return log_error_errno(mount_fd_idx, "Failed to push mount fd into varlink connection: %m");
sd_json_variant *reply = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.NamespaceResource.AddMountToUserNamespace",
&reply,
@ -192,13 +193,13 @@ int nsresource_add_mount(int userns_fd, int mount_fd) {
return 0;
}
if (error_id)
return log_error_errno(varlink_error_to_errno(error_id, reply), "Failed to mount image: %s", error_id);
return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to mount image: %s", error_id);
return 1;
}
int nsresource_add_cgroup(int userns_fd, int cgroup_fd) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
_cleanup_close_ int _userns_fd = -EBADF;
int r, userns_fd_idx, cgroup_fd_idx;
const char *error_id;
@ -213,24 +214,24 @@ int nsresource_add_cgroup(int userns_fd, int cgroup_fd) {
userns_fd = _userns_fd;
}
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
if (r < 0)
return log_debug_errno(r, "Failed to connect to namespace resource manager: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_debug_errno(r, "Failed to enable varlink fd passing for write: %m");
userns_fd_idx = varlink_push_dup_fd(vl, userns_fd);
userns_fd_idx = sd_varlink_push_dup_fd(vl, userns_fd);
if (userns_fd_idx < 0)
return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
cgroup_fd_idx = varlink_push_dup_fd(vl, cgroup_fd);
cgroup_fd_idx = sd_varlink_push_dup_fd(vl, cgroup_fd);
if (cgroup_fd_idx < 0)
return log_debug_errno(userns_fd_idx, "Failed to push cgroup fd into varlink connection: %m");
sd_json_variant *reply = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.NamespaceResource.AddControlGroupToUserNamespace",
&reply,
@ -244,7 +245,7 @@ int nsresource_add_cgroup(int userns_fd, int cgroup_fd) {
return 0;
}
if (error_id)
return log_debug_errno(varlink_error_to_errno(error_id, reply), "Failed to add cgroup to user namespace: %s", error_id);
return log_debug_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to add cgroup to user namespace: %s", error_id);
return 1;
}
@ -257,7 +258,7 @@ int nsresource_add_netif(
char **ret_namespace_ifname) {
_cleanup_close_ int _userns_fd = -EBADF, _netns_fd = -EBADF;
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r, userns_fd_idx, netns_fd_idx;
const char *error_id;
@ -277,24 +278,24 @@ int nsresource_add_netif(
netns_fd = _netns_fd;
}
r = varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.NamespaceResource");
if (r < 0)
return log_debug_errno(r, "Failed to connect to namespace resource manager: %m");
r = varlink_set_allow_fd_passing_output(vl, true);
r = sd_varlink_set_allow_fd_passing_output(vl, true);
if (r < 0)
return log_debug_errno(r, "Failed to enable varlink fd passing for write: %m");
userns_fd_idx = varlink_push_dup_fd(vl, userns_fd);
userns_fd_idx = sd_varlink_push_dup_fd(vl, userns_fd);
if (userns_fd_idx < 0)
return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
netns_fd_idx = varlink_push_dup_fd(vl, netns_fd);
netns_fd_idx = sd_varlink_push_dup_fd(vl, netns_fd);
if (netns_fd_idx < 0)
return log_debug_errno(netns_fd_idx, "Failed to push netns fd into varlink connection: %m");
sd_json_variant *reply = NULL;
r = varlink_callbo(
r = sd_varlink_callbo(
vl,
"io.systemd.NamespaceResource.AddNetworkToUserNamespace",
&reply,
@ -310,7 +311,7 @@ int nsresource_add_netif(
return 0;
}
if (error_id)
return log_debug_errno(varlink_error_to_errno(error_id, reply), "Failed to add network to user namespace: %s", error_id);
return log_debug_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to add network to user namespace: %s", error_id);
_cleanup_free_ char *host_interface_name = NULL, *namespace_interface_name = NULL;
r = sd_json_dispatch(

View File

@ -2,6 +2,8 @@
#include <sys/auxv.h>
#include "sd-varlink.h"
#include "conf-files.h"
#include "dirent-util.h"
#include "dlfcn-util.h"
@ -18,9 +20,8 @@
#include "user-util.h"
#include "userdb-dropin.h"
#include "userdb.h"
#include "varlink.h"
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(link_hash_ops, void, trivial_hash_func, trivial_compare_func, Varlink, varlink_unref);
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(link_hash_ops, void, trivial_hash_func, trivial_compare_func, sd_varlink, sd_varlink_unref);
typedef enum LookupWhat {
LOOKUP_USER,
@ -158,10 +159,10 @@ static void membership_data_done(struct membership_data *d) {
}
static int userdb_on_query_reply(
Varlink *link,
sd_varlink *link,
sd_json_variant *parameters,
const char *error_id,
VarlinkReplyFlags flags,
sd_varlink_reply_flags_t flags,
void *userdata) {
UserDBIterator *iterator = ASSERT_PTR(userdata);
@ -178,7 +179,7 @@ static int userdb_on_query_reply(
r = -EHOSTDOWN;
else if (streq(error_id, "io.systemd.UserDatabase.EnumerationNotSupported"))
r = -EOPNOTSUPP;
else if (streq(error_id, VARLINK_ERROR_TIMEOUT))
else if (streq(error_id, SD_VARLINK_ERROR_TIMEOUT))
r = -ETIMEDOUT;
else
r = -EIO;
@ -237,7 +238,7 @@ static int userdb_on_query_reply(
iterator->n_found++;
/* More stuff coming? then let's just exit cleanly here */
if (FLAGS_SET(flags, VARLINK_REPLY_CONTINUES))
if (FLAGS_SET(flags, SD_VARLINK_REPLY_CONTINUES))
return 0;
/* Otherwise, let's remove this link and exit cleanly then */
@ -291,7 +292,7 @@ static int userdb_on_query_reply(
iterator->found_group = TAKE_PTR(g);
iterator->n_found++;
if (FLAGS_SET(flags, VARLINK_REPLY_CONTINUES))
if (FLAGS_SET(flags, SD_VARLINK_REPLY_CONTINUES))
return 0;
r = 0;
@ -318,7 +319,7 @@ static int userdb_on_query_reply(
iterator->found_group_name = TAKE_PTR(membership_data.group_name);
iterator->n_found++;
if (FLAGS_SET(flags, VARLINK_REPLY_CONTINUES))
if (FLAGS_SET(flags, SD_VARLINK_REPLY_CONTINUES))
return 0;
r = 0;
@ -336,7 +337,7 @@ finish:
iterator->error = -r;
assert_se(set_remove(iterator->links, link) == link);
link = varlink_unref(link);
link = sd_varlink_unref(link);
return 0;
}
@ -347,18 +348,18 @@ static int userdb_connect(
bool more,
sd_json_variant *query) {
_cleanup_(varlink_unrefp) Varlink *vl = NULL;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL;
int r;
assert(iterator);
assert(path);
assert(method);
r = varlink_connect_address(&vl, path);
r = sd_varlink_connect_address(&vl, path);
if (r < 0)
return log_debug_errno(r, "Unable to connect to %s: %m", path);
varlink_set_userdata(vl, iterator);
sd_varlink_set_userdata(vl, iterator);
if (!iterator->event) {
r = sd_event_new(&iterator->event);
@ -366,20 +367,20 @@ static int userdb_connect(
return log_debug_errno(r, "Unable to allocate event loop: %m");
}
r = varlink_attach_event(vl, iterator->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_attach_event(vl, iterator->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return log_debug_errno(r, "Failed to attach varlink connection to event loop: %m");
(void) varlink_set_description(vl, path);
(void) sd_varlink_set_description(vl, path);
r = varlink_bind_reply(vl, userdb_on_query_reply);
r = sd_varlink_bind_reply(vl, userdb_on_query_reply);
if (r < 0)
return log_debug_errno(r, "Failed to bind reply callback: %m");
if (more)
r = varlink_observe(vl, method, query);
r = sd_varlink_observe(vl, method, query);
else
r = varlink_invoke(vl, method, query);
r = sd_varlink_invoke(vl, method, query);
if (r < 0)
return log_debug_errno(r, "Failed to invoke varlink method: %m");

View File

@ -1,182 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include "sd-json.h"
#include "macro.h"
/* This implements the Varlink Interface Definition Language ("Varlink IDL"),
* i.e. https://varlink.org/Interface-Definition
*
* Primarily allows encoding static interface definitions in C code, that can be converted to the textual IDL
* format on-the-fly. Can also parse the textual format back to C structures. Validates the interface
* definitions for internal consistency and validates JSON objects against the interface definitions. */
typedef enum VarlinkSymbolType {
VARLINK_ENUM_TYPE,
VARLINK_STRUCT_TYPE,
VARLINK_METHOD,
VARLINK_ERROR,
_VARLINK_INTERFACE_COMMENT, /* Not really a symbol, just a comment about the interface */
_VARLINK_SYMBOL_COMMENT, /* Not really a symbol, just a comment about a symbol */
_VARLINK_SYMBOL_TYPE_MAX,
_VARLINK_SYMBOL_TYPE_INVALID = -EINVAL,
} VarlinkSymbolType;
typedef enum VarlinkFieldType {
_VARLINK_FIELD_TYPE_END_MARKER = 0, /* zero type means: this is the last entry in the fields[] array of VarlinkSymbol */
VARLINK_STRUCT,
VARLINK_ENUM,
VARLINK_NAMED_TYPE,
VARLINK_BOOL,
VARLINK_INT,
VARLINK_FLOAT,
VARLINK_STRING,
VARLINK_OBJECT,
VARLINK_ENUM_VALUE,
_VARLINK_FIELD_COMMENT, /* Not really a field, just a comment about a field*/
_VARLINK_FIELD_TYPE_MAX,
_VARLINK_FIELD_TYPE_INVALID = -EINVAL,
} VarlinkFieldType;
typedef enum VarlinkFieldDirection {
VARLINK_REGULAR,
VARLINK_INPUT,
VARLINK_OUTPUT,
_VARLINK_FIELD_DIRECTION_MAX,
_VARLINK_FIELD_DIRECTION_INVALID = -EINVAL,
} VarlinkFieldDirection;
typedef enum VarlinkFieldFlags {
VARLINK_ARRAY = 1 << 0,
VARLINK_MAP = 1 << 1,
VARLINK_NULLABLE = 1 << 2,
_VARLINK_FIELD_FLAGS_MAX = (1 << 3) - 1,
_VARLINK_FIELD_FLAGS_INVALID = -EINVAL,
} VarlinkFieldFlags;
typedef struct VarlinkField VarlinkField;
typedef struct VarlinkSymbol VarlinkSymbol;
typedef struct VarlinkInterface VarlinkInterface;
/* Fields are the components making up symbols */
struct VarlinkField {
const char *name;
VarlinkFieldType field_type;
VarlinkFieldFlags field_flags;
VarlinkFieldDirection field_direction; /* in case of method call fields: whether input or output argument */
const VarlinkSymbol *symbol; /* VARLINK_STRUCT, VARLINK_ENUM: anonymous symbol that carries the definitions, VARLINK_NAMED_TYPE: resolved symbol */
const char *named_type; /* VARLINK_NAMED_TYPE */
};
/* Symbols are primary named concepts in an interface, and are methods, errors or named types (either enum or struct). */
struct VarlinkSymbol {
const char *name; /* most symbols have a name, but sometimes they are created on-the-fly for fields, in which case they are anonymous */
VarlinkSymbolType symbol_type;
VarlinkField fields[];
};
/* An interface definition has a name and consist of symbols */
struct VarlinkInterface {
const char *name;
const VarlinkSymbol *symbols[];
};
#define VARLINK_DEFINE_FIELD(_name, _field_type, _field_flags) \
{ .name = #_name, .field_type = (_field_type), .field_flags = (_field_flags) }
#define VARLINK_DEFINE_FIELD_BY_TYPE(_name, _named_type, _field_flags) \
{ .name = #_name, .field_type = VARLINK_NAMED_TYPE, .named_type = #_named_type, .symbol = &vl_type_ ## _named_type, .field_flags = (_field_flags) }
#define VARLINK_DEFINE_INPUT(_name, _field_type, _field_flags) \
{ .name = #_name, .field_type = (_field_type), .field_flags = (_field_flags), .field_direction = VARLINK_INPUT }
#define VARLINK_DEFINE_INPUT_BY_TYPE(_name, _named_type, _field_flags) \
{ .name = #_name, .field_type = VARLINK_NAMED_TYPE, .named_type = #_named_type, .symbol = &vl_type_ ## _named_type, .field_flags = (_field_flags), .field_direction = VARLINK_INPUT }
#define VARLINK_DEFINE_OUTPUT(_name, _field_type, _field_flags) \
{ .name = #_name, .field_type = (_field_type), .field_flags = (_field_flags), .field_direction = VARLINK_OUTPUT }
#define VARLINK_DEFINE_OUTPUT_BY_TYPE(_name, _named_type, _field_flags) \
{ .name = #_name, .field_type = VARLINK_NAMED_TYPE, .named_type = #_named_type, .symbol = &vl_type_ ## _named_type, .field_flags = (_field_flags), .field_direction = VARLINK_OUTPUT }
#define VARLINK_DEFINE_ENUM_VALUE(_name) \
{ .name = #_name, .field_type = VARLINK_ENUM_VALUE }
#define VARLINK_FIELD_COMMENT(text) \
{ .name = "" text, .field_type = _VARLINK_FIELD_COMMENT }
#define VARLINK_DEFINE_METHOD(_name, ...) \
const VarlinkSymbol vl_method_ ## _name = { \
.name = #_name, \
.symbol_type = VARLINK_METHOD, \
.fields = { __VA_ARGS__ __VA_OPT__(,) {}}, \
}
#define VARLINK_DEFINE_ERROR(_name, ...) \
const VarlinkSymbol vl_error_ ## _name = { \
.name = #_name, \
.symbol_type = VARLINK_ERROR, \
.fields = { __VA_ARGS__ __VA_OPT__(,) {}}, \
}
#define VARLINK_DEFINE_STRUCT_TYPE(_name, ...) \
const VarlinkSymbol vl_type_ ## _name = { \
.name = #_name, \
.symbol_type = VARLINK_STRUCT_TYPE, \
.fields = { __VA_ARGS__ __VA_OPT__(,) {}}, \
}
#define VARLINK_DEFINE_ENUM_TYPE(_name, ...) \
const VarlinkSymbol vl_type_ ## _name = { \
.name = #_name, \
.symbol_type = VARLINK_ENUM_TYPE, \
.fields = { __VA_ARGS__ __VA_OPT__(,) {}}, \
}
#define VARLINK_DEFINE_INTERFACE(_name, _full_name, ...) \
const VarlinkInterface vl_interface_ ## _name = { \
.name = (_full_name), \
.symbols = { __VA_ARGS__ __VA_OPT__(,) NULL}, \
}
#define VARLINK_SYMBOL_COMMENT(text) \
&(const VarlinkSymbol) { \
.name = "" text, \
.symbol_type = _VARLINK_SYMBOL_COMMENT, \
}
#define VARLINK_INTERFACE_COMMENT(text) \
&(const VarlinkSymbol) { \
.name = "" text, \
.symbol_type = _VARLINK_INTERFACE_COMMENT, \
}
int varlink_idl_dump(FILE *f, int use_colors, size_t cols, const VarlinkInterface *interface);
int varlink_idl_format_full(const VarlinkInterface *interface, size_t cols, char **ret);
static inline int varlink_idl_format(const VarlinkInterface *interface, char **ret) {
return varlink_idl_format_full(interface, SIZE_MAX, ret);
}
int varlink_idl_parse(const char *text, unsigned *ret_line, unsigned *ret_column, VarlinkInterface **ret);
VarlinkInterface* varlink_interface_free(VarlinkInterface *interface);
DEFINE_TRIVIAL_CLEANUP_FUNC(VarlinkInterface*, varlink_interface_free);
bool varlink_idl_field_name_is_valid(const char *name);
bool varlink_idl_symbol_name_is_valid(const char *name);
bool varlink_idl_interface_name_is_valid(const char *name);
int varlink_idl_qualified_symbol_name_is_valid(const char *name);
int varlink_idl_consistent(const VarlinkInterface *interface, int level);
const VarlinkSymbol* varlink_idl_find_symbol(const VarlinkInterface *interface, VarlinkSymbolType type, const char *name);
const VarlinkField* varlink_idl_find_field(const VarlinkSymbol *symbol, const char *name);
int varlink_idl_validate_method_call(const VarlinkSymbol *method, sd_json_variant *v, const char **bad_field);
int varlink_idl_validate_method_reply(const VarlinkSymbol *method, sd_json_variant *v, const char **bad_field);
int varlink_idl_validate_error(const VarlinkSymbol *error, sd_json_variant *v, const char **bad_field);

View File

@ -1,10 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdio.h>
#include "fdset.h"
#include "varlink.h"
int varlink_server_serialize(VarlinkServer *s, FILE *f, FDSet *fds);
int varlink_server_deserialize_one(VarlinkServer *s, const char *value, FDSet *fds);

View File

@ -2,83 +2,83 @@
#include "varlink-io.systemd.BootControl.h"
static VARLINK_DEFINE_ENUM_TYPE(
static SD_VARLINK_DEFINE_ENUM_TYPE(
BootEntryType,
VARLINK_FIELD_COMMENT("Boot Loader Specification Type #1 entries (.conf files)"),
VARLINK_DEFINE_ENUM_VALUE(type1),
VARLINK_FIELD_COMMENT("Boot Loader Specification Type #2 entries (UKIs)"),
VARLINK_DEFINE_ENUM_VALUE(type2),
VARLINK_FIELD_COMMENT("Additional entries reported by boot loader"),
VARLINK_DEFINE_ENUM_VALUE(loader),
VARLINK_FIELD_COMMENT("Automatically generated entries"),
VARLINK_DEFINE_ENUM_VALUE(auto));
SD_VARLINK_FIELD_COMMENT("Boot Loader Specification Type #1 entries (.conf files)"),
SD_VARLINK_DEFINE_ENUM_VALUE(type1),
SD_VARLINK_FIELD_COMMENT("Boot Loader Specification Type #2 entries (UKIs)"),
SD_VARLINK_DEFINE_ENUM_VALUE(type2),
SD_VARLINK_FIELD_COMMENT("Additional entries reported by boot loader"),
SD_VARLINK_DEFINE_ENUM_VALUE(loader),
SD_VARLINK_FIELD_COMMENT("Automatically generated entries"),
SD_VARLINK_DEFINE_ENUM_VALUE(auto));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
BootEntry,
VARLINK_DEFINE_FIELD_BY_TYPE(type, BootEntryType, 0),
VARLINK_FIELD_COMMENT("The string identifier of the entry"),
VARLINK_DEFINE_FIELD(id, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(path, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(root, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(title, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(showTitle, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(sortKey, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(version, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(machineId, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(architecture, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(options, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(linux, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(efi, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(initrd, VARLINK_STRING, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(devicetree, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(devicetreeOverlay, VARLINK_STRING, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_FIELD_COMMENT("Indicates whether the boot loader reported this entry on the current boot"),
VARLINK_DEFINE_FIELD(isReported, VARLINK_BOOL, 0),
VARLINK_FIELD_COMMENT("Indicates the number of tries left for this boot entry before it is assumed to be not working."),
VARLINK_DEFINE_FIELD(triesLeft, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Indicates the number of unsuccessful tries already made for this boot entry."),
VARLINK_DEFINE_FIELD(triesDone, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Indicates whether this entry is the default entry."),
VARLINK_DEFINE_FIELD(isDefault, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Indicates whether this entry has been booted."),
VARLINK_DEFINE_FIELD(isSelected, VARLINK_BOOL, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_FIELD_BY_TYPE(type, BootEntryType, 0),
SD_VARLINK_FIELD_COMMENT("The string identifier of the entry"),
SD_VARLINK_DEFINE_FIELD(id, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(path, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(root, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(title, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(showTitle, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(sortKey, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(version, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(machineId, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(architecture, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(options, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(linux, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(efi, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(initrd, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(devicetree, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(devicetreeOverlay, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_FIELD_COMMENT("Indicates whether the boot loader reported this entry on the current boot"),
SD_VARLINK_DEFINE_FIELD(isReported, SD_VARLINK_BOOL, 0),
SD_VARLINK_FIELD_COMMENT("Indicates the number of tries left for this boot entry before it is assumed to be not working."),
SD_VARLINK_DEFINE_FIELD(triesLeft, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Indicates the number of unsuccessful tries already made for this boot entry."),
SD_VARLINK_DEFINE_FIELD(triesDone, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Indicates whether this entry is the default entry."),
SD_VARLINK_DEFINE_FIELD(isDefault, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Indicates whether this entry has been booted."),
SD_VARLINK_DEFINE_FIELD(isSelected, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ListBootEntries,
VARLINK_FIELD_COMMENT("A boot menu entry structure"),
VARLINK_DEFINE_OUTPUT_BY_TYPE(entry, BootEntry, VARLINK_NULLABLE));
SD_VARLINK_FIELD_COMMENT("A boot menu entry structure"),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(entry, BootEntry, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
SetRebootToFirmware,
VARLINK_FIELD_COMMENT("The new value of the reboot-to-firmware-UI flag"),
VARLINK_DEFINE_INPUT(state, VARLINK_BOOL, 0));
SD_VARLINK_FIELD_COMMENT("The new value of the reboot-to-firmware-UI flag"),
SD_VARLINK_DEFINE_INPUT(state, SD_VARLINK_BOOL, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetRebootToFirmware,
VARLINK_FIELD_COMMENT("The current state of the reboot-to-firmware-UI flag"),
VARLINK_DEFINE_OUTPUT(state, VARLINK_BOOL, 0));
SD_VARLINK_FIELD_COMMENT("The current state of the reboot-to-firmware-UI flag"),
SD_VARLINK_DEFINE_OUTPUT(state, SD_VARLINK_BOOL, 0));
static VARLINK_DEFINE_ERROR(
static SD_VARLINK_DEFINE_ERROR(
RebootToFirmwareNotSupported);
static VARLINK_DEFINE_ERROR(
static SD_VARLINK_DEFINE_ERROR(
NoSuchBootEntry);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_BootControl,
"io.systemd.BootControl",
VARLINK_INTERFACE_COMMENT("Boot Loader control APIs"),
VARLINK_SYMBOL_COMMENT("The type of a boot entry"),
SD_VARLINK_INTERFACE_COMMENT("Boot Loader control APIs"),
SD_VARLINK_SYMBOL_COMMENT("The type of a boot entry"),
&vl_type_BootEntryType,
VARLINK_SYMBOL_COMMENT("A structure encapsulating a boot entry"),
SD_VARLINK_SYMBOL_COMMENT("A structure encapsulating a boot entry"),
&vl_type_BootEntry,
VARLINK_SYMBOL_COMMENT("Enumerates boot entries. Method call must be called with 'more' flag set. Each response returns one entry. If no entries are defined returns the NoSuchBootEntry error."),
SD_VARLINK_SYMBOL_COMMENT("Enumerates boot entries. Method call must be called with 'more' flag set. Each response returns one entry. If no entries are defined returns the NoSuchBootEntry error."),
&vl_method_ListBootEntries,
VARLINK_SYMBOL_COMMENT("Sets the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not."),
SD_VARLINK_SYMBOL_COMMENT("Sets the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not."),
&vl_method_SetRebootToFirmware,
VARLINK_SYMBOL_COMMENT("Gets the current state of the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not."),
SD_VARLINK_SYMBOL_COMMENT("Gets the current state of the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not."),
&vl_method_GetRebootToFirmware,
VARLINK_SYMBOL_COMMENT("SetRebootToFirmware() and GetRebootToFirmware() return this if the firmware does not actually support the reboot-to-firmware-UI concept."),
SD_VARLINK_SYMBOL_COMMENT("SetRebootToFirmware() and GetRebootToFirmware() return this if the firmware does not actually support the reboot-to-firmware-UI concept."),
&vl_error_RebootToFirmwareNotSupported,
VARLINK_SYMBOL_COMMENT("No boot entry defined."),
SD_VARLINK_SYMBOL_COMMENT("No boot entry defined."),
&vl_error_NoSuchBootEntry);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_BootControl;
extern const sd_varlink_interface vl_interface_io_systemd_BootControl;

View File

@ -2,65 +2,65 @@
#include "varlink-io.systemd.Credentials.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
Encrypt,
VARLINK_FIELD_COMMENT("The name for the encrypted credential, a string suitable for inclusion in a file name. If not specified no name is encoded in the credential. Typically, if this credential is stored on disk, this is how the file should be called, and permits authentication of the filename."),
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Plaintext to encrypt. Suitable only for textual data. Either this field or 'data' (below) must be provided."),
VARLINK_DEFINE_INPUT(text, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Plaintext to encrypt, encoded in Base64. Suitable for binary data. Either this field or 'text' (above) must be provided."),
VARLINK_DEFINE_INPUT(data, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Timestamp to store in the credential. In µs since the UNIX epoch, i.e. Jan 1st 1970. If not specified the current time is used."),
VARLINK_DEFINE_INPUT(timestamp, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Timestamp when to the credential should be considered invalid. In µs since the UNIX epoch. If not specified, the credential remains valid forever."),
VARLINK_DEFINE_INPUT(notAfter, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The intended scope for the credential. One of 'system' or 'user'. If not specified defaults to 'system', unless an uid is specified (see below), in which case it default to 'user'."),
VARLINK_DEFINE_INPUT(scope, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The numeric UNIX UID of the user the credential shall be scoped to. Only relevant if 'user' scope is selected (see above). If not specified and 'user' scope is selected defaults to the UID of the calling user, if that can be determined."),
VARLINK_DEFINE_INPUT(uid, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false."),
VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Encrypted credential in Base64 encoding. This can be stored in a credential file, for consumption in LoadEncryptedCredential= and similar calls. Note that the Base64 encoding should be retained when copied into a file."),
VARLINK_DEFINE_OUTPUT(blob, VARLINK_STRING, 0));
SD_VARLINK_FIELD_COMMENT("The name for the encrypted credential, a string suitable for inclusion in a file name. If not specified no name is encoded in the credential. Typically, if this credential is stored on disk, this is how the file should be called, and permits authentication of the filename."),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Plaintext to encrypt. Suitable only for textual data. Either this field or 'data' (below) must be provided."),
SD_VARLINK_DEFINE_INPUT(text, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Plaintext to encrypt, encoded in Base64. Suitable for binary data. Either this field or 'text' (above) must be provided."),
SD_VARLINK_DEFINE_INPUT(data, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Timestamp to store in the credential. In µs since the UNIX epoch, i.e. Jan 1st 1970. If not specified the current time is used."),
SD_VARLINK_DEFINE_INPUT(timestamp, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Timestamp when to the credential should be considered invalid. In µs since the UNIX epoch. If not specified, the credential remains valid forever."),
SD_VARLINK_DEFINE_INPUT(notAfter, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The intended scope for the credential. One of 'system' or 'user'. If not specified defaults to 'system', unless an uid is specified (see below), in which case it default to 'user'."),
SD_VARLINK_DEFINE_INPUT(scope, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The numeric UNIX UID of the user the credential shall be scoped to. Only relevant if 'user' scope is selected (see above). If not specified and 'user' scope is selected defaults to the UID of the calling user, if that can be determined."),
SD_VARLINK_DEFINE_INPUT(uid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false."),
SD_VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Encrypted credential in Base64 encoding. This can be stored in a credential file, for consumption in LoadEncryptedCredential= and similar calls. Note that the Base64 encoding should be retained when copied into a file."),
SD_VARLINK_DEFINE_OUTPUT(blob, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
Decrypt,
VARLINK_FIELD_COMMENT("The name of the encrypted credential. Must the same string specified when the credential was encrypted, in order to authenticate this. If not specified authentication of the credential name is not done."),
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The encrypted credential in Base64 encoding. This corresponds of the 'blob' field returned by the 'Encrypt' method."),
VARLINK_DEFINE_INPUT(blob, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("The timestamp to use when validating the credential's time validity range. If not specified the current time is used."),
VARLINK_DEFINE_INPUT(timestamp, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The scope for this credential. If not specified no restrictions on the credential scope are made."),
VARLINK_DEFINE_INPUT(scope, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("If the 'user' scope is selected, specifies the numeric UNIX UID of the user the credential is associated with. If not specified this is automatically derived from the UID of the calling user, if that can be determined."),
VARLINK_DEFINE_INPUT(uid, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false."),
VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The decrypted plaintext data in Base64 encoding."),
VARLINK_DEFINE_OUTPUT(data, VARLINK_STRING, 0));
SD_VARLINK_FIELD_COMMENT("The name of the encrypted credential. Must the same string specified when the credential was encrypted, in order to authenticate this. If not specified authentication of the credential name is not done."),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The encrypted credential in Base64 encoding. This corresponds of the 'blob' field returned by the 'Encrypt' method."),
SD_VARLINK_DEFINE_INPUT(blob, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("The timestamp to use when validating the credential's time validity range. If not specified the current time is used."),
SD_VARLINK_DEFINE_INPUT(timestamp, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The scope for this credential. If not specified no restrictions on the credential scope are made."),
SD_VARLINK_DEFINE_INPUT(scope, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("If the 'user' scope is selected, specifies the numeric UNIX UID of the user the credential is associated with. If not specified this is automatically derived from the UID of the calling user, if that can be determined."),
SD_VARLINK_DEFINE_INPUT(uid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false."),
SD_VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The decrypted plaintext data in Base64 encoding."),
SD_VARLINK_DEFINE_OUTPUT(data, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_ERROR(BadFormat);
static VARLINK_DEFINE_ERROR(NameMismatch);
static VARLINK_DEFINE_ERROR(TimeMismatch);
static VARLINK_DEFINE_ERROR(NoSuchUser);
static VARLINK_DEFINE_ERROR(BadScope);
static SD_VARLINK_DEFINE_ERROR(BadFormat);
static SD_VARLINK_DEFINE_ERROR(NameMismatch);
static SD_VARLINK_DEFINE_ERROR(TimeMismatch);
static SD_VARLINK_DEFINE_ERROR(NoSuchUser);
static SD_VARLINK_DEFINE_ERROR(BadScope);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Credentials,
"io.systemd.Credentials",
VARLINK_INTERFACE_COMMENT("APIs for encrypting and decrypting service credentials."),
VARLINK_SYMBOL_COMMENT("Encrypts some plaintext data, returns an encrypted credential."),
SD_VARLINK_INTERFACE_COMMENT("APIs for encrypting and decrypting service credentials."),
SD_VARLINK_SYMBOL_COMMENT("Encrypts some plaintext data, returns an encrypted credential."),
&vl_method_Encrypt,
VARLINK_SYMBOL_COMMENT("Decrypts an encrypted credential, returns plaintext data."),
SD_VARLINK_SYMBOL_COMMENT("Decrypts an encrypted credential, returns plaintext data."),
&vl_method_Decrypt,
VARLINK_SYMBOL_COMMENT("Indicates that a corrupt and unsupported encrypted credential was provided."),
SD_VARLINK_SYMBOL_COMMENT("Indicates that a corrupt and unsupported encrypted credential was provided."),
&vl_error_BadFormat,
VARLINK_SYMBOL_COMMENT("The specified name does not match the name stored in the credential."),
SD_VARLINK_SYMBOL_COMMENT("The specified name does not match the name stored in the credential."),
&vl_error_NameMismatch,
VARLINK_SYMBOL_COMMENT("The credential's is no longer or not yet valid."),
SD_VARLINK_SYMBOL_COMMENT("The credential's is no longer or not yet valid."),
&vl_error_TimeMismatch,
VARLINK_SYMBOL_COMMENT("The specified user does not exist."),
SD_VARLINK_SYMBOL_COMMENT("The specified user does not exist."),
&vl_error_NoSuchUser,
VARLINK_SYMBOL_COMMENT("The credential does not match the selected scope."),
SD_VARLINK_SYMBOL_COMMENT("The credential does not match the selected scope."),
&vl_error_BadScope);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Credentials;
extern const sd_varlink_interface vl_interface_io_systemd_Credentials;

View File

@ -2,39 +2,39 @@
#include "varlink-io.systemd.Credentials.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
Describe,
VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(Hostname, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(StaticHostname, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(PrettyHostname, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(DefaultHostname, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(HostnameSource, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(IconName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(Chassis, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(Deployment, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(Location, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(KernelName, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(KernelRelease, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(KernelVersion, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(OperatingSystemPrettyName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(OperatingSystemCPEName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(OperatingSystemHomeURL, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(OperatingSystemSupportEnd, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(OperatingSystemReleaseData, VARLINK_STRING, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(MachineInformationData, VARLINK_STRING, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(HardwareVendor, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(HardwareModel, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(HardwareSerial, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(FirmwareVersion, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(FirmwareVendor, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(FirmwareDate, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(MachineID, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(BootID, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(ProductUUID, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(VSockCID, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(Hostname, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(StaticHostname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(PrettyHostname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(DefaultHostname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(HostnameSource, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(IconName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(Chassis, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(Deployment, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(Location, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(KernelName, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(KernelRelease, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(KernelVersion, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(OperatingSystemPrettyName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(OperatingSystemCPEName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(OperatingSystemHomeURL, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(OperatingSystemSupportEnd, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(OperatingSystemReleaseData, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(MachineInformationData, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(HardwareVendor, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(HardwareModel, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(HardwareSerial, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(FirmwareVersion, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(FirmwareVendor, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(FirmwareDate, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(MachineID, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(BootID, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(ProductUUID, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(VSockCID, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Hostname,
"io.systemd.Hostname",
&vl_method_Describe);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Hostname;
extern const sd_varlink_interface vl_interface_io_systemd_Hostname;

View File

@ -2,128 +2,128 @@
#include "varlink-io.systemd.Import.h"
static VARLINK_DEFINE_ENUM_TYPE(
static SD_VARLINK_DEFINE_ENUM_TYPE(
ImageClass,
VARLINK_FIELD_COMMENT("An image to boot as a system on baremetal, in a VM or as a container"),
VARLINK_DEFINE_ENUM_VALUE(machine),
VARLINK_FIELD_COMMENT("An portable service image"),
VARLINK_DEFINE_ENUM_VALUE(portable),
VARLINK_FIELD_COMMENT("A system extension image"),
VARLINK_DEFINE_ENUM_VALUE(sysext),
VARLINK_FIELD_COMMENT("A configuration extension image"),
VARLINK_DEFINE_ENUM_VALUE(confext));
SD_VARLINK_FIELD_COMMENT("An image to boot as a system on baremetal, in a VM or as a container"),
SD_VARLINK_DEFINE_ENUM_VALUE(machine),
SD_VARLINK_FIELD_COMMENT("An portable service image"),
SD_VARLINK_DEFINE_ENUM_VALUE(portable),
SD_VARLINK_FIELD_COMMENT("A system extension image"),
SD_VARLINK_DEFINE_ENUM_VALUE(sysext),
SD_VARLINK_FIELD_COMMENT("A configuration extension image"),
SD_VARLINK_DEFINE_ENUM_VALUE(confext));
static VARLINK_DEFINE_ENUM_TYPE(
static SD_VARLINK_DEFINE_ENUM_TYPE(
RemoteType,
VARLINK_FIELD_COMMENT("Raw binary disk images, typically in a GPT envelope"),
VARLINK_DEFINE_ENUM_VALUE(raw),
VARLINK_FIELD_COMMENT("A tarball, optionally compressed"),
VARLINK_DEFINE_ENUM_VALUE(tar));
SD_VARLINK_FIELD_COMMENT("Raw binary disk images, typically in a GPT envelope"),
SD_VARLINK_DEFINE_ENUM_VALUE(raw),
SD_VARLINK_FIELD_COMMENT("A tarball, optionally compressed"),
SD_VARLINK_DEFINE_ENUM_VALUE(tar));
static VARLINK_DEFINE_ENUM_TYPE(
static SD_VARLINK_DEFINE_ENUM_TYPE(
TransferType,
VARLINK_FIELD_COMMENT("A local import of a tarball"),
VARLINK_DEFINE_ENUM_VALUE(import_tar),
VARLINK_FIELD_COMMENT("A local import of a raw disk image"),
VARLINK_DEFINE_ENUM_VALUE(import_raw),
VARLINK_FIELD_COMMENT("A local import of a file system tree"),
VARLINK_DEFINE_ENUM_VALUE(import_fs),
VARLINK_FIELD_COMMENT("A local export of a tarball"),
VARLINK_DEFINE_ENUM_VALUE(export_tar),
VARLINK_FIELD_COMMENT("A local export of a raw disk image"),
VARLINK_DEFINE_ENUM_VALUE(export_raw),
VARLINK_FIELD_COMMENT("A download of a tarball"),
VARLINK_DEFINE_ENUM_VALUE(pull_tar),
VARLINK_FIELD_COMMENT("A download of a raw disk image"),
VARLINK_DEFINE_ENUM_VALUE(pull_raw));
SD_VARLINK_FIELD_COMMENT("A local import of a tarball"),
SD_VARLINK_DEFINE_ENUM_VALUE(import_tar),
SD_VARLINK_FIELD_COMMENT("A local import of a raw disk image"),
SD_VARLINK_DEFINE_ENUM_VALUE(import_raw),
SD_VARLINK_FIELD_COMMENT("A local import of a file system tree"),
SD_VARLINK_DEFINE_ENUM_VALUE(import_fs),
SD_VARLINK_FIELD_COMMENT("A local export of a tarball"),
SD_VARLINK_DEFINE_ENUM_VALUE(export_tar),
SD_VARLINK_FIELD_COMMENT("A local export of a raw disk image"),
SD_VARLINK_DEFINE_ENUM_VALUE(export_raw),
SD_VARLINK_FIELD_COMMENT("A download of a tarball"),
SD_VARLINK_DEFINE_ENUM_VALUE(pull_tar),
SD_VARLINK_FIELD_COMMENT("A download of a raw disk image"),
SD_VARLINK_DEFINE_ENUM_VALUE(pull_raw));
static VARLINK_DEFINE_ENUM_TYPE(
static SD_VARLINK_DEFINE_ENUM_TYPE(
ImageVerify,
VARLINK_FIELD_COMMENT("No verification"),
VARLINK_DEFINE_ENUM_VALUE(no),
VARLINK_FIELD_COMMENT("Verify that downloads match checksum file (SHA256SUMS), but do not check signature of checksum file"),
VARLINK_DEFINE_ENUM_VALUE(checksum),
VARLINK_FIELD_COMMENT("Verify that downloads match checksum file (SHA256SUMS), and check signature of checksum file."),
VARLINK_DEFINE_ENUM_VALUE(signature));
SD_VARLINK_FIELD_COMMENT("No verification"),
SD_VARLINK_DEFINE_ENUM_VALUE(no),
SD_VARLINK_FIELD_COMMENT("Verify that downloads match checksum file (SHA256SUMS), but do not check signature of checksum file"),
SD_VARLINK_DEFINE_ENUM_VALUE(checksum),
SD_VARLINK_FIELD_COMMENT("Verify that downloads match checksum file (SHA256SUMS), and check signature of checksum file."),
SD_VARLINK_DEFINE_ENUM_VALUE(signature));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
LogMessage,
VARLINK_FIELD_COMMENT("The log message"),
VARLINK_DEFINE_FIELD(message, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("The priority of the log message, using the BSD syslog priority levels"),
VARLINK_DEFINE_FIELD(priority, VARLINK_INT, 0));
SD_VARLINK_FIELD_COMMENT("The log message"),
SD_VARLINK_DEFINE_FIELD(message, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("The priority of the log message, using the BSD syslog priority levels"),
SD_VARLINK_DEFINE_FIELD(priority, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ListTransfers,
VARLINK_FIELD_COMMENT("Image class to filter by"),
VARLINK_DEFINE_INPUT_BY_TYPE(class, ImageClass, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("A unique numeric identifier for the ongoing transfer"),
VARLINK_DEFINE_OUTPUT(id, VARLINK_INT, 0),
VARLINK_FIELD_COMMENT("The type of transfer"),
VARLINK_DEFINE_OUTPUT_BY_TYPE(type, TransferType, 0),
VARLINK_FIELD_COMMENT("The remote URL"),
VARLINK_DEFINE_OUTPUT(remote, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("The local image name"),
VARLINK_DEFINE_OUTPUT(local, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("The class of the image"),
VARLINK_DEFINE_OUTPUT_BY_TYPE(class, ImageClass, 0),
VARLINK_FIELD_COMMENT("Progress in percent"),
VARLINK_DEFINE_OUTPUT(percent, VARLINK_FLOAT, 0));
SD_VARLINK_FIELD_COMMENT("Image class to filter by"),
SD_VARLINK_DEFINE_INPUT_BY_TYPE(class, ImageClass, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("A unique numeric identifier for the ongoing transfer"),
SD_VARLINK_DEFINE_OUTPUT(id, SD_VARLINK_INT, 0),
SD_VARLINK_FIELD_COMMENT("The type of transfer"),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(type, TransferType, 0),
SD_VARLINK_FIELD_COMMENT("The remote URL"),
SD_VARLINK_DEFINE_OUTPUT(remote, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("The local image name"),
SD_VARLINK_DEFINE_OUTPUT(local, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("The class of the image"),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(class, ImageClass, 0),
SD_VARLINK_FIELD_COMMENT("Progress in percent"),
SD_VARLINK_DEFINE_OUTPUT(percent, SD_VARLINK_FLOAT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
Pull,
VARLINK_FIELD_COMMENT("The remote URL to download from"),
VARLINK_DEFINE_INPUT(remote, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("The local image name to download to"),
VARLINK_DEFINE_INPUT(local, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The type of the resource"),
VARLINK_DEFINE_INPUT_BY_TYPE(type, RemoteType, 0),
VARLINK_FIELD_COMMENT("The image class"),
VARLINK_DEFINE_INPUT_BY_TYPE(class, ImageClass, 0),
VARLINK_FIELD_COMMENT("The whether and how thoroughly to verify the download before installing it locally. Defauts to 'signature'."),
VARLINK_DEFINE_INPUT_BY_TYPE(verify, ImageVerify, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("If true, an existing image by the local name is deleted. Defaults to false."),
VARLINK_DEFINE_INPUT(force, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Whether to make the image read-only after downloading. Defaults ot false."),
VARLINK_DEFINE_INPUT(readOnly, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Whether to keep a pristine copy of the download separate from the locally installed image. Defaults to false."),
VARLINK_DEFINE_INPUT(keepDownload, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Whether to permit interactive authentication. Defaults to false."),
VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("A progress update, as percent value"),
VARLINK_DEFINE_OUTPUT(progress, VARLINK_FLOAT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("A log message about the ongoing transfer"),
VARLINK_DEFINE_OUTPUT_BY_TYPE(log, LogMessage, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The numeric ID of this download"),
VARLINK_DEFINE_OUTPUT(id, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_FIELD_COMMENT("The remote URL to download from"),
SD_VARLINK_DEFINE_INPUT(remote, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("The local image name to download to"),
SD_VARLINK_DEFINE_INPUT(local, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The type of the resource"),
SD_VARLINK_DEFINE_INPUT_BY_TYPE(type, RemoteType, 0),
SD_VARLINK_FIELD_COMMENT("The image class"),
SD_VARLINK_DEFINE_INPUT_BY_TYPE(class, ImageClass, 0),
SD_VARLINK_FIELD_COMMENT("The whether and how thoroughly to verify the download before installing it locally. Defauts to 'signature'."),
SD_VARLINK_DEFINE_INPUT_BY_TYPE(verify, ImageVerify, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("If true, an existing image by the local name is deleted. Defaults to false."),
SD_VARLINK_DEFINE_INPUT(force, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether to make the image read-only after downloading. Defaults ot false."),
SD_VARLINK_DEFINE_INPUT(readOnly, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether to keep a pristine copy of the download separate from the locally installed image. Defaults to false."),
SD_VARLINK_DEFINE_INPUT(keepDownload, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether to permit interactive authentication. Defaults to false."),
SD_VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("A progress update, as percent value"),
SD_VARLINK_DEFINE_OUTPUT(progress, SD_VARLINK_FLOAT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("A log message about the ongoing transfer"),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(log, LogMessage, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The numeric ID of this download"),
SD_VARLINK_DEFINE_OUTPUT(id, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_ERROR(AlreadyInProgress);
static VARLINK_DEFINE_ERROR(TransferCancelled);
static VARLINK_DEFINE_ERROR(TransferFailed);
static VARLINK_DEFINE_ERROR(NoTransfers);
static SD_VARLINK_DEFINE_ERROR(AlreadyInProgress);
static SD_VARLINK_DEFINE_ERROR(TransferCancelled);
static SD_VARLINK_DEFINE_ERROR(TransferFailed);
static SD_VARLINK_DEFINE_ERROR(NoTransfers);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Import,
"io.systemd.Import",
VARLINK_SYMBOL_COMMENT("Describes the class of images"),
SD_VARLINK_SYMBOL_COMMENT("Describes the class of images"),
&vl_type_ImageClass,
VARLINK_SYMBOL_COMMENT("Describes the type of a images to transfer"),
SD_VARLINK_SYMBOL_COMMENT("Describes the type of a images to transfer"),
&vl_type_RemoteType,
VARLINK_SYMBOL_COMMENT("Describes the type of a transfer"),
SD_VARLINK_SYMBOL_COMMENT("Describes the type of a transfer"),
&vl_type_TransferType,
VARLINK_SYMBOL_COMMENT("Describes whether and how thoroughly to verify the download before installing it locally"),
SD_VARLINK_SYMBOL_COMMENT("Describes whether and how thoroughly to verify the download before installing it locally"),
&vl_type_ImageVerify,
VARLINK_SYMBOL_COMMENT("Structure for log messages associated with a transfer operation"),
SD_VARLINK_SYMBOL_COMMENT("Structure for log messages associated with a transfer operation"),
&vl_type_LogMessage,
VARLINK_SYMBOL_COMMENT("List ongoing transfers, or query details about specific transfers"),
SD_VARLINK_SYMBOL_COMMENT("List ongoing transfers, or query details about specific transfers"),
&vl_method_ListTransfers,
VARLINK_SYMBOL_COMMENT("Download a .tar or .raw file. This must be called with the 'more' flag enabled. It will immediately return the numeric ID of the transfer, and then follow up with progress and log message updates, until the transfer is complete."),
SD_VARLINK_SYMBOL_COMMENT("Download a .tar or .raw file. This must be called with the 'more' flag enabled. It will immediately return the numeric ID of the transfer, and then follow up with progress and log message updates, until the transfer is complete."),
&vl_method_Pull,
VARLINK_SYMBOL_COMMENT("A transfer for the specified file is already ongoing"),
SD_VARLINK_SYMBOL_COMMENT("A transfer for the specified file is already ongoing"),
&vl_error_AlreadyInProgress,
VARLINK_SYMBOL_COMMENT("The transfer has been cancelled on user request"),
SD_VARLINK_SYMBOL_COMMENT("The transfer has been cancelled on user request"),
&vl_error_TransferCancelled,
VARLINK_SYMBOL_COMMENT("The transfer failed"),
SD_VARLINK_SYMBOL_COMMENT("The transfer failed"),
&vl_error_TransferFailed,
VARLINK_SYMBOL_COMMENT("No currently ongoing transfer"),
SD_VARLINK_SYMBOL_COMMENT("No currently ongoing transfer"),
&vl_error_NoTransfers);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Import;
extern const sd_varlink_interface vl_interface_io_systemd_Import;

View File

@ -2,14 +2,14 @@
#include "varlink-io.systemd.Journal.h"
static VARLINK_DEFINE_METHOD(Synchronize);
static VARLINK_DEFINE_METHOD(Rotate);
static VARLINK_DEFINE_METHOD(FlushToVar);
static VARLINK_DEFINE_METHOD(RelinquishVar);
static SD_VARLINK_DEFINE_METHOD(Synchronize);
static SD_VARLINK_DEFINE_METHOD(Rotate);
static SD_VARLINK_DEFINE_METHOD(FlushToVar);
static SD_VARLINK_DEFINE_METHOD(RelinquishVar);
static VARLINK_DEFINE_ERROR(NotSupportedByNamespaces);
static SD_VARLINK_DEFINE_ERROR(NotSupportedByNamespaces);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Journal,
"io.systemd.Journal",
&vl_method_Synchronize,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Journal;
extern const sd_varlink_interface vl_interface_io_systemd_Journal;

View File

@ -1,68 +1,69 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
#include "varlink-io.systemd.Machine.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
Register,
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(id, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(service, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(class, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(leader, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(rootDirectory, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(ifIndices, VARLINK_INT, VARLINK_ARRAY|VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(vSockCid, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(sshAddress, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(sshPrivateKeyPath, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Controls whether to allocate a scope unit for the machine to register. If false, the client already took care of that and registered a service/scope specific to the machine."),
VARLINK_DEFINE_INPUT(allocateUnit, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Whether to allow interactive authentication on this operation."),
VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, VARLINK_BOOL, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(id, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(service, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(class, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(leader, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(rootDirectory, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(ifIndices, SD_VARLINK_INT, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(vSockCid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(sshAddress, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(sshPrivateKeyPath, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Controls whether to allocate a scope unit for the machine to register. If false, the client already took care of that and registered a service/scope specific to the machine."),
SD_VARLINK_DEFINE_INPUT(allocateUnit, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Whether to allow interactive authentication on this operation."),
SD_VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
Timestamp,
VARLINK_FIELD_COMMENT("Timestamp in µs in the CLOCK_REALTIME clock (wallclock)"),
VARLINK_DEFINE_FIELD(realtime, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Timestamp in µs in the CLOCK_MONOTONIC clock"),
VARLINK_DEFINE_FIELD(monotonic, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_FIELD_COMMENT("Timestamp in µs in the CLOCK_REALTIME clock (wallclock)"),
SD_VARLINK_DEFINE_FIELD(realtime, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Timestamp in µs in the CLOCK_MONOTONIC clock"),
SD_VARLINK_DEFINE_FIELD(monotonic, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
List,
VARLINK_FIELD_COMMENT("If non-null the name of a running machine to report details on. If null/unspecified enumerates all running machines."),
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Name of the machine"),
VARLINK_DEFINE_OUTPUT(name, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("128bit ID identifying this machine, formatted in hexadecimal"),
VARLINK_DEFINE_OUTPUT(id, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Name of the software that registered this machine"),
VARLINK_DEFINE_OUTPUT(service, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The class of this machine"),
VARLINK_DEFINE_OUTPUT(class, VARLINK_STRING, 0),
VARLINK_FIELD_COMMENT("Leader process PID of this machine"),
VARLINK_DEFINE_OUTPUT(leader, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Root directory of this machine, if known, relative to host file system"),
VARLINK_DEFINE_OUTPUT(rootDirectory, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("The service manager unit this machine resides in"),
VARLINK_DEFINE_OUTPUT(unit, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("Timestamp when the machine was activated"),
VARLINK_DEFINE_OUTPUT_BY_TYPE(timestamp, Timestamp, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("AF_VSOCK CID of the machine if known and applicable"),
VARLINK_DEFINE_OUTPUT(vSockCid, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_FIELD_COMMENT("SSH address to connect to"),
VARLINK_DEFINE_OUTPUT(sshAddress, VARLINK_STRING, VARLINK_NULLABLE));
SD_VARLINK_FIELD_COMMENT("If non-null the name of a running machine to report details on. If null/unspecified enumerates all running machines."),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Name of the machine"),
SD_VARLINK_DEFINE_OUTPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("128bit ID identifying this machine, formatted in hexadecimal"),
SD_VARLINK_DEFINE_OUTPUT(id, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Name of the software that registered this machine"),
SD_VARLINK_DEFINE_OUTPUT(service, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The class of this machine"),
SD_VARLINK_DEFINE_OUTPUT(class, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("Leader process PID of this machine"),
SD_VARLINK_DEFINE_OUTPUT(leader, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Root directory of this machine, if known, relative to host file system"),
SD_VARLINK_DEFINE_OUTPUT(rootDirectory, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("The service manager unit this machine resides in"),
SD_VARLINK_DEFINE_OUTPUT(unit, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Timestamp when the machine was activated"),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(timestamp, Timestamp, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("AF_VSOCK CID of the machine if known and applicable"),
SD_VARLINK_DEFINE_OUTPUT(vSockCid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("SSH address to connect to"),
SD_VARLINK_DEFINE_OUTPUT(sshAddress, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_ERROR(NoSuchMachine);
static VARLINK_DEFINE_ERROR(MachineExists);
static SD_VARLINK_DEFINE_ERROR(NoSuchMachine);
static SD_VARLINK_DEFINE_ERROR(MachineExists);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Machine,
"io.systemd.Machine",
VARLINK_SYMBOL_COMMENT("A timestamp object consisting of both CLOCK_REALTIME and CLOCK_MONOTONIC timestamps"),
SD_VARLINK_SYMBOL_COMMENT("A timestamp object consisting of both CLOCK_REALTIME and CLOCK_MONOTONIC timestamps"),
&vl_type_Timestamp,
&vl_method_Register,
VARLINK_SYMBOL_COMMENT("List running machines"),
SD_VARLINK_SYMBOL_COMMENT("List running machines"),
&vl_method_List,
VARLINK_SYMBOL_COMMENT("No matching machine currently running"),
SD_VARLINK_SYMBOL_COMMENT("No matching machine currently running"),
&vl_error_NoSuchMachine,
&vl_error_MachineExists);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Machine;
extern const sd_varlink_interface vl_interface_io_systemd_Machine;

View File

@ -9,13 +9,13 @@
*
* Compare with io.systemd.oom where the client/server roles of oomd and the service manager are swapped! */
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
SubscribeManagedOOMCGroups,
VARLINK_DEFINE_OUTPUT_BY_TYPE(cgroups, ControlGroup, VARLINK_ARRAY));
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(cgroups, ControlGroup, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_ERROR(SubscriptionTaken);
static SD_VARLINK_DEFINE_ERROR(SubscriptionTaken);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_ManagedOOM,
"io.systemd.ManagedOOM",
&vl_method_SubscribeManagedOOMCGroups,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_ManagedOOM;
extern const sd_varlink_interface vl_interface_io_systemd_ManagedOOM;

View File

@ -2,60 +2,60 @@
#include "varlink-io.systemd.MountFileSystem.h"
static VARLINK_DEFINE_ENUM_TYPE(
static SD_VARLINK_DEFINE_ENUM_TYPE(
PartitionDesignator,
VARLINK_DEFINE_ENUM_VALUE(root),
VARLINK_DEFINE_ENUM_VALUE(usr),
VARLINK_DEFINE_ENUM_VALUE(home),
VARLINK_DEFINE_ENUM_VALUE(srv),
VARLINK_DEFINE_ENUM_VALUE(esp),
VARLINK_DEFINE_ENUM_VALUE(xbootldr),
VARLINK_DEFINE_ENUM_VALUE(swap),
VARLINK_DEFINE_ENUM_VALUE(root_verity),
VARLINK_DEFINE_ENUM_VALUE(usr_verity),
VARLINK_DEFINE_ENUM_VALUE(root_verity_sig),
VARLINK_DEFINE_ENUM_VALUE(usr_verity_sig),
VARLINK_DEFINE_ENUM_VALUE(tmp),
VARLINK_DEFINE_ENUM_VALUE(var));
SD_VARLINK_DEFINE_ENUM_VALUE(root),
SD_VARLINK_DEFINE_ENUM_VALUE(usr),
SD_VARLINK_DEFINE_ENUM_VALUE(home),
SD_VARLINK_DEFINE_ENUM_VALUE(srv),
SD_VARLINK_DEFINE_ENUM_VALUE(esp),
SD_VARLINK_DEFINE_ENUM_VALUE(xbootldr),
SD_VARLINK_DEFINE_ENUM_VALUE(swap),
SD_VARLINK_DEFINE_ENUM_VALUE(root_verity),
SD_VARLINK_DEFINE_ENUM_VALUE(usr_verity),
SD_VARLINK_DEFINE_ENUM_VALUE(root_verity_sig),
SD_VARLINK_DEFINE_ENUM_VALUE(usr_verity_sig),
SD_VARLINK_DEFINE_ENUM_VALUE(tmp),
SD_VARLINK_DEFINE_ENUM_VALUE(var));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
PartitionInfo,
VARLINK_DEFINE_FIELD(designator, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(writable, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(growFileSystem, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(partitionNumber, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(architecture, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(partitionUuid, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(fileSystemType, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(partitionLabel, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(size, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(offset, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(mountFileDescriptor, VARLINK_INT, 0));
SD_VARLINK_DEFINE_FIELD(designator, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(writable, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(growFileSystem, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(partitionNumber, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(architecture, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(partitionUuid, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(fileSystemType, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(partitionLabel, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(size, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(offset, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(mountFileDescriptor, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
MountImage,
VARLINK_DEFINE_INPUT(imageFileDescriptor, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(readOnly, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(growFileSystems, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(password, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(imagePolicy, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, VARLINK_BOOL, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(partitions, PartitionInfo, VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(imagePolicy, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(imageSize, VARLINK_INT, 0),
VARLINK_DEFINE_OUTPUT(sectorSize, VARLINK_INT, 0),
VARLINK_DEFINE_OUTPUT(imageName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(imageUuid, VARLINK_STRING, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(imageFileDescriptor, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(readOnly, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(growFileSystems, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(password, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(imagePolicy, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(allowInteractiveAuthentication, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(partitions, PartitionInfo, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(imagePolicy, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(imageSize, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_OUTPUT(sectorSize, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_OUTPUT(imageName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(imageUuid, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_ERROR(IncompatibleImage);
static VARLINK_DEFINE_ERROR(MultipleRootPartitionsFound);
static VARLINK_DEFINE_ERROR(RootPartitionNotFound);
static VARLINK_DEFINE_ERROR(DeniedByImagePolicy);
static VARLINK_DEFINE_ERROR(KeyNotFound);
static VARLINK_DEFINE_ERROR(VerityFailure);
static SD_VARLINK_DEFINE_ERROR(IncompatibleImage);
static SD_VARLINK_DEFINE_ERROR(MultipleRootPartitionsFound);
static SD_VARLINK_DEFINE_ERROR(RootPartitionNotFound);
static SD_VARLINK_DEFINE_ERROR(DeniedByImagePolicy);
static SD_VARLINK_DEFINE_ERROR(KeyNotFound);
static SD_VARLINK_DEFINE_ERROR(VerityFailure);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_MountFileSystem,
"io.systemd.MountFileSystem",
&vl_type_PartitionDesignator,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_MountFileSystem;
extern const sd_varlink_interface vl_interface_io_systemd_MountFileSystem;

View File

@ -2,48 +2,48 @@
#include "varlink-io.systemd.NamespaceResource.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
AllocateUserRange,
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(size, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(target, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(size, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(target, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
RegisterUserNamespace,
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
AddMountToUserNamespace,
VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(mountFileDescriptor, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(mountFileDescriptor, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
AddControlGroupToUserNamespace,
VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(controlGroupFileDescriptor, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(controlGroupFileDescriptor, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
AddNetworkToUserNamespace,
VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(networkNamespaceFileDescriptor, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(namespaceInterfaceName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(mode, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(hostInterfaceName, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(namespaceInterfaceName, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_INPUT(userNamespaceFileDescriptor, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(networkNamespaceFileDescriptor, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(namespaceInterfaceName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(mode, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(hostInterfaceName, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(namespaceInterfaceName, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_ERROR(UserNamespaceInterfaceNotSupported);
static VARLINK_DEFINE_ERROR(NameExists);
static VARLINK_DEFINE_ERROR(UserNamespaceExists);
static VARLINK_DEFINE_ERROR(DynamicRangeUnavailable);
static VARLINK_DEFINE_ERROR(NoDynamicRange);
static VARLINK_DEFINE_ERROR(UserNamespaceNotRegistered);
static VARLINK_DEFINE_ERROR(UserNamespaceWithoutUserRange);
static VARLINK_DEFINE_ERROR(TooManyControlGroups);
static VARLINK_DEFINE_ERROR(ControlGroupAlreadyAdded);
static SD_VARLINK_DEFINE_ERROR(UserNamespaceInterfaceNotSupported);
static SD_VARLINK_DEFINE_ERROR(NameExists);
static SD_VARLINK_DEFINE_ERROR(UserNamespaceExists);
static SD_VARLINK_DEFINE_ERROR(DynamicRangeUnavailable);
static SD_VARLINK_DEFINE_ERROR(NoDynamicRange);
static SD_VARLINK_DEFINE_ERROR(UserNamespaceNotRegistered);
static SD_VARLINK_DEFINE_ERROR(UserNamespaceWithoutUserRange);
static SD_VARLINK_DEFINE_ERROR(TooManyControlGroups);
static SD_VARLINK_DEFINE_ERROR(ControlGroupAlreadyAdded);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_NamespaceResource,
"io.systemd.NamespaceResource",
&vl_method_AllocateUserRange,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_NamespaceResource;
extern const sd_varlink_interface vl_interface_io_systemd_NamespaceResource;

View File

@ -2,51 +2,51 @@
#include "varlink-io.systemd.Network.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetStates,
VARLINK_DEFINE_OUTPUT(AddressState, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(IPv4AddressState, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(IPv6AddressState, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(CarrierState, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(OnlineState, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(OperationalState, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_OUTPUT(AddressState, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(IPv4AddressState, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(IPv6AddressState, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(CarrierState, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(OnlineState, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(OperationalState, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetNamespaceId,
VARLINK_DEFINE_OUTPUT(NamespaceId, VARLINK_INT, 0),
VARLINK_DEFINE_OUTPUT(NamespaceNSID, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_OUTPUT(NamespaceId, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_OUTPUT(NamespaceNSID, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
LLDPNeighbor,
VARLINK_DEFINE_FIELD(ChassisID, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(RawChassisID, VARLINK_INT, VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(PortID, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(RawPortID, VARLINK_INT, VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(PortDescription, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(SystemName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(SystemDescription, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(EnabledCapabilities, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_FIELD(ChassisID, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(RawChassisID, SD_VARLINK_INT, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(PortID, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(RawPortID, SD_VARLINK_INT, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(PortDescription, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(SystemName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(SystemDescription, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(EnabledCapabilities, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
LLDPNeighborsByInterface,
VARLINK_DEFINE_FIELD(InterfaceIndex, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(InterfaceName, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(InterfaceAlternativeNames, VARLINK_STRING, VARLINK_ARRAY|VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD_BY_TYPE(Neighbors, LLDPNeighbor, VARLINK_ARRAY));
SD_VARLINK_DEFINE_FIELD(InterfaceIndex, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(InterfaceName, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(InterfaceAlternativeNames, SD_VARLINK_STRING, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(Neighbors, LLDPNeighbor, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetLLDPNeighbors,
VARLINK_DEFINE_INPUT(InterfaceIndex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(InterfaceName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(Neighbors, LLDPNeighborsByInterface, VARLINK_ARRAY));
SD_VARLINK_DEFINE_INPUT(InterfaceIndex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(InterfaceName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(Neighbors, LLDPNeighborsByInterface, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
SetPersistentStorage,
VARLINK_DEFINE_INPUT(Ready, VARLINK_BOOL, 0));
SD_VARLINK_DEFINE_INPUT(Ready, SD_VARLINK_BOOL, 0));
static VARLINK_DEFINE_ERROR(StorageReadOnly);
static SD_VARLINK_DEFINE_ERROR(StorageReadOnly);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Network,
"io.systemd.Network",
&vl_method_GetStates,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Network;
extern const sd_varlink_interface vl_interface_io_systemd_Network;

View File

@ -2,13 +2,13 @@
#include "varlink-io.systemd.PCRExtend.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
Extend,
VARLINK_DEFINE_INPUT(pcr, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(text, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(data, VARLINK_STRING, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(pcr, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(text, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(data, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_PCRExtend,
"io.systemd.PCRExtend",
&vl_method_Extend);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_PCRExtend;
extern const sd_varlink_interface vl_interface_io_systemd_PCRExtend;

View File

@ -2,21 +2,21 @@
#include "varlink-io.systemd.PCRLock.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ReadEventLog,
VARLINK_DEFINE_OUTPUT(record, VARLINK_OBJECT, 0));
SD_VARLINK_DEFINE_OUTPUT(record, SD_VARLINK_OBJECT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
MakePolicy,
VARLINK_DEFINE_INPUT(force, VARLINK_BOOL, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(force, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
RemovePolicy);
static VARLINK_DEFINE_ERROR(
static SD_VARLINK_DEFINE_ERROR(
NoChange);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_PCRLock,
"io.systemd.PCRLock",
&vl_method_ReadEventLog,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_PCRLock;
extern const sd_varlink_interface vl_interface_io_systemd_PCRLock;

View File

@ -6,105 +6,105 @@
* hence import them here. */
#include "varlink-io.systemd.Resolve.h"
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ResourceRecordArray,
VARLINK_DEFINE_FIELD_BY_TYPE(rr, ResourceRecord, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(raw, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_FIELD_BY_TYPE(rr, ResourceRecord, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(raw, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
Answer,
VARLINK_DEFINE_FIELD_BY_TYPE(rr, ResourceRecord, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(raw, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(ifindex, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_FIELD_BY_TYPE(rr, ResourceRecord, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(raw, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
SubscribeQueryResults,
/* First reply */
VARLINK_DEFINE_OUTPUT(ready, VARLINK_BOOL, VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(ready, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
/* Subsequent replies */
VARLINK_DEFINE_OUTPUT(state, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(result, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(rcode, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(errno, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(extendedDNSErrorCode, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT(extendedDNSErrorMessage, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(question, ResourceKey, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT_BY_TYPE(collectedQuestions, ResourceKey, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT_BY_TYPE(answer, Answer, VARLINK_NULLABLE|VARLINK_ARRAY));
SD_VARLINK_DEFINE_OUTPUT(state, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(result, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(rcode, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(errno, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(extendedDNSErrorCode, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT(extendedDNSErrorMessage, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(question, ResourceKey, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(collectedQuestions, ResourceKey, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(answer, Answer, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
CacheEntry,
VARLINK_DEFINE_FIELD_BY_TYPE(key, ResourceKey, 0),
VARLINK_DEFINE_FIELD_BY_TYPE(rrs, ResourceRecordArray, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(type, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(until, VARLINK_INT, 0));
SD_VARLINK_DEFINE_FIELD_BY_TYPE(key, ResourceKey, 0),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(rrs, ResourceRecordArray, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(type, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(until, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ScopeCache,
VARLINK_DEFINE_FIELD(protocol, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(family, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(ifname, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD_BY_TYPE(cache, CacheEntry, VARLINK_ARRAY));
SD_VARLINK_DEFINE_FIELD(protocol, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(family, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(ifname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(cache, CacheEntry, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
DumpCache,
VARLINK_DEFINE_OUTPUT_BY_TYPE(dump, ScopeCache, VARLINK_ARRAY));
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(dump, ScopeCache, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ServerState,
VARLINK_DEFINE_FIELD(Server, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(Type, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(Interface, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(InterfaceIndex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(VerifiedFeatureLevel, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(PossibleFeatureLevel, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(DNSSECMode, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(DNSSECSupported, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(ReceivedUDPFragmentMax, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(FailedUDPAttempts, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(FailedTCPAttempts, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(PacketTruncated, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(PacketBadOpt, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(PacketRRSIGMissing, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(PacketInvalid, VARLINK_BOOL, 0),
VARLINK_DEFINE_FIELD(PacketDoOff, VARLINK_BOOL, 0));
SD_VARLINK_DEFINE_FIELD(Server, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(Type, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(Interface, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(InterfaceIndex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(VerifiedFeatureLevel, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(PossibleFeatureLevel, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(DNSSECMode, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(DNSSECSupported, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(ReceivedUDPFragmentMax, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(FailedUDPAttempts, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(FailedTCPAttempts, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(PacketTruncated, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(PacketBadOpt, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(PacketRRSIGMissing, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(PacketInvalid, SD_VARLINK_BOOL, 0),
SD_VARLINK_DEFINE_FIELD(PacketDoOff, SD_VARLINK_BOOL, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
DumpServerState,
VARLINK_DEFINE_OUTPUT_BY_TYPE(dump, ServerState, VARLINK_ARRAY));
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(dump, ServerState, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
TransactionStatistics,
VARLINK_DEFINE_FIELD(currentTransactions, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(totalTransactions, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(totalTimeouts, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(totalTimeoutsServedStale, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(totalFailedResponses, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(totalFailedResponsesServedStale, VARLINK_INT, 0));
SD_VARLINK_DEFINE_FIELD(currentTransactions, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(totalTransactions, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(totalTimeouts, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(totalTimeoutsServedStale, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(totalFailedResponses, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(totalFailedResponsesServedStale, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
CacheStatistics,
VARLINK_DEFINE_FIELD(size, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(hits, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(misses, VARLINK_INT, 0));
SD_VARLINK_DEFINE_FIELD(size, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(hits, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(misses, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
DnssecStatistics,
VARLINK_DEFINE_FIELD(secure, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(insecure, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(bogus, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(indeterminate, VARLINK_INT, 0));
SD_VARLINK_DEFINE_FIELD(secure, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(insecure, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(bogus, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(indeterminate, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
DumpStatistics,
VARLINK_DEFINE_OUTPUT_BY_TYPE(transactions, TransactionStatistics, 0),
VARLINK_DEFINE_OUTPUT_BY_TYPE(cache, CacheStatistics, 0),
VARLINK_DEFINE_OUTPUT_BY_TYPE(dnssec, DnssecStatistics, 0));
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(transactions, TransactionStatistics, 0),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(cache, CacheStatistics, 0),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(dnssec, DnssecStatistics, 0));
static VARLINK_DEFINE_METHOD(ResetStatistics);
static SD_VARLINK_DEFINE_METHOD(ResetStatistics);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Resolve_Monitor,
"io.systemd.Resolve.Monitor",
&vl_method_SubscribeQueryResults,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_Resolve_Monitor;
extern const sd_varlink_interface vl_interface_io_systemd_Resolve_Monitor;

View File

@ -2,175 +2,175 @@
#include "varlink-io.systemd.Resolve.h"
VARLINK_DEFINE_STRUCT_TYPE(
SD_VARLINK_DEFINE_STRUCT_TYPE(
ResourceKey,
VARLINK_DEFINE_FIELD(class, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(type, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(name, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_FIELD(class, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(type, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(name, SD_VARLINK_STRING, 0));
VARLINK_DEFINE_STRUCT_TYPE(
SD_VARLINK_DEFINE_STRUCT_TYPE(
ResourceRecord,
VARLINK_DEFINE_FIELD_BY_TYPE(key, ResourceKey, 0),
VARLINK_DEFINE_FIELD(priority, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(weight, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(port, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(name, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(cpu, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(os, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(items, VARLINK_STRING, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(address, VARLINK_INT, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(mname, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(rname, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(serial, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(refresh, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(expire, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(minimum, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(exchange, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(version, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(size, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(horiz_pre, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(vert_pre, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(latitude, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(longitude, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(altitude, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(keyTag, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(algorithm, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(digestType, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(digest, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(fptype, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(fingerprint, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(flags, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(protocol, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(dnskey, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(signer, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(typeCovered, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(labels, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(originalTtl, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(expiration, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(inception, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(signature, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(nextDomain, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(types, VARLINK_INT, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(iterations, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(salt, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(hash, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(certUsage, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(selector, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(matchingType, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(data, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(tag, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(value, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(target, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(params, VARLINK_STRING, VARLINK_NULLABLE|VARLINK_ARRAY),
VARLINK_DEFINE_FIELD(order, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(preference, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(naptrFlags, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(services, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(regexp, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(replacement, VARLINK_STRING, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_FIELD_BY_TYPE(key, ResourceKey, 0),
SD_VARLINK_DEFINE_FIELD(priority, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(weight, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(port, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(cpu, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(os, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(items, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(address, SD_VARLINK_INT, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(mname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(rname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(serial, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(refresh, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(expire, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(minimum, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(exchange, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(version, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(size, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(horiz_pre, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(vert_pre, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(latitude, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(longitude, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(altitude, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(keyTag, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(algorithm, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(digestType, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(digest, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(fptype, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(fingerprint, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(flags, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(protocol, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(dnskey, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(signer, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(typeCovered, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(labels, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(originalTtl, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(expiration, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(inception, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(signature, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(nextDomain, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(types, SD_VARLINK_INT, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(iterations, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(salt, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(hash, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(certUsage, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(selector, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(matchingType, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(data, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(tag, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(value, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(target, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(params, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(order, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(preference, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(naptrFlags, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(services, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(regexp, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(replacement, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ResolvedAddress,
VARLINK_DEFINE_FIELD(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(family, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(address, VARLINK_INT, VARLINK_ARRAY));
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(family, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(address, SD_VARLINK_INT, SD_VARLINK_ARRAY));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ResolveHostname,
VARLINK_DEFINE_INPUT(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(family, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(flags, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(addresses, ResolvedAddress, VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(name, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(flags, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(family, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(flags, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(addresses, ResolvedAddress, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(flags, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ResolvedName,
VARLINK_DEFINE_FIELD(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(name, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(name, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ResolveAddress,
VARLINK_DEFINE_INPUT(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(family, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(address, VARLINK_INT, VARLINK_ARRAY),
VARLINK_DEFINE_INPUT(flags, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(names, ResolvedName, VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(flags, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(family, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(address, SD_VARLINK_INT, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_INPUT(flags, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(names, ResolvedName, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(flags, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ResolvedService,
VARLINK_DEFINE_FIELD(priority, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(weight, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(port, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(hostname, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(canonicalName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD_BY_TYPE(addresses, ResolvedAddress, VARLINK_ARRAY|VARLINK_NULLABLE));
SD_VARLINK_DEFINE_FIELD(priority, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(weight, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(port, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(hostname, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(canonicalName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(addresses, ResolvedAddress, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ResolvedCanonical,
VARLINK_DEFINE_FIELD(name, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(type, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(domain, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_FIELD(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(type, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(domain, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ResolveService,
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(type, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(domain, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(family, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(flags, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(services, ResolvedService, VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(txt, VARLINK_STRING, VARLINK_ARRAY|VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(canonical, ResolvedCanonical, 0),
VARLINK_DEFINE_OUTPUT(flags, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(type, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(domain, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(family, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(flags, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(services, ResolvedService, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(txt, SD_VARLINK_STRING, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(canonical, ResolvedCanonical, 0),
SD_VARLINK_DEFINE_OUTPUT(flags, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_STRUCT_TYPE(
static SD_VARLINK_DEFINE_STRUCT_TYPE(
ResolvedRecord,
VARLINK_DEFINE_FIELD(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD_BY_TYPE(rr, ResourceRecord, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(raw, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(rr, ResourceRecord, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(raw, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ResolveRecord,
VARLINK_DEFINE_INPUT(ifindex, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(name, VARLINK_STRING, 0),
VARLINK_DEFINE_INPUT(class, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(type, VARLINK_INT, 0),
VARLINK_DEFINE_INPUT(flags, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_OUTPUT_BY_TYPE(rrs, ResolvedRecord, VARLINK_ARRAY),
VARLINK_DEFINE_OUTPUT(flags, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_INPUT(class, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(type, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_INPUT(flags, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(rrs, ResolvedRecord, SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_OUTPUT(flags, SD_VARLINK_INT, 0));
static VARLINK_DEFINE_ERROR(NoNameServers);
static VARLINK_DEFINE_ERROR(NoSuchResourceRecord);
static VARLINK_DEFINE_ERROR(QueryTimedOut);
static VARLINK_DEFINE_ERROR(MaxAttemptsReached);
static VARLINK_DEFINE_ERROR(InvalidReply);
static VARLINK_DEFINE_ERROR(QueryAborted);
static VARLINK_DEFINE_ERROR(
static SD_VARLINK_DEFINE_ERROR(NoNameServers);
static SD_VARLINK_DEFINE_ERROR(NoSuchResourceRecord);
static SD_VARLINK_DEFINE_ERROR(QueryTimedOut);
static SD_VARLINK_DEFINE_ERROR(MaxAttemptsReached);
static SD_VARLINK_DEFINE_ERROR(InvalidReply);
static SD_VARLINK_DEFINE_ERROR(QueryAborted);
static SD_VARLINK_DEFINE_ERROR(
DNSSECValidationFailed,
VARLINK_DEFINE_FIELD(result, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(extendedDNSErrorCode, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(extendedDNSErrorMessage, VARLINK_STRING, VARLINK_NULLABLE));
static VARLINK_DEFINE_ERROR(NoTrustAnchor);
static VARLINK_DEFINE_ERROR(ResourceRecordTypeUnsupported);
static VARLINK_DEFINE_ERROR(NetworkDown);
static VARLINK_DEFINE_ERROR(NoSource);
static VARLINK_DEFINE_ERROR(StubLoop);
static VARLINK_DEFINE_ERROR(
SD_VARLINK_DEFINE_FIELD(result, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(extendedDNSErrorCode, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(extendedDNSErrorMessage, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_ERROR(NoTrustAnchor);
static SD_VARLINK_DEFINE_ERROR(ResourceRecordTypeUnsupported);
static SD_VARLINK_DEFINE_ERROR(NetworkDown);
static SD_VARLINK_DEFINE_ERROR(NoSource);
static SD_VARLINK_DEFINE_ERROR(StubLoop);
static SD_VARLINK_DEFINE_ERROR(
DNSError,
VARLINK_DEFINE_FIELD(rcode, VARLINK_INT, 0),
VARLINK_DEFINE_FIELD(extendedDNSErrorCode, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_FIELD(extendedDNSErrorMessage, VARLINK_STRING, VARLINK_NULLABLE));
static VARLINK_DEFINE_ERROR(CNAMELoop);
static VARLINK_DEFINE_ERROR(BadAddressSize);
static VARLINK_DEFINE_ERROR(ResourceRecordTypeInvalidForQuery);
static VARLINK_DEFINE_ERROR(ZoneTransfersNotPermitted);
static VARLINK_DEFINE_ERROR(ResourceRecordTypeObsolete);
SD_VARLINK_DEFINE_FIELD(rcode, SD_VARLINK_INT, 0),
SD_VARLINK_DEFINE_FIELD(extendedDNSErrorCode, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(extendedDNSErrorMessage, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_ERROR(CNAMELoop);
static SD_VARLINK_DEFINE_ERROR(BadAddressSize);
static SD_VARLINK_DEFINE_ERROR(ResourceRecordTypeInvalidForQuery);
static SD_VARLINK_DEFINE_ERROR(ZoneTransfersNotPermitted);
static SD_VARLINK_DEFINE_ERROR(ResourceRecordTypeObsolete);
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_Resolve,
"io.systemd.Resolve",
&vl_method_ResolveHostname,

View File

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkSymbol vl_type_ResourceKey;
extern const VarlinkSymbol vl_type_ResourceRecord;
extern const sd_varlink_symbol vl_type_ResourceKey;
extern const sd_varlink_symbol vl_type_ResourceRecord;
extern const VarlinkInterface vl_interface_io_systemd_Resolve;
extern const sd_varlink_interface vl_interface_io_systemd_Resolve;

View File

@ -2,38 +2,38 @@
#include "varlink-io.systemd.UserDatabase.h"
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetUserRecord,
VARLINK_DEFINE_INPUT(uid, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(userName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(service, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(record, VARLINK_OBJECT, 0),
VARLINK_DEFINE_OUTPUT(incomplete, VARLINK_BOOL, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(uid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(userName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(service, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(record, SD_VARLINK_OBJECT, 0),
SD_VARLINK_DEFINE_OUTPUT(incomplete, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetGroupRecord,
VARLINK_DEFINE_INPUT(gid, VARLINK_INT, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(groupName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(service, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(record, VARLINK_OBJECT, 0),
VARLINK_DEFINE_OUTPUT(incomplete, VARLINK_BOOL, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_INPUT(gid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(groupName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(service, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(record, SD_VARLINK_OBJECT, 0),
SD_VARLINK_DEFINE_OUTPUT(incomplete, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
GetMemberships,
VARLINK_DEFINE_INPUT(userName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(groupName, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(service, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(userName, VARLINK_STRING, 0),
VARLINK_DEFINE_OUTPUT(groupName, VARLINK_STRING, 0));
SD_VARLINK_DEFINE_INPUT(userName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(groupName, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_INPUT(service, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(userName, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_OUTPUT(groupName, SD_VARLINK_STRING, 0));
static VARLINK_DEFINE_ERROR(NoRecordFound);
static VARLINK_DEFINE_ERROR(BadService);
static VARLINK_DEFINE_ERROR(ServiceNotAvailable);
static VARLINK_DEFINE_ERROR(ConflictingRecordNotFound);
static VARLINK_DEFINE_ERROR(EnumerationNotSupported);
static SD_VARLINK_DEFINE_ERROR(NoRecordFound);
static SD_VARLINK_DEFINE_ERROR(BadService);
static SD_VARLINK_DEFINE_ERROR(ServiceNotAvailable);
static SD_VARLINK_DEFINE_ERROR(ConflictingRecordNotFound);
static SD_VARLINK_DEFINE_ERROR(EnumerationNotSupported);
/* As per https://systemd.io/USER_GROUP_API/ */
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_UserDatabase,
"io.systemd.UserDatabase",
&vl_method_GetUserRecord,

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_UserDatabase;
extern const sd_varlink_interface vl_interface_io_systemd_UserDatabase;

View File

@ -1,6 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd;

View File

@ -7,18 +7,18 @@
* Compare with io.systemd.ManagedOOM where the client/server roles of the service manager and oomd are
* swapped! */
VARLINK_DEFINE_STRUCT_TYPE(
SD_VARLINK_DEFINE_STRUCT_TYPE(
ControlGroup,
VARLINK_DEFINE_FIELD(mode, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(path, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(property, VARLINK_STRING, 0),
VARLINK_DEFINE_FIELD(limit, VARLINK_INT, VARLINK_NULLABLE));
SD_VARLINK_DEFINE_FIELD(mode, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(path, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(property, SD_VARLINK_STRING, 0),
SD_VARLINK_DEFINE_FIELD(limit, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
ReportManagedOOMCGroups,
VARLINK_DEFINE_INPUT_BY_TYPE(cgroups, ControlGroup, VARLINK_ARRAY));
SD_VARLINK_DEFINE_INPUT_BY_TYPE(cgroups, ControlGroup, SD_VARLINK_ARRAY));
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_oom,
"io.systemd.oom",
&vl_method_ReportManagedOOMCGroups,

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink-idl.h"
#include "sd-varlink-idl.h"
extern const VarlinkSymbol vl_type_ControlGroup;
extern const VarlinkInterface vl_interface_io_systemd_oom;
extern const sd_varlink_symbol vl_type_ControlGroup;
extern const sd_varlink_interface vl_interface_io_systemd_oom;

View File

@ -2,35 +2,36 @@
#include <unistd.h>
#include "macro.h"
#include "varlink-io.systemd.service.h"
static VARLINK_DEFINE_METHOD(Ping);
static SD_VARLINK_DEFINE_METHOD(Ping);
static VARLINK_DEFINE_METHOD(Reload);
static SD_VARLINK_DEFINE_METHOD(Reload);
static VARLINK_DEFINE_METHOD(
static SD_VARLINK_DEFINE_METHOD(
SetLogLevel,
VARLINK_DEFINE_INPUT(level, VARLINK_INT, 0));
SD_VARLINK_DEFINE_INPUT(level, SD_VARLINK_INT, 0));
VARLINK_DEFINE_INTERFACE(
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_service,
"io.systemd.service",
&vl_method_Ping,
&vl_method_Reload,
&vl_method_SetLogLevel);
int varlink_method_ping(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int varlink_method_ping(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
assert(link);
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
log_debug("Received io.systemd.service.Ping");
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}
int varlink_method_set_log_level(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
int varlink_method_set_log_level(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dispatch_table[] = {
{ "level", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_int64, 0, SD_JSON_MANDATORY },
{}
@ -46,25 +47,25 @@ int varlink_method_set_log_level(Varlink *link, sd_json_variant *parameters, Var
/* NOTE: The method does have 1 parameter, but we must compare to 2 here, because
* sd_json_variant_elements() breaks abstraction and exposes internal structure of JsonObject. */
if (sd_json_variant_elements(parameters) != 2)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
r = varlink_dispatch(link, parameters, dispatch_table, &level);
r = sd_varlink_dispatch(link, parameters, dispatch_table, &level);
if (r != 0)
return r;
if (LOG_PRI(level) != level)
return varlink_error_invalid_parameter(link, parameters);
return sd_varlink_error_invalid_parameter(link, parameters);
r = varlink_get_peer_uid(link, &uid);
r = sd_varlink_get_peer_uid(link, &uid);
if (r < 0)
return r;
if (uid != getuid() && uid != 0)
return varlink_error(link, VARLINK_ERROR_PERMISSION_DENIED, parameters);
return sd_varlink_error(link, SD_VARLINK_ERROR_PERMISSION_DENIED, parameters);
log_debug("Received io.systemd.service.SetLogLevel(%" PRIi64 ")", level);
log_set_max_level(level);
return varlink_reply(link, NULL);
return sd_varlink_reply(link, NULL);
}

View File

@ -1,10 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "varlink.h"
#include "varlink-idl.h"
#include "sd-varlink.h"
#include "sd-varlink-idl.h"
extern const VarlinkInterface vl_interface_io_systemd_service;
extern const sd_varlink_interface vl_interface_io_systemd_service;
int varlink_method_ping(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int varlink_method_set_log_level(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata);
int varlink_method_ping(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
int varlink_method_set_log_level(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

Some files were not shown because too many files have changed in this diff Show More