Compare commits
15 Commits
cf33b70765
...
43e7dd70bc
Author | SHA1 | Date |
---|---|---|
Lennart Poettering | 43e7dd70bc | |
Lennart Poettering | 115fae8a07 | |
Lennart Poettering | f105d29b47 | |
Lennart Poettering | 6008336ffa | |
Lennart Poettering | dfc22cb472 | |
Lennart Poettering | d9067aba40 | |
Anita Zhang | 32ae9b1400 | |
Anita Zhang | 349a2003fd | |
Anita Zhang | f561e8c659 | |
Anita Zhang | 8922eddad6 | |
Anita Zhang | 620ed14e44 | |
Anita Zhang | 2801d36e25 | |
Anita Zhang | 3e9b4f9156 | |
Zbigniew Jędrzejewski-Szmek | ab4a88eb92 | |
Zbigniew Jędrzejewski-Szmek | 165fee860a |
|
@ -114,7 +114,23 @@ We define two directories below `$BOOT`:
|
||||||
|
|
||||||
**Note:** _In all cases the `/loader/` directory should be located directly in the root of the file system. Specifically, if `$BOOT` is the ESP, then `/loader/` directory should be located directly in the root directory of the ESP, and not in the `/EFI/` subdirectory._
|
**Note:** _In all cases the `/loader/` directory should be located directly in the root of the file system. Specifically, if `$BOOT` is the ESP, then `/loader/` directory should be located directly in the root directory of the ESP, and not in the `/EFI/` subdirectory._
|
||||||
|
|
||||||
Inside the `$BOOT/loader/entries/` directory each OS vendor may drop one or more configuration snippets with the suffix ".conf", one for each boot menu item. The file name of the file is used for identification of the boot item but shall never be presented to the user in the UI. The file name may be chosen freely but should be unique enough to avoid clashes between OS installations. More specifically it is suggested to include the machine ID (`/etc/machine-id` or the D-Bus machine ID for OSes that lack `/etc/machine-id`), the kernel version (as returned by `uname -r`) and an OS identifier (The ID field of `/etc/os-release`). Example: `$BOOT/loader/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf`.
|
Inside the `$BOOT/loader/entries/` directory each OS vendor may drop one or
|
||||||
|
more configuration snippets with the suffix ".conf", one for each boot menu
|
||||||
|
item. The file name of the file is used for identification of the boot item but
|
||||||
|
shall never be presented to the user in the UI. The file name may be chosen
|
||||||
|
freely but should be unique enough to avoid clashes between OS
|
||||||
|
installations. More specifically it is suggested to include the machine ID
|
||||||
|
(`/etc/machine-id` or the D-Bus machine ID for OSes that lack
|
||||||
|
`/etc/machine-id`), the kernel version (as returned by `uname -r`) and an OS
|
||||||
|
identifier (The ID field of `/etc/os-release`). Example:
|
||||||
|
`$BOOT/loader/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf`.
|
||||||
|
|
||||||
|
In order to maximize compatibility with file system implementations and
|
||||||
|
restricted boot loader environments, and to minimize conflicting character use
|
||||||
|
with other progams, file names shall be chosen from a restricted character set:
|
||||||
|
ASCII upper and lower case characters, digits, "+", "-", "_" and ".". Also, the
|
||||||
|
file names should have a length of at least one and at most 255 characters
|
||||||
|
(including file name suffix).
|
||||||
|
|
||||||
These configuration snippets shall be Unix-style text files (i.e. line separation with a single newline character), in the UTF-8 encoding. The configuration snippets are loosely inspired on Grub1's configuration syntax. Lines beginning with '#' shall be ignored and used for commenting. The first word of a line is used as key and shall be separated by one or more spaces from its value. The following keys are known:
|
These configuration snippets shall be Unix-style text files (i.e. line separation with a single newline character), in the UTF-8 encoding. The configuration snippets are loosely inspired on Grub1's configuration syntax. Lines beginning with '#' shall be ignored and used for commenting. The first word of a line is used as key and shall be separated by one or more spaces from its value. The following keys are known:
|
||||||
|
|
||||||
|
@ -171,6 +187,10 @@ extension `.efi`. Support for images of this type is of course specific to
|
||||||
systems with EFI firmware. Ignore this section if you work on systems not
|
systems with EFI firmware. Ignore this section if you work on systems not
|
||||||
supporting EFI.
|
supporting EFI.
|
||||||
|
|
||||||
|
Type #2 file names should be chosen from the same restricted character set as
|
||||||
|
Type #1 described above (but use a different file name suffix of `.efi` instead
|
||||||
|
of `.conf`).
|
||||||
|
|
||||||
Images of this type have the advantage that all metadata and payload that makes
|
Images of this type have the advantage that all metadata and payload that makes
|
||||||
up the boot entry is monopolized in a single PE file that can be signed
|
up the boot entry is monopolized in a single PE file that can be signed
|
||||||
cryptographically as one for the purpose of EFI SecureBoot.
|
cryptographically as one for the purpose of EFI SecureBoot.
|
||||||
|
|
|
@ -276,13 +276,20 @@
|
||||||
<para>Returned errors may indicate the following problems:</para>
|
<para>Returned errors may indicate the following problems:</para>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><constant>-EINVAL</constant></term>
|
<term><constant>-EINVAL</constant></term>
|
||||||
|
|
||||||
<listitem><para>The specified parameters are invalid.</para></listitem>
|
<listitem><para>The specified parameters are invalid.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><constant>-ENOMEDIUM</constant></term>
|
||||||
|
|
||||||
|
<listitem><para>The requested bus type is not available because of invalid environment (for example
|
||||||
|
the user session bus is not available because <varname>$XDG_RUNTIME_DIR</varname> is not set).
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><constant>-ENOMEM</constant></term>
|
<term><constant>-ENOMEM</constant></term>
|
||||||
|
|
||||||
|
|
|
@ -129,11 +129,11 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to set address: %m");
|
return bus_log_address_error(r);
|
||||||
|
|
||||||
r = sd_bus_start(bus);
|
r = sd_bus_start(bus);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
return bus_log_connect_error(r);
|
||||||
|
|
||||||
*ret = TAKE_PTR(bus);
|
*ret = TAKE_PTR(bus);
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,9 @@ static bool user_match_lookup_parameters(LookupParameters *p, const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int build_managed_oom_json_array_element(Unit *u, const char *property, JsonVariant **ret_v) {
|
static int build_managed_oom_json_array_element(Unit *u, const char *property, JsonVariant **ret_v) {
|
||||||
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
|
bool use_limit = false;
|
||||||
CGroupContext *c;
|
CGroupContext *c;
|
||||||
const char *mode;
|
const char *mode;
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
assert(property);
|
assert(property);
|
||||||
|
@ -74,19 +73,17 @@ static int build_managed_oom_json_array_element(Unit *u, const char *property, J
|
||||||
mode = managed_oom_mode_to_string(MANAGED_OOM_AUTO);
|
mode = managed_oom_mode_to_string(MANAGED_OOM_AUTO);
|
||||||
else if (streq(property, "ManagedOOMSwap"))
|
else if (streq(property, "ManagedOOMSwap"))
|
||||||
mode = managed_oom_mode_to_string(c->moom_swap);
|
mode = managed_oom_mode_to_string(c->moom_swap);
|
||||||
else if (streq(property, "ManagedOOMMemoryPressure"))
|
else if (streq(property, "ManagedOOMMemoryPressure")) {
|
||||||
mode = managed_oom_mode_to_string(c->moom_mem_pressure);
|
mode = managed_oom_mode_to_string(c->moom_mem_pressure);
|
||||||
else
|
use_limit = true;
|
||||||
|
} else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
r = json_build(&v, JSON_BUILD_OBJECT(
|
return json_build(ret_v, JSON_BUILD_OBJECT(
|
||||||
JSON_BUILD_PAIR("mode", JSON_BUILD_STRING(mode)),
|
JSON_BUILD_PAIR("mode", JSON_BUILD_STRING(mode)),
|
||||||
JSON_BUILD_PAIR("path", JSON_BUILD_STRING(u->cgroup_path)),
|
JSON_BUILD_PAIR("path", JSON_BUILD_STRING(u->cgroup_path)),
|
||||||
JSON_BUILD_PAIR("property", JSON_BUILD_STRING(property)),
|
JSON_BUILD_PAIR("property", JSON_BUILD_STRING(property)),
|
||||||
JSON_BUILD_PAIR("limit", JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit))));
|
JSON_BUILD_PAIR_CONDITION(use_limit, "limit", JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit))));
|
||||||
|
|
||||||
*ret_v = TAKE_PTR(v);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int manager_varlink_send_managed_oom_update(Unit *u) {
|
int manager_varlink_send_managed_oom_update(Unit *u) {
|
||||||
|
@ -478,10 +475,8 @@ void manager_varlink_done(Manager *m) {
|
||||||
assert(m);
|
assert(m);
|
||||||
|
|
||||||
/* Send the final message if we still have a subscribe request open. */
|
/* Send the final message if we still have a subscribe request open. */
|
||||||
if (m->managed_oom_varlink_request) {
|
if (m->managed_oom_varlink_request)
|
||||||
(void) varlink_error(m->managed_oom_varlink_request, VARLINK_ERROR_DISCONNECTED, NULL);
|
m->managed_oom_varlink_request = varlink_close_unref(m->managed_oom_varlink_request);
|
||||||
m->managed_oom_varlink_request = varlink_unref(m->managed_oom_varlink_request);
|
|
||||||
}
|
|
||||||
|
|
||||||
m->varlink_server = varlink_server_unref(m->varlink_server);
|
m->varlink_server = varlink_server_unref(m->varlink_server);
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ $1.IPIngressFilterPath, config_parse_ip_filter_bpf_progs, 0,
|
||||||
$1.IPEgressFilterPath, config_parse_ip_filter_bpf_progs, 0, offsetof($1, cgroup_context.ip_filters_egress)
|
$1.IPEgressFilterPath, config_parse_ip_filter_bpf_progs, 0, offsetof($1, cgroup_context.ip_filters_egress)
|
||||||
$1.ManagedOOMSwap, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_swap)
|
$1.ManagedOOMSwap, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_swap)
|
||||||
$1.ManagedOOMMemoryPressure, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_mem_pressure)
|
$1.ManagedOOMMemoryPressure, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_mem_pressure)
|
||||||
$1.ManagedOOMMemoryPressureLimitPercent,config_parse_managed_oom_mem_pressure_limit,0, offsetof($1, cgroup_context)
|
$1.ManagedOOMMemoryPressureLimitPercent, config_parse_managed_oom_mem_pressure_limit, 0, offsetof($1, cgroup_context.moom_mem_pressure_limit)
|
||||||
$1.NetClass, config_parse_warn_compat, DISABLED_LEGACY, 0'
|
$1.NetClass, config_parse_warn_compat, DISABLED_LEGACY, 0'
|
||||||
)m4_dnl
|
)m4_dnl
|
||||||
Unit.Description, config_parse_unit_string_printf, 0, offsetof(Unit, description)
|
Unit.Description, config_parse_unit_string_printf, 0, offsetof(Unit, description)
|
||||||
|
@ -277,7 +277,7 @@ Unit.RebootArgument, config_parse_unit_string_printf, 0,
|
||||||
Unit.ConditionPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, conditions)
|
Unit.ConditionPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, conditions)
|
||||||
Unit.ConditionPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, conditions)
|
Unit.ConditionPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, conditions)
|
||||||
Unit.ConditionPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, conditions)
|
Unit.ConditionPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, conditions)
|
||||||
Unit.ConditionPathIsSymbolicLink,config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK,offsetof(Unit, conditions)
|
Unit.ConditionPathIsSymbolicLink, config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK, offsetof(Unit, conditions)
|
||||||
Unit.ConditionPathIsMountPoint, config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT, offsetof(Unit, conditions)
|
Unit.ConditionPathIsMountPoint, config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT, offsetof(Unit, conditions)
|
||||||
Unit.ConditionPathIsReadWrite, config_parse_unit_condition_path, CONDITION_PATH_IS_READ_WRITE, offsetof(Unit, conditions)
|
Unit.ConditionPathIsReadWrite, config_parse_unit_condition_path, CONDITION_PATH_IS_READ_WRITE, offsetof(Unit, conditions)
|
||||||
Unit.ConditionPathIsEncrypted, config_parse_unit_condition_path, CONDITION_PATH_IS_ENCRYPTED, offsetof(Unit, conditions)
|
Unit.ConditionPathIsEncrypted, config_parse_unit_condition_path, CONDITION_PATH_IS_ENCRYPTED, offsetof(Unit, conditions)
|
||||||
|
@ -303,7 +303,7 @@ Unit.ConditionControlGroupController, config_parse_unit_condition_string, CONDIT
|
||||||
Unit.AssertPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, asserts)
|
Unit.AssertPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, asserts)
|
Unit.AssertPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, asserts)
|
Unit.AssertPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathIsSymbolicLink, config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK,offsetof(Unit, asserts)
|
Unit.AssertPathIsSymbolicLink, config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathIsMountPoint, config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT, offsetof(Unit, asserts)
|
Unit.AssertPathIsMountPoint, config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathIsReadWrite, config_parse_unit_condition_path, CONDITION_PATH_IS_READ_WRITE, offsetof(Unit, asserts)
|
Unit.AssertPathIsReadWrite, config_parse_unit_condition_path, CONDITION_PATH_IS_READ_WRITE, offsetof(Unit, asserts)
|
||||||
Unit.AssertPathIsEncrypted, config_parse_unit_condition_path, CONDITION_PATH_IS_ENCRYPTED, offsetof(Unit, asserts)
|
Unit.AssertPathIsEncrypted, config_parse_unit_condition_path, CONDITION_PATH_IS_ENCRYPTED, offsetof(Unit, asserts)
|
||||||
|
|
|
@ -3824,7 +3824,6 @@ int config_parse_managed_oom_mode(
|
||||||
const char *rvalue,
|
const char *rvalue,
|
||||||
void *data,
|
void *data,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
Unit *u = userdata;
|
|
||||||
ManagedOOMMode *mode = data, m;
|
ManagedOOMMode *mode = data, m;
|
||||||
UnitType t;
|
UnitType t;
|
||||||
|
|
||||||
|
@ -3836,7 +3835,7 @@ int config_parse_managed_oom_mode(
|
||||||
|
|
||||||
if (isempty(rvalue)) {
|
if (isempty(rvalue)) {
|
||||||
*mode = MANAGED_OOM_AUTO;
|
*mode = MANAGED_OOM_AUTO;
|
||||||
goto finish;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m = managed_oom_mode_from_string(rvalue);
|
m = managed_oom_mode_from_string(rvalue);
|
||||||
|
@ -3845,9 +3844,6 @@ int config_parse_managed_oom_mode(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*mode = m;
|
*mode = m;
|
||||||
|
|
||||||
finish:
|
|
||||||
(void) manager_varlink_send_managed_oom_update(u);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3862,8 +3858,7 @@ int config_parse_managed_oom_mem_pressure_limit(
|
||||||
const char *rvalue,
|
const char *rvalue,
|
||||||
void *data,
|
void *data,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
Unit *u = userdata;
|
int *limit = data;
|
||||||
CGroupContext *c = data;
|
|
||||||
UnitType t;
|
UnitType t;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -3874,8 +3869,8 @@ int config_parse_managed_oom_mem_pressure_limit(
|
||||||
return log_syntax(unit, LOG_WARNING, filename, line, 0, "%s= is not supported for this unit type, ignoring.", lvalue);
|
return log_syntax(unit, LOG_WARNING, filename, line, 0, "%s= is not supported for this unit type, ignoring.", lvalue);
|
||||||
|
|
||||||
if (isempty(rvalue)) {
|
if (isempty(rvalue)) {
|
||||||
c->moom_mem_pressure_limit = 0;
|
*limit = 0;
|
||||||
goto finish;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = parse_percent(rvalue);
|
r = parse_percent(rvalue);
|
||||||
|
@ -3884,12 +3879,7 @@ int config_parse_managed_oom_mem_pressure_limit(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->moom_mem_pressure_limit = r;
|
*limit = r;
|
||||||
|
|
||||||
finish:
|
|
||||||
/* Only update the limit if memory pressure detection is enabled because the information is irrelevant otherwise */
|
|
||||||
if (c->moom_mem_pressure == MANAGED_OOM_KILL)
|
|
||||||
(void) manager_varlink_send_managed_oom_update(u);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1684,6 +1684,7 @@ int unit_load(Unit *u) {
|
||||||
|
|
||||||
unit_add_to_dbus_queue(unit_follow_merge(u));
|
unit_add_to_dbus_queue(unit_follow_merge(u));
|
||||||
unit_add_to_gc_queue(u);
|
unit_add_to_gc_queue(u);
|
||||||
|
(void) manager_varlink_send_managed_oom_update(u);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2630,7 +2631,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
|
||||||
* sets one of the ManagedOOM*= properties to "kill", then later removes it. systemd-oomd needs to
|
* sets one of the ManagedOOM*= properties to "kill", then later removes it. systemd-oomd needs to
|
||||||
* know to stop monitoring when the unit changes from "kill" -> "auto" on daemon-reload, but we don't
|
* know to stop monitoring when the unit changes from "kill" -> "auto" on daemon-reload, but we don't
|
||||||
* have the information on the property. Thus, indiscriminately send an update. */
|
* have the information on the property. Thus, indiscriminately send an update. */
|
||||||
if (UNIT_IS_INACTIVE_OR_FAILED(ns) || ns == UNIT_ACTIVE)
|
if (UNIT_IS_INACTIVE_OR_FAILED(ns) || UNIT_IS_ACTIVE_OR_RELOADING(ns))
|
||||||
(void) manager_varlink_send_managed_oom_update(u);
|
(void) manager_varlink_send_managed_oom_update(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ static int acquire_bus(sd_bus **bus) {
|
||||||
|
|
||||||
r = bus_connect_transport(arg_transport, arg_host, false, bus);
|
r = bus_connect_transport(arg_transport, arg_host, false, bus);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
return bus_log_connect_error(r);
|
||||||
|
|
||||||
(void) sd_bus_set_allow_interactive_authorization(*bus, arg_ask_password);
|
(void) sd_bus_set_allow_interactive_authorization(*bus, arg_ask_password);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "namespace-util.h"
|
#include "namespace-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
|
#include "string-util.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
int bus_container_connect_socket(sd_bus *b) {
|
int bus_container_connect_socket(sd_bus *b) {
|
||||||
|
@ -24,10 +25,15 @@ int bus_container_connect_socket(sd_bus *b) {
|
||||||
assert(b->nspid > 0 || b->machine);
|
assert(b->nspid > 0 || b->machine);
|
||||||
|
|
||||||
if (b->nspid <= 0) {
|
if (b->nspid <= 0) {
|
||||||
|
log_debug("sd-bus: connecting bus%s%s to machine %s...",
|
||||||
|
b->description ? " " : "", strempty(b->description), b->machine);
|
||||||
|
|
||||||
r = container_get_leader(b->machine, &b->nspid);
|
r = container_get_leader(b->machine, &b->nspid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
} else
|
||||||
|
log_debug("sd-bus: connecting bus%s%s to namespace of PID "PID_FMT"...",
|
||||||
|
b->description ? " " : "", strempty(b->description), b->nspid);
|
||||||
|
|
||||||
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &usernsfd, &rootfd);
|
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &usernsfd, &rootfd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -885,6 +885,13 @@ int bus_socket_connect(sd_bus *b) {
|
||||||
assert(b->output_fd < 0);
|
assert(b->output_fd < 0);
|
||||||
assert(b->sockaddr.sa.sa_family != AF_UNSPEC);
|
assert(b->sockaddr.sa.sa_family != AF_UNSPEC);
|
||||||
|
|
||||||
|
if (DEBUG_LOGGING) {
|
||||||
|
_cleanup_free_ char *pretty = NULL;
|
||||||
|
(void) sockaddr_pretty(&b->sockaddr.sa, b->sockaddr_size, false, true, &pretty);
|
||||||
|
log_debug("sd-bus: starting bus%s%s by connecting to %s...",
|
||||||
|
b->description ? " " : "", strempty(b->description), strnull(pretty));
|
||||||
|
}
|
||||||
|
|
||||||
b->input_fd = socket(b->sockaddr.sa.sa_family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
|
b->input_fd = socket(b->sockaddr.sa.sa_family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
|
||||||
if (b->input_fd < 0)
|
if (b->input_fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -956,6 +963,9 @@ int bus_socket_exec(sd_bus *b) {
|
||||||
assert(b->exec_path);
|
assert(b->exec_path);
|
||||||
assert(b->busexec_pid == 0);
|
assert(b->busexec_pid == 0);
|
||||||
|
|
||||||
|
log_debug("sd-bus: starting bus%s%s with %s...",
|
||||||
|
b->description ? " " : "", strempty(b->description), b->exec_path);
|
||||||
|
|
||||||
r = socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, s);
|
r = socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, s);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
@ -1155,6 +1155,16 @@ static int bus_start_fd(sd_bus *b) {
|
||||||
assert(b->input_fd >= 0);
|
assert(b->input_fd >= 0);
|
||||||
assert(b->output_fd >= 0);
|
assert(b->output_fd >= 0);
|
||||||
|
|
||||||
|
if (DEBUG_LOGGING) {
|
||||||
|
_cleanup_free_ char *pi = NULL, *po = NULL;
|
||||||
|
(void) fd_get_path(b->input_fd, &pi);
|
||||||
|
(void) fd_get_path(b->output_fd, &po);
|
||||||
|
log_debug("sd-bus: starting bus%s%s on fds %d/%d (%s, %s)...",
|
||||||
|
b->description ? " " : "", strempty(b->description),
|
||||||
|
b->input_fd, b->output_fd,
|
||||||
|
pi ?: "???", po ?: "???");
|
||||||
|
}
|
||||||
|
|
||||||
r = fd_nonblock(b->input_fd, true);
|
r = fd_nonblock(b->input_fd, true);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -1330,7 +1340,8 @@ int bus_set_address_user(sd_bus *b) {
|
||||||
|
|
||||||
e = secure_getenv("XDG_RUNTIME_DIR");
|
e = secure_getenv("XDG_RUNTIME_DIR");
|
||||||
if (!e)
|
if (!e)
|
||||||
return -ENOENT;
|
return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM),
|
||||||
|
"sd-bus: $XDG_RUNTIME_DIR not set, cannot connect to user bus.");
|
||||||
|
|
||||||
ee = bus_address_escape(e);
|
ee = bus_address_escape(e);
|
||||||
if (!ee)
|
if (!ee)
|
||||||
|
|
|
@ -23,7 +23,7 @@ static int test_bus_open(void) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_open_user(&bus);
|
r = sd_bus_open_user(&bus);
|
||||||
if (IN_SET(r, -ECONNREFUSED, -ENOENT)) {
|
if (IN_SET(r, -ECONNREFUSED, -ENOENT, -ENOMEDIUM)) {
|
||||||
r = sd_bus_open_system(&bus);
|
r = sd_bus_open_system(&bus);
|
||||||
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
|
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
|
|
||||||
r = sd_bus_open_user(&a);
|
r = sd_bus_open_user(&a);
|
||||||
if (IN_SET(r, -ECONNREFUSED, -ENOENT)) {
|
if (IN_SET(r, -ECONNREFUSED, -ENOENT, -ENOMEDIUM)) {
|
||||||
r = sd_bus_open_system(&a);
|
r = sd_bus_open_system(&a);
|
||||||
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
|
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
|
||||||
return log_tests_skipped("Failed to connect to bus");
|
return log_tests_skipped("Failed to connect to bus");
|
||||||
|
|
|
@ -282,7 +282,7 @@ static int run(int argc, char *argv[]) {
|
||||||
|
|
||||||
r = sd_bus_default_system(&bus);
|
r = sd_bus_default_system(&bus);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
return bus_log_connect_error(r);
|
||||||
|
|
||||||
if (arg_action == ACTION_LIST)
|
if (arg_action == ACTION_LIST)
|
||||||
return print_inhibitors(bus);
|
return print_inhibitors(bus);
|
||||||
|
|
|
@ -170,15 +170,12 @@ static int recursively_get_cgroup_context(Hashmap *new_h, const char *path) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return (r == -ENOMEM) ? r : 0;
|
return (r == -ENOMEM) ? r : 0;
|
||||||
|
|
||||||
if (oom_group) {
|
if (oom_group)
|
||||||
r = oomd_insert_cgroup_context(NULL, new_h, cg_path);
|
r = oomd_insert_cgroup_context(NULL, new_h, cg_path);
|
||||||
if (r == -ENOMEM)
|
else
|
||||||
return r;
|
|
||||||
} else {
|
|
||||||
r = recursively_get_cgroup_context(new_h, cg_path);
|
r = recursively_get_cgroup_context(new_h, cg_path);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
} while ((r = cg_read_subgroup(d, &subpath)) > 0);
|
} while ((r = cg_read_subgroup(d, &subpath)) > 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -39,6 +39,7 @@ static int fork_and_sleep(unsigned sleep_min) {
|
||||||
static void test_oomd_cgroup_kill(void) {
|
static void test_oomd_cgroup_kill(void) {
|
||||||
_cleanup_free_ char *cgroup_root = NULL, *cgroup = NULL;
|
_cleanup_free_ char *cgroup_root = NULL, *cgroup = NULL;
|
||||||
int pid[2];
|
int pid[2];
|
||||||
|
int r;
|
||||||
|
|
||||||
if (geteuid() != 0)
|
if (geteuid() != 0)
|
||||||
return (void) log_tests_skipped("not root");
|
return (void) log_tests_skipped("not root");
|
||||||
|
@ -52,19 +53,20 @@ static void test_oomd_cgroup_kill(void) {
|
||||||
* by the test so that pid1 doesn't delete it before we can read the xattrs. */
|
* by the test so that pid1 doesn't delete it before we can read the xattrs. */
|
||||||
cgroup = path_join(cgroup_root, "oomdkilltest");
|
cgroup = path_join(cgroup_root, "oomdkilltest");
|
||||||
assert(cgroup);
|
assert(cgroup);
|
||||||
|
assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, cgroup) >= 0);
|
||||||
|
|
||||||
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities */
|
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities */
|
||||||
if (cg_set_xattr(SYSTEMD_CGROUP_CONTROLLER, cgroup, "user.oomd_test", "test", 4, 0) == -EPERM)
|
r = cg_set_xattr(SYSTEMD_CGROUP_CONTROLLER, cgroup, "user.oomd_test", "test", 4, 0);
|
||||||
return (void) log_tests_skipped("no permissions to set user xattrs");
|
if (IN_SET(r, -EPERM, -ENOTSUP))
|
||||||
|
return (void) log_tests_skipped("Cannot set user xattrs");
|
||||||
|
|
||||||
/* Do this twice to also check the increment behavior on the xattrs */
|
/* Do this twice to also check the increment behavior on the xattrs */
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
_cleanup_free_ char *v = NULL;
|
_cleanup_free_ char *v = NULL;
|
||||||
int r;
|
|
||||||
|
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
pid[j] = fork_and_sleep(5);
|
pid[j] = fork_and_sleep(5);
|
||||||
assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, cgroup, pid[j]) >= 0);
|
assert_se(cg_attach(SYSTEMD_CGROUP_CONTROLLER, cgroup, pid[j]) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = oomd_cgroup_kill(cgroup, false /* recurse */, false /* dry run */);
|
r = oomd_cgroup_kill(cgroup, false /* recurse */, false /* dry run */);
|
||||||
|
|
|
@ -178,7 +178,7 @@ static int acquire_bus(sd_bus **bus) {
|
||||||
|
|
||||||
r = bus_connect_transport(arg_transport, arg_host, false, bus);
|
r = bus_connect_transport(arg_transport, arg_host, false, bus);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
return bus_log_connect_error(r);
|
||||||
|
|
||||||
(void) sd_bus_set_allow_interactive_authorization(*bus, arg_ask_password);
|
(void) sd_bus_set_allow_interactive_authorization(*bus, arg_ask_password);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ static int boot_entry_load(
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
if (!efi_loader_entry_name_valid(tmp.id))
|
if (!efi_loader_entry_name_valid(tmp.id))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry: %s", tmp.id);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry name: %s", tmp.id);
|
||||||
|
|
||||||
tmp.path = strdup(path);
|
tmp.path = strdup(path);
|
||||||
if (!tmp.path)
|
if (!tmp.path)
|
||||||
|
@ -327,7 +327,7 @@ static int boot_entry_load_unified(
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
if (!efi_loader_entry_name_valid(tmp.id))
|
if (!efi_loader_entry_name_valid(tmp.id))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry: %s", tmp.id);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry name: %s", tmp.id);
|
||||||
|
|
||||||
tmp.path = strdup(path);
|
tmp.path = strdup(path);
|
||||||
if (!tmp.path)
|
if (!tmp.path)
|
||||||
|
|
|
@ -38,8 +38,14 @@ int bus_connect_user_systemd(sd_bus **_bus);
|
||||||
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||||
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||||
|
|
||||||
|
#define bus_log_address_error(r) \
|
||||||
|
log_error_errno(r, \
|
||||||
|
r == -ENOMEDIUM ? "Failed to set bus address: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined" : \
|
||||||
|
"Failed to set bus address: %m")
|
||||||
#define bus_log_connect_error(r) \
|
#define bus_log_connect_error(r) \
|
||||||
log_error_errno(r, "Failed to create bus connection: %m")
|
log_error_errno(r, \
|
||||||
|
r == -ENOMEDIUM ? "Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined" : \
|
||||||
|
"Failed to connect to bus: %m")
|
||||||
|
|
||||||
#define bus_log_parse_error(r) \
|
#define bus_log_parse_error(r) \
|
||||||
log_error_errno(r, "Failed to parse bus message: %m")
|
log_error_errno(r, "Failed to parse bus message: %m")
|
||||||
|
|
|
@ -52,7 +52,7 @@ int acquire_bus(BusFocus focus, sd_bus **ret) {
|
||||||
else
|
else
|
||||||
r = bus_connect_transport(arg_transport, arg_host, user, &buses[focus]);
|
r = bus_connect_transport(arg_transport, arg_host, user, &buses[focus]);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
return bus_log_connect_error(r);
|
||||||
|
|
||||||
(void) sd_bus_set_allow_interactive_authorization(buses[focus], arg_ask_password);
|
(void) sd_bus_set_allow_interactive_authorization(buses[focus], arg_ask_password);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1063,7 +1063,7 @@ static int parse_acls_from_arg(Item *item) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_warning_errno(r, "Failed to parse ACL \"%s\": %m. Ignoring", item->argument);
|
log_warning_errno(r, "Failed to parse ACL \"%s\": %m. Ignoring", item->argument);
|
||||||
#else
|
#else
|
||||||
log_warning_errno(SYNTHETIC_ERRNO(ENOSYS), "ACLs are not supported. Ignoring");
|
log_warning("ACLs are not supported. Ignoring.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Userspace Out-Of-Memory (OOM) Killer
|
Description=Userspace Out-Of-Memory (OOM) Killer
|
||||||
Documentation=man:systemd-oomd.service(8)
|
Documentation=man:systemd-oomd.service(8)
|
||||||
ConditionCapability=CAP_KILL
|
|
||||||
DefaultDependencies=no
|
DefaultDependencies=no
|
||||||
Before=multi-user.target shutdown.target
|
Before=multi-user.target shutdown.target
|
||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
|
|
Loading…
Reference in New Issue