mirror of
https://github.com/systemd/systemd
synced 2026-04-12 18:14:51 +02:00
Compare commits
7 Commits
a1a03fa54b
...
d5f8fd5b00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5f8fd5b00 | ||
|
|
1d18a466c4 | ||
|
|
07b0de6584 | ||
|
|
a7d15a2465 | ||
|
|
56a5f4969b | ||
|
|
49927ad813 | ||
|
|
d9f048b5d1 |
@ -1189,14 +1189,9 @@ static bool should_parse_proc_cmdline(void) {
|
||||
return getpid_cached() == p;
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
void log_parse_environment_variables(void) {
|
||||
const char *e;
|
||||
|
||||
/* Do not call from library code. */
|
||||
|
||||
if (should_parse_proc_cmdline())
|
||||
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
|
||||
|
||||
e = getenv("SYSTEMD_LOG_TARGET");
|
||||
if (e && log_set_target_from_string(e) < 0)
|
||||
log_warning("Failed to parse log target '%s'. Ignoring.", e);
|
||||
@ -1222,6 +1217,15 @@ void log_parse_environment(void) {
|
||||
log_warning("Failed to parse log tid '%s'. Ignoring.", e);
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
/* Do not call from library code. */
|
||||
|
||||
if (should_parse_proc_cmdline())
|
||||
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
|
||||
|
||||
log_parse_environment_variables();
|
||||
}
|
||||
|
||||
LogTarget log_get_target(void) {
|
||||
return log_target;
|
||||
}
|
||||
|
||||
@ -82,6 +82,7 @@ int log_open(void);
|
||||
void log_close(void);
|
||||
void log_forget_fds(void);
|
||||
|
||||
void log_parse_environment_variables(void);
|
||||
void log_parse_environment(void);
|
||||
|
||||
int log_dispatch_internal(
|
||||
|
||||
@ -1382,6 +1382,39 @@ static void print_yes_no_line(bool first, bool good, const char *name) {
|
||||
name);
|
||||
}
|
||||
|
||||
static int are_we_installed(void) {
|
||||
int r;
|
||||
|
||||
r = acquire_esp(/* privileged_mode= */ false, /* graceful= */ false, NULL, NULL, NULL, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Tests whether systemd-boot is installed. It's not obvious what to use as check here: we could
|
||||
* check EFI variables, we could check what binary /EFI/BOOT/BOOT*.EFI points to, or whether the
|
||||
* loader entries directory exists. Here we opted to check whether /EFI/systemd/ is non-empty, which
|
||||
* should be a suitable and very minimal check for a number of reasons:
|
||||
*
|
||||
* → The check is architecture independent (i.e. we check if any systemd-boot loader is installed,
|
||||
* not a specific one.)
|
||||
*
|
||||
* → It doesn't assume we are the only boot loader (i.e doesn't check if we own the main
|
||||
* /EFI/BOOT/BOOT*.EFI fallback binary.
|
||||
*
|
||||
* → It specifically checks for systemd-boot, not for other boot loaders (which a check for
|
||||
* /boot/loader/entries would do). */
|
||||
|
||||
_cleanup_free_ char *p = path_join(arg_esp_path, "/EFI/systemd/");
|
||||
if (!p)
|
||||
return log_oom();
|
||||
|
||||
log_debug("Checking whether %s contains any files…", p);
|
||||
r = dir_is_empty(p);
|
||||
if (r < 0 && r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check whether %s contains any files: %m", p);
|
||||
|
||||
return r == 0;
|
||||
}
|
||||
|
||||
static int verb_status(int argc, char *argv[], void *userdata) {
|
||||
sd_id128_t esp_uuid = SD_ID128_NULL, xbootldr_uuid = SD_ID128_NULL;
|
||||
int r, k;
|
||||
@ -1758,6 +1791,17 @@ static int verb_install(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!install) {
|
||||
/* If we are updating, don't do anything if sd-boot wasn't actually installed. */
|
||||
r = are_we_installed();
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0) {
|
||||
log_debug("Skipping update because sd-boot is not installed in the ESP.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
r = acquire_xbootldr(/* unprivileged_mode= */ false, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -1880,41 +1924,19 @@ static int verb_remove(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
|
||||
static int verb_is_installed(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int r;
|
||||
|
||||
r = acquire_esp(/* privileged_mode= */ false, /* graceful= */ false, NULL, NULL, NULL, NULL);
|
||||
r = are_we_installed();
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Tests whether systemd-boot is installed. It's not obvious what to use as check here: we could
|
||||
* check EFI variables, we could check what binary /EFI/BOOT/BOOT*.EFI points to, or whether the
|
||||
* loader entries directory exists. Here we opted to check whether /EFI/systemd/ is non-empty, which
|
||||
* should be a suitable and very minimal check for a number of reasons:
|
||||
*
|
||||
* → The check is architecture independent (i.e. we check if any systemd-boot loader is installed, not a
|
||||
* specific one.)
|
||||
*
|
||||
* → It doesn't assume we are the only boot loader (i.e doesn't check if we own the main
|
||||
* /EFI/BOOT/BOOT*.EFI fallback binary.
|
||||
*
|
||||
* → It specifically checks for systemd-boot, not for other boot loaders (which a check for
|
||||
* /boot/loader/entries would do). */
|
||||
|
||||
p = path_join(arg_esp_path, "/EFI/systemd/");
|
||||
if (!p)
|
||||
return log_oom();
|
||||
|
||||
r = dir_is_empty(p);
|
||||
if (r > 0 || r == -ENOENT) {
|
||||
if (r > 0) {
|
||||
puts("yes");
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
puts("no");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to detect whether systemd-boot is installed: %m");
|
||||
|
||||
puts("yes");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int parse_timeout(const char *arg1, char16_t **ret_timeout, size_t *ret_timeout_size) {
|
||||
|
||||
@ -646,9 +646,15 @@ static int dhcp6_configure(Link *link) {
|
||||
|
||||
r = sd_dhcp6_client_set_prefix_delegation(client, link->network->dhcp6_use_pd_prefix);
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to %s prefix delegation: %m",
|
||||
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to %s requesting prefixes to be delegated: %m",
|
||||
enable_disable(link->network->dhcp6_use_pd_prefix));
|
||||
|
||||
/* Even if UseAddress=no, we need to request IA_NA, as the dhcp6 client may be started in managed mode. */
|
||||
r = sd_dhcp6_client_set_address_request(client, link->network->dhcp6_use_pd_prefix ? link->network->dhcp6_use_address : true);
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to %s requesting address: %m",
|
||||
enable_disable(link->network->dhcp6_use_address));
|
||||
|
||||
if (link->network->dhcp6_pd_prefix_length > 0) {
|
||||
r = sd_dhcp6_client_set_prefix_delegation_hint(client,
|
||||
link->network->dhcp6_pd_prefix_length,
|
||||
|
||||
@ -22,14 +22,9 @@
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
static void setup_logging(void) {
|
||||
/* We need a dummy function because log_parse_environment is a macro. */
|
||||
log_parse_environment();
|
||||
}
|
||||
|
||||
static void setup_logging_once(void) {
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
assert_se(pthread_once(&once, setup_logging) == 0);
|
||||
assert_se(pthread_once(&once, log_parse_environment_variables) == 0);
|
||||
}
|
||||
|
||||
#define NSS_ENTRYPOINT_BEGIN \
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
static JsonDispatchFlags json_dispatch_flags = 0;
|
||||
|
||||
static void setup_logging(void) {
|
||||
log_parse_environment();
|
||||
log_parse_environment_variables();
|
||||
|
||||
if (DEBUG_LOGGING)
|
||||
json_dispatch_flags = JSON_LOG;
|
||||
|
||||
@ -116,14 +116,9 @@ static GetentData getsgent_data = {
|
||||
.mutex = PTHREAD_MUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
static void setup_logging(void) {
|
||||
/* We need a dummy function because log_parse_environment is a macro. */
|
||||
log_parse_environment();
|
||||
}
|
||||
|
||||
static void setup_logging_once(void) {
|
||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||
assert_se(pthread_once(&once, setup_logging) == 0);
|
||||
assert_se(pthread_once(&once, log_parse_environment_variables) == 0);
|
||||
}
|
||||
|
||||
#define NSS_ENTRYPOINT_BEGIN \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user