Compare commits

...

11 Commits

Author SHA1 Message Date
Joerg Behrmann 1f667d8a7c docs: Add syntax for templated units to systemd.preset man page
This documents the syntax

     enable template@.service foo bar baz

that was introduced in #9901 to preset templated units.
2020-03-17 17:12:06 +01:00
Zbigniew Jędrzejewski-Szmek 34bc838f15
Merge pull request #15136 from yuwata/network-dhcp4-use-gateway
network: add a flag to ignore gateway provided by DHCP server
2020-03-17 16:51:18 +01:00
Zbigniew Jędrzejewski-Szmek 52d247154b
Merge pull request #15108 from keszybz/systemctl-set-default-notices
Make systemctl set-default hint about some common issues
2020-03-17 16:39:45 +01:00
duguxy 24a3c4299f
hwdb: add support for Lenovo Legion Y9000X2020 (#15127) 2020-03-17 12:24:00 +01:00
Piotr Drąg 0208c4bb3c po: update Polish translation 2020-03-17 12:21:04 +01:00
Alexander Malafeev 1f5d1de269 Fix volume control keys on Lenovo Yoga S940
With the default config repeated press of fn+VolumeUp or fn+VolumeDown lead to
repeated presses even after release, which leads to volume going to 100% or 0%.
2020-03-17 12:16:13 +01:00
Zbigniew Jędrzejewski-Szmek 12877da215 systemctl: print a notice when set-default is not effective
$ sudo ln -svf multi-user.target /run/systemd/generator.early/default.target
'/run/systemd/generator.early/default.target' -> 'multi-user.target'
$ sudo build/systemctl set-default --root=/ sysinit.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/sysinit.target.
Note: "multi-user.target" is the default unit (possibly a runtime override).

The output is not super informative, but it should be enough to point the user in
the right direction.

Fixes #3645.
2020-03-17 12:11:09 +01:00
Yu Watanabe 0d7bd445d2 test-network: add a test case for DHCPv4.UseGateway=no 2020-03-16 19:34:47 +09:00
Yu Watanabe b453122789 network: add a flag to ignore gateway provided by DHCP server
Closes #15117.
2020-03-16 19:34:43 +09:00
Zbigniew Jędrzejewski-Szmek 5e59431c53 systemctl: emit notice about some kernel commandline options
Things can be pretty confusing when there's a commandline option overrding the
configured default... Let's be nice to the user and emit a warning.
2020-03-13 17:52:19 +01:00
Zbigniew Jędrzejewski-Szmek cd57038a30 core: consistently emit oom warning when parsing args
In practice we are very unlikely to fail at this point, but for
consistency, we should always warn when allocation fails, and
we have free_and_strdup_warn() for this.
2020-03-13 15:54:27 +01:00
14 changed files with 161 additions and 33 deletions

View File

@ -528,6 +528,13 @@ evdev:name:SynPS/2 Synaptics TouchPad:dmi:*:svnLENOVO:*pvrThinkPadT490:*
EVDEV_ABS_35=::57 EVDEV_ABS_35=::57
EVDEV_ABS_36=::33 EVDEV_ABS_36=::33
# Lenovo Legion Y9000X2020
evdev:name:MSFT0001:02 04F3:304B Touchpad:dmi:*svnLENOVO:*pvrLenovoLegionY9000X2020*
EVDEV_ABS_00=::31
EVDEV_ABS_01=::30
EVDEV_ABS_35=::31
EVDEV_ABS_36=::30
######################################### #########################################
# Razer # Razer
######################################### #########################################

View File

@ -808,6 +808,15 @@ evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO*:pn*IdeaPad*Z370*:pvr*
KEYBOARD_KEY_ae=!volumedown KEYBOARD_KEY_ae=!volumedown
KEYBOARD_KEY_b0=!volumeup KEYBOARD_KEY_b0=!volumeup
# Fix for volume keys on Lenovo Yoga S940
# For 10th gen it should be pn81Q8 instead of pn81Q7 but
# I don't have a device to test
# perhaps pn81Q* would work for both generations
evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO:pn81Q7*:pvrLenovoYogaS940*
KEYBOARD_KEY_a0=!mute
KEYBOARD_KEY_ae=!volumedown
KEYBOARD_KEY_b0=!volumeup
# Lenovo Y50-70 # Lenovo Y50-70
evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO*:pn*20378*:pvr* evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO*:pn*20378*:pvr*
KEYBOARD_KEY_f3=f21 # Fn+F6 (toggle touchpad) KEYBOARD_KEY_f3=f21 # Fn+F6 (toggle touchpad)

View File

@ -1474,7 +1474,13 @@
"link" scope will be used. For anything else, scope defaults to "global".</para> "link" scope will be used. For anything else, scope defaults to "global".</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>UseGateway=</varname></term>
<listitem>
<para>When true (the default), the gateway will be requested from the DHCP server and added to the
routing table with a metric of 1024, and a scope of "link".</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>UseTimezone=</varname></term> <term><varname>UseTimezone=</varname></term>

View File

@ -71,7 +71,10 @@
<literal>disable</literal> followed by a space and a unit name <literal>disable</literal> followed by a space and a unit name
(possibly with shell style wildcards), separated by newlines. (possibly with shell style wildcards), separated by newlines.
Empty lines and lines whose first non-whitespace character is <literal>#</literal> or Empty lines and lines whose first non-whitespace character is <literal>#</literal> or
<literal>;</literal> are ignored.</para> <literal>;</literal> are ignored. Multiple instance names for unit
templates may be specified as a space separated list at the end of
the line instead of the customary position between <literal>@</literal>
and the unit suffix.</para>
<para>Presets must refer to the "real" unit file, and not to any aliases. See <para>Presets must refer to the "real" unit file, and not to any aliases. See
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
@ -123,6 +126,17 @@ disable *</programlisting>
<literal>99-</literal>, it will be read last and hence can easily <literal>99-</literal>, it will be read last and hence can easily
be overridden by spin or administrator preset policy.</para> be overridden by spin or administrator preset policy.</para>
<example>
<title>Enable multiple template instances</title>
<programlisting># /usr/lib/systemd/system-preset/80-dirsrv.preset
enable dirsrv@.service foo bar baz</programlisting>
</example>
<para>This enables all three of <filename>dirsrv@foo.service</filename>,
<filename>dirsrv@bar.service</filename> and <filename>dirsrv@baz.service</filename>.</para>
<example> <example>
<title>A GNOME spin</title> <title>A GNOME spin</title>

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: systemd\n" "Project-Id-Version: systemd\n"
"Report-Msgid-Bugs-To: https://github.com/systemd/systemd/issues\n" "Report-Msgid-Bugs-To: https://github.com/systemd/systemd/issues\n"
"POT-Creation-Date: 2020-02-29 15:12+0000\n" "POT-Creation-Date: 2020-03-07 03:28+0000\n"
"PO-Revision-Date: 2020-03-01 14:45+0100\n" "PO-Revision-Date: 2020-03-15 13:13+0100\n"
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n" "Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
"Language-Team: Polish <trans-pl@lists.fedoraproject.org>\n" "Language-Team: Polish <trans-pl@lists.fedoraproject.org>\n"
"Language: pl\n" "Language: pl\n"
@ -776,26 +776,35 @@ msgid "Authentication is required to reset DNS settings."
msgstr "Wymagane jest uwierzytelnienie, aby przywrócić ustawienia DNS." msgstr "Wymagane jest uwierzytelnienie, aby przywrócić ustawienia DNS."
#: src/network/org.freedesktop.network1.policy:143 #: src/network/org.freedesktop.network1.policy:143
msgid "DHCP server sends force renew message"
msgstr "Serwer DHCP wysyła komunikat wymuszonego odnowienia"
#: src/network/org.freedesktop.network1.policy:144
msgid "Authentication is required to send force renew message."
msgstr ""
"Wymagane jest uwierzytelnienie, aby wysłać komunikat wymuszonego odnowienia."
#: src/network/org.freedesktop.network1.policy:154
msgid "Renew dynamic addresses" msgid "Renew dynamic addresses"
msgstr "Odnowienie adresów dynamicznych" msgstr "Odnowienie adresów dynamicznych"
#: src/network/org.freedesktop.network1.policy:144 #: src/network/org.freedesktop.network1.policy:155
msgid "Authentication is required to renew dynamic addresses." msgid "Authentication is required to renew dynamic addresses."
msgstr "Wymagane jest uwierzytelnienie, aby odnowić adresy dynamiczne." msgstr "Wymagane jest uwierzytelnienie, aby odnowić adresy dynamiczne."
#: src/network/org.freedesktop.network1.policy:154 #: src/network/org.freedesktop.network1.policy:165
msgid "Reload network settings" msgid "Reload network settings"
msgstr "Ponowne wczytanie ustawień sieci" msgstr "Ponowne wczytanie ustawień sieci"
#: src/network/org.freedesktop.network1.policy:155 #: src/network/org.freedesktop.network1.policy:166
msgid "Authentication is required to reload network settings." msgid "Authentication is required to reload network settings."
msgstr "Wymagane jest uwierzytelnienie, aby ponownie wczytać ustawienia sieci." msgstr "Wymagane jest uwierzytelnienie, aby ponownie wczytać ustawienia sieci."
#: src/network/org.freedesktop.network1.policy:165 #: src/network/org.freedesktop.network1.policy:176
msgid "Reconfigure network interface" msgid "Reconfigure network interface"
msgstr "Ponowna konfiguracja interfejsu sieciowego" msgstr "Ponowna konfiguracja interfejsu sieciowego"
#: src/network/org.freedesktop.network1.policy:166 #: src/network/org.freedesktop.network1.policy:177
msgid "Authentication is required to reconfigure network interface." msgid "Authentication is required to reconfigure network interface."
msgstr "" msgstr ""
"Wymagane jest uwierzytelnienie, aby ponownie skonfigurować interfejs " "Wymagane jest uwierzytelnienie, aby ponownie skonfigurować interfejs "

View File

@ -318,7 +318,6 @@ static int set_machine_id(const char *m) {
} }
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r; int r;
assert(key); assert(key);
@ -330,10 +329,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (!unit_name_is_valid(value, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) if (!unit_name_is_valid(value, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
log_warning("Unit name specified on %s= is not valid, ignoring: %s", key, value); log_warning("Unit name specified on %s= is not valid, ignoring: %s", key, value);
else if (in_initrd() == !!startswith(key, "rd.")) { else if (in_initrd() == !!startswith(key, "rd."))
if (free_and_strdup(&arg_default_unit, value) < 0) return free_and_strdup_warn(&arg_default_unit, value);
return log_oom();
}
} else if (proc_cmdline_key_streq(key, "systemd.dump_core")) { } else if (proc_cmdline_key_streq(key, "systemd.dump_core")) {
@ -510,7 +507,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
/* SysV compatibility */ /* SysV compatibility */
target = runlevel_to_target(key); target = runlevel_to_target(key);
if (target) if (target)
return free_and_strdup(&arg_default_unit, target); return free_and_strdup_warn(&arg_default_unit, target);
} }
return 0; return 0;
@ -987,11 +984,9 @@ static int parse_argv(int argc, char *argv[]) {
case 'b': case 'b':
case 's': case 's':
case 'z': case 'z':
/* Just to eat away the sysvinit kernel /* Just to eat away the sysvinit kernel cmdline args that we'll parse in
* cmdline args without getopt() error * parse_proc_cmdline_item() or ignore, without any getopt() error messages.
* messages that we'll parse in */
* parse_proc_cmdline_word() or ignore. */
case '?': case '?':
if (getpid_cached() != 1) if (getpid_cached() != 1)
return -EINVAL; return -EINVAL;

View File

@ -323,6 +323,9 @@ static int link_set_dhcp_routes(Link *link) {
} }
} }
if (!link->network->dhcp_use_gateway)
return 0;
r = sd_dhcp_lease_get_router(link->dhcp_lease, &router); r = sd_dhcp_lease_get_router(link->dhcp_lease, &router);
if (IN_SET(r, 0, -ENODATA)) if (IN_SET(r, 0, -ENODATA))
log_link_info(link, "DHCP: No gateway received from DHCP server."); log_link_info(link, "DHCP: No gateway received from DHCP server.");
@ -451,7 +454,7 @@ static int dhcp_remove_router(Link *link, sd_dhcp_lease *lease, const struct in_
assert(link); assert(link);
assert(address); assert(address);
if (!link->network->dhcp_use_routes) if (!link->network->dhcp_use_gateway)
return 0; return 0;
r = sd_dhcp_lease_get_router(lease, &router); r = sd_dhcp_lease_get_router(lease, &router);

View File

@ -163,6 +163,7 @@ DHCPv4.UseMTU, config_parse_bool,
DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname) DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname)
DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains)
DHCPv4.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes) DHCPv4.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes)
DHCPv4.UseGateway, config_parse_bool, 0, offsetof(Network, dhcp_use_gateway)
DHCPv4.RequestOptions, config_parse_dhcp_request_options, 0, 0 DHCPv4.RequestOptions, config_parse_dhcp_request_options, 0, 0
DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize) DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname) DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)

View File

@ -384,6 +384,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_use_dns = true, .dhcp_use_dns = true,
.dhcp_use_hostname = true, .dhcp_use_hostname = true,
.dhcp_use_routes = true, .dhcp_use_routes = true,
.dhcp_use_gateway = true,
/* NOTE: this var might be overwritten by network_apply_anonymize_if_set */ /* NOTE: this var might be overwritten by network_apply_anonymize_if_set */
.dhcp_send_hostname = true, .dhcp_send_hostname = true,
.dhcp_send_release = true, .dhcp_send_release = true,

View File

@ -109,6 +109,7 @@ struct Network {
bool dhcp_use_sip; bool dhcp_use_sip;
bool dhcp_use_mtu; bool dhcp_use_mtu;
bool dhcp_use_routes; bool dhcp_use_routes;
bool dhcp_use_gateway;
bool dhcp_use_timezone; bool dhcp_use_timezone;
bool rapid_commit; bool rapid_commit;
bool dhcp_use_hostname; bool dhcp_use_hostname;

View File

@ -2065,22 +2065,55 @@ static int list_machines(int argc, char *argv[], void *userdata) {
return rc; return rc;
} }
static int get_default(int argc, char *argv[], void *userdata) { static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; char **ret = data;
_cleanup_free_ char *_path = NULL;
const char *path; if (streq(key, "systemd.unit")) {
if (proc_cmdline_value_missing(key, value))
return 0;
if (!unit_name_is_valid(value, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
return log_warning("Unit name specified on %s= is not valid, ignoring: %s", key, value);
return free_and_strdup_warn(ret, key);
} else if (!value) {
if (runlevel_to_target(key))
return free_and_strdup_warn(ret, key);
}
return 0;
}
static void emit_cmdline_warning(void) {
if (arg_quiet || arg_root)
/* don't bother checking the commandline if we're operating on a container */
return;
_cleanup_free_ char *override = NULL;
int r;
r = proc_cmdline_parse(parse_proc_cmdline_item, &override, 0);
if (r < 0)
log_debug_errno(r, "Failed to parse kernel command line, ignoring: %m");
if (override)
log_notice("Note: found \"%s\" on the kernel commandline, which overrides the default unit.",
override);
}
static int determine_default(char **ret_name) {
int r; int r;
if (install_client_side()) { if (install_client_side()) {
r = unit_file_get_default(arg_scope, arg_root, &_path); r = unit_file_get_default(arg_scope, arg_root, ret_name);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get default target: %m"); return log_error_errno(r, "Failed to get default target: %m");
path = _path; return 0;
r = 0;
} else { } else {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus; sd_bus *bus;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *name;
r = acquire_bus(BUS_MANAGER, &bus); r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0) if (r < 0)
@ -2098,13 +2131,25 @@ static int get_default(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get default target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get default target: %s", bus_error_message(&error, r));
r = sd_bus_message_read(reply, "s", &path); r = sd_bus_message_read(reply, "s", &name);
if (r < 0) if (r < 0)
return bus_log_parse_error(r); return bus_log_parse_error(r);
}
if (path) return free_and_strdup_warn(ret_name, name);
printf("%s\n", path); }
}
static int get_default(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *name = NULL;
int r;
r = determine_default(&name);
if (r < 0)
return r;
printf("%s\n", name);
emit_cmdline_warning();
return 0; return 0;
} }
@ -2164,6 +2209,19 @@ static int set_default(int argc, char *argv[], void *userdata) {
r = 0; r = 0;
} }
emit_cmdline_warning();
if (!arg_quiet) {
_cleanup_free_ char *final = NULL;
r = determine_default(&final);
if (r < 0)
return r;
if (!streq(final, unit))
log_notice("Note: \"%s\" is the default unit (possibly a runtime override).", final);
}
finish: finish:
unit_file_changes_free(changes, n_changes); unit_file_changes_free(changes, n_changes);

View File

@ -73,6 +73,7 @@ UseDNS=
RoutesToDNS= RoutesToDNS=
UseDomains= UseDomains=
UseRoutes= UseRoutes=
UseGateway=
IAID= IAID=
UserClass= UserClass=
UseNTP= UseNTP=

View File

@ -0,0 +1,9 @@
[Match]
Name=veth99
[Network]
DHCP=ipv4
IPv6AcceptRA=false
[DHCPv4]
UseGateway=no

View File

@ -2921,6 +2921,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
'dhcp-client-ipv4-dhcp-settings.network', 'dhcp-client-ipv4-dhcp-settings.network',
'dhcp-client-ipv4-only-ipv6-disabled.network', 'dhcp-client-ipv4-only-ipv6-disabled.network',
'dhcp-client-ipv4-only.network', 'dhcp-client-ipv4-only.network',
'dhcp-client-ipv4-use-gateway-no.network',
'dhcp-client-ipv4-use-routes-no.network', 'dhcp-client-ipv4-use-routes-no.network',
'dhcp-client-ipv6-only.network', 'dhcp-client-ipv6-only.network',
'dhcp-client-ipv6-rapid-commit.network', 'dhcp-client-ipv6-rapid-commit.network',
@ -3040,6 +3041,19 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
self.assertRegex(output, r'default via 192.168.5.1 proto dhcp src 192.168.5.181 metric 1024') self.assertRegex(output, r'default via 192.168.5.1 proto dhcp src 192.168.5.181 metric 1024')
self.assertRegex(output, r'192.168.5.1 proto dhcp scope link src 192.168.5.181 metric 1024') self.assertRegex(output, r'192.168.5.1 proto dhcp scope link src 192.168.5.181 metric 1024')
def test_dhcp_client_ipv4_use_gateway_no(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-use-gateway-no.network')
start_networkd()
self.wait_online(['veth-peer:carrier'])
start_dnsmasq(additional_options='--dhcp-option=option:dns-server,192.168.5.6,192.168.5.7', lease_time='2m')
self.wait_online(['veth99:routable', 'veth-peer:routable'])
output = check_output('ip route show dev veth99')
print(output)
self.assertRegex(output, r'192.168.5.0/24 via 192.168.5.5 proto dhcp src 192.168.5.181 metric 1024')
self.assertNotRegex(output, r'default via 192.168.5.1')
def test_dhcp_client_ipv4_ipv6(self): def test_dhcp_client_ipv4_ipv6(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network', copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv6-only.network',
'dhcp-client-ipv4-only.network') 'dhcp-client-ipv4-only.network')