Compare commits

...

16 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 0d0248c665
Merge pull request #16246 from benzea/benzea/xdg-autostart
Minor xdg-autostart changes
2020-06-23 21:13:07 +02:00
Zbigniew Jędrzejewski-Szmek 21856e3462
Merge pull request #16213 from yuwata/network-cleanup-link-state-file
network: cleanup link state file
2020-06-23 21:09:24 +02:00
Luca Boccassi 87d25bdead make-autosuspend-rules: restore compatibility with Python3 < 3.6
The f'...' format was introduced in Python 3.6 ( https://www.python.org/dev/peps/pep-0498/ )
and returns an error when systemd is built on a system with an older Python3 version:

<...>
  File /home/bluca/git/systemd/tools/make-autosuspend-rules.py, line 15
    print(f'pci:v{vendor:08X}d{device:08X}*')
                                           ^
SyntaxError: invalid syntax
[2/388] Generating version.h with a custom command.
ninja: build stopped: subcommand failed.
$ python3 --version
Python 3.5.6

Use an older format to keep backward compatibility.
2020-06-23 21:02:15 +02:00
Lennart Poettering 21385e639a man: replace perl bug tracker link that went away with link to paper
Fixes: #16245
2020-06-23 17:19:05 +02:00
Lennart Poettering 92d64d1444 man: s/PROGRAMM/PROGRAM/ 2020-06-23 17:13:26 +02:00
Zbigniew Jędrzejewski-Szmek 311a0e2ee6 Revert "cgroup: Allow empty assignments of Memory{Low,Min}="
This reverts commit 53aa85af24.
The reason is that that patch changes the dbus api to be different than
the types declared by introspection api.

Replaces #16122.
2020-06-23 16:54:23 +02:00
Susant Sahani 3d0c8750c5 networkctl: display DHCPv4 server address 2020-06-23 19:13:06 +09:00
Yu Watanabe fd1f3b3eed dhcp: fix entry name in parsing lease file 2020-06-23 19:13:06 +09:00
Yu Watanabe 46986251d6 network: drop duplicated information from link state file
Those entries are already in DHCP4 lease file, and not used anymore.
2020-06-23 19:13:05 +09:00
Yu Watanabe 5202be27ee sd-network: drop unused functions 2020-06-23 19:13:05 +09:00
Yu Watanabe 862e710820 networkctl: use lease file to get DHCPv4 client ID 2020-06-23 19:13:05 +09:00
Yu Watanabe d41fa6ee91 networkctl: use lease file to get DHCPv4 address 2020-06-23 19:13:05 +09:00
Yu Watanabe 35cab5f99d networkctl: load DHCPv4 lease file and use timezone data from the lease file 2020-06-23 19:13:05 +09:00
Yu Watanabe ef0daa1129 libsystemd-network: move prototypes of dhcp_lese_save/load() to network-internal.h 2020-06-23 19:13:05 +09:00
Benjamin Berg 9d9a9500cd xdg-autostart: Ignore all files with GNOME autostart phase
If an autostart file for GNOME has a phase specified, then this implies
it is a session service that needs to be started at a specific time.

We have no way of handling the ordering, and while it does make sense
to explicitly hide these services with X-systemd-skip, there is no point
in even trying to handle them.
2020-06-23 11:20:27 +02:00
Benjamin Berg 566cb7e23b xdg-autostart: Fix info message if Type= is not Application
The message was copy-pasted and not changed to correctly specify what
the problem was.
2020-06-23 11:04:44 +02:00
14 changed files with 131 additions and 226 deletions

View File

@ -118,7 +118,7 @@ requires random numbers as well, including for the following uses:
* systemd maintains various hash tables internally. In order to harden them * systemd maintains various hash tables internally. In order to harden them
against [collision against [collision
attacks](https://rt.perl.org/Public/Bug/Display.html?CSRF_Token=165691af9ddaa95f653402f1b68de728) attacks](https://www.cs.auckland.ac.nz/~mcw/Teaching/refs/misc/denial-of-service.pdf)
they are seeded with random numbers. they are seeded with random numbers.
* At various places systemd needs random bytes for temporary file name * At various places systemd needs random bytes for temporary file name

View File

@ -670,8 +670,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>IPIngressFilterPath=<replaceable>BPF_FS_PROGRAMM_PATH</replaceable></varname></term> <term><varname>IPIngressFilterPath=<replaceable>BPF_FS_PROGRAM_PATH</replaceable></varname></term>
<term><varname>IPEgressFilterPath=<replaceable>BPF_FS_PROGRAMM_PATH</replaceable></varname></term> <term><varname>IPEgressFilterPath=<replaceable>BPF_FS_PROGRAM_PATH</replaceable></varname></term>
<listitem> <listitem>
<para>Add custom network traffic filters implemented as BPF programs, applying to all IP packets <para>Add custom network traffic filters implemented as BPF programs, applying to all IP packets

View File

@ -707,112 +707,14 @@ static int bus_cgroup_set_boolean(
return 1; \ return 1; \
} }
#define BUS_DEFINE_SET_CGROUP_PROTECTION(function, mask, scale) \
static int bus_cgroup_set_##function( \
Unit *u, \
const char *name, \
uint64_t *p, \
bool *s, \
sd_bus_message *message, \
UnitWriteFlags flags, \
sd_bus_error *error) { \
\
uint64_t v = CGROUP_LIMIT_MIN; \
bool nonempty = true; \
char type; \
int r; \
\
assert(p); \
assert(s); \
\
r = sd_bus_message_peek_type(message, &type, NULL); \
if (r < 0) \
return r; \
if (type == SD_BUS_TYPE_BOOLEAN) { \
r = sd_bus_message_read(message, "b", &nonempty); \
if (r < 0) \
return r; \
/* Bool is used to denote empty value only */ \
if (nonempty) \
return -EINVAL; \
} else if (type != SD_BUS_TYPE_UINT64) { \
return -EINVAL; \
} else { \
r = sd_bus_message_read(message, "t", &v); \
if (r < 0) \
return r; \
} \
\
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
*p = v; \
unit_invalidate_cgroup(u, mask); \
if (!nonempty) { \
*s = false; \
unit_write_settingf(u, flags, name, \
"%s=", name); \
} else if (v == CGROUP_LIMIT_MAX) { \
*s = true; \
unit_write_settingf(u, flags, name, \
"%s=infinity", name); \
} else { \
*s = true; \
unit_write_settingf(u, flags, name, \
"%s=%" PRIu64, name, v); \
} \
} \
\
return 1; \
} \
static int bus_cgroup_set_##function##_scale( \
Unit *u, \
const char *name, \
uint64_t *p, \
bool *s, \
sd_bus_message *message, \
UnitWriteFlags flags, \
sd_bus_error *error) { \
\
uint64_t v; \
uint32_t raw; \
int r; \
\
assert(p); \
assert(s); \
\
r = sd_bus_message_read(message, "u", &raw); \
if (r < 0) \
return r; \
\
v = scale(raw, UINT32_MAX); \
if (v >= UINT64_MAX) \
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, \
"Value specified in %s is out of range", name); \
\
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
*p = v; \
unit_invalidate_cgroup(u, mask); \
\
/* Prepare to chop off suffix */ \
assert_se(endswith(name, "Scale")); \
\
uint32_t scaled = DIV_ROUND_UP((uint64_t) raw * 1000, (uint64_t) UINT32_MAX); \
unit_write_settingf(u, flags, name, "%.*s=%" PRIu32 ".%" PRIu32 "%%", \
(int)(strlen(name) - strlen("Scale")), name, \
scaled / 10, scaled % 10); \
} \
\
*s = true; \
return 1; \
}
DISABLE_WARNING_TYPE_LIMITS; DISABLE_WARNING_TYPE_LIMITS;
BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_weight, CGROUP_MASK_CPU, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID); BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_weight, CGROUP_MASK_CPU, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID);
BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_shares, CGROUP_MASK_CPU, CGROUP_CPU_SHARES_IS_OK, CGROUP_CPU_SHARES_INVALID); BUS_DEFINE_SET_CGROUP_WEIGHT(cpu_shares, CGROUP_MASK_CPU, CGROUP_CPU_SHARES_IS_OK, CGROUP_CPU_SHARES_INVALID);
BUS_DEFINE_SET_CGROUP_WEIGHT(io_weight, CGROUP_MASK_IO, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID); BUS_DEFINE_SET_CGROUP_WEIGHT(io_weight, CGROUP_MASK_IO, CGROUP_WEIGHT_IS_OK, CGROUP_WEIGHT_INVALID);
BUS_DEFINE_SET_CGROUP_WEIGHT(blockio_weight, CGROUP_MASK_BLKIO, CGROUP_BLKIO_WEIGHT_IS_OK, CGROUP_BLKIO_WEIGHT_INVALID); BUS_DEFINE_SET_CGROUP_WEIGHT(blockio_weight, CGROUP_MASK_BLKIO, CGROUP_BLKIO_WEIGHT_IS_OK, CGROUP_BLKIO_WEIGHT_INVALID);
BUS_DEFINE_SET_CGROUP_LIMIT(memory, CGROUP_MASK_MEMORY, physical_memory_scale, 1); BUS_DEFINE_SET_CGROUP_LIMIT(memory, CGROUP_MASK_MEMORY, physical_memory_scale, 1);
BUS_DEFINE_SET_CGROUP_LIMIT(memory_protection, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
BUS_DEFINE_SET_CGROUP_LIMIT(swap, CGROUP_MASK_MEMORY, physical_memory_scale, 0); BUS_DEFINE_SET_CGROUP_LIMIT(swap, CGROUP_MASK_MEMORY, physical_memory_scale, 0);
BUS_DEFINE_SET_CGROUP_PROTECTION(memory_protection, CGROUP_MASK_MEMORY, physical_memory_scale);
REENABLE_WARNING; REENABLE_WARNING;
static int bus_cgroup_set_tasks_max( static int bus_cgroup_set_tasks_max(
@ -938,17 +840,33 @@ int bus_cgroup_set_property(
if (streq(name, "MemoryAccounting")) if (streq(name, "MemoryAccounting"))
return bus_cgroup_set_boolean(u, name, &c->memory_accounting, CGROUP_MASK_MEMORY, message, flags, error); return bus_cgroup_set_boolean(u, name, &c->memory_accounting, CGROUP_MASK_MEMORY, message, flags, error);
if (streq(name, "MemoryMin")) if (streq(name, "MemoryMin")) {
return bus_cgroup_set_memory_protection(u, name, &c->memory_min, &c->memory_min_set, message, flags, error); r = bus_cgroup_set_memory_protection(u, name, &c->memory_min, message, flags, error);
if (r > 0)
c->memory_min_set = true;
return r;
}
if (streq(name, "MemoryLow")) if (streq(name, "MemoryLow")) {
return bus_cgroup_set_memory_protection(u, name, &c->memory_low, &c->memory_low_set, message, flags, error); r = bus_cgroup_set_memory_protection(u, name, &c->memory_low, message, flags, error);
if (r > 0)
c->memory_low_set = true;
return r;
}
if (streq(name, "DefaultMemoryMin")) if (streq(name, "DefaultMemoryMin")) {
return bus_cgroup_set_memory_protection(u, name, &c->default_memory_min, &c->default_memory_min_set, message, flags, error); r = bus_cgroup_set_memory_protection(u, name, &c->default_memory_min, message, flags, error);
if (r > 0)
c->default_memory_min_set = true;
return r;
}
if (streq(name, "DefaultMemoryLow")) if (streq(name, "DefaultMemoryLow")) {
return bus_cgroup_set_memory_protection(u, name, &c->default_memory_low, &c->default_memory_low_set, message, flags, error); r = bus_cgroup_set_memory_protection(u, name, &c->default_memory_low, message, flags, error);
if (r > 0)
c->default_memory_low_set = true;
return r;
}
if (streq(name, "MemoryHigh")) if (streq(name, "MemoryHigh"))
return bus_cgroup_set_memory(u, name, &c->memory_high, message, flags, error); return bus_cgroup_set_memory(u, name, &c->memory_high, message, flags, error);
@ -962,17 +880,33 @@ int bus_cgroup_set_property(
if (streq(name, "MemoryLimit")) if (streq(name, "MemoryLimit"))
return bus_cgroup_set_memory(u, name, &c->memory_limit, message, flags, error); return bus_cgroup_set_memory(u, name, &c->memory_limit, message, flags, error);
if (streq(name, "MemoryMinScale")) if (streq(name, "MemoryMinScale")) {
return bus_cgroup_set_memory_protection_scale(u, name, &c->memory_min, &c->memory_min_set, message, flags, error); r = bus_cgroup_set_memory_protection_scale(u, name, &c->memory_min, message, flags, error);
if (r > 0)
c->memory_min_set = true;
return r;
}
if (streq(name, "MemoryLowScale")) if (streq(name, "MemoryLowScale")) {
return bus_cgroup_set_memory_protection_scale(u, name, &c->memory_low, &c->memory_low_set, message, flags, error); r = bus_cgroup_set_memory_protection_scale(u, name, &c->memory_low, message, flags, error);
if (r > 0)
c->memory_low_set = true;
return r;
}
if (streq(name, "DefaultMemoryMinScale")) if (streq(name, "DefaultMemoryMinScale")) {
return bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_min, &c->default_memory_min_set, message, flags, error); r = bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_min, message, flags, error);
if (r > 0)
c->default_memory_min_set = true;
return r;
}
if (streq(name, "DefaultMemoryLowScale")) if (streq(name, "DefaultMemoryLowScale")) {
return bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_low, &c->default_memory_low_set, message, flags, error); r = bus_cgroup_set_memory_protection_scale(u, name, &c->default_memory_low, message, flags, error);
if (r > 0)
c->default_memory_low_set = true;
return r;
}
if (streq(name, "MemoryHighScale")) if (streq(name, "MemoryHighScale"))
return bus_cgroup_set_memory_scale(u, name, &c->memory_high, message, flags, error); return bus_cgroup_set_memory_scale(u, name, &c->memory_high, message, flags, error);

View File

@ -3456,8 +3456,6 @@ int config_parse_memory_limit(
} }
} }
/* Keep Memory{Low,Min} unset with empty assignment so that we fall back to DefaultMemory* which in
* contrast means zeroing the property. */
if (streq(lvalue, "DefaultMemoryLow")) { if (streq(lvalue, "DefaultMemoryLow")) {
c->default_memory_low = bytes; c->default_memory_low = bytes;
c->default_memory_low_set = true; c->default_memory_low_set = true;
@ -3466,10 +3464,10 @@ int config_parse_memory_limit(
c->default_memory_min_set = true; c->default_memory_min_set = true;
} else if (streq(lvalue, "MemoryMin")) { } else if (streq(lvalue, "MemoryMin")) {
c->memory_min = bytes; c->memory_min = bytes;
c->memory_min_set = !isempty(rvalue); c->memory_min_set = true;
} else if (streq(lvalue, "MemoryLow")) { } else if (streq(lvalue, "MemoryLow")) {
c->memory_low = bytes; c->memory_low = bytes;
c->memory_low_set = !isempty(rvalue); c->memory_low_set = true;
} else if (streq(lvalue, "MemoryHigh")) } else if (streq(lvalue, "MemoryHigh"))
c->memory_high = bytes; c->memory_high = bytes;
else if (streq(lvalue, "MemoryMax")) else if (streq(lvalue, "MemoryMax"))

View File

@ -82,6 +82,3 @@ int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const vo
int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease); int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len); int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t client_id_len);
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);

View File

@ -61,9 +61,13 @@ int deserialize_in6_addrs(struct in6_addr **addresses, const char *string);
/* don't include "dhcp-lease-internal.h" as it causes conflicts between netinet/ip.h and linux/ip.h */ /* don't include "dhcp-lease-internal.h" as it causes conflicts between netinet/ip.h and linux/ip.h */
struct sd_dhcp_route; struct sd_dhcp_route;
struct sd_dhcp_lease;
void serialize_dhcp_routes(FILE *f, const char *key, sd_dhcp_route **routes, size_t size); void serialize_dhcp_routes(FILE *f, const char *key, sd_dhcp_route **routes, size_t size);
int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t *ret_allocated, const char *string); int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t *ret_allocated, const char *string);
/* It is not necessary to add deserialize_dhcp_option(). Use unhexmem() instead. */ /* It is not necessary to add deserialize_dhcp_option(). Use unhexmem() instead. */
int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size); int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size);
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);

View File

@ -1076,7 +1076,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
"ADDRESS", &address, "ADDRESS", &address,
"ROUTER", &router, "ROUTER", &router,
"NETMASK", &netmask, "NETMASK", &netmask,
"SERVER_IDENTIFIER", &server_address, "SERVER_ADDRESS", &server_address,
"NEXT_SERVER", &next_server, "NEXT_SERVER", &next_server,
"BROADCAST", &broadcast, "BROADCAST", &broadcast,
"DNS", &dns, "DNS", &dns,

View File

@ -168,10 +168,6 @@ _public_ int sd_network_link_get_address_state(int ifindex, char **state) {
return network_link_get_string(ifindex, "ADDRESS_STATE", state); return network_link_get_string(ifindex, "ADDRESS_STATE", state);
} }
_public_ int sd_network_link_get_dhcp4_client_id_string(int ifindex, char **client_id) {
return network_link_get_string(ifindex, "DHCP4_CLIENT_ID", client_id);
}
_public_ int sd_network_link_get_dhcp6_client_iaid_string(int ifindex, char **iaid) { _public_ int sd_network_link_get_dhcp6_client_iaid_string(int ifindex, char **iaid) {
return network_link_get_string(ifindex, "DHCP6_CLIENT_IAID", iaid); return network_link_get_string(ifindex, "DHCP6_CLIENT_IAID", iaid);
} }
@ -236,14 +232,6 @@ _public_ int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char
return network_link_get_strv(ifindex, "DNSSEC_NTA", nta); return network_link_get_strv(ifindex, "DNSSEC_NTA", nta);
} }
_public_ int sd_network_link_get_timezone(int ifindex, char **ret) {
return network_link_get_string(ifindex, "TIMEZONE", ret);
}
_public_ int sd_network_link_get_dhcp4_address(int ifindex, char **ret) {
return network_link_get_string(ifindex, "DHCP4_ADDRESS", ret);
}
_public_ int sd_network_link_get_dns(int ifindex, char ***ret) { _public_ int sd_network_link_get_dns(int ifindex, char ***ret) {
return network_link_get_strv(ifindex, "DNS", ret); return network_link_get_strv(ifindex, "DNS", ret);
} }

View File

@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */ /* SPDX-License-Identifier: LGPL-2.1+ */
#include <arpa/inet.h>
#include <getopt.h> #include <getopt.h>
#include <linux/if_addrlabel.h> #include <linux/if_addrlabel.h>
#include <net/if.h> #include <net/if.h>
@ -930,12 +931,13 @@ static int dump_gateways(
static int dump_addresses( static int dump_addresses(
sd_netlink *rtnl, sd_netlink *rtnl,
sd_dhcp_lease *lease,
Table *table, Table *table,
int ifindex) { int ifindex) {
_cleanup_free_ struct local_address *local = NULL; _cleanup_free_ struct local_address *local = NULL;
_cleanup_free_ char *dhcp4_address = NULL;
_cleanup_strv_free_ char **buf = NULL; _cleanup_strv_free_ char **buf = NULL;
struct in_addr dhcp4_address = {};
int r, n, i; int r, n, i;
assert(rtnl); assert(rtnl);
@ -945,7 +947,8 @@ static int dump_addresses(
if (n <= 0) if (n <= 0)
return n; return n;
(void) sd_network_link_get_dhcp4_address(ifindex, &dhcp4_address); if (lease)
(void) sd_dhcp_lease_get_address(lease, &dhcp4_address);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
_cleanup_free_ char *pretty = NULL; _cleanup_free_ char *pretty = NULL;
@ -955,13 +958,19 @@ static int dump_addresses(
if (r < 0) if (r < 0)
return r; return r;
if (dhcp4_address && streq(pretty, dhcp4_address)) { if (local[i].family == AF_INET && in4_addr_equal(&local[i].address.in, &dhcp4_address)) {
_cleanup_free_ char *p = NULL; struct in_addr server_address;
char *p, s[INET_ADDRSTRLEN];
p = pretty; r = sd_dhcp_lease_get_server_identifier(lease, &server_address);
pretty = strjoin(pretty , " (DHCP4)"); if (r >= 0 && inet_ntop(AF_INET, &server_address, s, sizeof(s)))
if (!pretty) p = strjoin(pretty, " (DHCP4 via ", s, ")");
else
p = strjoin(pretty, " (DHCP4)");
if (!p)
return log_oom(); return log_oom();
free_and_replace(pretty, p);
} }
r = strv_extendf(&buf, "%s%s%s", r = strv_extendf(&buf, "%s%s%s",
@ -1379,12 +1388,12 @@ static int link_status_one(
const LinkInfo *info) { const LinkInfo *info) {
_cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL; _cleanup_strv_free_ char **dns = NULL, **ntp = NULL, **sip = NULL, **search_domains = NULL, **route_domains = NULL;
_cleanup_free_ char *t = NULL, *network = NULL, *client_id = NULL, *iaid = NULL, *duid = NULL; _cleanup_free_ char *t = NULL, *network = NULL, *iaid = NULL, *duid = NULL,
const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL; *setup_state = NULL, *operational_state = NULL, *lease_file = NULL;
_cleanup_free_ char *setup_state = NULL, *operational_state = NULL, *tz = NULL; const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL,
const char *on_color_operational, *off_color_operational, *on_color_operational, *off_color_operational, *on_color_setup, *off_color_setup;
*on_color_setup, *off_color_setup;
_cleanup_free_ int *carrier_bound_to = NULL, *carrier_bound_by = NULL; _cleanup_free_ int *carrier_bound_to = NULL, *carrier_bound_by = NULL;
_cleanup_(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
_cleanup_(table_unrefp) Table *table = NULL; _cleanup_(table_unrefp) Table *table = NULL;
TableCell *cell; TableCell *cell;
int r; int r;
@ -1425,6 +1434,11 @@ static int link_status_one(
(void) sd_network_link_get_carrier_bound_to(info->ifindex, &carrier_bound_to); (void) sd_network_link_get_carrier_bound_to(info->ifindex, &carrier_bound_to);
(void) sd_network_link_get_carrier_bound_by(info->ifindex, &carrier_bound_by); (void) sd_network_link_get_carrier_bound_by(info->ifindex, &carrier_bound_by);
if (asprintf(&lease_file, "/run/systemd/netif/leases/%d", info->ifindex) < 0)
return log_oom();
(void) dhcp_lease_load(&lease, lease_file);
table = table_new("dot", "key", "value"); table = table_new("dot", "key", "value");
if (!table) if (!table)
return log_oom(); return log_oom();
@ -2022,7 +2036,7 @@ static int link_status_one(
} }
} }
r = dump_addresses(rtnl, table, info->ifindex); r = dump_addresses(rtnl, lease, table, info->ifindex);
if (r < 0) if (r < 0)
return r; return r;
r = dump_gateways(rtnl, hwdb, table, info->ifindex); r = dump_gateways(rtnl, hwdb, table, info->ifindex);
@ -2050,24 +2064,35 @@ static int link_status_one(
if (r < 0) if (r < 0)
return r; return r;
(void) sd_network_link_get_timezone(info->ifindex, &tz); if (lease) {
if (tz) { const void *client_id;
r = table_add_many(table, size_t client_id_len;
TABLE_EMPTY, const char *tz;
TABLE_STRING, "Time Zone:",
TABLE_STRING, tz);
if (r < 0)
return table_log_add_error(r);
}
r = sd_network_link_get_dhcp4_client_id_string(info->ifindex, &client_id); r = sd_dhcp_lease_get_timezone(lease, &tz);
if (r >= 0) { if (r >= 0) {
r = table_add_many(table, r = table_add_many(table,
TABLE_EMPTY, TABLE_EMPTY,
TABLE_STRING, "DHCP4 Client ID:", TABLE_STRING, "Time Zone:",
TABLE_STRING, client_id); TABLE_STRING, tz);
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
}
r = sd_dhcp_lease_get_client_id(lease, &client_id, &client_id_len);
if (r >= 0) {
_cleanup_free_ char *id = NULL;
r = sd_dhcp_client_id_to_string(client_id, client_id_len, &id);
if (r >= 0) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "DHCP4 Client ID:",
TABLE_STRING, id);
if (r < 0)
return table_log_add_error(r);
}
}
} }
r = sd_network_link_get_dhcp6_client_iaid_string(info->ifindex, &iaid); r = sd_network_link_get_dhcp6_client_iaid_string(info->ifindex, &iaid);
@ -2147,7 +2172,7 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
r = dump_addresses(rtnl, table, 0); r = dump_addresses(rtnl, NULL, table, 0);
if (r < 0) if (r < 0)
return r; return r;
r = dump_gateways(rtnl, hwdb, table, 0); r = dump_gateways(rtnl, hwdb, table, 0);

View File

@ -4351,33 +4351,6 @@ int link_save(Link *link) {
print_link_hashmap(f, "CARRIER_BOUND_BY=", link->bound_by_links); print_link_hashmap(f, "CARRIER_BOUND_BY=", link->bound_by_links);
if (link->dhcp_lease) { if (link->dhcp_lease) {
struct in_addr address;
const char *tz = NULL;
size_t client_id_len;
const void *client_id;
assert(link->network);
r = sd_dhcp_lease_get_timezone(link->dhcp_lease, &tz);
if (r >= 0)
fprintf(f, "TIMEZONE=%s\n", tz);
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
if (r >= 0) {
fputs("DHCP4_ADDRESS=", f);
serialize_in_addrs(f, &address, 1, NULL, NULL);
fputc('\n', f);
}
r = sd_dhcp_lease_get_client_id(link->dhcp_lease, &client_id, &client_id_len);
if (r >= 0) {
_cleanup_free_ char *id = NULL;
r = sd_dhcp_client_id_to_string(client_id, client_id_len, &id);
if (r >= 0)
fprintf(f, "DHCP4_CLIENT_ID=%s\n", id);
}
r = dhcp_lease_save(link->dhcp_lease, link->lease_file); r = dhcp_lease_save(link->dhcp_lease, link->lease_file);
if (r < 0) if (r < 0)
goto fail; goto fail;

View File

@ -496,18 +496,16 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
return 1; return 1;
} else if (isempty(eq) && STR_IN_SET(field, "DefaultMemoryLow",
"DefaultMemoryMin",
"MemoryLow",
"MemoryMin")) {
/* We can't use CGROUP_LIMIT_MIN nor CGROUP_LIMIT_MAX to convey the empty assignment
* so marshall specially as a boolean. */
r = sd_bus_message_append(m, "(sv)", field, "b", 0);
if (r < 0)
return bus_log_create_error(r);
return 1;
} else if (isempty(eq)) { } else if (isempty(eq)) {
r = sd_bus_message_append(m, "(sv)", field, "t", CGROUP_LIMIT_MAX); uint64_t empty_value = STR_IN_SET(field,
"DefaultMemoryLow",
"DefaultMemoryMin",
"MemoryLow",
"MemoryMin") ?
CGROUP_LIMIT_MIN :
CGROUP_LIMIT_MAX;
r = sd_bus_message_append(m, "(sv)", field, "t", empty_value);
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
return 1; return 1;

View File

@ -110,10 +110,6 @@ int sd_network_link_get_network_file(int ifindex, char **filename);
* IP addresses */ * IP addresses */
int sd_network_link_get_dns(int ifindex, char ***ret); int sd_network_link_get_dns(int ifindex, char ***ret);
/* Get DHCP4 address for a given link. This is string representations of
* IPv4 address */
int sd_network_link_get_dhcp4_address(int ifindex, char **ret);
/* Get NTP entries for a given link. These are domain names or string /* Get NTP entries for a given link. These are domain names or string
* representations of IP addresses */ * representations of IP addresses */
int sd_network_link_get_ntp(int ifindex, char ***ret); int sd_network_link_get_ntp(int ifindex, char ***ret);
@ -173,12 +169,6 @@ int sd_network_link_get_carrier_bound_to(int ifindex, int **ifindexes);
/* Get the CARRIERS that are bound to current link. */ /* Get the CARRIERS that are bound to current link. */
int sd_network_link_get_carrier_bound_by(int ifindex, int **ifindexes); int sd_network_link_get_carrier_bound_by(int ifindex, int **ifindexes);
/* Get the timezone that was learnt on a specific link. */
int sd_network_link_get_timezone(int ifindex, char **timezone);
/* Get DHCPv4 client id for a given link. */
int sd_network_link_get_dhcp4_client_id_string(int ifindex, char **client_id);
/* Get DHCPv6 client IAID for a given link. */ /* Get DHCPv6 client IAID for a given link. */
int sd_network_link_get_dhcp6_client_iaid_string(int ifindex, char **iaid); int sd_network_link_get_dhcp6_client_iaid_string(int ifindex, char **iaid);

View File

@ -496,7 +496,7 @@ int xdg_autostart_service_generate_unit(
/* Nothing to do if type is not Application. */ /* Nothing to do if type is not Application. */
if (!streq_ptr(service->type, "Application")) { if (!streq_ptr(service->type, "Application")) {
log_info("Not generating service for XDG autostart %s, it is hidden.", service->name); log_info("Not generating service for XDG autostart %s, only Type=Application is supported.", service->name);
return 0; return 0;
} }
@ -527,8 +527,9 @@ int xdg_autostart_service_generate_unit(
return 0; return 0;
} }
if (streq_ptr(service->gnome_autostart_phase, "EarlyInitialization")) { if (service->gnome_autostart_phase) {
log_info("Not generating service for XDG autostart %s, EarlyInitialization needs to be handled separately.", /* There is no explicit value for the "Application" phase. */
log_info("Not generating service for XDG autostart %s, startup phases are not supported.",
service->name); service->name);
return 0; return 0;
} }
@ -563,10 +564,7 @@ int xdg_autostart_service_generate_unit(
fprintf(f, "Description=%s\n", t); fprintf(f, "Description=%s\n", t);
} }
/* Only start after the session is ready. /* Only start after the session is ready. */
* XXX: GNOME has an autostart order which we may want to support.
* It is not clear how this can be implemented reliably, which
* is why it is skipped for now. */
fprintf(f, fprintf(f,
"After=graphical-session.target\n"); "After=graphical-session.target\n");

View File

@ -12,13 +12,13 @@ for entry in chromiumos.gen_autosuspend_rules.PCI_IDS:
vendor, device = entry.split(':') vendor, device = entry.split(':')
vendor = int(vendor, 16) vendor = int(vendor, 16)
device = int(device, 16) device = int(device, 16)
print(f'pci:v{vendor:08X}d{device:08X}*') print('pci:v{:08X}d{:08X}*'.format(vendor, device))
print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice') print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice')
for entry in chromiumos.gen_autosuspend_rules.USB_IDS: for entry in chromiumos.gen_autosuspend_rules.USB_IDS:
vendor, product = entry.split(':') vendor, product = entry.split(':')
vendor = int(vendor, 16) vendor = int(vendor, 16)
product = int(product, 16) product = int(product, 16)
print(f'usb:v{vendor:04X}p{product:04X}*') print('usb:v{:04X}p{:04X}*'.format(vendor, product))
print(' ID_AUTOSUSPEND=1') print(' ID_AUTOSUSPEND=1')