[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.
This commit is contained in:
Adriaan de Groot 2021-11-16 14:21:46 +01:00
parent 7cc84b89be
commit 7b3c4db8f0
3 changed files with 7 additions and 7 deletions

View File

@ -229,7 +229,7 @@ toString( const QVariant& v )
} }
QDebug& QDebug&
operator<<( QDebug& s, const Redacted& l ) operator<<( QDebug& s, const RedactedCommand& l )
{ {
// Special case logging: don't log the (encrypted) password. // Special case logging: don't log the (encrypted) password.
if ( l.list.contains( "usermod" ) ) if ( l.list.contains( "usermod" ) )

View File

@ -214,9 +214,9 @@ public:
* since the log may get posted to bug reports, or stored in * since the log may get posted to bug reports, or stored in
* the target system. * the target system.
*/ */
struct Redacted struct RedactedCommand
{ {
Redacted( const QStringList& l ) RedactedCommand( const QStringList& l )
: list( l ) : list( l )
{ {
} }
@ -224,7 +224,7 @@ struct Redacted
const QStringList& list; const QStringList& list;
}; };
QDebug& operator<<( QDebug& s, const Redacted& l ); QDebug& operator<<( QDebug& s, const RedactedCommand& l );
/** /**
* @brief Formatted logging of a pointer * @brief Formatted logging of a pointer

View File

@ -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(); process.start();
if ( !process.waitForStarted() ) if ( !process.waitForStarted() )
{ {
@ -225,13 +225,13 @@ Calamares::Utils::Runner::run()
{ {
if ( !output.isEmpty() ) 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" << "output:\n"
<< Logger::NoQuote << output; << Logger::NoQuote << output;
} }
else 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)"; << "(no output)";
} }
} }