From dbab170b9ef2a8c00b88c8dfb89de47009e8ffbb Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Tue, 10 Dec 2024 09:40:43 +0900
Subject: [PATCH 1054/1160] journalctl: honor --quiet with --setup-keys
Closes #35504.
(cherry picked from commit a5b2973850e5952b9dffdfa3f6a0ef486957cb17)
(cherry picked from commit 644f2a02c8befba986ebbc5d58767807fb2999ee)
(cherry picked from commit c03e3169ddd663c6d3aaea3df7af0031fe00cf5c)
src/journal/journalctl.c | 15 +++++++++------
test/units/testsuite-04.fss.sh | 6 ++++--
2 files changed, 13 insertions(+), 8 deletions(-)
@@ -1672,15 +1672,18 @@ static int setup_keys(void) {
state_size = FSPRG_stateinbytes(FSPRG_RECOMMENDED_SECPAR);
state = alloca_safe(state_size);
- log_info("Generating seed...");
+ if (!arg_quiet)
+ log_info("Generating seed...");
r = crypto_random_bytes(seed, seed_size);
if (r < 0)
return log_error_errno(r, "Failed to acquire random seed: %m");
- log_info("Generating key pair...");
+ if (!arg_quiet)
+ log_info("Generating key pair...");
FSPRG_GenMK(NULL, mpk, seed, seed_size, FSPRG_RECOMMENDED_SECPAR);
- log_info("Generating sealing key...");
+ if (!arg_quiet)
+ log_info("Generating sealing key...");
FSPRG_GenState0(state, mpk, seed, seed_size);
assert(arg_interval > 0);
@@ -1695,7 +1698,7 @@ static int setup_keys(void) {
r = chattr_secret(fd, CHATTR_WARN_UNSUPPORTED_FLAGS);
if (r < 0)
- log_full_errno(ERRNO_IS_NOT_SUPPORTED(r) ? LOG_DEBUG : LOG_WARNING,
+ log_full_errno(ERRNO_IS_NOT_SUPPORTED(r) || arg_quiet ? LOG_DEBUG : LOG_WARNING,
r, "Failed to set file attributes on '%s', ignoring: %m", k);
struct FSSHeader h = {
@@ -1728,7 +1731,7 @@ static int setup_keys(void) {
if (r < 0)
return r;
- if (on_tty()) {
+ if (on_tty() && !arg_quiet) {
hn = gethostname_malloc();
if (hn)
hostname_cleanup(hn);
@@ -1759,7 +1762,7 @@ static int setup_keys(void) {
puts(key);
- if (on_tty()) {
+ if (on_tty() && !arg_quiet) {
fprintf(stderr, "%s", ansi_normal());
#if HAVE_QRENCODE
_cleanup_free_ char *url = NULL;
@@ -10,8 +10,10 @@ if ! journalctl --version | grep -qF +GCRYPT; then
exit 0
fi
-journalctl --force --setup-keys --interval=2 |& tee /tmp/fss
-FSS_VKEY="$(sed -rn '/([a-f0-9]{6}\-){3}[a-f0-9]{6}\/[a-f0-9]+\-[a-f0-9]+/p' /tmp/fss)"
+# without --quiet, should be effectively equivalent to the below, as we are not on tty
+journalctl --force --setup-keys --interval=2
+
+FSS_VKEY=$(journalctl --force --setup-keys --interval=2 --quiet)
[[ -n "$FSS_VKEY" ]]
# Generate some buzz in the journal and wait until the FSS key is changed
--
2.33.0