1
0
mirror of https://github.com/systemd/systemd synced 2026-03-14 17:14:49 +01:00

Compare commits

...

7 Commits

Author SHA1 Message Date
gitm0
cbec0bfa5d
hwdb: add accel matrix for One-netbook OneMix 3s (#19549) 2021-05-10 22:20:58 +02:00
Lennart Poettering
aa67e45b4b
Merge pull request #19570 from poettering/userdb-followup-fixlets
two minor userdb fixes
2021-05-10 22:06:32 +02:00
Lennart Poettering
708274eef3
Merge pull request #19568 from poettering/userdbctl-dropin
userdbctl: add new --with-varlink= and --with-drop-in= flags
2021-05-10 22:06:07 +02:00
Lennart Poettering
40fb3503f4 userdb: initialize .synthesize_root/.synthesize_nobody in generic code
Let's initialize this at the same place for any iterator allocated. (Yes
not all types of iterator objects need this, but it's still nice to
share this trivial code at one place).
2021-05-10 18:11:06 +02:00
Lennart Poettering
58dbf4c925 userdb: return ESRCH if we didn't find a single varlink service
Clearly communicate to callers that we didn't find a single varlink
service, when a lookup is attempted. Note that the fallback's to NSS,
drop-ins and synthesis might eat up this error again, but we should
really make this case reasonably recognizable, in particular as our
various tools already handle this condition correctly and print a nice
message then.
2021-05-10 18:08:38 +02:00
Lennart Poettering
c96a301213 man: document new userdbctl features 2021-05-10 18:02:50 +02:00
Lennart Poettering
59092877b3 userdbctl: add two new switches --with-dropin=/--with-varlink=
These directly correspond to the underlying flags. They are useful for
testing.
2021-05-10 18:02:50 +02:00
4 changed files with 74 additions and 14 deletions

View File

@ -663,6 +663,11 @@ sensor:modalias:acpi:SMO8500*:dmi:bvnAmericanMegatrendsInc.:bvr5.6.5:bd07/25/201
sensor:modalias:acpi:BOSC0200*:dmi:*svnONE-NETBOOKTECHNOLOGYCO*:pnOne-Mix3Pro:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
# One-netbook OneMix 3s
# OneMix 3s has no product name filled, matching entire dmi-alias
sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvr5.12:bd07/17/2019:br5.12:svnDefaultstring:pnDefaultstring:pvrDefaultstring:rvnDefaultstring:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
#########################################
# Peaq
#########################################

View File

@ -39,7 +39,10 @@
url="https://systemd.io/USER_RECORD">JSON User Records</ulink> and <ulink
url="https://systemd.io/GROUP_RECORD">JSON Group Records</ulink> definitions), and classic UNIX NSS/glibc
user and group records. This tool is primarily a client to the <ulink
url="https://systemd.io/USER_GROUP_API">User/Group Record Lookup API via Varlink</ulink>.</para>
url="https://systemd.io/USER_GROUP_API">User/Group Record Lookup API via Varlink</ulink>, and may also
pick up drop-in JSON user and group records from <filename>/etc/userdb/</filename>,
<filename>/run/userdb/</filename>, <filename>/run/host/userdb/</filename>,
<filename>/use/lib/userdb/</filename>.</para>
</refsect1>
<refsect1>
@ -86,6 +89,27 @@
are included in the output (which is the default).</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--with-varlink=</option><replaceable>BOOL</replaceable></term>
<listitem><para>Controls whether to include Varlink user/group lookups in the output, i.e. those done
via the <ulink url="https://systemd.io/USER_GROUP_API">User/Group Record Lookup API via
Varlink</ulink>. If <option>--with-varlink=no</option> is used any attempts to resolve or enumerate
users/groups provided only via Varlink are suppressed. If <option>--with-varlink=yes</option> is
specified such users/groups are included in the output (which is the default).</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--with-dropin=</option><replaceable>BOOL</replaceable></term>
<listitem><para>Controls whether to include user/group lookups in the output that are defined using
drop-in files in <filename>/etc/userdb/</filename>, <filename>/run/userdb/</filename>,
<filename>/run/host/userdb/</filename>, <filename>/use/lib/userdb/</filename>. If
<option>--with-dropin=no</option> is used these records are suppressed. If
<option>--with-dropin=yes</option> is specified such users/groups are included in the output (which
is the default).</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--synthesize=</option><replaceable>BOOL</replaceable></term>
@ -228,6 +252,17 @@
data, however the NSS/glibc APIs necessarily expose a more reduced set of fields
only.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>io.systemd.DropIn</constant></term>
<listitem><para>This service is (also) provided by
<citerefentry><refentrytitle>systemd-userdbd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
and picks up JSON user/group records from <filename>/etc/userdb/</filename>,
<filename>/run/userdb/</filename>, <filename>/run/host/userdb/</filename>,
<filename>/use/lib/userdb/</filename>.</para></listitem>
</varlistentry>
</variablelist>
<para>Note that <command>userdbctl</command> has internal support for NSS-based lookups too. This means

View File

@ -114,6 +114,8 @@ static UserDBIterator* userdb_iterator_new(LookupWhat what, UserDBFlags flags) {
*i = (UserDBIterator) {
.what = what,
.flags = flags,
.synthesize_root = !FLAGS_SET(flags, USERDB_DONT_SYNTHESIZE),
.synthesize_nobody = !FLAGS_SET(flags, USERDB_DONT_SYNTHESIZE),
};
return i;
@ -510,7 +512,7 @@ static int userdb_start_query(
}
if (set_isempty(iterator->links))
return ret; /* propagate last error we saw if we couldn't connect to anything. */
return ret < 0 ? ret : -ESRCH; /* propagate last error we saw if we couldn't connect to anything. */
/* We connected to some services, in this case, ignore the ones we failed on */
return 0;
@ -730,8 +732,6 @@ int userdb_all(UserDBFlags flags, UserDBIterator **ret) {
if (!iterator)
return -ENOMEM;
iterator->synthesize_root = iterator->synthesize_nobody = !FLAGS_SET(flags, USERDB_DONT_SYNTHESIZE);
qr = userdb_start_query(iterator, "io.systemd.UserDatabase.GetUserRecord", true, NULL, flags);
if (!FLAGS_SET(flags, USERDB_EXCLUDE_NSS) && (qr < 0 || !iterator->nss_covered)) {
@ -1002,8 +1002,6 @@ int groupdb_all(UserDBFlags flags, UserDBIterator **ret) {
if (!iterator)
return -ENOMEM;
iterator->synthesize_root = iterator->synthesize_nobody = !FLAGS_SET(flags, USERDB_DONT_SYNTHESIZE);
qr = userdb_start_query(iterator, "io.systemd.UserDatabase.GetGroupRecord", true, NULL, flags);
if (!FLAGS_SET(flags, USERDB_EXCLUDE_NSS) && (qr < 0 || !iterator->nss_covered)) {

View File

@ -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)