Merge pull request #26993 from mrc0mmand/TEST-46-tweaks

test: explicitly pull in systemd-userdbd.service
This commit is contained in:
Yu Watanabe
2023-03-28 13:39:08 +09:00
committed by GitHub
2 changed files with 18 additions and 24 deletions
+16 -22
View File
@@ -142,10 +142,20 @@ struct user_group_data {
bool incomplete;
};
static void user_group_data_release(struct user_group_data *d) {
static void user_group_data_done(struct user_group_data *d) {
json_variant_unref(d->record);
}
struct membership_data {
char *user_name;
char *group_name;
};
static void membership_data_done(struct membership_data *d) {
free(d->user_name);
free(d->group_name);
}
static int userdb_on_query_reply(
Varlink *link,
JsonVariant *parameters,
@@ -178,7 +188,7 @@ static int userdb_on_query_reply(
switch (iterator->what) {
case LOOKUP_USER: {
_cleanup_(user_group_data_release) struct user_group_data user_data = {};
_cleanup_(user_group_data_done) struct user_group_data user_data = {};
static const JsonDispatch dispatch_table[] = {
{ "record", _JSON_VARIANT_TYPE_INVALID, json_dispatch_variant, offsetof(struct user_group_data, record), 0 },
@@ -235,7 +245,7 @@ static int userdb_on_query_reply(
}
case LOOKUP_GROUP: {
_cleanup_(user_group_data_release) struct user_group_data group_data = {};
_cleanup_(user_group_data_done) struct user_group_data group_data = {};
static const JsonDispatch dispatch_table[] = {
{ "record", _JSON_VARIANT_TYPE_INVALID, json_dispatch_variant, offsetof(struct user_group_data, record), 0 },
@@ -288,10 +298,7 @@ static int userdb_on_query_reply(
}
case LOOKUP_MEMBERSHIP: {
struct membership_data {
const char *user_name;
const char *group_name;
} membership_data = {};
_cleanup_(membership_data_done) struct membership_data membership_data = {};
static const JsonDispatch dispatch_table[] = {
{ "userName", JSON_VARIANT_STRING, json_dispatch_user_group_name, offsetof(struct membership_data, user_name), JSON_RELAX },
@@ -306,21 +313,8 @@ static int userdb_on_query_reply(
if (r < 0)
goto finish;
iterator->found_user_name = mfree(iterator->found_user_name);
iterator->found_group_name = mfree(iterator->found_group_name);
iterator->found_user_name = strdup(membership_data.user_name);
if (!iterator->found_user_name) {
r = -ENOMEM;
goto finish;
}
iterator->found_group_name = strdup(membership_data.group_name);
if (!iterator->found_group_name) {
r = -ENOMEM;
goto finish;
}
iterator->found_user_name = TAKE_PTR(membership_data.user_name);
iterator->found_group_name = TAKE_PTR(membership_data.group_name);
iterator->n_found++;
if (FLAGS_SET(flags, VARLINK_REPLY_CONTINUES))
+2 -2
View File
@@ -3,8 +3,8 @@
Description=TEST-46-HOMED
Wants=getty-pre.target
Before=getty-pre.target
Wants=systemd-homed.service
After=systemd-homed.service
Requires=systemd-homed.service systemd-userdbd.socket
After=systemd-homed.service systemd-userdbd.socket
[Service]
ExecStartPre=rm -f /failed /testok