From 7b3c4db8f00495bc58a173a11f67329ea42d6ec0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 16 Nov 2021 14:21:46 +0100 Subject: [PATCH] [libcalamares] Redacted -> RedactedCommand - For logging (shell) commands where a password might become visible, use RedactedCommand. Rename it to allow for other kinds of redaction, too. --- src/libcalamares/utils/Logger.cpp | 2 +- src/libcalamares/utils/Logger.h | 6 +++--- src/libcalamares/utils/Runner.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 79ae873db..01c3e1539 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -229,7 +229,7 @@ toString( const QVariant& v ) } QDebug& -operator<<( QDebug& s, const Redacted& l ) +operator<<( QDebug& s, const RedactedCommand& l ) { // Special case logging: don't log the (encrypted) password. if ( l.list.contains( "usermod" ) ) diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index bf6b99d00..9f0aeffea 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -214,9 +214,9 @@ public: * since the log may get posted to bug reports, or stored in * the target system. */ -struct Redacted +struct RedactedCommand { - Redacted( const QStringList& l ) + RedactedCommand( const QStringList& l ) : list( l ) { } @@ -224,7 +224,7 @@ struct Redacted const QStringList& list; }; -QDebug& operator<<( QDebug& s, const Redacted& l ); +QDebug& operator<<( QDebug& s, const RedactedCommand& l ); /** * @brief Formatted logging of a pointer diff --git a/src/libcalamares/utils/Runner.cpp b/src/libcalamares/utils/Runner.cpp index e138b1c68..c7146c2d7 100644 --- a/src/libcalamares/utils/Runner.cpp +++ b/src/libcalamares/utils/Runner.cpp @@ -163,7 +163,7 @@ Calamares::Utils::Runner::run() } ); } - cDebug() << Logger::SubEntry << "Running" << Logger::Redacted( m_command ); + cDebug() << Logger::SubEntry << "Running" << Logger::RedactedCommand( m_command ); process.start(); if ( !process.waitForStarted() ) { @@ -225,13 +225,13 @@ Calamares::Utils::Runner::run() { if ( !output.isEmpty() ) { - cDebug() << Logger::SubEntry << "Target cmd:" << Logger::Redacted( m_command ) << "Exit code:" << r + cDebug() << Logger::SubEntry << "Target cmd:" << Logger::RedactedCommand( m_command ) << "Exit code:" << r << "output:\n" << Logger::NoQuote << output; } else { - cDebug() << Logger::SubEntry << "Target cmd:" << Logger::Redacted( m_command ) << "Exit code:" << r + cDebug() << Logger::SubEntry << "Target cmd:" << Logger::RedactedCommand( m_command ) << "Exit code:" << r << "(no output)"; } }