Compare commits

...

15 Commits

Author SHA1 Message Date
Finn b5b179e49e Fix keys on Medion Akoya P6669 2020-03-19 10:10:29 +01:00
Arnaud Ferraris 19bb87fbfa login: allow non-console sessions to change vt
When starting a wayland session through a systemd service for a non-root
user, the compositor (based on wlroots) is denied the authorization to
change vt.
Once the user logs in, either through a local console or via ssh, the
compositor can work properly.

This is related to the login polkit policy:
- `allow_inactive` has value `auth_admin_keep`, denying any non-root
  user session the authorization to change vt
- `allow_active` has value `yes`, which explains why the vt change
  becomes possible once the user logs in through another channel

By changing the `allow_inactive` value to `yes`, any user session setup
in a service file can switch vt, allowing wayland sessions for non-root
users.
2020-03-19 09:29:23 +01:00
Franck Bui b39648ed47 logind: log a more accurate error when we failed at session creation
We used to log the following error:

  "Start job for unit user-1000.slice failed with 'canceled'"

which can be really misleading if the actual job failed at *stopping* a unit.

Indeed "Start" was hard coded but it was wrong since we can also fail with stop
jobs which are enqueued when a session is stopped.
2020-03-19 09:22:43 +01:00
Zbigniew Jędrzejewski-Szmek 677ceb0c2f
Merge pull request #15153 from keszybz/man-bus-address
Add two man pages for sd-bus
2020-03-19 09:11:14 +01:00
David Wood 7354900ddd network: Fix split in `SendOption=` on client and server
When specifying `DHCPv4.SendOption=`, it is used by systemd-networkd to
set the value of that option within the DHCP request that is sent out.
This differs to setting `DHCPServer.SendOption=`, which will place all
the options together as suboptions into the vendor-specific information
(code 43) option.

This commit adds two new config options, `DHCPv4.SendVendorOption=` and
`DHCPServer.SendVendorOption=`. These both have the behaviour of the old
`DHCPServer.SendOption=` flag, and set the value of the suboption in the
vendor-specific information option.

The behaviour of `DHCPServer.SendOption=` is then changed to reflect
that of `DHCPv4.SendOption=`. It will set the value of the corresponding
option in the DHCP request.
2020-03-19 09:08:40 +01:00
Susant Sahani d69b62de44 networkctl: Add support to display IPv6 addrgenmode 2020-03-19 08:57:59 +01:00
Christian Göttsche 194fe32296 selinux: delay mac_selinux_enforcing call after SELinux was determined to be enabled
Calling `mac_selinux_enforcing()`, which calls `security_getenforce()`, on a SELinux disabled system causes the following error message to be printed:
    Failed to get SELinux enforced status: No such file or directory

Fixes: 257188f80c ("selinux: cache enforced status and treat retrieve failure as enforced mode")
Supersedes: #15145
2020-03-19 08:56:30 +01:00
Zbigniew Jędrzejewski-Szmek 9178398f2e man: say "is" not "has been" 2020-03-18 19:57:44 +01:00
Zbigniew Jędrzejewski-Szmek 92b6df1d68 man: mention sd_bus_is_anonymous() and sd_bus_is_trusted() 2020-03-18 19:57:44 +01:00
Zbigniew Jędrzejewski-Szmek cc3d85eb97 sd-bus: mark sd_bus_try_close() as deprecated
codesearch.debian.net shows no uses (except for the definition in systemd and
elogind).

$ cat > test.c

int main() {
  sd_bus_try_close(NULL);
  return 0;
}
$ gcc -Isrc/systemd -Wall -o testbus test.c -lsystemd
test.c: In function ‘main’:
test.c:4:3: warning: ‘sd_bus_try_close’ is deprecated [-Wdeprecated-declarations]
    4 |   sd_bus_try_close(NULL);
      |   ^~~~~~~~~~~~~~~~
In file included from test.c:1:
src/systemd/sd-bus.h:180:5: note: declared here
  180 | int sd_bus_try_close(sd_bus *bus) _sd_deprecated_; /* deprecated */
      |     ^~~~~~~~~~~~~~~~
2020-03-18 19:57:44 +01:00
Zbigniew Jędrzejewski-Szmek 99cde098f8 bus: drop dead code for kdbus support
sd_bus_try_close() always returns -EOPNOTSUPP if bus is a valid object.
It nevers returns -EBUSY. So we'd always go into the "fallback" path.
2020-03-18 19:57:44 +01:00
Zbigniew Jędrzejewski-Szmek 9783b59bf6 man: describe sd_bus_default_flush_close() 2020-03-18 19:57:43 +01:00
Zbigniew Jędrzejewski-Szmek 3f549982a5 man: add sd_bus_set_address(3) 2020-03-18 19:57:43 +01:00
Zbigniew Jędrzejewski-Szmek d3d5ff4bc2 sd-bus: make bus_set_address_user always go through sd_bus_set_address
This way all the checks are done, and we don't leak a pointer if
bus_set_address_user() is called twice.
2020-03-18 19:57:43 +01:00
Zbigniew Jędrzejewski-Szmek 27622235c4 man: add sd_bus_start(3) 2020-03-18 19:57:43 +01:00
29 changed files with 560 additions and 91 deletions

View File

@ -1121,6 +1121,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnMAXDATA:pnPro*7000*:pvr*
# Akoya # Akoya
evdev:atkbd:dmi:bvn*:bvr*:svnMEDION*:pnS3409*:pvr* evdev:atkbd:dmi:bvn*:bvr*:svnMEDION*:pnS3409*:pvr*
evdev:atkbd:dmi:bvn*:bvr*:svnMedion*:pnAkoya*:pvr* evdev:atkbd:dmi:bvn*:bvr*:svnMedion*:pnAkoya*:pvr*
evdev:atkbd:dmi:bvn*:bvr*:svnMedion*:pnP6669*:pvr*
KEYBOARD_KEY_a0=!mute KEYBOARD_KEY_a0=!mute
KEYBOARD_KEY_ae=!volumedown KEYBOARD_KEY_ae=!volumedown
KEYBOARD_KEY_b0=!volumeup KEYBOARD_KEY_b0=!volumeup

View File

@ -139,7 +139,7 @@ manpages = [
['sd_bus_attach_event', '3', ['sd_bus_detach_event', 'sd_bus_get_event'], ''], ['sd_bus_attach_event', '3', ['sd_bus_detach_event', 'sd_bus_get_event'], ''],
['sd_bus_call', '3', ['sd_bus_call_async'], ''], ['sd_bus_call', '3', ['sd_bus_call_async'], ''],
['sd_bus_call_method', '3', ['sd_bus_call_method_async'], ''], ['sd_bus_call_method', '3', ['sd_bus_call_method_async'], ''],
['sd_bus_close', '3', ['sd_bus_flush'], ''], ['sd_bus_close', '3', ['sd_bus_default_flush_close', 'sd_bus_flush'], ''],
['sd_bus_creds_get_pid', ['sd_bus_creds_get_pid',
'3', '3',
['sd_bus_creds_get_audit_login_uid', ['sd_bus_creds_get_audit_login_uid',
@ -330,12 +330,15 @@ manpages = [
'sd_bus_release_name_async', 'sd_bus_release_name_async',
'sd_bus_request_name_async'], 'sd_bus_request_name_async'],
''], ''],
['sd_bus_set_address', '3', ['sd_bus_get_address'], ''],
['sd_bus_set_close_on_exit', '3', ['sd_bus_get_close_on_exit'], ''], ['sd_bus_set_close_on_exit', '3', ['sd_bus_get_close_on_exit'], ''],
['sd_bus_set_connected_signal', '3', ['sd_bus_get_connected_signal'], ''], ['sd_bus_set_connected_signal', '3', ['sd_bus_get_connected_signal'], ''],
['sd_bus_set_description', ['sd_bus_set_description',
'3', '3',
['sd_bus_get_allow_interactive_authorization', ['sd_bus_get_allow_interactive_authorization',
'sd_bus_get_description', 'sd_bus_get_description',
'sd_bus_is_anonymous',
'sd_bus_is_trusted',
'sd_bus_set_allow_interactive_authorization', 'sd_bus_set_allow_interactive_authorization',
'sd_bus_set_anonymous', 'sd_bus_set_anonymous',
'sd_bus_set_trusted'], 'sd_bus_set_trusted'],
@ -360,6 +363,7 @@ manpages = [
''], ''],
['sd_bus_slot_set_floating', '3', ['sd_bus_slot_get_floating'], ''], ['sd_bus_slot_set_floating', '3', ['sd_bus_slot_get_floating'], ''],
['sd_bus_slot_set_userdata', '3', ['sd_bus_slot_get_userdata'], ''], ['sd_bus_slot_set_userdata', '3', ['sd_bus_slot_get_userdata'], ''],
['sd_bus_start', '3', [], ''],
['sd_bus_track_add_name', ['sd_bus_track_add_name',
'3', '3',
['sd_bus_track_add_sender', ['sd_bus_track_add_sender',

View File

@ -54,6 +54,7 @@
<citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_get_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_n_queued_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_get_n_queued_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
@ -86,6 +87,7 @@
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_reply_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_reply_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_set_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
@ -96,6 +98,7 @@
<citerefentry><refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_slot_set_destroy_callback</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_slot_set_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_slot_set_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_track_add_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_track_add_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry> <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</literallayout> </literallayout>

View File

@ -19,6 +19,7 @@
<refnamediv> <refnamediv>
<refname>sd_bus_close</refname> <refname>sd_bus_close</refname>
<refname>sd_bus_flush</refname> <refname>sd_bus_flush</refname>
<refname>sd_bus_default_flush_close</refname>
<refpurpose>Close and flush a bus connection</refpurpose> <refpurpose>Close and flush a bus connection</refpurpose>
</refnamediv> </refnamediv>
@ -36,6 +37,11 @@
<funcdef>int <function>sd_bus_flush</function></funcdef> <funcdef>int <function>sd_bus_flush</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype> </funcprototype>
<funcprototype>
<funcdef>void <function>sd_bus_default_flush_close</function></funcdef>
<paramdef>void</paramdef>
</funcprototype>
</funcsynopsis> </funcsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
@ -59,6 +65,15 @@
bus object so that it may be freed. Since these three operations are frequently done together a helper call bus object so that it may be freed. Since these three operations are frequently done together a helper call
<citerefentry><refentrytitle>sd_bus_flush_close_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> is <citerefentry><refentrytitle>sd_bus_flush_close_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> is
provided that combines them into one.</para> provided that combines them into one.</para>
<para><function>sd_bus_default_flush_close()</function> is similar to
<function>sd_bus_flush_close_unref</function>, but does not take a bus pointer argument and instead
iterates over any of the "default" busses opened by
<citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
and similar calls. <function>sd_bus_default_flush_close()</function> is particularly useful to clean up
any busses opened using those calls before the program exits.</para>
</refsect1> </refsect1>
<refsect1> <refsect1>

View File

@ -186,14 +186,14 @@
<para>Note that entering a container is a privileged operation, and will likely only <para>Note that entering a container is a privileged operation, and will likely only
work for the root user on the remote machine.</para> work for the root user on the remote machine.</para>
<para><function>sd_bus_open_system_machine()</function> connects <para><function>sd_bus_open_system_machine()</function> connects to the system bus in the specified
to the system bus in the specified <parameter>machine</parameter>, <parameter>machine</parameter>, where <parameter>machine</parameter> is the name of a local
where <parameter>machine</parameter> is the name of a local container. See
container. See <citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for a description of the address syntax, and
for more information about the "machine" concept. Note that <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for more
connections into local containers are only available to privileged information about the "machine" concept. Note that connections into local containers are only available
processes at this time.</para> to privileged processes at this time.</para>
<para>These calls allocate a bus connection object and initiate <para>These calls allocate a bus connection object and initiate
the connection to a well-known bus of some form. An alternative to the connection to a well-known bus of some form. An alternative to
@ -297,7 +297,7 @@
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<para>In addition, any further connection-related errors may be by returned. See <para>In addition, other connection-related errors may be returned. See
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> <citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
</refsect2> </refsect2>
</refsect1> </refsect1>
@ -313,6 +313,7 @@
<citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry project='die-net'><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry project='die-net'><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>

View File

@ -87,14 +87,12 @@
or a related call, and then start the connection with or a related call, and then start the connection with
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
<para>In most cases, it is a better idea to invoke <para>In most cases, it is better to use
<citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry> <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>
or related calls instead of the more low-level or related calls instead of the more low-level <function>sd_bus_new()</function> and
<function>sd_bus_new()</function> and <function>sd_bus_start()</function>. The higher-level functions not only allocate a bus object but also
<function>sd_bus_start()</function>. The higher-level calls not start the connection to a well-known bus in a single function call.</para>
only allocate a bus object but also start the connection to a
well-known bus in a single function invocation.</para>
<para><function>sd_bus_ref()</function> increases the reference <para><function>sd_bus_ref()</function> increases the reference
counter of <parameter>bus</parameter> by one.</para> counter of <parameter>bus</parameter> by one.</para>

176
man/sd_bus_set_address.xml Normal file
View File

@ -0,0 +1,176 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_set_address"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_set_address</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_set_address</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_set_address</refname>
<refname>sd_bus_get_address</refname>
<refpurpose>Set or query the address of the bus connection</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_set_address</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char* <parameter>address</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_get_address</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char** <parameter>address</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_set_address()</function> configures a list of addresses of bus brokers to try to
connect to from a subsequent
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry> call.
The argument is a <literal>;</literal>-separated list of addresses to try. Each item must be one of the
following:
</para>
<itemizedlist>
<listitem>
<para>A unix socket address specified as
<literal>unix:guid=<replaceable>guid</replaceable>,path=<replaceable>path</replaceable></literal> or
<literal>unix:guid=<replaceable>guid</replaceable>,abstract=<replaceable>path</replaceable></literal>.
Exactly one of the <varname>path=</varname> and <varname>abstract=</varname> keys must be present,
while <varname>guid=</varname> is optional.</para>
</listitem>
<listitem>
<para>A TCP socket address specified as
<literal>tcp:[guid=<replaceable>guid</replaceable>,][host=<replaceable>host</replaceable>][,port=<replaceable>port</replaceable>][,family=<replaceable>family</replaceable>]</literal>.
One or both of the <varname>host=</varname> and <varname>port=</varname> keys must be present, while
the rest is optional. <replaceable>family</replaceable> may be either <option>ipv4</option> or
<option>ipv6</option>.</para>
</listitem>
<listitem>
<para>An executable to spawn specified as
<literal>unixexec:guid=<replaceable>guid</replaceable>,path=<replaceable>path</replaceable>,argv1=<replaceable>argument</replaceable>,argv2=<replaceable>argument</replaceable>,...</literal>.
The <varname>path=</varname> key must be present, while <varname>guid=</varname> is optional.</para>
</listitem>
<listitem>
<para>A machine (container) to connect to specified as
<literal>x-machine-unix:guid=<replaceable>guid</replaceable>,machine=<replaceable>machine</replaceable>,pid=<replaceable>pid</replaceable></literal>.
Exactly one of the <varname>machine=</varname> and <varname>pid=</varname> keys must be present,
while <varname>guid=</varname> is optional. <parameter>machine</parameter> is the name of a local
container. See
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
more information about the "machine" concept. <literal>machine=.host</literal> may be used to specify
the host machine. A connection to the standard system bus socket inside of the specified machine will
be created.</para>
</listitem>
</itemizedlist>
<para>In all cases, parameter <parameter>guid</parameter> is an identifier of the remote peer, in the
syntax accepted by
<citerefentry><refentrytitle>sd_id128_from_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
If specified, the identifier returned by the peer after the connection is established will be checked and
the connection will be rejected in case of a mismatch.</para>
<para>Note that the addresses passed to <function>sd_bus_set_address()</function> may not be verified
immediately. If they are invalid, an error may be returned e.g. from a subsequent call to
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
<para><function>sd_bus_get_address()</function> returns any previously set addresses. In addition to
being explicitly set by <function>sd_bus_set_address()</function>, the address will also be set
automatically by
<citerefentry><refentrytitle>sd_bus_open</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
similar calls, based on environment variables or built-in defaults.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, these functions return a non-negative integer. On failure, they return a negative
errno-style error code.</para>
<refsect2>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The input parameters <parameter>bus</parameter> or <parameter>address</parameter> are <constant>NULL</constant>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOPKG</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> could not be resolved.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>The input parameter <parameter>bus</parameter> is in a wrong state
(<function>sd_bus_set_address()</function> may only be called once on a newly-created bus object).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> was created in a different
process.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENODATA</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> has no address configured.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -19,7 +19,9 @@
<refname>sd_bus_set_description</refname> <refname>sd_bus_set_description</refname>
<refname>sd_bus_get_description</refname> <refname>sd_bus_get_description</refname>
<refname>sd_bus_set_anonymous</refname> <refname>sd_bus_set_anonymous</refname>
<refname>sd_bus_is_anonymous</refname>
<refname>sd_bus_set_trusted</refname> <refname>sd_bus_set_trusted</refname>
<refname>sd_bus_is_trusted</refname>
<refname>sd_bus_set_allow_interactive_authorization</refname> <refname>sd_bus_set_allow_interactive_authorization</refname>
<refname>sd_bus_get_allow_interactive_authorization</refname> <refname>sd_bus_get_allow_interactive_authorization</refname>
@ -48,12 +50,22 @@
<paramdef>int <parameter>b</parameter></paramdef> <paramdef>int <parameter>b</parameter></paramdef>
</funcprototype> </funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_is_anonymous</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype>
<funcprototype> <funcprototype>
<funcdef>int <function>sd_bus_set_trusted</function></funcdef> <funcdef>int <function>sd_bus_set_trusted</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>int <parameter>b</parameter></paramdef> <paramdef>int <parameter>b</parameter></paramdef>
</funcprototype> </funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_is_trusted</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype>
<funcprototype> <funcprototype>
<funcdef>int <function>sd_bus_set_allow_interactive_authorization</function></funcdef> <funcdef>int <function>sd_bus_set_allow_interactive_authorization</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
@ -75,7 +87,7 @@
and freed when the bus object is deallocated. The and freed when the bus object is deallocated. The
<parameter>description</parameter> argument may be <constant>NULL</constant>, in <parameter>description</parameter> argument may be <constant>NULL</constant>, in
which case the description is unset. This function must be called before the bus which case the description is unset. This function must be called before the bus
has been started.</para> is started.</para>
<para><function>sd_bus_get_description()</function> returns a description string <para><function>sd_bus_get_description()</function> returns a description string
in <parameter>description</parameter>. This string may have been previously set in <parameter>description</parameter>. This string may have been previously set
@ -87,14 +99,20 @@
<para><function>sd_bus_set_anonymous()</function> enables or disables "anonymous <para><function>sd_bus_set_anonymous()</function> enables or disables "anonymous
authentication", i.e. lack of authentication, of the bus peer. This function must authentication", i.e. lack of authentication, of the bus peer. This function must
be called before the bus has been started. See the <ulink be called before the bus is started. See the <ulink
url="view-source:https://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms">Authentication url="view-source:https://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms">Authentication
Mechanisms</ulink> section of the D-Bus specification for details.</para> Mechanisms</ulink> section of the D-Bus specification for details.</para>
<para><function>sd_bus_is_anonymous()</function> returns true if the bus connection allows anonymous
authentication (in the sense described in previous paragraph).</para>
<para><function>sd_bus_set_trusted()</function> sets the "trusted" state on the <para><function>sd_bus_set_trusted()</function> sets the "trusted" state on the
<parameter>bus</parameter> object. If true, all connections on the bus are <parameter>bus</parameter> object. If true, all connections on the bus are
trusted and access to all privileged and unprivileged methods is granted. This trusted and access to all privileged and unprivileged methods is granted. This
function must be called before the bus has been started.</para> function must be called before the bus is started.</para>
<para><function>sd_bus_is_trusted()</function> returns true if the bus connection is trusted (in the
sense described in previous paragraph).</para>
<para><function>sd_bus_set_allow_interactive_authorization()</function> <para><function>sd_bus_set_allow_interactive_authorization()</function>
enables or disables interactive authorization for method calls. If true, enables or disables interactive authorization for method calls. If true,

124
man/sd_bus_start.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_start"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_start</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_start</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_start</refname>
<refpurpose>Initiate a bus connection to the D-bus broker daemon
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_start</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_start()</function> connects an existing bus connection object to the D-Bus
broker daemon, usually
<citerefentry project='die-net'><refentrytitle>dbus-daemon</refentrytitle><manvolnum>1</manvolnum></citerefentry>
or
<citerefentry project='mankier'><refentrytitle>dbus-broker</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
The mechanism to use for the connection must be configured before the call to
<function>sd_bus_start()</function>, using one of
<citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or
<citerefentry><refentrytitle>sd_bus_set_exec</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
<function>sd_bus_start()</function> will open the connection socket or spawn the executable as
needed, and asynchronously start a <function>org.freedesktop.DBus.Hello()</function> call. The
answer to the Hello call will be processed later from
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If
opening of the connection or queuing of the asynchronous call fail, the connection will be closed with
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
<para>In most cases, it is better to use
<citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>
or related calls instead of the more low-level <function>sd_bus_new()</function> and
<function>sd_bus_start()</function>. The higher-level functions not only allocate a bus object but also
start the connection to a well-known bus in a single function call.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, this function returns a non-negative integer. On failure, it returns a negative
errno-style error code.</para>
<refsect2 id='errors'>
<title>Errors</title>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The input parameter <parameter>bus</parameter> is <constant>NULL</constant>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOPKG</constant></term>
<listitem><para>Bus object <parameter>bus</parameter> could not be resolved.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>The input parameter <parameter>bus</parameter> is in a wrong state
(<function>sd_bus_start()</function> may only be called once on a newly-created bus object).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus object <parameter>bus</parameter> was created in a different
process.</para>
</listitem>
</varlistentry>
</variablelist>
<para>In addition, other connection-related errors may be returned. See
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -1635,7 +1635,22 @@
<varlistentry> <varlistentry>
<term><varname>SendOption=</varname></term> <term><varname>SendOption=</varname></term>
<listitem> <listitem>
<para>Send an arbitrary option in the DHCPv4 request. Takes a DHCP option number, data type <para>Send an arbitrary raw option in the DHCPv4 request. Takes a DHCP option number, data type
and data separated with a colon
(<literal><replaceable>option</replaceable>:<replaceable>type</replaceable>:<replaceable>value</replaceable></literal>).
The option number must be an integer in the range 1..254. The type takes one of <literal>uint8</literal>,
<literal>uint16</literal>, <literal>uint32</literal>, <literal>ipv4address</literal>, or
<literal>string</literal>. Special characters in the data string may be escaped using
<ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C-style
escapes</ulink>. This setting can be specified multiple times. If an empty string is specified,
then all options specified earlier are cleared. Defaults to unset.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>SendVendorOption=</varname></term>
<listitem>
<para>Send an arbitrary vendor option in the DHCPv4 request. Takes a DHCP option number, data type
and data separated with a colon and data separated with a colon
(<literal><replaceable>option</replaceable>:<replaceable>type</replaceable>:<replaceable>value</replaceable></literal>). (<literal><replaceable>option</replaceable>:<replaceable>type</replaceable>:<replaceable>value</replaceable></literal>).
The option number must be an integer in the range 1..254. The type takes one of <literal>uint8</literal>, The option number must be an integer in the range 1..254. The type takes one of <literal>uint8</literal>,
@ -1926,6 +1941,20 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>SendVendorOption=</varname></term>
<listitem>
<para>Send a vendor option with value via DHCPv4 server. Takes a DHCP option number, data type
and data (<literal><replaceable>option</replaceable>:<replaceable>type</replaceable>:<replaceable>value</replaceable></literal>).
The option number is an integer in the range 1..254. The type takes one of <literal>uint8</literal>,
<literal>uint16</literal>, <literal>uint32</literal>, <literal>ipv4address</literal>, or
<literal>string</literal>. Special characters in the data string may be escaped using
<ulink url="https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences">C-style
escapes</ulink>. This setting can be specified multiple times. If an empty string is specified,
then all options specified earlier are cleared. Defaults to unset.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@ -185,7 +185,7 @@ int mac_selinux_generic_access_check(
_cleanup_free_ char *cl = NULL; _cleanup_free_ char *cl = NULL;
_cleanup_freecon_ char *fcon = NULL; _cleanup_freecon_ char *fcon = NULL;
char **cmdline = NULL; char **cmdline = NULL;
const bool enforce = mac_selinux_enforcing(); bool enforce;
int r = 0; int r = 0;
assert(message); assert(message);
@ -196,6 +196,9 @@ int mac_selinux_generic_access_check(
if (r <= 0) if (r <= 0)
return r; return r;
/* delay call until we checked in `access_init()` if SELinux is actually enabled */
enforce = mac_selinux_enforcing();
r = sd_bus_query_sender_creds( r = sd_bus_query_sender_creds(
message, message,
SD_BUS_CREDS_PID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_EGID| SD_BUS_CREDS_PID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_EGID|

View File

@ -58,7 +58,8 @@ struct sd_dhcp_server {
struct in_addr *ntp, *dns, *sip; struct in_addr *ntp, *dns, *sip;
unsigned n_ntp, n_dns, n_sip; unsigned n_ntp, n_dns, n_sip;
OrderedHashmap *raw_option; OrderedHashmap *extra_options;
OrderedHashmap *vendor_options;
bool emit_router; bool emit_router;

View File

@ -89,7 +89,8 @@ struct sd_dhcp_client {
usec_t start_time; usec_t start_time;
uint64_t attempt; uint64_t attempt;
uint64_t max_attempts; uint64_t max_attempts;
OrderedHashmap *options; OrderedHashmap *extra_options;
OrderedHashmap *vendor_options;
usec_t request_sent; usec_t request_sent;
sd_event_source *timeout_t1; sd_event_source *timeout_t1;
sd_event_source *timeout_t2; sd_event_source *timeout_t2;
@ -540,17 +541,17 @@ int sd_dhcp_client_set_max_attempts(sd_dhcp_client *client, uint64_t max_attempt
return 0; return 0;
} }
int sd_dhcp_client_set_dhcp_option(sd_dhcp_client *client, sd_dhcp_option *v) { int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v) {
int r; int r;
assert_return(client, -EINVAL); assert_return(client, -EINVAL);
assert_return(v, -EINVAL); assert_return(v, -EINVAL);
r = ordered_hashmap_ensure_allocated(&client->options, &dhcp_option_hash_ops); r = ordered_hashmap_ensure_allocated(&client->extra_options, &dhcp_option_hash_ops);
if (r < 0) if (r < 0)
return r; return r;
r = ordered_hashmap_put(client->options, UINT_TO_PTR(v->option), v); r = ordered_hashmap_put(client->extra_options, UINT_TO_PTR(v->option), v);
if (r < 0) if (r < 0)
return r; return r;
@ -558,6 +559,25 @@ int sd_dhcp_client_set_dhcp_option(sd_dhcp_client *client, sd_dhcp_option *v) {
return 0; return 0;
} }
int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v) {
int r;
assert_return(client, -EINVAL);
assert_return(v, -EINVAL);
r = ordered_hashmap_ensure_allocated(&client->vendor_options, &dhcp_option_hash_ops);
if (r < 0)
return -ENOMEM;
r = ordered_hashmap_put(client->vendor_options, v, v);
if (r < 0)
return r;
sd_dhcp_option_ref(v);
return 1;
}
int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) { int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) {
assert_return(client, -EINVAL); assert_return(client, -EINVAL);
@ -884,13 +904,22 @@ static int client_send_discover(sd_dhcp_client *client) {
return r; return r;
} }
ORDERED_HASHMAP_FOREACH(j, client->options, i) { ORDERED_HASHMAP_FOREACH(j, client->extra_options, i) {
r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0, r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
j->option, j->length, j->data); j->option, j->length, j->data);
if (r < 0) if (r < 0)
return r; return r;
} }
if (!ordered_hashmap_isempty(client->vendor_options)) {
r = dhcp_option_append(
&discover->dhcp, optlen, &optoffset, 0,
SD_DHCP_OPTION_VENDOR_SPECIFIC,
ordered_hashmap_size(client->vendor_options), client->vendor_options);
if (r < 0)
return r;
}
r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0, r = dhcp_option_append(&discover->dhcp, optlen, &optoffset, 0,
SD_DHCP_OPTION_END, 0, NULL); SD_DHCP_OPTION_END, 0, NULL);
if (r < 0) if (r < 0)
@ -2073,7 +2102,8 @@ static sd_dhcp_client *dhcp_client_free(sd_dhcp_client *client) {
free(client->hostname); free(client->hostname);
free(client->vendor_class_identifier); free(client->vendor_class_identifier);
client->user_class = strv_free(client->user_class); client->user_class = strv_free(client->user_class);
ordered_hashmap_free(client->options); ordered_hashmap_free(client->extra_options);
ordered_hashmap_free(client->vendor_options);
return mfree(client); return mfree(client);
} }

View File

@ -143,7 +143,8 @@ static sd_dhcp_server *dhcp_server_free(sd_dhcp_server *server) {
hashmap_free(server->leases_by_client_id); hashmap_free(server->leases_by_client_id);
ordered_hashmap_free(server->raw_option); ordered_hashmap_free(server->extra_options);
ordered_hashmap_free(server->vendor_options);
free(server->bound_leases); free(server->bound_leases);
return mfree(server); return mfree(server);
@ -455,6 +456,8 @@ static int server_send_ack(sd_dhcp_server *server, DHCPRequest *req,
be32_t address) { be32_t address) {
_cleanup_free_ DHCPPacket *packet = NULL; _cleanup_free_ DHCPPacket *packet = NULL;
be32_t lease_time; be32_t lease_time;
sd_dhcp_option *j;
Iterator i;
size_t offset; size_t offset;
int r; int r;
@ -519,11 +522,18 @@ static int server_send_ack(sd_dhcp_server *server, DHCPRequest *req,
return r; return r;
} }
if (!ordered_hashmap_isempty(server->raw_option)) { ORDERED_HASHMAP_FOREACH(j, server->extra_options, i) {
r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0,
j->option, j->length, j->data);
if (r < 0)
return r;
}
if (!ordered_hashmap_isempty(server->vendor_options)) {
r = dhcp_option_append( r = dhcp_option_append(
&packet->dhcp, req->max_optlen, &offset, 0, &packet->dhcp, req->max_optlen, &offset, 0,
SD_DHCP_OPTION_VENDOR_SPECIFIC, SD_DHCP_OPTION_VENDOR_SPECIFIC,
ordered_hashmap_size(server->raw_option), server->raw_option); ordered_hashmap_size(server->vendor_options), server->vendor_options);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -1188,11 +1198,29 @@ int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v) {
assert_return(server, -EINVAL); assert_return(server, -EINVAL);
assert_return(v, -EINVAL); assert_return(v, -EINVAL);
r = ordered_hashmap_ensure_allocated(&server->raw_option, &dhcp_option_hash_ops); r = ordered_hashmap_ensure_allocated(&server->extra_options, &dhcp_option_hash_ops);
if (r < 0)
return r;
r = ordered_hashmap_put(server->extra_options, UINT_TO_PTR(v->option), v);
if (r < 0)
return r;
sd_dhcp_option_ref(v);
return 0;
}
int sd_dhcp_server_add_vendor_option(sd_dhcp_server *server, sd_dhcp_option *v) {
int r;
assert_return(server, -EINVAL);
assert_return(v, -EINVAL);
r = ordered_hashmap_ensure_allocated(&server->vendor_options, &dhcp_option_hash_ops);
if (r < 0) if (r < 0)
return -ENOMEM; return -ENOMEM;
r = ordered_hashmap_put(server->raw_option, v, v); r = ordered_hashmap_put(server->vendor_options, v, v);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -980,9 +980,8 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
return -EINVAL; return -EINVAL;
free_and_replace(b->machine, machine); free_and_replace(b->machine, machine);
} else { } else
b->machine = mfree(b->machine); b->machine = mfree(b->machine);
}
if (pid) { if (pid) {
r = parse_pid(pid, &b->nspid); r = parse_pid(pid, &b->nspid);
@ -1271,10 +1270,7 @@ int bus_set_address_system(sd_bus *b) {
assert(b); assert(b);
e = secure_getenv("DBUS_SYSTEM_BUS_ADDRESS"); e = secure_getenv("DBUS_SYSTEM_BUS_ADDRESS");
if (e) return sd_bus_set_address(b, e ?: DEFAULT_SYSTEM_BUS_ADDRESS);
return sd_bus_set_address(b, e);
return sd_bus_set_address(b, DEFAULT_SYSTEM_BUS_ADDRESS);
} }
_public_ int sd_bus_open_system_with_description(sd_bus **ret, const char *description) { _public_ int sd_bus_open_system_with_description(sd_bus **ret, const char *description) {
@ -1319,29 +1315,30 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
} }
int bus_set_address_user(sd_bus *b) { int bus_set_address_user(sd_bus *b) {
const char *e; const char *a;
_cleanup_free_ char *ee = NULL, *s = NULL; _cleanup_free_ char *_a = NULL;
assert(b); assert(b);
e = secure_getenv("DBUS_SESSION_BUS_ADDRESS"); a = secure_getenv("DBUS_SESSION_BUS_ADDRESS");
if (e) if (!a) {
return sd_bus_set_address(b, e); const char *e;
_cleanup_free_ char *ee = NULL;
e = secure_getenv("XDG_RUNTIME_DIR"); e = secure_getenv("XDG_RUNTIME_DIR");
if (!e) if (!e)
return -ENOENT; return -ENOENT;
ee = bus_address_escape(e); ee = bus_address_escape(e);
if (!ee) if (!ee)
return -ENOMEM; return -ENOMEM;
if (asprintf(&s, DEFAULT_USER_BUS_ADDRESS_FMT, ee) < 0) if (asprintf(&_a, DEFAULT_USER_BUS_ADDRESS_FMT, ee) < 0)
return -ENOMEM; return -ENOMEM;
a = _a;
}
b->address = TAKE_PTR(s); return sd_bus_set_address(b, a);
return 0;
} }
_public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *description) { _public_ int sd_bus_open_user_with_description(sd_bus **ret, const char *description) {

View File

@ -3424,7 +3424,7 @@ const sd_bus_vtable manager_vtable[] = {
SD_BUS_VTABLE_END SD_BUS_VTABLE_END
}; };
static int session_jobs_reply(Session *s, const char *unit, const char *result) { static int session_jobs_reply(Session *s, uint32_t jid, const char *unit, const char *result) {
assert(s); assert(s);
assert(unit); assert(unit);
@ -3435,7 +3435,7 @@ static int session_jobs_reply(Session *s, const char *unit, const char *result)
_cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
sd_bus_error_setf(&e, BUS_ERROR_JOB_FAILED, sd_bus_error_setf(&e, BUS_ERROR_JOB_FAILED,
"Start job for unit '%s' failed with '%s'", unit, result); "Job %u for unit '%s' failed with '%s'", jid, unit, result);
return session_send_create_reply(s, &e); return session_send_create_reply(s, &e);
} }
@ -3475,7 +3475,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
if (session) { if (session) {
if (streq_ptr(path, session->scope_job)) { if (streq_ptr(path, session->scope_job)) {
session->scope_job = mfree(session->scope_job); session->scope_job = mfree(session->scope_job);
(void) session_jobs_reply(session, unit, result); (void) session_jobs_reply(session, id, unit, result);
session_save(session); session_save(session);
user_save(session->user); user_save(session->user);
@ -3490,7 +3490,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
user->service_job = mfree(user->service_job); user->service_job = mfree(user->service_job);
LIST_FOREACH(sessions_by_user, session, user->sessions) LIST_FOREACH(sessions_by_user, session, user->sessions)
(void) session_jobs_reply(session, unit, NULL /* don't propagate user service failures to the client */); (void) session_jobs_reply(session, id, unit, NULL /* don't propagate user service failures to the client */);
user_save(user); user_save(user);
} }

View File

@ -396,7 +396,7 @@
<message gettext-domain="systemd">Authentication is required to change the virtual terminal.</message> <message gettext-domain="systemd">Authentication is required to change the virtual terminal.</message>
<defaults> <defaults>
<allow_any>auth_admin_keep</allow_any> <allow_any>auth_admin_keep</allow_any>
<allow_inactive>auth_admin_keep</allow_inactive> <allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active> <allow_active>yes</allow_active>
</defaults> </defaults>
</action> </action>

View File

@ -127,6 +127,7 @@ typedef struct LinkInfo {
uint32_t max_mtu; uint32_t max_mtu;
uint32_t tx_queues; uint32_t tx_queues;
uint32_t rx_queues; uint32_t rx_queues;
uint8_t addr_gen_mode;
char *qdisc; char *qdisc;
char **alternative_names; char **alternative_names;
@ -188,6 +189,7 @@ typedef struct LinkInfo {
bool has_ethtool_link_info:1; bool has_ethtool_link_info:1;
bool has_wlan_link_info:1; bool has_wlan_link_info:1;
bool has_tunnel_ipv4:1; bool has_tunnel_ipv4:1;
bool has_ipv6_address_generation_mode:1;
bool needs_freeing:1; bool needs_freeing:1;
} LinkInfo; } LinkInfo;
@ -397,6 +399,19 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b
(void) sd_netlink_message_read_u32(m, IFLA_MASTER, &info->master); (void) sd_netlink_message_read_u32(m, IFLA_MASTER, &info->master);
r = sd_netlink_message_enter_container(m, IFLA_AF_SPEC);
if (r >= 0) {
r = sd_netlink_message_enter_container(m, AF_INET6);
if (r >= 0) {
r = sd_netlink_message_read_u8(m, IFLA_INET6_ADDR_GEN_MODE, &info->addr_gen_mode);
if (r >= 0)
info->has_ipv6_address_generation_mode = true;
(void) sd_netlink_message_exit_container(m);
}
(void) sd_netlink_message_exit_container(m);
}
/* fill kind info */ /* fill kind info */
(void) decode_netdev(m, info); (void) decode_netdev(m, info);
@ -1418,6 +1433,24 @@ static int link_status_one(
return table_log_add_error(r); return table_log_add_error(r);
} }
if (info->has_ipv6_address_generation_mode) {
static const struct {
const char *mode;
} mode_table[] = {
{ "eui64" },
{ "none" },
{ "stable-privacy" },
{ "random" },
};
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "IPv6 Address Generation Mode:",
TABLE_STRING, mode_table[info->addr_gen_mode]);
if (r < 0)
return table_log_add_error(r);
}
if (streq_ptr(info->netdev_kind, "bridge")) { if (streq_ptr(info->netdev_kind, "bridge")) {
r = table_add_many(table, r = table_add_many(table,
TABLE_EMPTY, TABLE_EMPTY,

View File

@ -312,6 +312,14 @@ int dhcp4_server_configure(Link *link) {
return log_link_error_errno(link, r, "Failed to set DHCPv4 option: %m"); return log_link_error_errno(link, r, "Failed to set DHCPv4 option: %m");
} }
ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_vendor_options, i) {
r = sd_dhcp_server_add_vendor_option(link->dhcp_server, p);
if (r == -EEXIST)
continue;
if (r < 0)
return log_link_error_errno(link, r, "Failed to set DHCPv4 option: %m");
}
if (!sd_dhcp_server_is_running(link->dhcp_server)) { if (!sd_dhcp_server_is_running(link->dhcp_server)) {
r = sd_dhcp_server_start(link->dhcp_server); r = sd_dhcp_server_start(link->dhcp_server);
if (r < 0) if (r < 0)

View File

@ -1430,7 +1430,17 @@ int dhcp4_configure(Link *link) {
} }
ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_options, i) { ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_options, i) {
r = sd_dhcp_client_set_dhcp_option(link->dhcp_client, send_option); r = sd_dhcp_client_add_option(link->dhcp_client, send_option);
if (r == -EEXIST)
continue;
if (r < 0)
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set send option: %m");
}
ORDERED_HASHMAP_FOREACH(send_option, link->network->dhcp_client_send_vendor_options, i) {
r = sd_dhcp_client_add_vendor_option(link->dhcp_client, send_option);
if (r == -EEXIST)
continue;
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set send option: %m"); return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set send option: %m");
} }

View File

@ -184,6 +184,7 @@ DHCPv4.SendDecline, config_parse_bool,
DHCPv4.BlackList, config_parse_dhcp_black_listed_ip_address, 0, 0 DHCPv4.BlackList, config_parse_dhcp_black_listed_ip_address, 0, 0
DHCPv4.IPServiceType, config_parse_dhcp_ip_service_type, 0, offsetof(Network, ip_service_type) DHCPv4.IPServiceType, config_parse_dhcp_ip_service_type, 0, offsetof(Network, ip_service_type)
DHCPv4.SendOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_options) DHCPv4.SendOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_options)
DHCPv4.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_vendor_options)
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu) DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
DHCPv6.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp6_use_dns) DHCPv6.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp6_use_dns)
DHCPv6.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp6_use_ntp) DHCPv6.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp6_use_ntp)
@ -211,6 +212,7 @@ DHCPServer.EmitTimezone, config_parse_bool,
DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone) DHCPServer.Timezone, config_parse_timezone, 0, offsetof(Network, dhcp_server_timezone)
DHCPServer.PoolOffset, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_offset) DHCPServer.PoolOffset, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_offset)
DHCPServer.PoolSize, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_size) DHCPServer.PoolSize, config_parse_uint32, 0, offsetof(Network, dhcp_server_pool_size)
DHCPServer.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_server_send_vendor_options)
DHCPServer.SendOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_server_send_options) DHCPServer.SendOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_server_send_options)
Bridge.Cost, config_parse_uint32, 0, offsetof(Network, cost) Bridge.Cost, config_parse_uint32, 0, offsetof(Network, cost)
Bridge.UseBPDU, config_parse_tristate, 0, offsetof(Network, use_bpdu) Bridge.UseBPDU, config_parse_tristate, 0, offsetof(Network, use_bpdu)

View File

@ -723,7 +723,9 @@ static Network *network_free(Network *network) {
set_free_free(network->dnssec_negative_trust_anchors); set_free_free(network->dnssec_negative_trust_anchors);
ordered_hashmap_free(network->dhcp_client_send_options); ordered_hashmap_free(network->dhcp_client_send_options);
ordered_hashmap_free(network->dhcp_client_send_vendor_options);
ordered_hashmap_free(network->dhcp_server_send_options); ordered_hashmap_free(network->dhcp_server_send_options);
ordered_hashmap_free(network->dhcp_server_send_vendor_options);
ordered_hashmap_free(network->ipv6_tokens); ordered_hashmap_free(network->ipv6_tokens);
return mfree(network); return mfree(network);

View File

@ -121,7 +121,9 @@ struct Network {
Set *dhcp_black_listed_ip; Set *dhcp_black_listed_ip;
Set *dhcp_request_options; Set *dhcp_request_options;
OrderedHashmap *dhcp_client_send_options; OrderedHashmap *dhcp_client_send_options;
OrderedHashmap *dhcp_client_send_vendor_options;
OrderedHashmap *dhcp_server_send_options; OrderedHashmap *dhcp_server_send_options;
OrderedHashmap *dhcp_server_send_vendor_options;
/* DHCPv6 Client support*/ /* DHCPv6 Client support*/
bool dhcp6_use_dns; bool dhcp6_use_dns;

View File

@ -115,36 +115,16 @@ int bus_event_loop_with_idle(
return r; return r;
if (r == 0 && !exiting && idle) { if (r == 0 && !exiting && idle) {
/* Inform the service manager that we are going down, so that it will queue all
* further start requests, instead of assuming we are already running. */
sd_notify(false, "STOPPING=1");
r = sd_bus_try_close(bus); r = bus_async_unregister_and_exit(e, bus, name);
if (r == -EBUSY)
continue;
/* Fallback for dbus1 connections: we
* unregister the name and wait for the
* response to come through for it */
if (r == -EOPNOTSUPP) {
/* Inform the service manager that we
* are going down, so that it will
* queue all further start requests,
* instead of assuming we are already
* running. */
sd_notify(false, "STOPPING=1");
r = bus_async_unregister_and_exit(e, bus, name);
if (r < 0)
return r;
exiting = true;
continue;
}
if (r < 0) if (r < 0)
return r; return r;
sd_event_exit(e, 0); exiting = true;
break; continue;
} }
} }

View File

@ -177,7 +177,7 @@ int sd_bus_get_sender(sd_bus *bus, const char **ret);
int sd_bus_start(sd_bus *bus); int sd_bus_start(sd_bus *bus);
int sd_bus_try_close(sd_bus *bus); int sd_bus_try_close(sd_bus *bus) _sd_deprecated_; /* deprecated */
void sd_bus_close(sd_bus *bus); void sd_bus_close(sd_bus *bus);
sd_bus *sd_bus_ref(sd_bus *bus); sd_bus *sd_bus_ref(sd_bus *bus);

View File

@ -179,7 +179,8 @@ int sd_dhcp_client_set_service_type(
sd_dhcp_client *client, sd_dhcp_client *client,
int type); int type);
int sd_dhcp_client_set_dhcp_option(sd_dhcp_client *client, sd_dhcp_option *v); int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
int sd_dhcp_client_stop(sd_dhcp_client *client); int sd_dhcp_client_stop(sd_dhcp_client *client);
int sd_dhcp_client_start(sd_dhcp_client *client); int sd_dhcp_client_start(sd_dhcp_client *client);

View File

@ -53,6 +53,7 @@ int sd_dhcp_server_set_sip(sd_dhcp_server *server, const struct in_addr sip[], u
int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled); int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled);
int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v); int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v);
int sd_dhcp_server_add_vendor_option(sd_dhcp_server *server, sd_dhcp_option *v);
int sd_dhcp_server_set_max_lease_time(sd_dhcp_server *server, uint32_t t); int sd_dhcp_server_set_max_lease_time(sd_dhcp_server *server, uint32_t t);
int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t); int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t);

View File

@ -100,6 +100,7 @@ SendRelease=
MaxAttempts= MaxAttempts=
IPServiceType= IPServiceType=
SendOption= SendOption=
SendVendorOption=
SendDecline= SendDecline=
RouteMTUBytes= RouteMTUBytes=
[DHCPv6] [DHCPv6]
@ -273,6 +274,7 @@ DefaultLeaseTimeSec=
EmitTimezone= EmitTimezone=
DNS= DNS=
SendOption= SendOption=
SendVendorOption=
[NextHop] [NextHop]
Id= Id=
Gateway= Gateway=

View File

@ -6,7 +6,7 @@ sd_total=0
udev_good=0 udev_good=0
udev_total=0 udev_total=0
for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | sort -u` ; do for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | grep -wv sd_bus_try_close | sort -u` ; do
if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then
echo "✓ Symbol $symbol() is documented." echo "✓ Symbol $symbol() is documented."
good=1 good=1