1
0
mirror of https://github.com/systemd/systemd synced 2026-04-12 18:14:51 +02:00

Compare commits

..

No commits in common. "d5f8fd5b00e938710b5e80396f8b3fab59dd6d00" and "a1a03fa54bfb45315eefaa49ceb38a21aceafde8" have entirely different histories.

7 changed files with 47 additions and 70 deletions

View File

@ -1189,9 +1189,14 @@ static bool should_parse_proc_cmdline(void) {
return getpid_cached() == p; return getpid_cached() == p;
} }
void log_parse_environment_variables(void) { void log_parse_environment(void) {
const char *e; 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"); e = getenv("SYSTEMD_LOG_TARGET");
if (e && log_set_target_from_string(e) < 0) if (e && log_set_target_from_string(e) < 0)
log_warning("Failed to parse log target '%s'. Ignoring.", e); log_warning("Failed to parse log target '%s'. Ignoring.", e);
@ -1217,15 +1222,6 @@ void log_parse_environment_variables(void) {
log_warning("Failed to parse log tid '%s'. Ignoring.", e); 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) { LogTarget log_get_target(void) {
return log_target; return log_target;
} }

View File

@ -82,7 +82,6 @@ int log_open(void);
void log_close(void); void log_close(void);
void log_forget_fds(void); void log_forget_fds(void);
void log_parse_environment_variables(void);
void log_parse_environment(void); void log_parse_environment(void);
int log_dispatch_internal( int log_dispatch_internal(

View File

@ -1382,39 +1382,6 @@ static void print_yes_no_line(bool first, bool good, const char *name) {
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) { static int verb_status(int argc, char *argv[], void *userdata) {
sd_id128_t esp_uuid = SD_ID128_NULL, xbootldr_uuid = SD_ID128_NULL; sd_id128_t esp_uuid = SD_ID128_NULL, xbootldr_uuid = SD_ID128_NULL;
int r, k; int r, k;
@ -1791,17 +1758,6 @@ static int verb_install(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; 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); r = acquire_xbootldr(/* unprivileged_mode= */ false, NULL);
if (r < 0) if (r < 0)
return r; return r;
@ -1924,19 +1880,41 @@ static int verb_remove(int argc, char *argv[], void *userdata) {
} }
static int verb_is_installed(int argc, char *argv[], void *userdata) { static int verb_is_installed(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *p = NULL;
int r; int r;
r = are_we_installed(); r = acquire_esp(/* privileged_mode= */ false, /* graceful= */ false, NULL, NULL, NULL, NULL);
if (r < 0) if (r < 0)
return r; return r;
if (r > 0) { /* Tests whether systemd-boot is installed. It's not obvious what to use as check here: we could
puts("yes"); * check EFI variables, we could check what binary /EFI/BOOT/BOOT*.EFI points to, or whether the
return EXIT_SUCCESS; * loader entries directory exists. Here we opted to check whether /EFI/systemd/ is non-empty, which
} else { * 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) {
puts("no"); puts("no");
return EXIT_FAILURE; 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) { static int parse_timeout(const char *arg1, char16_t **ret_timeout, size_t *ret_timeout_size) {

View File

@ -646,15 +646,9 @@ static int dhcp6_configure(Link *link) {
r = sd_dhcp6_client_set_prefix_delegation(client, link->network->dhcp6_use_pd_prefix); r = sd_dhcp6_client_set_prefix_delegation(client, link->network->dhcp6_use_pd_prefix);
if (r < 0) if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to %s requesting prefixes to be delegated: %m", return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to %s prefix delegation: %m",
enable_disable(link->network->dhcp6_use_pd_prefix)); 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) { if (link->network->dhcp6_pd_prefix_length > 0) {
r = sd_dhcp6_client_set_prefix_delegation_hint(client, r = sd_dhcp6_client_set_prefix_delegation_hint(client,
link->network->dhcp6_pd_prefix_length, link->network->dhcp6_pd_prefix_length,

View File

@ -22,9 +22,14 @@
#include "signal-util.h" #include "signal-util.h"
#include "string-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 void setup_logging_once(void) {
static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_once_t once = PTHREAD_ONCE_INIT;
assert_se(pthread_once(&once, log_parse_environment_variables) == 0); assert_se(pthread_once(&once, setup_logging) == 0);
} }
#define NSS_ENTRYPOINT_BEGIN \ #define NSS_ENTRYPOINT_BEGIN \

View File

@ -22,7 +22,7 @@
static JsonDispatchFlags json_dispatch_flags = 0; static JsonDispatchFlags json_dispatch_flags = 0;
static void setup_logging(void) { static void setup_logging(void) {
log_parse_environment_variables(); log_parse_environment();
if (DEBUG_LOGGING) if (DEBUG_LOGGING)
json_dispatch_flags = JSON_LOG; json_dispatch_flags = JSON_LOG;

View File

@ -116,9 +116,14 @@ static GetentData getsgent_data = {
.mutex = PTHREAD_MUTEX_INITIALIZER, .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 void setup_logging_once(void) {
static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_once_t once = PTHREAD_ONCE_INIT;
assert_se(pthread_once(&once, log_parse_environment_variables) == 0); assert_se(pthread_once(&once, setup_logging) == 0);
} }
#define NSS_ENTRYPOINT_BEGIN \ #define NSS_ENTRYPOINT_BEGIN \