Skip to content

Commit 4c88d0e

Browse files
yuwatabluca
authored andcommitted
journalctl: honor --quiet with --setup-keys
Closes #35504. (cherry picked from commit a5b2973) (cherry picked from commit 644f2a0) (cherry picked from commit c03e316) (cherry picked from commit dbab170)
1 parent bfcb6d0 commit 4c88d0e

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/journal/journalctl.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,15 +1649,18 @@ static int setup_keys(void) {
16491649
state_size = FSPRG_stateinbytes(FSPRG_RECOMMENDED_SECPAR);
16501650
state = alloca_safe(state_size);
16511651

1652-
log_info("Generating seed...");
1652+
if (!arg_quiet)
1653+
log_info("Generating seed...");
16531654
r = crypto_random_bytes(seed, seed_size);
16541655
if (r < 0)
16551656
return log_error_errno(r, "Failed to acquire random seed: %m");
16561657

1657-
log_info("Generating key pair...");
1658+
if (!arg_quiet)
1659+
log_info("Generating key pair...");
16581660
FSPRG_GenMK(NULL, mpk, seed, seed_size, FSPRG_RECOMMENDED_SECPAR);
16591661

1660-
log_info("Generating sealing key...");
1662+
if (!arg_quiet)
1663+
log_info("Generating sealing key...");
16611664
FSPRG_GenState0(state, mpk, seed, seed_size);
16621665

16631666
assert(arg_interval > 0);
@@ -1672,7 +1675,7 @@ static int setup_keys(void) {
16721675

16731676
r = chattr_secret(fd, CHATTR_WARN_UNSUPPORTED_FLAGS);
16741677
if (r < 0)
1675-
log_full_errno(ERRNO_IS_NOT_SUPPORTED(r) ? LOG_DEBUG : LOG_WARNING,
1678+
log_full_errno(ERRNO_IS_NOT_SUPPORTED(r) || arg_quiet ? LOG_DEBUG : LOG_WARNING,
16761679
r, "Failed to set file attributes on '%s', ignoring: %m", k);
16771680

16781681
struct FSSHeader h = {
@@ -1705,7 +1708,7 @@ static int setup_keys(void) {
17051708
if (r < 0)
17061709
return r;
17071710

1708-
if (on_tty()) {
1711+
if (on_tty() && !arg_quiet) {
17091712
hn = gethostname_malloc();
17101713
if (hn)
17111714
hostname_cleanup(hn);
@@ -1736,7 +1739,7 @@ static int setup_keys(void) {
17361739

17371740
puts(key);
17381741

1739-
if (on_tty()) {
1742+
if (on_tty() && !arg_quiet) {
17401743
fprintf(stderr, "%s", ansi_normal());
17411744
#if HAVE_QRENCODE
17421745
_cleanup_free_ char *url = NULL;

test/units/testsuite-04.fss.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ if ! journalctl --version | grep -qF +GCRYPT; then
1010
exit 0
1111
fi
1212

13-
journalctl --force --setup-keys --interval=2 |& tee /tmp/fss
14-
FSS_VKEY="$(sed -rn '/([a-f0-9]{6}\-){3}[a-f0-9]{6}\/[a-f0-9]+\-[a-f0-9]+/p' /tmp/fss)"
13+
# without --quiet, should be effectively equivalent to the below, as we are not on tty
14+
journalctl --force --setup-keys --interval=2
15+
16+
FSS_VKEY=$(journalctl --force --setup-keys --interval=2 --quiet)
1517
[[ -n "$FSS_VKEY" ]]
1618

1719
# Generate some buzz in the journal and wait until the FSS key is changed

0 commit comments

Comments
 (0)