credentials: add policy that can allow key=null creds from the ESP
This commit adds a new `systemd.credentials_boot_policy=` kernel commandline that allows to control if credentials with a `null` key are accepted. The possible options are: * strict: always insist on tpm encryption * tofu: allow null encryption in firstboot mode and when no tpm is available * relaxed: allow null encryption when sb is off, or no tpm is available * off: allow null encryption always The default is currently `relaxed` which is the same behavior as before. This replaces the initial idea of using plaintext credentials at firstboot (thanks to Lennart for this nicer and simpler design). Note that this also moves `in_first_boot()` to `basic/initrd-util` which is a better fit now.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "initrd-util.h"
|
||||
#include "log.h"
|
||||
#include "parse-util.h"
|
||||
|
||||
static int saved_in_initrd = -1;
|
||||
|
||||
@@ -38,3 +40,25 @@ bool in_initrd(void) {
|
||||
void in_initrd_force(bool value) {
|
||||
saved_in_initrd = value;
|
||||
}
|
||||
|
||||
bool in_first_boot(void) {
|
||||
static int first_boot = -1;
|
||||
int r;
|
||||
|
||||
if (first_boot >= 0)
|
||||
return first_boot;
|
||||
|
||||
const char *e = secure_getenv("SYSTEMD_FIRST_BOOT");
|
||||
if (e) {
|
||||
r = parse_boolean(e);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to parse $SYSTEMD_FIRST_BOOT, ignoring: %m");
|
||||
else
|
||||
return (first_boot = r);
|
||||
}
|
||||
|
||||
r = RET_NERRNO(access("/run/systemd/first-boot", F_OK));
|
||||
if (r < 0 && r != -ENOENT)
|
||||
log_debug_errno(r, "Failed to check if /run/systemd/first-boot exists, assuming no: %m");
|
||||
return r >= 0;
|
||||
}
|
||||
|
||||
@@ -5,3 +5,5 @@
|
||||
|
||||
bool in_initrd(void);
|
||||
void in_initrd_force(bool value);
|
||||
|
||||
bool in_first_boot(void);
|
||||
|
||||
Reference in New Issue
Block a user