From 59092877b37e68bfbcbc2aabe06b4131a9b6ef67 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 6 May 2021 16:38:38 +0200 Subject: [PATCH 1/2] userdbctl: add two new switches --with-dropin=/--with-varlink= These directly correspond to the underlying flags. They are useful for testing. --- src/userdb/userdbctl.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index 56511eae44..8db0c34fb5 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -601,6 +601,8 @@ static int help(int argc, char *argv[], void *userdata) { " -N Do not synthesize or include glibc NSS data\n" " (Same as --synthesize=no --with-nss=no)\n" " --synthesize=BOOL Synthesize root/nobody user\n" + " --with-dropin=BOOL Control whether to include drop-in records\n" + " --with-varlink=BOOL Control whether to talk to services at all\n" "\nSee the %s for details.\n", program_invocation_short_name, ansi_highlight(), @@ -618,18 +620,22 @@ static int parse_argv(int argc, char *argv[]) { ARG_NO_LEGEND, ARG_OUTPUT, ARG_WITH_NSS, + ARG_WITH_DROPIN, + ARG_WITH_VARLINK, ARG_SYNTHESIZE, }; static const struct option options[] = { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, ARG_VERSION }, - { "no-pager", no_argument, NULL, ARG_NO_PAGER }, - { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, - { "output", required_argument, NULL, ARG_OUTPUT }, - { "service", required_argument, NULL, 's' }, - { "with-nss", required_argument, NULL, ARG_WITH_NSS }, - { "synthesize", required_argument, NULL, ARG_SYNTHESIZE }, + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, ARG_VERSION }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, + { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, + { "output", required_argument, NULL, ARG_OUTPUT }, + { "service", required_argument, NULL, 's' }, + { "with-nss", required_argument, NULL, ARG_WITH_NSS }, + { "with-dropin", required_argument, NULL, ARG_WITH_DROPIN }, + { "with-varlink", required_argument, NULL, ARG_WITH_VARLINK }, + { "synthesize", required_argument, NULL, ARG_SYNTHESIZE }, {} }; @@ -728,6 +734,22 @@ static int parse_argv(int argc, char *argv[]) { SET_FLAG(arg_userdb_flags, USERDB_EXCLUDE_NSS, !r); break; + case ARG_WITH_DROPIN: + r = parse_boolean_argument("--with-dropin=", optarg, NULL); + if (r < 0) + return r; + + SET_FLAG(arg_userdb_flags, USERDB_EXCLUDE_DROPIN, !r); + break; + + case ARG_WITH_VARLINK: + r = parse_boolean_argument("--with-varlink=", optarg, NULL); + if (r < 0) + return r; + + SET_FLAG(arg_userdb_flags, USERDB_EXCLUDE_VARLINK, !r); + break; + case ARG_SYNTHESIZE: r = parse_boolean_argument("--synthesize=", optarg, NULL); if (r < 0) From c96a30121399caf9ae458fd90ab1ad32ab2a0c92 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 7 May 2021 12:18:07 +0200 Subject: [PATCH 2/2] man: document new userdbctl features --- man/userdbctl.xml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/man/userdbctl.xml b/man/userdbctl.xml index 896ad22256..0871306b20 100644 --- a/man/userdbctl.xml +++ b/man/userdbctl.xml @@ -39,7 +39,10 @@ url="https://systemd.io/USER_RECORD">JSON User Records and JSON Group Records definitions), and classic UNIX NSS/glibc user and group records. This tool is primarily a client to the User/Group Record Lookup API via Varlink. + url="https://systemd.io/USER_GROUP_API">User/Group Record Lookup API via Varlink, and may also + pick up drop-in JSON user and group records from /etc/userdb/, + /run/userdb/, /run/host/userdb/, + /use/lib/userdb/. @@ -86,6 +89,27 @@ are included in the output (which is the default). + + BOOL + + Controls whether to include Varlink user/group lookups in the output, i.e. those done + via the User/Group Record Lookup API via + Varlink. If is used any attempts to resolve or enumerate + users/groups provided only via Varlink are suppressed. If is + specified such users/groups are included in the output (which is the default). + + + + BOOL + + Controls whether to include user/group lookups in the output that are defined using + drop-in files in /etc/userdb/, /run/userdb/, + /run/host/userdb/, /use/lib/userdb/. If + is used these records are suppressed. If + is specified such users/groups are included in the output (which + is the default). + + BOOL @@ -228,6 +252,17 @@ data, however the NSS/glibc APIs necessarily expose a more reduced set of fields only. + + + io.systemd.DropIn + + This service is (also) provided by + systemd-userdbd.service8 + and picks up JSON user/group records from /etc/userdb/, + /run/userdb/, /run/host/userdb/, + /use/lib/userdb/. + + Note that userdbctl has internal support for NSS-based lookups too. This means