mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
bootctl: honor $KERNEL_INSTALL_CONF_ROOT
Honor $KERNEL_INSTALL_CONF_ROOT for reading config files, as kernel-install does.
This commit is contained in:
parent
cd48e23f6a
commit
2e76ca79b3
@ -256,6 +256,9 @@ All tools:
|
|||||||
`--path=` switch only very superficial validation of the specified path is
|
`--path=` switch only very superficial validation of the specified path is
|
||||||
done when this environment variable is used.
|
done when this environment variable is used.
|
||||||
|
|
||||||
|
* `$KERNEL_INSTALL_CONF_ROOT=…` — override the built in default configuration
|
||||||
|
directory /etc/kernel/ to read files like entry-token and install.conf from.
|
||||||
|
|
||||||
`systemd` itself:
|
`systemd` itself:
|
||||||
|
|
||||||
* `$SYSTEMD_ACTIVATION_UNIT` — set for all NSS and PAM module invocations that
|
* `$SYSTEMD_ACTIVATION_UNIT` — set for all NSS and PAM module invocations that
|
||||||
|
@ -130,6 +130,7 @@ int fsck_exists_for_fstype(const char *fstype);
|
|||||||
|
|
||||||
/* Similar to path_join(), but only works for two components, and only the first one may be NULL and returns
|
/* Similar to path_join(), but only works for two components, and only the first one may be NULL and returns
|
||||||
* an alloca() buffer, or possibly a const pointer into the path parameter. */
|
* an alloca() buffer, or possibly a const pointer into the path parameter. */
|
||||||
|
/* DEPRECATED: use path_join() instead */
|
||||||
#define prefix_roota(root, path) \
|
#define prefix_roota(root, path) \
|
||||||
({ \
|
({ \
|
||||||
const char* _path = (path), *_root = (root), *_ret; \
|
const char* _path = (path), *_root = (root), *_ret; \
|
||||||
|
@ -77,15 +77,18 @@ static int load_etc_machine_info(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int load_etc_kernel_install_conf(void) {
|
static int load_etc_kernel_install_conf(void) {
|
||||||
_cleanup_free_ char *layout = NULL;
|
_cleanup_free_ char *layout = NULL, *p = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = parse_env_file(NULL, "/etc/kernel/install.conf",
|
p = path_join(etc_kernel(), "install.conf");
|
||||||
"layout", &layout);
|
if (!p)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
r = parse_env_file(NULL, p, "layout", &layout);
|
||||||
if (r == -ENOENT)
|
if (r == -ENOENT)
|
||||||
return 0;
|
return 0;
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to parse /etc/kernel/install.conf: %m");
|
return log_error_errno(r, "Failed to parse %s: %m", p);
|
||||||
|
|
||||||
if (!isempty(layout)) {
|
if (!isempty(layout)) {
|
||||||
log_debug("layout=%s is specified in /etc/machine-info.", layout);
|
log_debug("layout=%s is specified in /etc/machine-info.", layout);
|
||||||
@ -488,6 +491,7 @@ static int install_entry_directory(const char *root) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int install_entry_token(void) {
|
static int install_entry_token(void) {
|
||||||
|
_cleanup_free_ char* p = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(arg_make_entry_directory >= 0);
|
assert(arg_make_entry_directory >= 0);
|
||||||
@ -499,9 +503,13 @@ static int install_entry_token(void) {
|
|||||||
if (!arg_make_entry_directory && arg_entry_token_type == ARG_ENTRY_TOKEN_MACHINE_ID)
|
if (!arg_make_entry_directory && arg_entry_token_type == ARG_ENTRY_TOKEN_MACHINE_ID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = write_string_file("/etc/kernel/entry-token", arg_entry_token, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
|
p = path_join(etc_kernel(), "entry-token");
|
||||||
|
if (!p)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
r = write_string_file(p, arg_entry_token, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to write entry token '%s' to /etc/kernel/entry-token", arg_entry_token);
|
return log_error_errno(r, "Failed to write entry token '%s' to %s", arg_entry_token, p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "bootctl-util.h"
|
#include "bootctl-util.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "os-util.h"
|
#include "os-util.h"
|
||||||
|
#include "path-util.h"
|
||||||
#include "stat-util.h"
|
#include "stat-util.h"
|
||||||
#include "sync-util.h"
|
#include "sync-util.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
@ -118,10 +119,13 @@ int settle_entry_token(void) {
|
|||||||
switch (arg_entry_token_type) {
|
switch (arg_entry_token_type) {
|
||||||
|
|
||||||
case ARG_ENTRY_TOKEN_AUTO: {
|
case ARG_ENTRY_TOKEN_AUTO: {
|
||||||
_cleanup_free_ char *buf = NULL;
|
_cleanup_free_ char *buf = NULL, *p = NULL;
|
||||||
r = read_one_line_file("/etc/kernel/entry-token", &buf);
|
p = path_join(etc_kernel(), "entry-token");
|
||||||
|
if (!p)
|
||||||
|
return log_oom();
|
||||||
|
r = read_one_line_file(p, &buf);
|
||||||
if (r < 0 && r != -ENOENT)
|
if (r < 0 && r != -ENOENT)
|
||||||
return log_error_errno(r, "Failed to read /etc/kernel/entry-token: %m");
|
return log_error_errno(r, "Failed to read %s: %m", p);
|
||||||
|
|
||||||
if (!isempty(buf)) {
|
if (!isempty(buf)) {
|
||||||
free_and_replace(arg_entry_token, buf);
|
free_and_replace(arg_entry_token, buf);
|
||||||
|
@ -8,3 +8,7 @@ const char *get_efi_arch(void);
|
|||||||
int get_file_version(int fd, char **ret);
|
int get_file_version(int fd, char **ret);
|
||||||
|
|
||||||
int settle_entry_token(void);
|
int settle_entry_token(void);
|
||||||
|
|
||||||
|
static inline const char* etc_kernel(void) {
|
||||||
|
return getenv("KERNEL_INSTALL_CONF_ROOT") ?: "/etc/kernel/";
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user